Compare commits
No commits in common. "master" and "v0.2-beta" have entirely different histories.
12
COPYRIGHT
12
COPYRIGHT
@ -1,7 +1,7 @@
|
||||
/*****************************************************************************/
|
||||
/* WonX - WonderWitch on X. */
|
||||
/* Wonx - WonderWitch on X. */
|
||||
/* */
|
||||
/* WonX Copyright (c) 2000-2002 Sakai Hiroaki. */
|
||||
/* Wonx Copyright (c) 2000 Sakai Hiroaki. */
|
||||
/* All Rights Reserved. */
|
||||
/*===========================================================================*/
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
@ -37,14 +37,10 @@
|
||||
/* あるものとします. */
|
||||
/*===========================================================================*/
|
||||
/* 坂井弘亮の連絡先のメールアドレスは, */
|
||||
/* hsakai@m8.people.or.jp */
|
||||
/* sakai@seki.ee.kagu.sut.ac.jp */
|
||||
/* hsakai@pfu.co.jp */
|
||||
/* です.また,本ソフトウエアの最新版を, */
|
||||
/* 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 */
|
||||
/* ミラーサイトは,坂井が気が向いたときにアップデートするので,常に最新, */
|
||||
/* というわけではありません.あくまでバックアップ用です. */
|
||||
/* ご意見,ご感想がありましたら,ぜひ連絡ください. */
|
||||
/*****************************************************************************/
|
||||
|
||||
260
HISTORY
260
HISTORY
@ -1,262 +1,4 @@
|
||||
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(土)
|
||||
|
||||
wonx-2.1 公開
|
||||
|
||||
パレットデータのダンプ時に,RGB値もダンプするようにした.
|
||||
データのダンプ部分を一部修正.
|
||||
|
||||
perl スクリプトの行頭を,/usr/bin/perl から /usr/local/bin/perl に変更.
|
||||
(FreeBSD では,日本語 perl は /usr/local/bin に入るので)
|
||||
|
||||
disp.c, libwwc.c の,キャラクタのビットマップデータ読み込み用・取得用関数で,
|
||||
ビットマップデータの型を unsigned char * でなく short int *, long int * などの
|
||||
適切な型に修正した.
|
||||
WWCharacter クラスのビットマップを,uchar, ushort, ulong の union とし,
|
||||
WWCharacter_GetPixel() では適切な型でアクセスすることにより,
|
||||
ビットマップデータのエンディアンの依存性を無くした.(i386, SPARC で確認済)
|
||||
|
||||
WWCharacter_GetPixel() の 16PACKED カラーモード時の値の取得方法を修正した.
|
||||
(キャラクタが左右反転表示されていたバグが解消した)
|
||||
|
||||
F11 で10秒間停止,もしくは Ctrl-c もしくは F12 で強制終了,
|
||||
Ctrl-i でアイコン化の追加.(もともとあった機能だったが,忘れてたのを,
|
||||
多少修正して正式サポートにした)
|
||||
|
||||
表示/非表示の切替えキーを p から F10 に移動.マニュアル修正.
|
||||
|
||||
XDisplay.c:XDisplay_DrawLCDWindow() で,XColorGC_CreateFromRGB() で生成した
|
||||
XColorGC オブジェクトを Destroy() していないので,メモリフローしていたバグを
|
||||
修正.(XColorGC_Destroy(x_color_gc) 追加)
|
||||
|
||||
wonx_include/fcntl.h 追加.内容は,/usr/include/fcntl.h,
|
||||
/usr/include/sys/fcntl.h をインクルードするだけ.
|
||||
|
||||
シリアル出力時のメッセージ(output to serial port : )の書式変更.
|
||||
("" でくくるようにした)
|
||||
etc.c:wonx_print_character() 修正.(\", \\ などを追加)
|
||||
sout2str.pl 修正.(\", \\ などを追加.上記のシリアル出力時のメッセージの
|
||||
書式変更にあわせて修正した)
|
||||
|
||||
int2sint.pl, filters.pl, challsrc.sh 追加.
|
||||
sys2wonx.pl 変更.
|
||||
|
||||
wonx_include/types.h の
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned long DWORD;
|
||||
を
|
||||
typedef unsigned short int WORD;
|
||||
typedef unsigned long int DWORD;
|
||||
に変更.
|
||||
|
||||
README 修正.
|
||||
|
||||
|
||||
|
||||
|
||||
2001/1/3(水)
|
||||
|
||||
wonx-2.0 公開
|
||||
|
||||
カラー化対応.GCの管理用に,XColorGC クラスを追加.(XFireworks から流用した)
|
||||
|
||||
カラー化に対応させて,transparent(透過色)の判定処理を WWPalette クラスから
|
||||
WWDisplay クラスに移動した.
|
||||
|
||||
WWLCDPanel の pixel を,unsigned short int * に変更.(カラー対応)
|
||||
|
||||
テキストフォントの格納フォーマットを変更.(WWTextFonts.c)
|
||||
|
||||
テキスト表示で,表示時に WWDisplay_GetForegroundColor(),
|
||||
WWDisplay_GetBackgroundColor() を見てコピーするように修正.(WWText.c)
|
||||
(WWText クラス中で WWCharacter の配列を確保しているのが不要になったので,
|
||||
いずれ削除すること)
|
||||
|
||||
WWDisplay クラスにボーダーカラーのパレット追加.
|
||||
|
||||
カラー化に対応させて,その他もろもろの修正を加えた.
|
||||
(キャラクタデータの格納方法,テキスト表示,ボーダーカラーの処理など)
|
||||
|
||||
display_control(), display_status() で,ボーダーカラーのビットシフトが
|
||||
7 になっていたバグを修正.(8 に修正)
|
||||
|
||||
while(1){/*none*/} での割り込み待ちループ中にも,F1 などのキー入力を受け付ける
|
||||
ように修正.(WonXSystem.c のタイマ割り込みのコールバック関数
|
||||
WonXTimer_Callback() に,WonXDisplay_PrintData() を追加)
|
||||
|
||||
fcntl_attention.h, filesys.h, indirect.h, oswork.h, process.h を追加.
|
||||
(中身はカラ,もしくは適当なファイルをインクルードするだけ)
|
||||
|
||||
wonx_configure.h で,
|
||||
#ifndef _WONX_winx_configure_h_INCLUDED_
|
||||
#define _WONX_wonx_configure_h_INCLUDED_
|
||||
になっていたバグを修正.
|
||||
|
||||
|
||||
|
||||
|
||||
2000/12/28(木)
|
||||
|
||||
wonx-1.1 公開
|
||||
|
||||
_asm_*() のダミー関数を追加.
|
||||
FP_OFF(), FP_SEG() を,WonderWitch での割り込み設定時のコールバック関数の
|
||||
設定方法にあわせて,適切に変更.(wwterm に合わせた)
|
||||
|
||||
UNIXTimer.c:UNIXTimer_Unpause() で,
|
||||
((unix_timer->pause == 1) && (unix_timer->interrupt_in_pause == 0))
|
||||
だったときに unix_timer->pause--; されないバグを修正.
|
||||
(ポーズ中に割り込みがかからなかった場合に,アンポーズされていなかった)
|
||||
|
||||
シリアル受信割り込み,キーボード割り込み追加.(wwterm に対応,動作確認済)
|
||||
UNIXSerialPort クラス追加.
|
||||
|
||||
これにより,WonderWitch での,
|
||||
com_intvector.callback = (void (near *)())FP_OFF(com_handler);
|
||||
com_intvector.cs = _asm_inline("\tmov\tax,cs");
|
||||
com_intvector.ds = _asm_inline("\tmov\tax,ds");
|
||||
sys_interrupt_set_hook(SYS_INT_RECEIVEREADY,
|
||||
&com_intvector, &com_last_intvector);
|
||||
のような割り込みの設定が正しく実行されるようになった.
|
||||
|
||||
ワーニング用に,WonX_Warning() 追加.
|
||||
WonX_Error() を WonX.c に移動.
|
||||
|
||||
comm_send_string(), text_put_string(), text_put_substring() 実行時の
|
||||
出力メッセージを修正.
|
||||
|
||||
カーソル表示機能を実装.(WWCursor クラス追加)(点滅はしない.表示のみ)
|
||||
カーソル表示をする際に,WWDisplay_DrawLCDPanel() 内部でテキスト情報が
|
||||
読める必要があるので,WonXText クラスを廃止して,WWText クラスを
|
||||
WWDisplay クラスのメンバに移動した.
|
||||
|
||||
palette_get_color() 内で,WWPalette_GetMappedColors() の実行時に透明色が
|
||||
-1として返されることを考慮していなかったために,palette_get_color() の
|
||||
戻り値がおかしな値になっていたバグを修正.
|
||||
|
||||
キャラクタカラーパレット,LCDカラーパレットの初期値を,WonderWitch での
|
||||
初期値と一致させた.
|
||||
|
||||
サンプルとして,wwterm-b05 を追加.(Makefile に wwterm ターゲットを追加)
|
||||
|
||||
|
||||
|
||||
|
||||
2000/11/23(木)
|
||||
|
||||
wonx-1.0 公開
|
||||
|
||||
正式名称を Wonx から WonX に変更.
|
||||
|
||||
MANUAL ファイルを追加.
|
||||
|
||||
OMAKE.jpn に文章追加.
|
||||
|
||||
|
||||
|
||||
|
||||
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 公開
|
||||
|
||||
UNIXTimer.c で,コールバック関数が呼ばれるたびにコールバック関数を
|
||||
設定しなおすように修正.
|
||||
(UNIXTimer_ON() 中に signal() を追加)
|
||||
(IRIX ではコール毎にコールバック関数がクリアされてしまうことへの対処)
|
||||
|
||||
ualarm() は BSD 依存なので,alarm() を使用するように修正.
|
||||
|
||||
UNIXTimer クラスのインターバル時間の設定の単位をマイクロ秒からミリ秒に変更.
|
||||
|
||||
シリアル通信をサポート.(WonxSerialPort, WWSerialPort, comm.c 参照)
|
||||
|
||||
key.c 中の printf() で,戻り値の表示の際に関数名が表示されていなかったのを
|
||||
修正.
|
||||
|
||||
|
||||
|
||||
|
||||
2000/11/13(月)
|
||||
|
||||
wonx-b03 公開
|
||||
|
||||
ヘッダファイルを独自に作成.Wonx のみでコンパイル可能になった.
|
||||
libwonx.a のリンク時に Error() 関数がぶつかる可能性があるので,
|
||||
Wonx_Error() に変更した.
|
||||
bios_exit() を追加.
|
||||
sprite_set_char, sprite_get_char で,パレット番号が8を引いた値で
|
||||
指定されていないバグを修正.
|
||||
disp.c の font_set_monodata(), font_set_colordata(), font_get_data(),
|
||||
screen_set_char(), screen_get_char(), sprite_set_data() の引数を
|
||||
void * から適切な型に変更.
|
||||
サンプルプログラムと SpeedMac を添付した.
|
||||
ドキュメントを追加した.
|
||||
|
||||
|
||||
|
||||
|
||||
2000/11/3(金)
|
||||
|
||||
wonx-b02 公開
|
||||
wonx-b02
|
||||
|
||||
割り込み処理の追加.タイマ割り込みサポート.
|
||||
(UNIXTimer, WWInterrupt, WWTimer, WonxSystem 追加)
|
||||
|
||||
76
MANUAL
76
MANUAL
@ -1,76 +0,0 @@
|
||||
WonX のプログラム構造についての解説です.
|
||||
改造するときの参考にしてください.(ライセンスはGPLなので,改造は自由です)
|
||||
|
||||
■ ファイル構成
|
||||
|
||||
WonX はオブジェクト指向で書いてあり,クラス単位でファイルを分けてあります.
|
||||
ファイル自体は一つのクラスにつき3つずつあります.例えば X のウインドウを
|
||||
管理するための XDisplay クラス用には,以下の3つのファイルがあります.
|
||||
|
||||
XDisplay.h ... 外部公開用ヘッダファイル.XDisplay クラスを使用したい
|
||||
ときには,このファイルを include する.
|
||||
XDisplayP.h ... 外部に公開しないプライベートなヘッダファイル.
|
||||
一般には include しない.デバッグ時などにメンバを直接
|
||||
参照したいときに include するためのもの.
|
||||
XDisplay.c ... メンバ関数などの本体.
|
||||
|
||||
クラスのメンバ変数は XDisplayP.h で定義してあるので,メンバを直接参照することは
|
||||
できません.必ずアクセス用のメンバ関数を通して参照します.値の設定も同様です.
|
||||
|
||||
この他に,disp.c や text.c などのファイルがあります.これらは,
|
||||
WonderWitch の互換関数です.
|
||||
|
||||
■ オブジェクトのツリー
|
||||
|
||||
オブジェクトは以下のようなツリー構造になっています.
|
||||
|
||||
┌─ WWColorMap
|
||||
├─ WWPalette[16]
|
||||
├─ WWCharacter[512]
|
||||
┌─WWDisplay ─┼─ WWSprite[128]
|
||||
┌─ WonXDisplay ──┤ ├─ WWScreen[2]
|
||||
│ └─XDisplay ├─ WWLCDPanel
|
||||
│ ├─ WWText
|
||||
│ └─ WWCursor
|
||||
│ ┌─ WWInterrupt
|
||||
WonX ─┼─ WonXSystem ───┼─ WWTimer[3]
|
||||
│ └─ UNIXTimer
|
||||
│
|
||||
│
|
||||
│ ┌─ WWSerialPort
|
||||
└─ WonXSerialPort ─┤
|
||||
└─ UNIXSerialPort
|
||||
|
||||
WW という接頭語がつくクラスは WonderWitch 依存のものです.主に
|
||||
WonderSwan の状態情報を格納します.
|
||||
X という接頭語がつくクラスは X 依存のもの,UNIX という接頭語がつくクラスは
|
||||
UNIX 依存のものです.
|
||||
WonX という接頭語がつくクラスはそれらを統括するものです.
|
||||
|
||||
ツリー構造を理解したかったら,各クラスの *P.h ファイルのメンバの定義と,
|
||||
*.c ファイルの *_Create() 関数を参照してください.
|
||||
|
||||
■ オブジェクトの生成
|
||||
|
||||
各クラスには,オブジェクトの生成用に,[クラス名]_Create() という
|
||||
関数が用意されています.
|
||||
|
||||
WonX_Create() が呼ばれると,内部で WonXDisplay_Create(), WonXSystem_Create(),
|
||||
WonXSerialPort_Create() が呼ばれ,子の WonXDisplay, WonXSystem,
|
||||
WonXSerialPort オブジェクトが生成されます.
|
||||
WonXDisplay_Create() が呼ばれると,内部で WWDisplay_Create(),
|
||||
XDisplay_Create() が呼ばれ,... というように続いて,すべてのツリーか
|
||||
生成されます.
|
||||
オブジェクトを解放するときも同様なのですが,WonX_Destroy() が
|
||||
呼ばれるタイミングが無いため,あまりちゃんと書いてません.
|
||||
|
||||
WonderWitch 用の互換関数では,必ず先頭で,
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
のようなことをやっています.つまり,互換関数のどれかが最初に呼ばれたときに,
|
||||
WonX オブジェクトのツリーが作成されます.
|
||||
|
||||
■ メンバ関数
|
||||
|
||||
クラスのメンバ関数は,[クラス名]_xxx() という名前になっています.
|
||||
|
||||
■ このファイルはここまでです
|
||||
97
Makefile
97
Makefile
@ -2,107 +2,30 @@ XINCLUDEDIR = /usr/X11R6/include
|
||||
INCLUDEDIR = .
|
||||
XLIBDIR = /usr/X11R6/lib
|
||||
|
||||
VERSION = WonX-2.2
|
||||
PKGNAME = wonx-2.2
|
||||
VERSION = Wonx-b02
|
||||
PKGNAME = wonx-b02
|
||||
|
||||
SMAC = smac-b02
|
||||
WWTERM = wwterm-b05
|
||||
|
||||
OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWCursor.o WWText.o WWInterrupt.o WWTimer.o WWSerialPort.o WonX.o WonXDisplay.o WonXSystem.o WonXSerialPort.o XDisplay.o 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
|
||||
|
||||
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
|
||||
OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWText.o WWInterrupt.o WWTimer.o Wonx.o WonxDisplay.o WonxText.o WonxSystem.o XDisplay.o UNIXTimer.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o etc.o
|
||||
|
||||
.SUFFIXES: .c .o
|
||||
.SUFFIXES: .perl .pl
|
||||
|
||||
all : libwonx.a $(PERLS)
|
||||
all : libwonx.a
|
||||
|
||||
libwonx.a : $(OBJS)
|
||||
$(AR) ruc libwonx.a $(OBJS)
|
||||
# $(RANLIB) libwonx.a
|
||||
ar ruc libwonx.a $(OBJS)
|
||||
# ranlib libwonx.a
|
||||
|
||||
.c.o : $*.c
|
||||
$(CC) -c $*.c $(CFLAGS) -I$(INCLUDEDIR) -I$(XINCLUDEDIR)
|
||||
gcc -c $*.c -O -Wall -I$(INCLUDEDIR) -I$(XINCLUDEDIR)
|
||||
|
||||
clean :
|
||||
rm -f libwonx.a sample1 sample2 sample3 *.o *.pl
|
||||
rm -fR $(SMAC) $(WWTERM)
|
||||
|
||||
sample1 : libwonx.a sample1.o
|
||||
$(CC) sample1.o -o sample1 \
|
||||
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
|
||||
|
||||
sample2 : libwonx.a sample2.o
|
||||
$(CC) sample2.o -o sample2 \
|
||||
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
|
||||
|
||||
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
|
||||
mkdir -p $(SMAC)/wonx
|
||||
cp wonx/*.h $(SMAC)/wonx
|
||||
cp libwonx.a $(SMAC)
|
||||
mv $(SMAC)/makefile $(SMAC)/makefile.orig
|
||||
cp makefile_for_smac $(SMAC)/makefile
|
||||
cp challsrc.sh $(PERLS) $(SMAC)
|
||||
cd $(SMAC) ; ./challsrc.sh *.[ch] makefile
|
||||
|
||||
wwterm : libwonx.a $(WWTERM)
|
||||
cd $(WWTERM) ; $(MAKE)
|
||||
|
||||
$(WWTERM) : $(WWTERM).zip $(PERLS)
|
||||
unzip $(WWTERM).zip
|
||||
mkdir -p $(WWTERM)/wonx
|
||||
cp wonx/*.h $(WWTERM)/wonx
|
||||
cp libwonx.a $(WWTERM)
|
||||
mv $(WWTERM)/makefile $(WWTERM)/makefile.orig
|
||||
cp makefile_for_wwterm $(WWTERM)/makefile
|
||||
cp challsrc.sh $(PERLS) $(WWTERM)
|
||||
cd $(WWTERM) ; ./challsrc.sh *.[ch] makefile
|
||||
|
||||
.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
|
||||
rm -f libwonx.a *.o
|
||||
|
||||
package :
|
||||
mkdir -p $(PKGNAME)
|
||||
rm -fR $(PKGNAME)/*
|
||||
mkdir -p $(PKGNAME)/wonx
|
||||
cp COPYING COPYRIGHT HISTORY README MANUAL OMAKE.jpn Makefile \
|
||||
makefile_for_smac makefile_for_wwterm *.sh *.perl \
|
||||
*.h *.c $(SMAC).zip $(WWTERM).zip $(PKGNAME)
|
||||
cp wonx/*.h $(PKGNAME)/wonx
|
||||
cp COPYING COPYRIGHT HISTORY README OMAKE.jpn Makefile \
|
||||
*.h *.c $(PKGNAME)
|
||||
tar cvzf $(PKGNAME).tar.gz $(PKGNAME)
|
||||
|
||||
# End of Makefile.
|
||||
|
||||
396
Obj.c
396
Obj.c
@ -1,396 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* Obj.c - A library for object list. */
|
||||
/* */
|
||||
/* Obj.c Copyright (c) 2000 Sakai Hiroaki. */
|
||||
/* All Rights Reserved. */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "ObjP.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ObjListData 型の操作 */
|
||||
/*****************************************************************************/
|
||||
|
||||
static ObjListData ObjListData_Create(Obj obj, Obj (*destructor)())
|
||||
{
|
||||
ObjListData list_data;
|
||||
|
||||
list_data = (ObjListData)malloc(sizeof(_ObjListData));
|
||||
|
||||
list_data->obj = obj;
|
||||
list_data->destructor = destructor;
|
||||
|
||||
return (list_data);
|
||||
}
|
||||
|
||||
static ObjListData ObjListData_Destroy(ObjListData list_data)
|
||||
{
|
||||
if (list_data == NULL) return (NULL);
|
||||
|
||||
/* デストラクタの実行 */
|
||||
if (list_data->destructor)
|
||||
(*(list_data->destructor))(list_data->obj);
|
||||
|
||||
free(list_data);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ObjList 型オブジェクトの操作 */
|
||||
/*****************************************************************************/
|
||||
|
||||
Obj ObjListData_GetObj(ObjListData data)
|
||||
{
|
||||
if (data == NULL) return (NULL);
|
||||
return (data->obj);
|
||||
}
|
||||
|
||||
ObjListData ObjListData_GetPrev(ObjListData data)
|
||||
{
|
||||
if (data == NULL) return (NULL);
|
||||
return (data->prev);
|
||||
}
|
||||
|
||||
ObjListData ObjListData_GetNext(ObjListData data)
|
||||
{
|
||||
if (data == NULL) return (NULL);
|
||||
return (data->next);
|
||||
}
|
||||
|
||||
int ObjList_GetLength(ObjList list)
|
||||
{
|
||||
if (list == NULL) return (-1);
|
||||
return (list->length);
|
||||
}
|
||||
|
||||
ObjListData ObjList_GetStartEdge(ObjList list)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
return (list->start_edge);
|
||||
}
|
||||
|
||||
ObjListData ObjList_GetEndEdge(ObjList list)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
return (list->end_edge);
|
||||
}
|
||||
|
||||
ObjListData ObjList_GetStart(ObjList list)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
return (list->start_edge->next);
|
||||
}
|
||||
|
||||
ObjListData ObjList_GetEnd(ObjList list)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
return (list->end_edge->prev);
|
||||
}
|
||||
|
||||
int ObjList_IsEmpty(ObjList list)
|
||||
{
|
||||
if (list == NULL) return (1);
|
||||
return (list->start_edge->next == list->end_edge);
|
||||
}
|
||||
|
||||
int ObjList_IsStartEdge(ObjList list, ObjListData data)
|
||||
{
|
||||
if (list == NULL) return (0);
|
||||
return (data == list->start_edge);
|
||||
}
|
||||
|
||||
int ObjList_IsEndEdge(ObjList list, ObjListData data)
|
||||
{
|
||||
if (list == NULL) return (0);
|
||||
return (data == list->end_edge);
|
||||
}
|
||||
|
||||
int ObjList_IsStart(ObjList list, ObjListData data)
|
||||
{
|
||||
if (list == NULL) return (0);
|
||||
return (data == list->start_edge->next);
|
||||
}
|
||||
|
||||
int ObjList_IsEnd(ObjList list, ObjListData data)
|
||||
{
|
||||
if (list == NULL) return (0);
|
||||
return (data == list->end_edge->prev);
|
||||
}
|
||||
|
||||
ObjListData ObjList_InsertObjToPrev(ObjList list, ObjListData current,
|
||||
Obj obj, Obj (*destructor)())
|
||||
{
|
||||
ObjListData data;
|
||||
|
||||
if (list == NULL) return (NULL);
|
||||
if (ObjList_IsStartEdge(list, current)) return (NULL);
|
||||
|
||||
data = ObjListData_Create(obj, destructor);
|
||||
if (data == NULL) return (NULL);
|
||||
|
||||
data->prev = current->prev;
|
||||
data->next = current;
|
||||
current->prev->next = data;
|
||||
current->prev = data;
|
||||
(list->length)++;
|
||||
|
||||
return (data);
|
||||
}
|
||||
|
||||
ObjListData ObjList_InsertObjToNext(ObjList list, ObjListData current,
|
||||
Obj obj, Obj (*destructor)())
|
||||
{
|
||||
ObjListData data;
|
||||
|
||||
if (list == NULL) return (NULL);
|
||||
if (ObjList_IsEndEdge(list, current)) return (NULL);
|
||||
|
||||
data = ObjListData_Create(obj, destructor);
|
||||
if (data == NULL) return (NULL);
|
||||
|
||||
data->next = current->next;
|
||||
data->prev = current;
|
||||
current->next->prev = data;
|
||||
current->next = data;
|
||||
(list->length)++;
|
||||
|
||||
return (data);
|
||||
}
|
||||
|
||||
ObjListData ObjList_InsertObjToStart(ObjList list, Obj obj,
|
||||
Obj (*destructor)())
|
||||
{
|
||||
ObjListData current;
|
||||
current = ObjList_GetStart(list);
|
||||
return (ObjList_InsertObjToPrev(list, current, obj, destructor));
|
||||
}
|
||||
|
||||
ObjListData ObjList_InsertObjToEnd(ObjList list, Obj obj,
|
||||
Obj (*destructor)())
|
||||
{
|
||||
ObjListData current;
|
||||
current = ObjList_GetEnd(list);
|
||||
return (ObjList_InsertObjToNext(list, current, obj, destructor));
|
||||
}
|
||||
|
||||
ObjListData ObjList_DeleteObjToPrev(ObjList list, ObjListData current)
|
||||
{
|
||||
ObjListData ret;
|
||||
|
||||
if (list == NULL) return (NULL);
|
||||
if (ObjList_IsStartEdge(list, current) || ObjList_IsEndEdge(list, current))
|
||||
return (NULL);
|
||||
|
||||
current->prev->next = current->next;
|
||||
current->next->prev = current->prev;
|
||||
|
||||
ret = current->prev;
|
||||
ObjListData_Destroy(current);
|
||||
(list->length)--;
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
ObjListData ObjList_DeleteObjToNext(ObjList list, ObjListData current)
|
||||
{
|
||||
ObjListData ret;
|
||||
|
||||
if (list == NULL) return (NULL);
|
||||
if (ObjList_IsStartEdge(list, current) || ObjList_IsEndEdge(list, current))
|
||||
return (NULL);
|
||||
|
||||
current->prev->next = current->next;
|
||||
current->next->prev = current->prev;
|
||||
|
||||
ret = current->next;
|
||||
ObjListData_Destroy(current);
|
||||
(list->length)--;
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
ObjListData ObjList_DeleteObjFromStart(ObjList list)
|
||||
{
|
||||
ObjListData current;
|
||||
if (list == NULL) return (NULL);
|
||||
current = ObjList_GetStart(list);
|
||||
return (ObjList_DeleteObjToNext(list, current));
|
||||
}
|
||||
|
||||
ObjListData ObjList_DeleteObjFromEnd(ObjList list)
|
||||
{
|
||||
ObjListData current;
|
||||
if (list == NULL) return (NULL);
|
||||
current = ObjList_GetEnd(list);
|
||||
return (ObjList_DeleteObjToPrev(list, current));
|
||||
}
|
||||
|
||||
ObjListData ObjList_MoveObjToPrev(ObjList list,
|
||||
ObjListData current,
|
||||
ObjListData to)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
return (ObjList_MoveObjToPrevOfOtherList(list, current, list, to));
|
||||
}
|
||||
|
||||
ObjListData ObjList_MoveObjToNext(ObjList list,
|
||||
ObjListData current,
|
||||
ObjListData to)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
return (ObjList_MoveObjToNextOfOtherList(list, current, list, to));
|
||||
}
|
||||
|
||||
ObjListData ObjList_MoveObjToStart(ObjList list, ObjListData current)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
return (ObjList_MoveObjToStartOfOtherList(list, current, list));
|
||||
}
|
||||
|
||||
ObjListData ObjList_MoveObjToEnd(ObjList list, ObjListData current)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
return (ObjList_MoveObjToEndOfOtherList(list, current, list));
|
||||
}
|
||||
|
||||
ObjList ObjList_Create() /* ObjList 型オブジェクトを作成する */
|
||||
{
|
||||
ObjList list;
|
||||
|
||||
list = (ObjList)malloc(sizeof(_ObjList));
|
||||
if (list == NULL) return (NULL);
|
||||
|
||||
list->start_edge = ObjListData_Create(NULL, NULL);
|
||||
list->end_edge = ObjListData_Create(NULL, NULL);
|
||||
list->length = 0; /* 現在存在しているデータの数 */
|
||||
|
||||
list->start_edge->prev = NULL;
|
||||
list->start_edge->next = list->end_edge;
|
||||
list->end_edge->prev = list->start_edge;
|
||||
list->end_edge->next = NULL;
|
||||
|
||||
return (list);
|
||||
}
|
||||
|
||||
ObjList ObjList_Destroy(ObjList list) /* */
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
|
||||
while (!ObjList_IsEmpty(list))
|
||||
ObjList_DeleteObjFromStart(list);
|
||||
|
||||
if (list->start_edge)
|
||||
list->start_edge = ObjListData_Destroy(list->start_edge);
|
||||
if (list->end_edge)
|
||||
list->end_edge = ObjListData_Destroy(list->end_edge);
|
||||
|
||||
free(list);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 複数のリスト間での操作 */
|
||||
/*===========================================================================*/
|
||||
|
||||
ObjListData ObjList_MoveObjToPrevOfOtherList(ObjList list, ObjListData current,
|
||||
ObjList to_list, ObjListData to)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
if (to_list == NULL) return (NULL);
|
||||
if (ObjList_IsStartEdge(list, current) || ObjList_IsEndEdge(list, current))
|
||||
return (NULL);
|
||||
|
||||
if (ObjList_IsStartEdge(to_list, to)) return (NULL);
|
||||
if ((list == to_list) && (current == to)) return (current);
|
||||
|
||||
current->prev->next = current->next;
|
||||
current->next->prev = current->prev;
|
||||
|
||||
current->prev = to->prev;
|
||||
current->next = to;
|
||||
to->prev->next = current;
|
||||
to->prev = current;
|
||||
|
||||
(list->length)--;
|
||||
(to_list->length)++;
|
||||
|
||||
return (current);
|
||||
}
|
||||
|
||||
ObjListData ObjList_MoveObjToNextOfOtherList(ObjList list, ObjListData current,
|
||||
ObjList to_list, ObjListData to)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
if (ObjList_IsStartEdge(list, current) || ObjList_IsEndEdge(list, current))
|
||||
return (NULL);
|
||||
|
||||
if (ObjList_IsEndEdge(to_list, to)) return (NULL);
|
||||
if ((list == to_list) && (current == to)) return (current);
|
||||
|
||||
current->prev->next = current->next;
|
||||
current->next->prev = current->prev;
|
||||
|
||||
current->next = to->next;
|
||||
current->prev = to;
|
||||
to->next->prev = current;
|
||||
to->next = current;
|
||||
|
||||
(list->length)--;
|
||||
(to_list->length)++;
|
||||
|
||||
return (current);
|
||||
}
|
||||
|
||||
ObjListData ObjList_MoveObjToStartOfOtherList(ObjList list,
|
||||
ObjListData current,
|
||||
ObjList to_list)
|
||||
{
|
||||
ObjListData to;
|
||||
if (list == NULL) return (NULL);
|
||||
if (to_list == NULL) return (NULL);
|
||||
to = ObjList_GetStart(to_list);
|
||||
return (ObjList_MoveObjToPrevOfOtherList(list, current, to_list, to));
|
||||
}
|
||||
|
||||
ObjListData ObjList_MoveObjToEndOfOtherList(ObjList list,
|
||||
ObjListData current,
|
||||
ObjList to_list)
|
||||
{
|
||||
ObjListData to;
|
||||
if (list == NULL) return (NULL);
|
||||
if (to_list == NULL) return (NULL);
|
||||
to = ObjList_GetEnd(to_list);
|
||||
return (ObjList_MoveObjToNextOfOtherList(list, current, to_list, to));
|
||||
}
|
||||
|
||||
ObjList ObjList_Concatenate(ObjList list1, ObjList list2)
|
||||
{
|
||||
ObjListData tmp;
|
||||
|
||||
if (list1 == NULL) {
|
||||
list1 = list2;
|
||||
return (list1);
|
||||
}
|
||||
if (list2 == NULL) return (list1);
|
||||
|
||||
list1->end_edge->prev->next = list2->start_edge->next;
|
||||
list2->start_edge->next->prev = list1->end_edge->prev;
|
||||
|
||||
tmp = list1->end_edge;
|
||||
list1->end_edge = list2->end_edge;
|
||||
list2->end_edge = tmp;
|
||||
|
||||
list2->start_edge->next = list2->end_edge;
|
||||
list2->end_edge->prev = list2->start_edge;
|
||||
|
||||
list1->length += list2->length;
|
||||
list2->length = 0;
|
||||
|
||||
ObjList_Destroy(list2);
|
||||
|
||||
return (list1);
|
||||
}
|
||||
|
||||
/* End of File. */
|
||||
76
Obj.h
76
Obj.h
@ -1,76 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* Obj.h - A library for object list. */
|
||||
/* */
|
||||
/* Obj.h Copyright (c) 2000 Sakai Hiroaki. */
|
||||
/* All Rights Reserved. */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _SAKAILIB_OBJ_H_INCLUDED_
|
||||
#define _SAKAILIB_OBJ_H_INCLUDED_
|
||||
|
||||
typedef void * Obj;
|
||||
typedef struct _ObjListData * ObjListData;
|
||||
typedef struct _ObjList * ObjList;
|
||||
typedef Obj (*ObjDestructor)(Obj);
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ObjList 型オブジェクトの操作 */
|
||||
/*****************************************************************************/
|
||||
|
||||
Obj ObjListData_GetObj(ObjListData data);
|
||||
ObjListData ObjListData_GetPrev(ObjListData data);
|
||||
ObjListData ObjListData_GetNext(ObjListData data);
|
||||
int ObjList_GetLength(ObjList list);
|
||||
ObjListData ObjList_GetStartEdge(ObjList list);
|
||||
ObjListData ObjList_GetEndEdge(ObjList list);
|
||||
ObjListData ObjList_GetStart(ObjList list);
|
||||
ObjListData ObjList_GetEnd(ObjList list);
|
||||
int ObjList_IsEmpty(ObjList list);
|
||||
int ObjList_IsStartEdge(ObjList list, ObjListData data);
|
||||
int ObjList_IsEndEdge(ObjList list, ObjListData data);
|
||||
int ObjList_IsStart(ObjList list, ObjListData data);
|
||||
int ObjList_IsEnd(ObjList list, ObjListData data);
|
||||
ObjListData ObjList_InsertObjToPrev(ObjList list, ObjListData current,
|
||||
Obj obj, Obj (*destructor)());
|
||||
ObjListData ObjList_InsertObjToNext(ObjList list, ObjListData current,
|
||||
Obj obj, Obj (*destructor)());
|
||||
ObjListData ObjList_InsertObjToStart(ObjList list, Obj obj,
|
||||
Obj (*destructor)());
|
||||
ObjListData ObjList_InsertObjToEnd(ObjList list, Obj obj,
|
||||
Obj (*destructor)());
|
||||
ObjListData ObjList_DeleteObjToPrev(ObjList list, ObjListData current);
|
||||
ObjListData ObjList_DeleteObjToNext(ObjList list, ObjListData current);
|
||||
ObjListData ObjList_DeleteObjFromStart(ObjList list);
|
||||
ObjListData ObjList_DeleteObjFromEnd(ObjList list);
|
||||
ObjListData ObjList_MoveObjToPrev(ObjList list,
|
||||
ObjListData current,
|
||||
ObjListData to);
|
||||
ObjListData ObjList_MoveObjToNext(ObjList list,
|
||||
ObjListData current,
|
||||
ObjListData to);
|
||||
ObjListData ObjList_MoveObjToStart(ObjList list, ObjListData current);
|
||||
ObjListData ObjList_MoveObjToEnd(ObjList list, ObjListData current);
|
||||
ObjList ObjList_Create(); /* ObjList 型オブジェクトを作成する */
|
||||
ObjList ObjList_Destroy(ObjList list); /* */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 複数のリスト間での操作 */
|
||||
/*===========================================================================*/
|
||||
|
||||
ObjListData ObjList_MoveObjToPrevOfOtherList(ObjList list, ObjListData current,
|
||||
ObjList to_list, ObjListData to);
|
||||
ObjListData ObjList_MoveObjToNextOfOtherList(ObjList list, ObjListData current,
|
||||
ObjList to_list, ObjListData to);
|
||||
ObjListData ObjList_MoveObjToStartOfOtherList(ObjList list,
|
||||
ObjListData current,
|
||||
ObjList to_list);
|
||||
ObjListData ObjList_MoveObjToEndOfOtherList(ObjList list,
|
||||
ObjListData current,
|
||||
ObjList to_list);
|
||||
ObjList ObjList_Concatenate(ObjList list1, ObjList list2);
|
||||
|
||||
#endif
|
||||
|
||||
28
ObjP.h
28
ObjP.h
@ -1,28 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ObjP.h - A library for object list. */
|
||||
/* */
|
||||
/* ObjP.h Copyright (c) 2000 Sakai Hiroaki. */
|
||||
/* All Rights Reserved. */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _SAKAILIB_OBJP_H_INCLUDED_
|
||||
#define _SAKAILIB_OBJP_H_INCLUDED_
|
||||
|
||||
#include "Obj.h"
|
||||
|
||||
/* データ格納用構造体 */
|
||||
typedef struct _ObjListData {
|
||||
struct _ObjListData * prev; /* 前のデータ */
|
||||
struct _ObjListData * next; /* 次のデータ */
|
||||
Obj obj; /* オブジェクト */
|
||||
Obj (*destructor)(Obj); /* 削除時に呼ばれるデストラクタ */
|
||||
} _ObjListData;
|
||||
|
||||
/* リスト構造の管理用 */
|
||||
typedef struct _ObjList {
|
||||
struct _ObjListData * start_edge;
|
||||
struct _ObjListData * end_edge;
|
||||
int length;
|
||||
} _ObjList;
|
||||
|
||||
#endif
|
||||
182
UNIXSerialPort.c
182
UNIXSerialPort.c
@ -1,182 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "UNIXSerialPortP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ポートの open/close */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int UNIXSerialPort_Open(UNIXSerialPort unix_serial_port)
|
||||
{
|
||||
unix_serial_port->opened = 1;
|
||||
return (0);
|
||||
}
|
||||
int UNIXSerialPort_Close(UNIXSerialPort unix_serial_port)
|
||||
{
|
||||
unix_serial_port->opened = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
int UNIXSerialPort_IsOpened(UNIXSerialPort unix_serial_port)
|
||||
{ return (unix_serial_port->opened != 0); }
|
||||
int UNIXSerialPort_IsClosed(UNIXSerialPort unix_serial_port)
|
||||
{ return (unix_serial_port->opened == 0); }
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 受信データがあるかどうか */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* タイムアウト時間をミリ秒単位で指定.
|
||||
* 0 のときは,即時
|
||||
* -1 のときは,無期限待ち
|
||||
*/
|
||||
|
||||
int UNIXSerialPort_IsDataExisting(UNIXSerialPort unix_serial_port,
|
||||
int timeout)
|
||||
{
|
||||
fd_set bitmap;
|
||||
struct timeval t;
|
||||
struct timeval * t_p;
|
||||
#if 0
|
||||
int c;
|
||||
#endif
|
||||
|
||||
if (UNIXSerialPort_IsClosed(unix_serial_port)) return (0);
|
||||
|
||||
/*
|
||||
* 0 のときは,即時
|
||||
* -1 のときは,無期限待ち
|
||||
*/
|
||||
if (timeout == -1) {
|
||||
t_p = NULL;
|
||||
} else {
|
||||
t.tv_sec = timeout / 1000;
|
||||
t.tv_usec = (timeout % 1000) * 1000;
|
||||
t_p = &t;
|
||||
}
|
||||
|
||||
/*
|
||||
* FreeBSD3.4 で実験したところ,
|
||||
* アラームシグナルを使用する場合,select()でのブロック中に
|
||||
* アラームシグナルが発生すると,その直後にselect()もタイムアウト
|
||||
* してしまうので,注意.
|
||||
* (select() がタイムアウトした後にアラームシグナルが発生する場合は,
|
||||
* 正常に動作した)
|
||||
* 論理上は問題が無いが,期待した時間だけ待ってくれないという現象が
|
||||
* 起きる可能性がある.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
/* 読み飛ばしたい文字があるときは,こっちのコードを使う */
|
||||
do {
|
||||
FD_ZERO(&bitmap);
|
||||
FD_SET(fileno(stdin), &bitmap);
|
||||
select(fileno(stdin) + 1, &bitmap, NULL, NULL, t_p);
|
||||
|
||||
if (!FD_ISSET(fileno(stdin), &bitmap))
|
||||
return (0);
|
||||
|
||||
c = fgetc(stdin);
|
||||
} while (0); /* 読み飛ばしたい文字があるときは,ここでcをチェックする */
|
||||
ungetc(c, stdin);
|
||||
#else
|
||||
FD_ZERO(&bitmap);
|
||||
FD_SET(fileno(stdin), &bitmap);
|
||||
select(fileno(stdin) + 1, &bitmap, NULL, NULL, t_p);
|
||||
|
||||
if (!FD_ISSET(fileno(stdin), &bitmap))
|
||||
return (0);
|
||||
#endif
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 受信 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int UNIXSerialPort_ReceiveCharacter(UNIXSerialPort unix_serial_port,
|
||||
int timeout)
|
||||
{
|
||||
int c;
|
||||
|
||||
if (UNIXSerialPort_IsClosed(unix_serial_port)) return (-1);
|
||||
|
||||
c = UNIXSerialPort_IsDataExisting(unix_serial_port, timeout)
|
||||
? fgetc(stdin) : -1;
|
||||
c = (c == '\n') ? '\r' : c; /* \r のエミュレーション */
|
||||
|
||||
return (c);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 送信 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int UNIXSerialPort_SendCharacter(UNIXSerialPort unix_serial_port,
|
||||
unsigned char c)
|
||||
{
|
||||
if (UNIXSerialPort_IsClosed(unix_serial_port)) return (0);
|
||||
|
||||
wonx_print_character(stdout, c);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの作成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
UNIXSerialPort UNIXSerialPort_Create()
|
||||
{
|
||||
UNIXSerialPort unix_serial_port;
|
||||
|
||||
unix_serial_port = (UNIXSerialPort)malloc(sizeof(_UNIXSerialPort));
|
||||
if (unix_serial_port == NULL)
|
||||
WonX_Error("UNIXSerialPort_Create", "Cannot allocate memory.");
|
||||
|
||||
unix_serial_port->opened = 0;
|
||||
|
||||
return (unix_serial_port);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
UNIXSerialPort UNIXSerialPort_Destroy(UNIXSerialPort unix_serial_port)
|
||||
{
|
||||
if (unix_serial_port == NULL)
|
||||
WonX_Error("UNIXSerialPort_Destroy", "Object is not created.");
|
||||
|
||||
if (UNIXSerialPort_IsOpened(unix_serial_port)) {
|
||||
UNIXSerialPort_Close(unix_serial_port);
|
||||
unix_serial_port->opened = 0;
|
||||
}
|
||||
|
||||
free(unix_serial_port);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
@ -1,82 +0,0 @@
|
||||
#ifndef _UNIXSerialPort_h_INCLUDED_
|
||||
#define _UNIXSerialPort_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _UNIXSerialPort * UNIXSerialPort;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ポートの open/close */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int UNIXSerialPort_Open(UNIXSerialPort unix_serial_port);
|
||||
int UNIXSerialPort_Close(UNIXSerialPort unix_serial_port);
|
||||
|
||||
int UNIXSerialPort_IsOpened(UNIXSerialPort unix_serial_port);
|
||||
int UNIXSerialPort_IsClosed(UNIXSerialPort unix_serial_port);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 受信データがあるかどうか */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* タイムアウト時間をミリ秒単位で指定.
|
||||
* 0 のときは,即時
|
||||
* -1 のときは,無期限待ち
|
||||
*/
|
||||
|
||||
int UNIXSerialPort_IsDataExisting(UNIXSerialPort unix_serial_port,
|
||||
int timeout);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 受信 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int UNIXSerialPort_ReceiveCharacter(UNIXSerialPort unix_serial_port,
|
||||
int timeout);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 送信 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int UNIXSerialPort_SendCharacter(UNIXSerialPort unix_serial_port,
|
||||
unsigned char c);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの作成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
UNIXSerialPort UNIXSerialPort_Create();
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
UNIXSerialPort UNIXSerialPort_Destroy(UNIXSerialPort unix_serial_port);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
66
UNIXTimer.c
66
UNIXTimer.c
@ -6,7 +6,7 @@
|
||||
#include <signal.h>
|
||||
|
||||
#include "UNIXTimerP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
@ -23,21 +23,17 @@ volatile static UNIXTimer pointed_unix_timer = NULL;
|
||||
static void UNIXTimer_CallBackFunction(int argument)
|
||||
{
|
||||
int ret;
|
||||
int old;
|
||||
|
||||
/*
|
||||
* static なフラグを立てて,コールバック関数からコールバック関数が
|
||||
* 呼ばれたのを検出するのが必要かも.
|
||||
*/
|
||||
static なフラグを立てて,コールバック関数からコールバック関数が
|
||||
呼ばれたのを検出するのが必要かも.
|
||||
*/
|
||||
|
||||
if (pointed_unix_timer == NULL) return;
|
||||
if (!pointed_unix_timer->timer_on) return;
|
||||
|
||||
if (pointed_unix_timer->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 {
|
||||
if (pointed_unix_timer->interrupt_in_pause == 0)
|
||||
pointed_unix_timer->interrupt_in_pause = 1;
|
||||
@ -48,15 +44,13 @@ static void UNIXTimer_CallBackFunction(int argument)
|
||||
/*
|
||||
* コールバック関数の中から UNIXTimer_Unpause() などが呼ばれて,
|
||||
* そこからさらにコールバック関数が呼ばれたりしたときのために,
|
||||
* ポーズする.またこのとき,interrupt_in_pause がインクリメント
|
||||
* されると無限ループに陥ってしまう可能性がある(?)ので,
|
||||
* interrupt_in_pause を保存してコールバック関数の実行後に元に戻す.
|
||||
* ポーズする.
|
||||
*/
|
||||
pointed_unix_timer->pause++;
|
||||
old = pointed_unix_timer->interrupt_in_pause;
|
||||
|
||||
ret = (*pointed_unix_timer->callback)(pointed_unix_timer->parameter);
|
||||
|
||||
pointed_unix_timer->pause--;
|
||||
pointed_unix_timer->interrupt_in_pause = old;
|
||||
|
||||
/*
|
||||
* コールバック関数の中で UNIXTimer_* 関連の関数が呼び出されると,
|
||||
@ -107,29 +101,9 @@ static void UNIXTimer_CallBackFunction(int argument)
|
||||
|
||||
int UNIXTimer_ON(UNIXTimer unix_timer)
|
||||
{
|
||||
int t;
|
||||
|
||||
unix_timer->timer_on = 1;
|
||||
pointed_unix_timer = unix_timer;
|
||||
|
||||
/*
|
||||
* SIGALRM を使用するので,sleep() 中にアラームが起きた場合には,
|
||||
* コールバック関数からの復帰後に sleep() の残り時間は継続されない.
|
||||
*/
|
||||
signal(SIGALRM, UNIXTimer_CallBackFunction);
|
||||
|
||||
#if 0 /* use ualarm() */
|
||||
/* ualarm(); の引数に0を用いてはダメなので */
|
||||
t = unix_timer->interval * 1000;
|
||||
if (t < 1) t = 1;
|
||||
ualarm(t, 0);
|
||||
#else /* use alarm() */
|
||||
/* alarm(); の引数に0を用いてはダメなので */
|
||||
t = unix_timer->interval / 1000;
|
||||
if (t < 1) t = 1;
|
||||
alarm(t);
|
||||
#endif
|
||||
|
||||
ualarm(unix_timer->interval, 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@ -176,9 +150,7 @@ int UNIXTimer_Pause(UNIXTimer unix_timer)
|
||||
int UNIXTimer_Unpause(UNIXTimer unix_timer)
|
||||
{
|
||||
if (unix_timer->pause == 0)
|
||||
WonX_Error("UNIXTimer_Unpause", "Duplicated unpause.");
|
||||
if (unix_timer->pause < 0)
|
||||
WonX_Error("UNIXTimer_Unpause", "Invalid pause.");
|
||||
Error("UNIXTimer_Unpause", "Duplicated unpause.");
|
||||
|
||||
if (unix_timer->pause == 1) {
|
||||
if (unix_timer->interrupt_in_pause > 0) {
|
||||
@ -206,10 +178,6 @@ int UNIXTimer_Unpause(UNIXTimer unix_timer)
|
||||
|
||||
/* コールバック関数の呼び出し */
|
||||
UNIXTimer_CallBackFunction(0);
|
||||
} else {
|
||||
if (unix_timer->interrupt_in_pause < 0)
|
||||
WonX_Error("UNIXTimer_Unpause", "Invalid interrupt_in_pause.");
|
||||
unix_timer->pause--; /* ポーズはネストできる */
|
||||
}
|
||||
} else {
|
||||
unix_timer->pause--; /* ポーズはネストできる */
|
||||
@ -239,7 +207,11 @@ int UNIXTimer_IsAutoPreset(UNIXTimer unix_timer)
|
||||
int UNIXTimer_GetInterval(UNIXTimer unix_timer)
|
||||
{ return (unix_timer->interval); }
|
||||
int UNIXTimer_SetInterval(UNIXTimer unix_timer, int interval)
|
||||
{ return (unix_timer->interval = interval); }
|
||||
{
|
||||
/* ualarm(); の引数に0を用いてはダメなので */
|
||||
if (interval < 1) interval = 1;
|
||||
return (unix_timer->interval = interval);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* コールバック関数の呼び出し時のパラメータ */
|
||||
@ -271,7 +243,7 @@ UNIXTimer UNIXTimer_Create(int auto_preset, int interval, void * parameter,
|
||||
|
||||
unix_timer = (UNIXTimer)malloc(sizeof(_UNIXTimer));
|
||||
if (unix_timer == NULL)
|
||||
WonX_Error("UNIXTimer_Create", "Cannot allocate memory.");
|
||||
Error("UNIXTimer_Create", "Cannot allocate memory.");
|
||||
|
||||
unix_timer->timer_on = 0;
|
||||
unix_timer->pause = 0;
|
||||
@ -288,6 +260,12 @@ UNIXTimer UNIXTimer_Create(int auto_preset, int interval, void * parameter,
|
||||
UNIXTimer_SetParameter(unix_timer, parameter);
|
||||
UNIXTimer_SetCallBack(unix_timer, callback);
|
||||
|
||||
/*
|
||||
* SIGALRM を使用するので,sleep() 中にアラームが起きた場合には,
|
||||
* コールバック関数からの復帰後に sleep() の残り時間は継続されない.
|
||||
*/
|
||||
signal(SIGALRM, UNIXTimer_CallBackFunction);
|
||||
|
||||
return (unix_timer);
|
||||
}
|
||||
|
||||
@ -303,7 +281,7 @@ UNIXTimer UNIXTimer_Create(int auto_preset, int interval, void * parameter,
|
||||
UNIXTimer UNIXTimer_Destroy(UNIXTimer unix_timer)
|
||||
{
|
||||
if (unix_timer == NULL)
|
||||
WonX_Error("UNIXTimer_Destroy", "Object is not created.");
|
||||
Error("UNIXTimer_Destroy", "Object is not created.");
|
||||
|
||||
UNIXTimer_OFF(unix_timer);
|
||||
|
||||
|
||||
10
UNIXTimer.h
10
UNIXTimer.h
@ -5,6 +5,9 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
@ -12,13 +15,6 @@
|
||||
typedef struct _UNIXTimer * UNIXTimer;
|
||||
typedef int (*UNIXTimerCallBack)(void *);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
@ -19,7 +19,7 @@ typedef struct _UNIXTimer {
|
||||
* タイマの一時停止.停止中にタイマの時間が来た場合には,
|
||||
* 時間が来たことだけ記憶しておき,一時停止の解除時にコールバック関数が
|
||||
* 呼び出される.
|
||||
* WonX では X サーバとの通信中にタイマ割り込みが入って,さらに X サーバとの
|
||||
* Wonx では X サーバとの通信中にタイマ割り込みが入って,さらに X サーバとの
|
||||
* 通信が発生したりすると,通信の整合性がとれなくなるような気がするので,
|
||||
* それを防ぐために,一部の関数内部ではタイマ割り込みを停止させる.
|
||||
*/
|
||||
@ -32,7 +32,7 @@ typedef struct _UNIXTimer {
|
||||
int interrupt_in_pause;
|
||||
|
||||
int auto_preset; /* オートプリセット.1 だとオートプリセットを行う */
|
||||
int interval; /* タイマのインターバル.ミリ秒で指定 */
|
||||
int interval; /* タイマのインターバル.マイクロ秒で指定 */
|
||||
void * parameter; /* コールバック関数の呼び出し時のパラメータ */
|
||||
UNIXTimerCallBack callback; /* コールバック関数 */
|
||||
|
||||
|
||||
266
WWCharacter.c
266
WWCharacter.c
@ -2,136 +2,38 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "WWCharacterP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ナンバーの操作 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WWCharacter_GetNumber(WWCharacter c)
|
||||
{
|
||||
if (c == NULL) WonX_Error("WWCharacter_GetNumber", "WWCharacter is NULL.");
|
||||
if (c == NULL) Error("WWCharacter_GetNumber()", "WWCharacter is NULL.");
|
||||
|
||||
return (c->number);
|
||||
}
|
||||
|
||||
int WWCharacter_SetNumber(WWCharacter c, int n)
|
||||
{
|
||||
if (c == NULL) WonX_Error("WWCharacter_SetNumber", "WWCharacter is NULL.");
|
||||
|
||||
if ((n < 0) || (n > 512 - 1))
|
||||
WonX_Error("WWCharacter_SetNumber", "Invalid range.");
|
||||
if ((n < 0) || (n >= 512))
|
||||
Error("WWCharacter_SetNumber()", "Invalid range.");
|
||||
|
||||
return (c->number = n);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ビットマップの操作 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* char 型として操作するための関数 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
unsigned char WWCharacter_GetBitmapAsChar(WWCharacter c, int n)
|
||||
{
|
||||
if (c == NULL)
|
||||
WonX_Error("WWCharacter_GetBitmapAsChar", "WWCharacter is NULL.");
|
||||
|
||||
if ((n < 0) || (n > 32 - 1))
|
||||
WonX_Error("WWCharacter_GetBitmapAsChar", "Invalid range.");
|
||||
|
||||
return (c->bitmap.bitmap_char[n]);
|
||||
}
|
||||
|
||||
unsigned char WWCharacter_SetBitmapAsChar(WWCharacter c, int n,
|
||||
unsigned char bitmap)
|
||||
{
|
||||
if (c == NULL)
|
||||
WonX_Error("WWCharacter_SetBitmapAsChar", "WWCharacter is NULL.");
|
||||
|
||||
if ((n < 0) || (n > 32 - 1))
|
||||
WonX_Error("WWCharacter_SetBitmapAsChar", "Invalid range.");
|
||||
|
||||
return (c->bitmap.bitmap_char[n] = bitmap);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* short int 型として操作するための関数 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
unsigned short int WWCharacter_GetBitmapAsShortInt(WWCharacter c, int n)
|
||||
{
|
||||
if (c == NULL)
|
||||
WonX_Error("WWCharacter_GetBitmapAsShortInt", "WWCharacter is NULL.");
|
||||
|
||||
if ((n < 0) || (n > 16 - 1))
|
||||
WonX_Error("WWCharacter_GetBitmapAsShortInt", "Invalid range.");
|
||||
|
||||
return (c->bitmap.bitmap_short_int[n]);
|
||||
}
|
||||
|
||||
unsigned short int WWCharacter_SetBitmapAsShortInt(WWCharacter c, int n,
|
||||
unsigned short int bitmap)
|
||||
{
|
||||
if (c == NULL)
|
||||
WonX_Error("WWCharacter_SetBitmapAsShortInt", "WWCharacter is NULL.");
|
||||
|
||||
if ((n < 0) || (n > 16 - 1))
|
||||
WonX_Error("WWCharacter_SetBitmapAsShortInt", "Invalid range.");
|
||||
|
||||
return (c->bitmap.bitmap_short_int[n] = bitmap);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* long int 型として操作するための関数 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
unsigned long int WWCharacter_GetBitmapAsLongInt(WWCharacter c, int n)
|
||||
{
|
||||
if (c == NULL)
|
||||
WonX_Error("WWCharacter_GetBitmapAsLongInt", "WWCharacter is NULL.");
|
||||
|
||||
if ((n < 0) || (n > 8 - 1))
|
||||
WonX_Error("WWCharacter_GetBitmapAsLongInt", "Invalid range.");
|
||||
|
||||
return (c->bitmap.bitmap_long_int[n]);
|
||||
}
|
||||
|
||||
unsigned long int WWCharacter_SetBitmapAsLongInt(WWCharacter c, int n,
|
||||
unsigned long int bitmap)
|
||||
{
|
||||
if (c == NULL)
|
||||
WonX_Error("WWCharacter_SetBitmapAsLongInt", "WWCharacter is NULL.");
|
||||
|
||||
if ((n < 0) || (n > 8 - 1))
|
||||
WonX_Error("WWCharacter_SetBitmapAsLongInt", "Invalid range.");
|
||||
|
||||
return (c->bitmap.bitmap_long_int[n] = bitmap);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* オブジェクトの生成と削除 */
|
||||
/*===========================================================================*/
|
||||
|
||||
WWCharacter WWCharacter_Create(int number)
|
||||
WWCharacter WWCharacter_Create(int number, unsigned char * bitmap)
|
||||
{
|
||||
WWCharacter character;
|
||||
|
||||
character = (WWCharacter)malloc(sizeof(_WWCharacter));
|
||||
if (character == NULL)
|
||||
WonX_Error("WWCharacter_Create", "Cannot allocate memory.");
|
||||
Error("WWCharacter_Create", "Cannot allocate memory.");
|
||||
|
||||
WWCharacter_SetNumber(character, number);
|
||||
WWCharacter_ClearAllPixels(character);
|
||||
WWCharacter_SetBitmap(character, bitmap);
|
||||
|
||||
return (character);
|
||||
}
|
||||
@ -139,135 +41,89 @@ WWCharacter WWCharacter_Create(int number)
|
||||
WWCharacter WWCharacter_Destroy(WWCharacter character)
|
||||
{
|
||||
if (character == NULL)
|
||||
WonX_Error("WWCharacter_Destroy", "Object is not created.");
|
||||
Error("WWCharacter_Destroy()", "WWCharacter is NULL.");
|
||||
free(character);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ピクセルの操作 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WWCharacter_GetPixel(WWCharacter character, int x, int y,
|
||||
WWDisplay display)
|
||||
int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap)
|
||||
{
|
||||
unsigned short int pixel;
|
||||
unsigned short int spixel;
|
||||
unsigned long int lpixel;
|
||||
int i;
|
||||
|
||||
if (character == NULL)
|
||||
WonX_Error("WWCharacter_GetPixel", "WWCharacter is NULL.");
|
||||
Error("WWCharacter_SetBitmap()", "WWCharacter is NULL.");
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (bitmap == NULL) {
|
||||
character->bitmap[i] = 0x00;
|
||||
} else {
|
||||
character->bitmap[i] = bitmap[i];
|
||||
}
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int WWCharacter_GetPixel(WWCharacter character, int x, int y)
|
||||
{
|
||||
if (character == NULL)
|
||||
Error("WWCharacter_GetPixel()", "WWCharacter is NULL.");
|
||||
|
||||
if ((x < 0) || (x > 7))
|
||||
WonX_Error("WWCharacter_GetPixel", "x is out of range.");
|
||||
Error("WWCharacter_GetPixel()", "x is invalid value.");
|
||||
if ((y < 0) || (y > 7))
|
||||
WonX_Error("WWCharacter_GetPixel", "y is out of range.");
|
||||
Error("WWCharacter_GetPixel()", "y is invalid value.");
|
||||
|
||||
/* パレット色を返す */
|
||||
pixel = 0;
|
||||
switch (WWDisplay_GetColorMode(display)) {
|
||||
case COLOR_MODE_GRAYSCALE:
|
||||
case COLOR_MODE_4COLOR:
|
||||
spixel = (character->bitmap.bitmap_short_int[y] >> (7-x)) & 0x0101;
|
||||
pixel =
|
||||
((spixel & 0x0001) ? 1 : 0) |
|
||||
((spixel & 0x0100) ? 2 : 0);
|
||||
#if 0
|
||||
pixel = ((character->bitmap.bitmap_char[y * 2 + 0] >> (7-x)) & 1) << 0;
|
||||
pixel |= ((character->bitmap.bitmap_char[y * 2 + 1] >> (7-x)) & 1) << 1;
|
||||
#endif
|
||||
break;
|
||||
case COLOR_MODE_16COLOR:
|
||||
lpixel = (character->bitmap.bitmap_long_int[y] >> (7-x)) & 0x01010101;
|
||||
pixel =
|
||||
((lpixel & 0x00000001) ? 1 : 0) |
|
||||
((lpixel & 0x00000100) ? 2 : 0) |
|
||||
((lpixel & 0x00010000) ? 4 : 0) |
|
||||
((lpixel & 0x01000000) ? 8 : 0);
|
||||
#if 0
|
||||
pixel = ((character->bitmap[y * 4 + 0] >> (7-x)) & 1) << 0;
|
||||
pixel |= ((character->bitmap[y * 4 + 1] >> (7-x)) & 1) << 1;
|
||||
pixel |= ((character->bitmap[y * 4 + 2] >> (7-x)) & 1) << 2;
|
||||
pixel |= ((character->bitmap[y * 4 + 3] >> (7-x)) & 1) << 3;
|
||||
#endif
|
||||
break;
|
||||
case COLOR_MODE_16PACKED:
|
||||
lpixel = character->bitmap.bitmap_long_int[y];
|
||||
lpixel = lpixel >> (3 - (7-x) / 2) * 8;
|
||||
lpixel = lpixel >> ((7-x) % 2) * 4;
|
||||
pixel = lpixel & 0x0f;
|
||||
#if 0
|
||||
pixel = character->bitmap[y * 4 + 3 - (7-x) / 2] >> (((7-x) % 2) * 4);
|
||||
pixel &= 0x0f;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
WonX_Error("WWCharacter_GetPixel", "Unknown color mode.");
|
||||
}
|
||||
/* ビットマップは2ビットでぴとつのピクセルに対応する. */
|
||||
/* 2ビットの値が,palette の色に対応する. */
|
||||
/* bitmap は unsigned char bitmap[16]; に定義してある. */
|
||||
|
||||
/* パレット色(0~3)を返す */
|
||||
return ( (character->bitmap[y * 2 + x / 4] >> ((x % 4) * 2)) & 0x03 );
|
||||
}
|
||||
|
||||
int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel)
|
||||
{
|
||||
unsigned char p;
|
||||
if (character == NULL)
|
||||
Error("WWCharacter_SetPixel()", "WWCharacter is NULL.");
|
||||
|
||||
if ((x < 0) || (x > 7))
|
||||
Error("WWCharacter_SetPixel()", "x is invalid value.");
|
||||
if ((y < 0) || (y > 7))
|
||||
Error("WWCharacter_SetPixel()", "y is invalid value.");
|
||||
if ((pixel < 0) || (pixel > 3))
|
||||
Error("WWCharacter_SetPixel()", "Invalid pixel.");
|
||||
|
||||
p = ((unsigned char)pixel) & 0x03;
|
||||
p = p << ((x % 4) * 2);
|
||||
|
||||
character->bitmap[y * 2 + x / 4] &= ~(0x03 << ((x % 4) * 2));
|
||||
character->bitmap[y * 2 + x / 4] |= p;
|
||||
|
||||
return (pixel);
|
||||
}
|
||||
|
||||
int WWCharacter_ClearAllPixels(WWCharacter character)
|
||||
int WWCharacter_CopyBitmap(WWCharacter dst, WWCharacter src)
|
||||
{
|
||||
if (character == NULL)
|
||||
WonX_Error("WWCharacter_ClearAllPixels", "WWCharacter is NULL.");
|
||||
|
||||
memset(character->bitmap.bitmap_char, 0, 32);
|
||||
|
||||
return (0);
|
||||
return (WWCharacter_SetBitmap(dst, src->bitmap));
|
||||
}
|
||||
|
||||
int WWCharacter_CopyAllPixels(WWCharacter dst, WWCharacter src)
|
||||
int WWCharacter_PrintData(WWCharacter character, FILE * f)
|
||||
{
|
||||
if (dst == NULL)
|
||||
WonX_Error("WWCharacter_CopyAllPixel", "dst is NULL.");
|
||||
if (src == NULL)
|
||||
WonX_Error("WWCharacter_CopyAllPixel", "src is NULL.");
|
||||
|
||||
memcpy(dst->bitmap.bitmap_char, src->bitmap.bitmap_char, 32);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 内部データ出力 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WWCharacter_PrintData(WWCharacter character, WWDisplay display, FILE * f)
|
||||
{
|
||||
int i, x, y, n;
|
||||
int pixel;
|
||||
|
||||
if (character == NULL)
|
||||
WonX_Error("WWCharacter_PrintData", "WWCharacter is NULL.");
|
||||
int x, y, n;
|
||||
|
||||
n = WWCharacter_GetNumber(character);
|
||||
|
||||
fprintf(f, "\n");
|
||||
|
||||
fprintf(f, "character[%03d] :\tnumber = %d\n",
|
||||
fprintf(f, "character[%d] :\tnumber = %d\n",
|
||||
n, WWCharacter_GetNumber(character));
|
||||
|
||||
for (i = 0; i < 32; i += 8) {
|
||||
fprintf(f, "character[%03d] :\tbitmap[%02d] =", n, i);
|
||||
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i ));
|
||||
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+1));
|
||||
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+2));
|
||||
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+3));
|
||||
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+4));
|
||||
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+5));
|
||||
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+6));
|
||||
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+7));
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
fprintf(f, "character[%03d] :\tpixels : 01234567\n", n);
|
||||
for (y = 0; y < 8; y++) {
|
||||
fprintf(f, "character[%03d] :\tpixels : %01d ", n, y);
|
||||
fprintf(f, "character[%d] :\tbitmap : ", n);
|
||||
for (x = 0; x < 8; x++) {
|
||||
pixel = WWCharacter_GetPixel(character, x, y, display);
|
||||
fprintf(f, "%c", wonx_dec_to_hex(pixel));
|
||||
fprintf(f, "%d", WWCharacter_GetPixel(character, x, y));
|
||||
}
|
||||
fprintf(f, "\n");
|
||||
}
|
||||
|
||||
@ -5,82 +5,28 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWCharacter * WWCharacter;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "WWDisplay.h"
|
||||
#include "wonx/libwwc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ナンバーの操作 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WWCharacter_GetNumber(WWCharacter c);
|
||||
int WWCharacter_SetNumber(WWCharacter c, int n);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ビットマップの操作 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* char 型として操作するための関数 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
unsigned char WWCharacter_GetBitmapAsChar(WWCharacter c, int n);
|
||||
unsigned char WWCharacter_SetBitmapAsChar(WWCharacter c, int n,
|
||||
unsigned char bitmap);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* short int 型として操作するための関数 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
unsigned short int WWCharacter_GetBitmapAsShortInt(WWCharacter c, int n);
|
||||
unsigned short int WWCharacter_SetBitmapAsShortInt(WWCharacter c, int n,
|
||||
unsigned short int bitmap);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* long int 型として操作するための関数 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
unsigned long int WWCharacter_GetBitmapAsLongInt(WWCharacter c, int n);
|
||||
unsigned long int WWCharacter_SetBitmapAsLongInt(WWCharacter c, int n,
|
||||
unsigned long int bitmap);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* オブジェクトの生成と削除 */
|
||||
/*===========================================================================*/
|
||||
|
||||
WWCharacter WWCharacter_Create(int number);
|
||||
WWCharacter WWCharacter_Create(int number, unsigned char * bitmap);
|
||||
WWCharacter WWCharacter_Destroy(WWCharacter character);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ピクセルの操作 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WWCharacter_GetPixel(WWCharacter character, int x, int y,
|
||||
WWDisplay display);
|
||||
int WWCharacter_ClearAllPixels(WWCharacter character);
|
||||
int WWCharacter_CopyAllPixels(WWCharacter dst, WWCharacter src);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 内部データ出力 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WWCharacter_PrintData(WWCharacter character, WWDisplay display, FILE * f);
|
||||
int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap);
|
||||
int WWCharacter_GetPixel(WWCharacter character, int x, int y);
|
||||
int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel);
|
||||
int WWCharacter_CopyBitmap(WWCharacter dst, WWCharacter src);
|
||||
int WWCharacter_PrintData(WWCharacter character, FILE * f);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
|
||||
@ -14,12 +14,9 @@
|
||||
typedef struct _WWCharacter {
|
||||
int number;
|
||||
|
||||
/* キャラクタのビットマップ */
|
||||
union {
|
||||
unsigned char bitmap_char[32];
|
||||
unsigned short int bitmap_short_int[16];
|
||||
unsigned long int bitmap_long_int[8];
|
||||
} bitmap;
|
||||
/* ビットマップは2ビットでぴとつのピクセルに対応する. */
|
||||
/* 2ビットの値が,palette の色に対応する. */
|
||||
unsigned char bitmap[16];
|
||||
} _WWCharacter;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
10
WWColorMap.c
10
WWColorMap.c
@ -3,7 +3,7 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWColorMapP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ĽáĽóĽĐ´Řżô¤ÎÄęľÁ */
|
||||
@ -14,8 +14,7 @@ WWColorMap WWColorMap_Create(int * lcd_colors)
|
||||
WWColorMap color_map;
|
||||
|
||||
color_map = (WWColorMap)malloc(sizeof(_WWColorMap));
|
||||
if (color_map == NULL)
|
||||
WonX_Error("WWColorMap_Create", "Cannot allocate memory");
|
||||
if (color_map == NULL) Error("WWColorMap_Create", "Cannot allocate memory");
|
||||
|
||||
WWColorMap_SetLCDColors(color_map, lcd_colors);
|
||||
|
||||
@ -24,8 +23,7 @@ WWColorMap WWColorMap_Create(int * lcd_colors)
|
||||
|
||||
WWColorMap WWColorMap_Destroy(WWColorMap color_map)
|
||||
{
|
||||
if (color_map == NULL)
|
||||
WonX_Error("WWColorMap_Destroy", "Object is not created.");
|
||||
if (color_map == NULL) return (NULL);
|
||||
free(color_map);
|
||||
return (NULL);
|
||||
}
|
||||
@ -73,7 +71,7 @@ int WWColorMap_PrintData(WWColorMap c, FILE * f)
|
||||
fprintf(f, "\n");
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
fprintf(f, "colormap :\tcolor[%01d] = %d\n",
|
||||
fprintf(f, "colormap :\tcolor[%d] = %d\n",
|
||||
i, WWColorMap_GetLCDColor(c, i));
|
||||
}
|
||||
|
||||
|
||||
10
WWColorMap.h
10
WWColorMap.h
@ -5,19 +5,15 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWColorMap * WWColorMap;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
68
WWCursor.c
68
WWCursor.c
@ -1,68 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWCursorP.h"
|
||||
#include "WonX.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
int WWCursor_ON( WWCursor p) { return (p->on = 1); }
|
||||
int WWCursor_OFF( WWCursor p) { return (p->on = 0); }
|
||||
int WWCursor_IsON( WWCursor p) { return (p->on != 0); }
|
||||
int WWCursor_IsOFF(WWCursor p) { return (p->on == 0); }
|
||||
|
||||
int WWCursor_GetX( WWCursor p ) { return (p->x ); }
|
||||
int WWCursor_SetX( WWCursor p, int n) { return (p->x = n); }
|
||||
int WWCursor_GetY( WWCursor p ) { return (p->y ); }
|
||||
int WWCursor_SetY( WWCursor p, int n) { return (p->y = n); }
|
||||
int WWCursor_GetWidth( WWCursor p ) { return (p->width ); }
|
||||
int WWCursor_SetWidth( WWCursor p, int n) { return (p->width = n); }
|
||||
int WWCursor_GetHeight( WWCursor p ) { return (p->height ); }
|
||||
int WWCursor_SetHeight( WWCursor p, int n) { return (p->height = n); }
|
||||
int WWCursor_GetInterval(WWCursor p ) { return (p->interval ); }
|
||||
int WWCursor_SetInterval(WWCursor p, int n) { return (p->interval = n); }
|
||||
|
||||
WWPalette WWCursor_GetPalette(WWCursor p)
|
||||
{ return (p->palette ); }
|
||||
WWPalette WWCursor_SetPalette(WWCursor p, WWPalette plt)
|
||||
{ return (p->palette = plt); }
|
||||
|
||||
WWCursor WWCursor_Create(WWPalette palette)
|
||||
{
|
||||
WWCursor cursor;
|
||||
|
||||
cursor = (WWCursor)malloc(sizeof(_WWCursor));
|
||||
if (cursor == NULL)
|
||||
WonX_Error("WWCursor_Create", "Cannot allocate memory");
|
||||
|
||||
WWCursor_OFF(cursor);
|
||||
|
||||
WWCursor_SetX( cursor, 0);
|
||||
WWCursor_SetY( cursor, 0);
|
||||
WWCursor_SetWidth( cursor, 1);
|
||||
WWCursor_SetHeight( cursor, 1);
|
||||
WWCursor_SetInterval(cursor, 30);
|
||||
|
||||
WWCursor_SetPalette(cursor, palette);
|
||||
|
||||
return (cursor);
|
||||
}
|
||||
|
||||
WWCursor WWCursor_Destroy(WWCursor cursor)
|
||||
{
|
||||
if (cursor == NULL)
|
||||
WonX_Error("WWCursor_Destroy", "Object is not created.");
|
||||
free(cursor);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
57
WWCursor.h
57
WWCursor.h
@ -1,57 +0,0 @@
|
||||
#ifndef _WWCursor_h_INCLUDED_
|
||||
#define _WWCursor_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWCursor * WWCursor;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "WWPalette.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
int WWCursor_ON( WWCursor p);
|
||||
int WWCursor_OFF( WWCursor p);
|
||||
int WWCursor_IsON( WWCursor p);
|
||||
int WWCursor_IsOFF(WWCursor p);
|
||||
|
||||
int WWCursor_GetX( WWCursor p );
|
||||
int WWCursor_SetX( WWCursor p, int n);
|
||||
int WWCursor_GetY( WWCursor p );
|
||||
int WWCursor_SetY( WWCursor p, int n);
|
||||
int WWCursor_GetWidth( WWCursor p );
|
||||
int WWCursor_SetWidth( WWCursor p, int n);
|
||||
int WWCursor_GetHeight( WWCursor p );
|
||||
int WWCursor_SetHeight( WWCursor p, int n);
|
||||
int WWCursor_GetInterval(WWCursor p );
|
||||
int WWCursor_SetInterval(WWCursor p, int n);
|
||||
|
||||
WWPalette WWCursor_GetPalette(WWCursor p);
|
||||
WWPalette WWCursor_SetPalette(WWCursor p, WWPalette plt);
|
||||
|
||||
WWCursor WWCursor_Create(WWPalette palette);
|
||||
WWCursor WWCursor_Destroy(WWCursor cursor);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
30
WWCursorP.h
30
WWCursorP.h
@ -1,30 +0,0 @@
|
||||
#ifndef _WWCursorP_h_INCLUDED_
|
||||
#define _WWCursorP_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWCursor.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWCursor {
|
||||
int on; /* 表示/非表示のフラグ */
|
||||
int x, y; /* カーソル座標 */
|
||||
int width, height; /* カーソルのサイズ */
|
||||
int interval; /* 点滅周期 */
|
||||
WWPalette palette; /* カーソル表示用パレット */
|
||||
} _WWCursor;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
220
WWDisplay.c
220
WWDisplay.c
@ -2,12 +2,8 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "wonx/disp.h"
|
||||
#include "wonx/text.h"
|
||||
#include "wonx/libwwc.h"
|
||||
|
||||
#include "WWDisplayP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
@ -24,10 +20,6 @@ WWCharacter WWDisplay_GetCharacter(WWDisplay d, int n)
|
||||
WWSprite WWDisplay_GetSprite(WWDisplay d, int n) { return (d->sprite[n]); }
|
||||
WWScreen WWDisplay_GetScreen(WWDisplay d, int n) { return (d->screen[n]); }
|
||||
WWLCDPanel WWDisplay_GetLCDPanel(WWDisplay d) { return (d->lcd_panel); }
|
||||
WWText WWDisplay_GetText(WWDisplay d) { return (d->text); }
|
||||
WWCursor WWDisplay_GetCursor(WWDisplay d) { return (d->cursor); }
|
||||
|
||||
unsigned int WWDisplay_GetColorMode(WWDisplay d) { return (d->color_mode); }
|
||||
|
||||
int WWDisplay_GetSpriteEnable(WWDisplay d) { return (d->sprite_enable); }
|
||||
int WWDisplay_GetSpriteWindowEnable(WWDisplay d)
|
||||
@ -42,10 +34,7 @@ int WWDisplay_GetSpriteWindowWidth(WWDisplay d)
|
||||
int WWDisplay_GetSpriteWindowHeight(WWDisplay d)
|
||||
{ return (d->sprite_window_height); }
|
||||
|
||||
WWPalette WWDisplay_GetBorderPalette(WWDisplay d)
|
||||
{ return (d->border_palette); }
|
||||
int WWDisplay_GetBorderColor(WWDisplay d)
|
||||
{ return (d->border_color); }
|
||||
int WWDisplay_GetBorder(WWDisplay d) { return (d->border); }
|
||||
|
||||
int WWDisplay_GetForegroundColor(WWDisplay d) { return (d->foreground_color); }
|
||||
int WWDisplay_GetBackgroundColor(WWDisplay d) { return (d->background_color); }
|
||||
@ -69,13 +58,6 @@ WWScreen WWDisplay_SetScreen(WWDisplay d, int n, WWScreen s)
|
||||
{ return (d->screen[n] = s); }
|
||||
WWLCDPanel WWDisplay_SetLCDPanel(WWDisplay d, WWLCDPanel p)
|
||||
{ return (d->lcd_panel = p); }
|
||||
WWText WWDisplay_SetText(WWDisplay d, WWText p)
|
||||
{ return (d->text = p); }
|
||||
WWCursor WWDisplay_SetCursor(WWDisplay d, WWCursor p)
|
||||
{ return (d->cursor = p); }
|
||||
|
||||
unsigned int WWDisplay_SetColorMode(WWDisplay d, unsigned int mode)
|
||||
{ return (d->color_mode = mode); }
|
||||
|
||||
int WWDisplay_SetSpriteEnable(WWDisplay d, int f)
|
||||
{ return (d->sprite_enable = f); }
|
||||
@ -91,10 +73,7 @@ int WWDisplay_SetSpriteWindowWidth(WWDisplay d, int n)
|
||||
int WWDisplay_SetSpriteWindowHeight(WWDisplay d, int n)
|
||||
{ return (d->sprite_window_height = n); }
|
||||
|
||||
WWPalette WWDisplay_SetBorderPalette(WWDisplay d, WWPalette p)
|
||||
{ return (d->border_palette = p); }
|
||||
int WWDisplay_SetBorderColor(WWDisplay d, int b)
|
||||
{ return (d->border_color = b); }
|
||||
int WWDisplay_SetBorder(WWDisplay d, int b) { return (d->border = b); }
|
||||
|
||||
int WWDisplay_SetForegroundColor(WWDisplay d, int c)
|
||||
{ return (d->foreground_color = c); }
|
||||
@ -115,42 +94,19 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
|
||||
{
|
||||
WWDisplay display;
|
||||
int i;
|
||||
static int default_lcd_colors[] = {
|
||||
0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0f
|
||||
};
|
||||
static struct palette_colors {
|
||||
int colors[4];
|
||||
} default_palette_colors[] = {
|
||||
{{0, 3, 5, 7}}, {{2, 3, 5, 7}}, {{0, 0, 0, 7}}, {{2, 0, 0, 7}},
|
||||
{{0, 0, 3, 7}}, {{0, 7, 7, 7}}, {{0, 7, 7, 7}}, {{0, 0, 2, 7}},
|
||||
{{2, 5, 7, 7}}, {{7, 7, 7, 7}}, {{7, 6, 5, 7}}, {{3, 7, 5, 7}},
|
||||
{{0, 0, 4, 7}}, {{0, 0, 0, 7}}, {{0, 7, 7, 5}}, {{0, 7, 3, 7}}
|
||||
};
|
||||
|
||||
display = (WWDisplay)malloc(sizeof(_WWDisplay));
|
||||
if (display == NULL)
|
||||
WonX_Error("WWDisplay_Create", "Cannot allocate memory.");
|
||||
if (display == NULL) Error("WWDisplay_Create", "Cannot allocate memory.");
|
||||
|
||||
WWDisplay_SetColorMap(display, WWColorMap_Create(default_lcd_colors));
|
||||
WWDisplay_SetColorMap(display, WWColorMap_Create(NULL));
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
/*
|
||||
* WonX-2.0 以降では,透明色は WWPalette クラスでは管理しないように
|
||||
* 変更したので,透明色の設定は必要無くなった.
|
||||
*/
|
||||
#if 1
|
||||
WWDisplay_SetPalette(display, i,
|
||||
WWPalette_Create(i,default_palette_colors[i].colors));
|
||||
#else /* WonX-2.0 以前では,透明色の設定が必要だった.一応コードを残しておく */
|
||||
WWDisplay_SetPalette(display, i,
|
||||
WWPalette_Create(i,
|
||||
default_palette_colors[i].colors,
|
||||
((i / 4) % 2) ? 1 : 0));
|
||||
#endif
|
||||
WWPalette_Create(i, NULL, ((i / 4) % 2) ? 1 : 0));
|
||||
}
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
WWDisplay_SetCharacter(display, i, WWCharacter_Create(i));
|
||||
WWDisplay_SetCharacter(display, i, WWCharacter_Create(i, NULL));
|
||||
}
|
||||
|
||||
for (i = 0; i < 128; i++) {
|
||||
@ -172,24 +128,6 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
|
||||
WWDisplay_SetLCDPanel(display, WWLCDPanel_Create(lcd_panel_width,
|
||||
lcd_panel_height));
|
||||
|
||||
/* デフォルトのテキスト表示用パレットは0 */
|
||||
WWDisplay_SetText(display,
|
||||
WWText_Create(WWDisplay_GetScreen(display, SCREEN2),
|
||||
0, 0,
|
||||
TEXT_SCREEN_WIDTH, TEXT_SCREEN_HEIGHT,
|
||||
WWDisplay_GetPalette(display, 0)));
|
||||
|
||||
/*
|
||||
* WWDisplay_GetPalette() を呼び出すので,パレットを設定してから
|
||||
* カーソルの設定を行うこと.
|
||||
* デフォルトのカーソルパレットは1
|
||||
*/
|
||||
WWDisplay_SetCursor(display,
|
||||
WWCursor_Create(WWDisplay_GetPalette(display, 1)));
|
||||
|
||||
/* デフォルトのカラーモードは白黒モード */
|
||||
WWDisplay_SetColorMode(display, COLOR_MODE_GRAYSCALE);
|
||||
|
||||
WWDisplay_SetSpriteEnable(display, 0);
|
||||
WWDisplay_SetSpriteWindowEnable(display, 0);
|
||||
|
||||
@ -198,8 +136,7 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
|
||||
WWDisplay_SetSpriteWindowWidth( display, lcd_panel_width);
|
||||
WWDisplay_SetSpriteWindowHeight(display, lcd_panel_height);
|
||||
|
||||
WWDisplay_SetBorderPalette(display, WWDisplay_GetPalette(display, 0));
|
||||
WWDisplay_SetBorderColor(display, 0);
|
||||
WWDisplay_SetBorder(display, 0);
|
||||
|
||||
WWDisplay_SetForegroundColor(display, 3);
|
||||
WWDisplay_SetBackgroundColor(display, 0);
|
||||
@ -214,8 +151,7 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (display == NULL)
|
||||
WonX_Error("WWDisplay_Destroy", "Object is not created.");
|
||||
if (display == NULL) return (NULL);
|
||||
|
||||
if (WWDisplay_GetColorMap(display) != NULL)
|
||||
WWDisplay_SetColorMap(display,
|
||||
@ -251,14 +187,6 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
|
||||
WWDisplay_SetLCDPanel(display,
|
||||
WWLCDPanel_Destroy(WWDisplay_GetLCDPanel(display)));
|
||||
|
||||
if (WWDisplay_GetText(display) != NULL)
|
||||
WWDisplay_SetText(display,
|
||||
WWText_Destroy(WWDisplay_GetText(display)));
|
||||
|
||||
if (WWDisplay_GetCursor(display) != NULL)
|
||||
WWDisplay_SetCursor(display,
|
||||
WWCursor_Destroy(WWDisplay_GetCursor(display)));
|
||||
|
||||
free(display);
|
||||
|
||||
return (NULL);
|
||||
@ -268,8 +196,7 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
|
||||
/* LCDパネルの描画 */
|
||||
/*===========================================================================*/
|
||||
|
||||
static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen,
|
||||
WWCursor cursor)
|
||||
static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen)
|
||||
{
|
||||
WWLCDPanel lcd_panel;
|
||||
int lcd_panel_width;
|
||||
@ -286,8 +213,8 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen,
|
||||
lcd_panel_width = WWLCDPanel_GetWidth( lcd_panel);
|
||||
lcd_panel_height = WWLCDPanel_GetHeight(lcd_panel);
|
||||
|
||||
if ( (WWScreen_GetMode(screen) == WW_SCREEN_INSIDE_ONLY) ||
|
||||
(WWScreen_GetMode(screen) == WW_SCREEN_OUTSIDE_ONLY) ) {
|
||||
if ( (WWScreen_GetMode(screen) == WWSCREEN_INSIDE_ONLY) ||
|
||||
(WWScreen_GetMode(screen) == WWSCREEN_OUTSIDE_ONLY) ) {
|
||||
sx = WWScreen_GetDrawX(screen);
|
||||
sy = WWScreen_GetDrawX(screen);
|
||||
|
||||
@ -318,7 +245,7 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen,
|
||||
|
||||
for (y = 0; y < lcd_panel_height; y++) {
|
||||
|
||||
if (mode == WW_SCREEN_INSIDE_ONLY) {
|
||||
if (mode == WWSCREEN_INSIDE_ONLY) {
|
||||
if (y > ey) { break; }
|
||||
if (y < sy) { y = sy - 1; continue; }
|
||||
}
|
||||
@ -327,10 +254,10 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen,
|
||||
|
||||
for (x = 0; x < lcd_panel_width; x++) {
|
||||
|
||||
if (mode == WW_SCREEN_INSIDE_ONLY) {
|
||||
if (mode == WWSCREEN_INSIDE_ONLY) {
|
||||
if (x > ex) { x = lcd_panel_width - 1; continue; }
|
||||
if (x < sx) { x = sx - 1; continue; }
|
||||
} else if (mode == WW_SCREEN_OUTSIDE_ONLY) {
|
||||
} else if (mode == WWSCREEN_OUTSIDE_ONLY) {
|
||||
if ( (x >= sx) && (x <= ex) && (y >= sy) && (y <= ey) ) {
|
||||
x = ex;
|
||||
continue;
|
||||
@ -339,25 +266,12 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen,
|
||||
|
||||
px = x + WWScreen_GetRollX(screen);
|
||||
|
||||
/* 透明色の場合には,-1が返ってくる */
|
||||
pixel = WWScreen_GetPixel(screen, px, py, display, cursor);
|
||||
pixel = WWScreen_GetPixel(screen, px, py);
|
||||
|
||||
/* 透明色の場合 */
|
||||
if (pixel == -1) continue;
|
||||
|
||||
/* カラー対応 */
|
||||
switch (WWDisplay_GetColorMode(display)) {
|
||||
case COLOR_MODE_GRAYSCALE:
|
||||
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
|
||||
break;
|
||||
case COLOR_MODE_4COLOR:
|
||||
case COLOR_MODE_16COLOR:
|
||||
case COLOR_MODE_16PACKED:
|
||||
break;
|
||||
default:
|
||||
WonX_Error("WWDisplay_DrawSprite", "Unknown color mode.");
|
||||
}
|
||||
|
||||
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
|
||||
WWLCDPanel_SetPixel(lcd_panel, x, y, pixel);
|
||||
}
|
||||
}
|
||||
@ -385,9 +299,7 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite)
|
||||
|
||||
for (y = 0; y < 8; y++) {
|
||||
for (x = 0; x < 8; x++) {
|
||||
|
||||
/* 透明色は-1が返ってくる */
|
||||
pixel = WWSprite_GetPixel(sprite, x, y, display);
|
||||
pixel = WWSprite_GetPixel(sprite, x, y);
|
||||
|
||||
/* 透明色の場合 */
|
||||
if (pixel == -1) continue;
|
||||
@ -408,19 +320,7 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite)
|
||||
}
|
||||
}
|
||||
|
||||
/* カラー対応 */
|
||||
switch (WWDisplay_GetColorMode(display)) {
|
||||
case COLOR_MODE_GRAYSCALE:
|
||||
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
|
||||
break;
|
||||
case COLOR_MODE_4COLOR:
|
||||
case COLOR_MODE_16COLOR:
|
||||
case COLOR_MODE_16PACKED:
|
||||
break;
|
||||
default:
|
||||
WonX_Error("WWDisplay_DrawSprite", "Unknown color mode.");
|
||||
}
|
||||
|
||||
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
|
||||
WWLCDPanel_SetPixel(WWDisplay_GetLCDPanel(display), lcd_x, lcd_y, pixel);
|
||||
}
|
||||
}
|
||||
@ -435,58 +335,25 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
|
||||
int lcd_panel_width;
|
||||
int lcd_panel_height;
|
||||
WWColorMap color_map;
|
||||
WWPalette border_palette;
|
||||
int border_color;
|
||||
WWScreen screen;
|
||||
int border;
|
||||
WWSprite sprite;
|
||||
WWCursor cursor;
|
||||
|
||||
lcd_panel = WWDisplay_GetLCDPanel(display);
|
||||
lcd_panel_width = WWLCDPanel_GetWidth( lcd_panel);
|
||||
lcd_panel_height = WWLCDPanel_GetHeight(lcd_panel);
|
||||
color_map = WWDisplay_GetColorMap(display);
|
||||
border_palette = WWDisplay_GetBorderPalette(display);
|
||||
border_color = WWDisplay_GetBorderColor(display);
|
||||
|
||||
/* カラー対応 */
|
||||
switch (WWDisplay_GetColorMode(display)) {
|
||||
case COLOR_MODE_GRAYSCALE:
|
||||
border_color &= (DCM_BORDER_COLOR >> 8);
|
||||
border_color = WWColorMap_GetLCDColor(color_map, border_color);
|
||||
break;
|
||||
case COLOR_MODE_4COLOR:
|
||||
border_color &= 0x03;
|
||||
border_color =
|
||||
((unsigned short int)WWPalette_GetRed( border_palette,border_color)<<8)|
|
||||
((unsigned short int)WWPalette_GetGreen(border_palette,border_color)<<4)|
|
||||
((unsigned short int)WWPalette_GetBlue( border_palette,border_color)<<0);
|
||||
break;
|
||||
case COLOR_MODE_16COLOR:
|
||||
case COLOR_MODE_16PACKED:
|
||||
border_color &= 0x0f;
|
||||
border_color =
|
||||
((unsigned short int)WWPalette_GetRed( border_palette,border_color)<<8)|
|
||||
((unsigned short int)WWPalette_GetGreen(border_palette,border_color)<<4)|
|
||||
((unsigned short int)WWPalette_GetBlue( border_palette,border_color)<<0);
|
||||
break;
|
||||
default:
|
||||
WonX_Error("WWDisplay_DrawLCDPanel", "Unknown color mode.");
|
||||
}
|
||||
border = WWDisplay_GetBorder(display);
|
||||
|
||||
/* ボーダーカラーで埋める */
|
||||
for (x = 0; x < lcd_panel_width; x++) {
|
||||
for (y = 0; y < lcd_panel_height; y++) {
|
||||
WWLCDPanel_SetPixel(lcd_panel, x, y, border_color);
|
||||
WWLCDPanel_SetPixel(lcd_panel, x, y,
|
||||
WWColorMap_GetLCDColor(color_map, border));
|
||||
}
|
||||
}
|
||||
|
||||
/* スクリーン1描画 */
|
||||
screen = WWDisplay_GetScreen(display, 0);
|
||||
if (WWText_GetScreen(WWDisplay_GetText(display)) == screen)
|
||||
cursor = WWDisplay_GetCursor(display);
|
||||
else
|
||||
cursor = NULL;
|
||||
WWDisplay_DrawScreen(display, screen, cursor);
|
||||
WWDisplay_DrawScreen(display, WWDisplay_GetScreen(display, 0));
|
||||
|
||||
/* スプライト描画(スクリーン2より優先でないもの) */
|
||||
/* 重なった場合は,番号の若いものが手前に表示される */
|
||||
@ -501,12 +368,7 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
|
||||
}
|
||||
|
||||
/* スクリーン2描画 */
|
||||
screen = WWDisplay_GetScreen(display, 1);
|
||||
if (WWText_GetScreen(WWDisplay_GetText(display)) == screen)
|
||||
cursor = WWDisplay_GetCursor(display);
|
||||
else
|
||||
cursor = NULL;
|
||||
WWDisplay_DrawScreen(display, screen, cursor);
|
||||
WWDisplay_DrawScreen(display, WWDisplay_GetScreen(display, 1));
|
||||
|
||||
/* スプライト描画(スクリーン2より優先なもの) */
|
||||
/* 重なった場合は,番号の若いものが手前に表示される */
|
||||
@ -523,38 +385,6 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 透明色かどうか調べる */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WWDisplay_IsTransparent(WWDisplay display, WWPalette palette, int color)
|
||||
{
|
||||
int mode;
|
||||
int palette_num;
|
||||
int ret;
|
||||
|
||||
if (color != 0) return (0);
|
||||
|
||||
mode = WWDisplay_GetColorMode(display);
|
||||
palette_num = WWPalette_GetNumber(palette);
|
||||
|
||||
ret = 0;
|
||||
switch (mode) {
|
||||
case COLOR_MODE_GRAYSCALE :
|
||||
case COLOR_MODE_4COLOR :
|
||||
ret = ((palette_num / 4) % 2) ? 1 : 0;
|
||||
break;
|
||||
case COLOR_MODE_16COLOR :
|
||||
case COLOR_MODE_16PACKED :
|
||||
ret = 1;
|
||||
break;
|
||||
default :
|
||||
WonX_Error("WWDisplay_IsTransparent", "Unknown color mode.");
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
41
WWDisplay.h
41
WWDisplay.h
@ -5,27 +5,21 @@
|
||||
/* ¤³¤³¤«¤é */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWDisplay * WWDisplay;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWColorMap.h"
|
||||
#include "WWPalette.h"
|
||||
#include "WWCharacter.h"
|
||||
#include "WWSprite.h"
|
||||
#include "WWScreen.h"
|
||||
#include "WWLCDPanel.h"
|
||||
#include "WWText.h"
|
||||
#include "WWCursor.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWDisplay * WWDisplay;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*===========================================================================*/
|
||||
@ -38,11 +32,6 @@ WWCharacter WWDisplay_GetCharacter(WWDisplay d, int n);
|
||||
WWSprite WWDisplay_GetSprite(WWDisplay d, int n);
|
||||
WWScreen WWDisplay_GetScreen(WWDisplay d, int n);
|
||||
WWLCDPanel WWDisplay_GetLCDPanel(WWDisplay d);
|
||||
WWText WWDisplay_GetText(WWDisplay d);
|
||||
WWCursor WWDisplay_GetCursor(WWDisplay d);
|
||||
|
||||
unsigned int WWDisplay_GetColorMode(WWDisplay d);
|
||||
|
||||
int WWDisplay_GetSpriteEnable(WWDisplay d);
|
||||
int WWDisplay_GetSpriteWindowEnable(WWDisplay d);
|
||||
|
||||
@ -51,8 +40,7 @@ int WWDisplay_GetSpriteWindowY(WWDisplay d);
|
||||
int WWDisplay_GetSpriteWindowWidth(WWDisplay d);
|
||||
int WWDisplay_GetSpriteWindowHeight(WWDisplay d);
|
||||
|
||||
WWPalette WWDisplay_GetBorderPalette(WWDisplay d);
|
||||
int WWDisplay_GetBorderColor(WWDisplay d);
|
||||
int WWDisplay_GetBorder(WWDisplay d);
|
||||
|
||||
int WWDisplay_GetForegroundColor(WWDisplay d);
|
||||
int WWDisplay_GetBackgroundColor(WWDisplay d);
|
||||
@ -70,10 +58,6 @@ WWCharacter WWDisplay_SetCharacter(WWDisplay d, int n, WWCharacter c);
|
||||
WWSprite WWDisplay_SetSprite(WWDisplay d, int n, WWSprite s);
|
||||
WWScreen WWDisplay_SetScreen(WWDisplay d, int n, WWScreen s);
|
||||
WWLCDPanel WWDisplay_SetLCDPanel(WWDisplay d, WWLCDPanel p);
|
||||
WWText WWDisplay_SetText(WWDisplay d, WWText p);
|
||||
WWCursor WWDisplay_SetCursor(WWDisplay d, WWCursor p);
|
||||
|
||||
unsigned int WWDisplay_SetColorMode(WWDisplay d, unsigned int mode);
|
||||
|
||||
int WWDisplay_SetSpriteEnable(WWDisplay d, int f);
|
||||
int WWDisplay_SetSpriteWindowEnable(WWDisplay d, int f);
|
||||
@ -83,8 +67,7 @@ int WWDisplay_SetSpriteWindowY(WWDisplay d, int n);
|
||||
int WWDisplay_SetSpriteWindowWidth(WWDisplay d, int n);
|
||||
int WWDisplay_SetSpriteWindowHeight(WWDisplay d, int n);
|
||||
|
||||
WWPalette WWDisplay_SetBorderPalette(WWDisplay d, WWPalette p);
|
||||
int WWDisplay_SetBorderColor(WWDisplay d, int b);
|
||||
int WWDisplay_SetBorder(WWDisplay d, int b);
|
||||
|
||||
int WWDisplay_SetForegroundColor(WWDisplay d, int c);
|
||||
int WWDisplay_SetBackgroundColor(WWDisplay d, int c);
|
||||
@ -106,12 +89,6 @@ WWDisplay WWDisplay_Destroy(WWDisplay display);
|
||||
|
||||
int WWDisplay_DrawLCDPanel(WWDisplay display);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 透明色かどうか調べる */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WWDisplay_IsTransparent(WWDisplay display, WWPalette palette, int color);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ¤³¤³¤Þ¤Ç */
|
||||
/*****************************************************************************/
|
||||
|
||||
10
WWDisplayP.h
10
WWDisplayP.h
@ -19,12 +19,8 @@ typedef struct _WWDisplay {
|
||||
WWSprite sprite[128];
|
||||
WWScreen screen[2];
|
||||
WWLCDPanel lcd_panel;
|
||||
WWText text;
|
||||
WWCursor cursor;
|
||||
|
||||
/* ディスプレイの属性情報 */
|
||||
unsigned int color_mode; /* カラーモード */
|
||||
|
||||
int sprite_enable; /* スプライト表示イネーブルフラグ */
|
||||
int sprite_window_enable; /* スプライトウインドウ機能イネーブルフラグ */
|
||||
int sprite_window_x; /* スプライトウインドウ用 */
|
||||
@ -32,16 +28,14 @@ typedef struct _WWDisplay {
|
||||
int sprite_window_width; /* スプライトウインドウ用 */
|
||||
int sprite_window_height; /* スプライトウインドウ用 */
|
||||
|
||||
/* ボーダーカラーのパレット.カラーで必要 */
|
||||
WWPalette border_palette;
|
||||
/* ボーダーカラー.白黒の場合には,0~7のカラーマップ番号 */
|
||||
int border_color;
|
||||
int border; /* ボーダーカラー.0~7のカラーマップ番号 */
|
||||
|
||||
int foreground_color; /* モノクロフォント展開時の色 */
|
||||
int background_color; /* モノクロフォント展開時の色 */
|
||||
|
||||
int sprite_start; /* スプライトの描画の指定 */
|
||||
int sprite_count; /* スプライトの描画の指定 */
|
||||
|
||||
} _WWDisplay;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWInterruptP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ¥á¥ó¥Ð´Ø¿ô¤ÎÄêµÁ */
|
||||
@ -45,7 +45,7 @@ static WWInterruptVector WWInterruptVector_Create(int number)
|
||||
|
||||
vector = (WWInterruptVector)malloc(sizeof(_WWInterruptVector));
|
||||
if (vector == NULL)
|
||||
WonX_Error("WWInterruptVector_Create", "Cannot allocate memory.");
|
||||
Error("WWInterruptVector_Create", "Cannot allocate memory.");
|
||||
|
||||
WWInterruptVector_SetNumber(vector, number);
|
||||
WWInterruptVector_SetCallback(vector, NULL);
|
||||
@ -58,7 +58,7 @@ static WWInterruptVector WWInterruptVector_Create(int number)
|
||||
static WWInterruptVector WWInterruptVector_Destroy(WWInterruptVector vector)
|
||||
{
|
||||
if (vector == NULL)
|
||||
WonX_Error("WWInterruptVector_Destroy", "Object is not created.");
|
||||
Error("WWInterruptVector_Destroy", "Object is not created.");
|
||||
free(vector);
|
||||
return (NULL);
|
||||
}
|
||||
@ -71,7 +71,7 @@ static WWInterruptVector WWInterrupt_GetVector(WWInterrupt interrupt,
|
||||
int number)
|
||||
{
|
||||
if ((number < 0) || (number > 7))
|
||||
WonX_Error("WWInterrupt_SetVector", "Invalid interrupt number.");
|
||||
Error("WWInterrupt_SetVector", "Invalid interrupt number.");
|
||||
return (interrupt->vector[number]);
|
||||
}
|
||||
|
||||
@ -80,7 +80,7 @@ static WWInterruptVector WWInterrupt_SetVector(WWInterrupt interrupt,
|
||||
WWInterruptVector vector)
|
||||
{
|
||||
if ((number < 0) || (number > 7))
|
||||
WonX_Error("WWInterrupt_SetVector", "Invalid interrupt number.");
|
||||
Error("WWInterrupt_SetVector", "Invalid interrupt number.");
|
||||
return (interrupt->vector[number] = vector);
|
||||
}
|
||||
|
||||
@ -313,7 +313,7 @@ WWInterrupt WWInterrupt_Create()
|
||||
|
||||
interrupt = (WWInterrupt)malloc(sizeof(_WWInterrupt));
|
||||
if (interrupt == NULL)
|
||||
WonX_Error("WWInterrupt_Create", "Cannot allocate memory.");
|
||||
Error("WWInterrupt_Create", "Cannot allocate memory.");
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
WWInterrupt_SetVector(interrupt, i, WWInterruptVector_Create(i));
|
||||
@ -331,7 +331,7 @@ WWInterrupt WWInterrupt_Destroy(WWInterrupt interrupt)
|
||||
WWInterruptVector vector;
|
||||
|
||||
if (interrupt == NULL)
|
||||
WonX_Error("WWInterrupt_Destroy", "Object is not created.");
|
||||
Error("WWInterrupt_Destroy", "Object is not created.");
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
vector = WWInterrupt_GetVector(interrupt, i);
|
||||
|
||||
@ -5,6 +5,11 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sys/system.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
@ -12,15 +17,6 @@
|
||||
typedef struct _WWInterrupt * WWInterrupt;
|
||||
typedef void (*WWInterruptCallback)();
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wonx/system.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
57
WWLCDPanel.c
57
WWLCDPanel.c
@ -3,7 +3,7 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWLCDPanelP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ¥á¥ó¥Ð´Ø¿ô¤ÎÄêµÁ */
|
||||
@ -28,59 +28,56 @@ int WWLCDPanel_ResetAllDraw(WWLCDPanel p) { return (p->all_draw = 0); }
|
||||
int WWLCDPanel_SetAllDraw(WWLCDPanel p) { return (p->all_draw = 1); }
|
||||
int WWLCDPanel_IsAllDraw(WWLCDPanel p) { return (p->all_draw); }
|
||||
|
||||
unsigned short int * WWLCDPanel_GetPixelMap(WWLCDPanel p)
|
||||
unsigned char * WWLCDPanel_GetPixelMap(WWLCDPanel p)
|
||||
{
|
||||
return (p->pixel[p->current]);
|
||||
}
|
||||
|
||||
/* LCDは1ピクセル4096色(12ビット必要) */
|
||||
static unsigned short int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel,
|
||||
int current,
|
||||
int x, int y)
|
||||
/* LCDは1ピクセル16色(4ビット必要) */
|
||||
static int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel, int current,
|
||||
int x, int y)
|
||||
{
|
||||
unsigned short int pixel;
|
||||
unsigned char pixel;
|
||||
|
||||
if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
|
||||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
|
||||
return (-1);
|
||||
|
||||
pixel = lcd_panel->pixel[current][y * WWLCDPanel_GetWidth(lcd_panel) + x];
|
||||
pixel &= 0x0f;
|
||||
return ((int)pixel);
|
||||
}
|
||||
|
||||
static unsigned short int WWLCDPanel_GetOldPixel(WWLCDPanel lcd_panel,
|
||||
int x, int y)
|
||||
static int WWLCDPanel_GetOldPixel(WWLCDPanel lcd_panel, int x, int y)
|
||||
{
|
||||
return (WWLCDPanel_GetPixelByCurrent(lcd_panel,
|
||||
1 - lcd_panel->current, x, y));
|
||||
return (WWLCDPanel_GetPixelByCurrent(lcd_panel, 1 - lcd_panel->current, x, y));
|
||||
}
|
||||
|
||||
unsigned short int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y)
|
||||
int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y)
|
||||
{
|
||||
return (WWLCDPanel_GetPixelByCurrent(lcd_panel, lcd_panel->current, x, y));
|
||||
}
|
||||
|
||||
unsigned short int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y,
|
||||
unsigned short int pixel)
|
||||
int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y, int pixel)
|
||||
{
|
||||
unsigned short int p;
|
||||
unsigned char p;
|
||||
int n;
|
||||
|
||||
if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
|
||||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
|
||||
return (-1);
|
||||
|
||||
p = pixel & 0x0fff;
|
||||
p = ((unsigned char)pixel) & 0x0f;
|
||||
n = y * WWLCDPanel_GetWidth(lcd_panel) + x;
|
||||
lcd_panel->pixel[lcd_panel->current][n] = p;
|
||||
|
||||
return (p);
|
||||
return (pixel);
|
||||
}
|
||||
|
||||
int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y)
|
||||
{
|
||||
unsigned short int old_pixel;
|
||||
unsigned short int current_pixel;
|
||||
int old_pixel;
|
||||
int current_pixel;
|
||||
|
||||
if (WWLCDPanel_IsAllDraw(lcd_panel)) return (1);
|
||||
old_pixel = WWLCDPanel_GetOldPixel(lcd_panel, x, y);
|
||||
@ -93,26 +90,23 @@ WWLCDPanel WWLCDPanel_Create(int width, int height)
|
||||
{
|
||||
WWLCDPanel lcd_panel;
|
||||
int x, y, i;
|
||||
unsigned short int * p;
|
||||
|
||||
lcd_panel = (WWLCDPanel)malloc(sizeof(_WWLCDPanel));
|
||||
if (lcd_panel == NULL)
|
||||
WonX_Error("WWLCDPanel_Create", "Cannot allocate memory.");
|
||||
if (lcd_panel == NULL) Error("WWLCDPanel_Create", "Cannot allocate memory.");
|
||||
|
||||
WWLCDPanel_SetWidth( lcd_panel, width);
|
||||
WWLCDPanel_SetHeight(lcd_panel, height);
|
||||
|
||||
for (i = 0; i < 2; i++) {
|
||||
p = (unsigned short int *)malloc(sizeof(unsigned short int) *
|
||||
WWLCDPanel_GetWidth(lcd_panel) *
|
||||
WWLCDPanel_GetHeight(lcd_panel));
|
||||
if (p == NULL) WonX_Error("WWLCDPanel_Create", "Cannot allocate memory.");
|
||||
lcd_panel->pixel[i] = p;
|
||||
lcd_panel->pixel[i] =
|
||||
(unsigned char *)malloc(sizeof(unsigned char) *
|
||||
WWLCDPanel_GetWidth(lcd_panel) *
|
||||
WWLCDPanel_GetHeight(lcd_panel));
|
||||
}
|
||||
|
||||
for (y = 0; y < lcd_panel->height; y++) {
|
||||
for (x = 0; x < lcd_panel->width / 2; x++) {
|
||||
WWLCDPanel_SetPixel(lcd_panel, x, y, 0);
|
||||
WWLCDPanel_SetPixel(lcd_panel, x, y, 0x00);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,16 +119,11 @@ WWLCDPanel WWLCDPanel_Create(int width, int height)
|
||||
WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (lcd_panel == NULL)
|
||||
WonX_Error("WWLCDPanel_Destroy", "Object is not created.");
|
||||
|
||||
if (lcd_panel == NULL) return (NULL);
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (lcd_panel->pixel[i]) free(lcd_panel->pixel[i]);
|
||||
}
|
||||
|
||||
free(lcd_panel);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
|
||||
15
WWLCDPanel.h
15
WWLCDPanel.h
@ -5,18 +5,14 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWLCDPanel * WWLCDPanel;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
@ -32,10 +28,9 @@ int WWLCDPanel_ResetAllDraw(WWLCDPanel p);
|
||||
int WWLCDPanel_SetAllDraw(WWLCDPanel p);
|
||||
int WWLCDPanel_IsAllDraw(WWLCDPanel p);
|
||||
|
||||
unsigned short int * WWLCDPanel_GetPixelMap(WWLCDPanel p);
|
||||
unsigned short int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y);
|
||||
unsigned short int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y,
|
||||
unsigned short int pixel);
|
||||
unsigned char * WWLCDPanel_GetPixelMap(WWLCDPanel p);
|
||||
int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y);
|
||||
int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y, int pixel);
|
||||
int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y);
|
||||
WWLCDPanel WWLCDPanel_Create(int width, int height);
|
||||
WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel);
|
||||
|
||||
@ -15,20 +15,18 @@ typedef struct _WWLCDPanel {
|
||||
int width;
|
||||
int height;
|
||||
|
||||
/* Xサーバの負荷を減らすため,ビットマップを2枚持ち, */
|
||||
/* 前回と同じ部分は書き換えないようにする. */
|
||||
/* pixel[current] が現在描画中のビットマップになる. */
|
||||
/* pixel[1 - current] が前回のビットマップになる. */
|
||||
/* Xサーバの負荷を減らすため,ビットマップを2枚持ち, */
|
||||
/* 前回と同じ部分は書き換えないようにする. */
|
||||
/* pixel[current] が現在描画中のビットマップになる. */
|
||||
/* pixel[1 - current] が前回のビットマップになる. */
|
||||
int current;
|
||||
|
||||
/* all_draw == 1 のときは,前回分が無いので, */
|
||||
/* 全部描画することを示す. */
|
||||
/* all_draw == 1 のときは,前回分が無いので, */
|
||||
/* 全部描画することを示す. */
|
||||
int all_draw;
|
||||
|
||||
/* 4096色のカラー情報.1バイトで1ピクセル分の情報を持つ */
|
||||
/* Xサーバの負荷を減らすため,ビットマップを2枚持ち, */
|
||||
/* 前回と同じ部分は書き換えないようにする. */
|
||||
unsigned short int * pixel[2];
|
||||
/* 16色のカラー情報.1バイトで1ピクセル分の情報を持つ */
|
||||
unsigned char * pixel[2];
|
||||
} _WWLCDPanel;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
94
WWPalette.c
94
WWPalette.c
@ -3,7 +3,6 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWPaletteP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -13,57 +12,19 @@
|
||||
int WWPalette_GetNumber(WWPalette p) { return (p->number); }
|
||||
int WWPalette_SetNumber(WWPalette p, int n) { return (p->number = n); }
|
||||
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
|
||||
*/
|
||||
#if 0
|
||||
int WWPalette_GetTransparent(WWPalette p) { return (p->transparent); }
|
||||
int WWPalette_SetTransparent(WWPalette p, int f)
|
||||
{ return (p->transparent = f); }
|
||||
#endif
|
||||
|
||||
int WWPalette_GetRed( WWPalette p, int n) { return (p->red[ n]); }
|
||||
int WWPalette_GetGreen(WWPalette p, int n) { return (p->green[n]); }
|
||||
int WWPalette_GetBlue( WWPalette p, int n) { return (p->blue[ n]); }
|
||||
int WWPalette_SetRed( WWPalette p, int n, int value)
|
||||
{ return (p->red[ n] = value); }
|
||||
int WWPalette_SetGreen(WWPalette p, int n, int value)
|
||||
{ return (p->green[n] = value); }
|
||||
int WWPalette_SetBlue( WWPalette p, int n, int value)
|
||||
{ return (p->blue[ n] = value); }
|
||||
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.
|
||||
* もともとは,
|
||||
* WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent)
|
||||
* のように,引数 transparent があった.
|
||||
*/
|
||||
WWPalette WWPalette_Create(int number, int * mapped_colors)
|
||||
WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent)
|
||||
{
|
||||
WWPalette palette;
|
||||
int i;
|
||||
|
||||
palette = (WWPalette)malloc(sizeof(_WWPalette));
|
||||
if (palette == NULL)
|
||||
WonX_Error("WWPalette_Create", "Cannot allocate memory");
|
||||
if (palette == NULL) Error("WWPalette_Create", "Cannot allocate memory");
|
||||
|
||||
WWPalette_SetNumber(palette, number);
|
||||
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
|
||||
*/
|
||||
#if 0
|
||||
WWPalette_SetTransparent(palette, transparent);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
WWPalette_SetRed( palette, i, 0);
|
||||
WWPalette_SetGreen(palette, i, 0);
|
||||
WWPalette_SetBlue( palette, i, 0);
|
||||
}
|
||||
WWPalette_SetMappedColors(palette, mapped_colors);
|
||||
|
||||
return (palette);
|
||||
@ -71,8 +32,7 @@ WWPalette WWPalette_Create(int number, int * mapped_colors)
|
||||
|
||||
WWPalette WWPalette_Destroy(WWPalette palette)
|
||||
{
|
||||
if (palette == NULL)
|
||||
WonX_Error("WWPalette_Destroy", "Object is not created.");
|
||||
if (palette == NULL) return (NULL);
|
||||
free(palette);
|
||||
return (NULL);
|
||||
}
|
||||
@ -108,73 +68,35 @@ int WWPalette_GetMappedColor(WWPalette palette, int color)
|
||||
int pixel;
|
||||
|
||||
pixel = palette->mapped_color[color];
|
||||
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
|
||||
*/
|
||||
#if 0
|
||||
if (WWPalette_GetTransparent(palette) && (pixel == 0)) {
|
||||
pixel = -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (pixel);
|
||||
}
|
||||
|
||||
int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_color)
|
||||
{
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
|
||||
*/
|
||||
#if 0
|
||||
if (mapped_color == -1) mapped_color = 0;
|
||||
#endif
|
||||
return (palette->mapped_color[color] = mapped_color);
|
||||
}
|
||||
|
||||
int WWPalette_PrintData(WWPalette p, WWDisplay display, FILE * f)
|
||||
int WWPalette_PrintData(WWPalette p, FILE * f)
|
||||
{
|
||||
int i, n;
|
||||
int transparent;
|
||||
int red, green, blue;
|
||||
|
||||
n = WWPalette_GetNumber(p);
|
||||
|
||||
fprintf(f, "\n");
|
||||
|
||||
fprintf(f, "palette[%02d] :\tnumber = %d\n", n, WWPalette_GetNumber(p));
|
||||
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
|
||||
*/
|
||||
#if 1
|
||||
transparent = WWDisplay_IsTransparent(display, p, 0);
|
||||
fprintf(f, "palette[%02d] :\ttransparent = %s\n",
|
||||
n, wonx_true_false(transparent));
|
||||
#else
|
||||
fprintf(f, "palette[%02d] :\ttransparent = %s\n",
|
||||
n, wonx_true_false(WWPalette_GetTransparent(p)));
|
||||
#endif
|
||||
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[%02d] :\tcolor[%01d] = %d\n",
|
||||
fprintf(f, "palette[%d] :\tcolor[%d] = %d\n",
|
||||
n, i, WWPalette_GetMappedColor(p, i));
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
red = WWPalette_GetRed( p, i);
|
||||
green = WWPalette_GetGreen(p, i);
|
||||
blue = WWPalette_GetBlue( p, i);
|
||||
fprintf(f, "palette[%02d] :\tRGB[%02d] = 0x%c%c%c\n",
|
||||
n, i,
|
||||
wonx_dec_to_hex(red),
|
||||
wonx_dec_to_hex(green),
|
||||
wonx_dec_to_hex(blue));
|
||||
}
|
||||
|
||||
fflush(f);
|
||||
|
||||
return (0);
|
||||
|
||||
37
WWPalette.h
37
WWPalette.h
@ -5,59 +5,30 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWPalette * WWPalette;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "WWDisplay.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
int WWPalette_GetNumber(WWPalette p);
|
||||
int WWPalette_SetNumber(WWPalette p, int n);
|
||||
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
|
||||
*/
|
||||
#if 0
|
||||
int WWPalette_GetTransparent(WWPalette palette);
|
||||
int WWPalette_SetTransparent(WWPalette palette, int f);
|
||||
#endif
|
||||
|
||||
int WWPalette_GetRed( WWPalette p, int n);
|
||||
int WWPalette_GetGreen(WWPalette p, int n);
|
||||
int WWPalette_GetBlue( WWPalette p, int n);
|
||||
int WWPalette_SetRed( WWPalette p, int n, int value);
|
||||
int WWPalette_SetGreen(WWPalette p, int n, int value);
|
||||
int WWPalette_SetBlue( WWPalette p, int n, int value);
|
||||
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
|
||||
*/
|
||||
#if 1
|
||||
WWPalette WWPalette_Create(int number, int * mapped_colors);
|
||||
#else
|
||||
WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent);
|
||||
#endif
|
||||
WWPalette WWPalette_Destroy(WWPalette palette);
|
||||
int * WWPalette_GetMappedColors(WWPalette palette, int * mapped_colors);
|
||||
int WWPalette_SetMappedColors(WWPalette palette, int * mapped_colors);
|
||||
int WWPalette_GetMappedColor(WWPalette palette, int color);
|
||||
int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_color);
|
||||
int WWPalette_PrintData(WWPalette p, WWDisplay display, FILE * f);
|
||||
int WWPalette_PrintData(WWPalette p, FILE * f);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
|
||||
20
WWPaletteP.h
20
WWPaletteP.h
@ -12,28 +12,12 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWPalette {
|
||||
|
||||
int number;
|
||||
|
||||
/*
|
||||
* WonX-2.0 以降から,透明色の判定は WWDisplay で行うように変更したので,
|
||||
* WWPalette で透明色を管理する必要は無くなった.一応コードを残しておく.
|
||||
*/
|
||||
#if 0
|
||||
int transparent; /* 0 は透明色になるかどうかのフラグ */
|
||||
#endif
|
||||
|
||||
/* 白黒モードの場合には,カラーマップの8色中から4色を選択 */
|
||||
int mapped_color[4]; /* 白黒モードでは,カラーマップの番号(0~7)を持つ */
|
||||
|
||||
/*
|
||||
* 4色カラー,16色カラーモードの場合には,rgb の色を使用する.
|
||||
* 4色カラーモードの場合には,0~3までを使用する.
|
||||
* 16色カラーモードの場合には,0~15までを全部使用する.
|
||||
*/
|
||||
int red[16];
|
||||
int green[16];
|
||||
int blue[16];
|
||||
/* カラーマップの8色中から4色を選択 */
|
||||
int mapped_color[4]; /* カラーマップの番号(0~7)を持つ */
|
||||
|
||||
} _WWPalette;
|
||||
|
||||
|
||||
57
WWScreen.c
57
WWScreen.c
@ -3,7 +3,7 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWScreenP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
@ -41,7 +41,7 @@ static WWScreenCharacter WWScreenCharacter_Create(int horizontal, int vertical,
|
||||
|
||||
screen_character = (WWScreenCharacter)malloc(sizeof(_WWScreenCharacter));
|
||||
if (screen_character == NULL)
|
||||
WonX_Error("WWScreenCharacter", "Cannot allocate memory.");
|
||||
Error("WWScreenCharacter", "Cannot allocate memory.");
|
||||
|
||||
WWScreenCharacter_SetHorizontal(screen_character, horizontal);
|
||||
WWScreenCharacter_SetVertical(screen_character, vertical);
|
||||
@ -54,8 +54,7 @@ static WWScreenCharacter WWScreenCharacter_Create(int horizontal, int vertical,
|
||||
static WWScreenCharacter WWScreenCharacter_Destroy(WWScreenCharacter
|
||||
screen_character)
|
||||
{
|
||||
if (screen_character == NULL)
|
||||
WonX_Error("WWScreenCharacter_Destroy", "Object is not created.");
|
||||
if (screen_character == NULL) return (NULL);
|
||||
free(screen_character);
|
||||
return (NULL);
|
||||
}
|
||||
@ -160,8 +159,7 @@ int WWScreen_SetDrawWidth( WWScreen s, int n) { return (s->draw_width = n); }
|
||||
int WWScreen_SetDrawHeight(WWScreen s, int n) { return (s->draw_height = n); }
|
||||
|
||||
/* カラーマップの色(0~7)を返す(透明色は-1を返す) */
|
||||
int WWScreen_GetPixel(WWScreen screen, int x, int y,
|
||||
WWDisplay display, WWCursor cursor)
|
||||
int WWScreen_GetPixel(WWScreen screen, int x, int y)
|
||||
{
|
||||
int cx, cy, px, py;
|
||||
int pixel;
|
||||
@ -182,45 +180,10 @@ int WWScreen_GetPixel(WWScreen screen, int x, int y,
|
||||
if (WWScreen_GetVertical( screen, cx, cy)) py = 7 - py;
|
||||
|
||||
character = WWScreen_GetCharacter(screen, cx, cy);
|
||||
|
||||
/* カーソル表示の処理 */
|
||||
palette = WWScreen_GetPalette(screen, cx, cy);
|
||||
if (cursor != NULL) {
|
||||
if ( WWCursor_IsON(cursor) &&
|
||||
(cx >= WWCursor_GetX(cursor)) &&
|
||||
(cx <= WWCursor_GetX(cursor) + WWCursor_GetWidth( cursor) - 1) &&
|
||||
(cy >= WWCursor_GetY(cursor)) &&
|
||||
(cy <= WWCursor_GetY(cursor) + WWCursor_GetHeight(cursor) - 1) ) {
|
||||
palette = WWCursor_GetPalette(cursor);
|
||||
}
|
||||
}
|
||||
|
||||
pixel = WWCharacter_GetPixel(character, px, py, display);
|
||||
|
||||
/* カラー対応 */
|
||||
switch (WWDisplay_GetColorMode(display)) {
|
||||
case COLOR_MODE_GRAYSCALE:
|
||||
/*
|
||||
* WonX-2.0 以降では,透明色の処理は WWDisplay クラスで行うように
|
||||
* 変更したので,WWPalette_GetMappedColor() が -1 を返すことは無い.
|
||||
*/
|
||||
pixel = WWPalette_GetMappedColor(palette, pixel);
|
||||
break;
|
||||
case COLOR_MODE_4COLOR:
|
||||
case COLOR_MODE_16COLOR:
|
||||
case COLOR_MODE_16PACKED:
|
||||
pixel =
|
||||
((unsigned short int)WWPalette_GetRed( palette, pixel) << 8) |
|
||||
((unsigned short int)WWPalette_GetGreen(palette, pixel) << 4) |
|
||||
((unsigned short int)WWPalette_GetBlue( palette, pixel) << 0);
|
||||
break;
|
||||
default:
|
||||
WonX_Error("WWScreen_GetPixel", "Unknown color mode.");
|
||||
}
|
||||
|
||||
/* 透明色の場合には -1 を返す */
|
||||
if (WWDisplay_IsTransparent(display, palette, pixel))
|
||||
pixel = -1;
|
||||
pixel = WWCharacter_GetPixel(character, px, py);
|
||||
pixel = WWPalette_GetMappedColor(palette, pixel);
|
||||
|
||||
return (pixel);
|
||||
}
|
||||
@ -237,8 +200,7 @@ WWScreen WWScreen_Create(int number,
|
||||
int x, y;
|
||||
|
||||
screen = (WWScreen)malloc(sizeof(_WWScreen));
|
||||
if (screen == NULL)
|
||||
WonX_Error("WWScreen_Create", "Cannot allocate memory.");
|
||||
if (screen == NULL) Error("WWScreen_Create", "Cannot allocate memory.");
|
||||
|
||||
WWScreen_SetNumber(screen, number);
|
||||
WWScreen_SetWidth( screen, width);
|
||||
@ -247,7 +209,7 @@ WWScreen WWScreen_Create(int number,
|
||||
WWScreen_SetRollY( screen, 0);
|
||||
|
||||
WWScreen_SetEnable(screen, 1);
|
||||
WWScreen_SetMode( screen, WW_SCREEN_DRAW_ALL);
|
||||
WWScreen_SetMode( screen, WWSCREEN_DRAW_ALL);
|
||||
|
||||
WWScreen_SetDrawX( screen, draw_x);
|
||||
WWScreen_SetDrawY( screen, draw_y);
|
||||
@ -273,8 +235,7 @@ WWScreen WWScreen_Destroy(WWScreen screen)
|
||||
int x, y;
|
||||
WWScreenCharacter sc;
|
||||
|
||||
if (screen == NULL)
|
||||
WonX_Error("WWScreen_Destroy", "Object is not created.");
|
||||
if (screen == NULL) return (NULL);
|
||||
|
||||
for (y = 0; y < screen->height; y++) {
|
||||
for (x = 0; x < screen->width; x++) {
|
||||
|
||||
25
WWScreen.h
25
WWScreen.h
@ -5,30 +5,24 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "WWPalette.h"
|
||||
#include "WWCharacter.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWScreen * WWScreen;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "WWPalette.h"
|
||||
#include "WWCharacter.h"
|
||||
#include "WWCursor.h"
|
||||
#include "WWDisplay.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 定数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define WW_SCREEN_DRAW_ALL 0
|
||||
#define WW_SCREEN_INSIDE_ONLY 1
|
||||
#define WW_SCREEN_OUTSIDE_ONLY 2
|
||||
#define WWSCREEN_DRAW_ALL 0
|
||||
#define WWSCREEN_INSIDE_ONLY 1
|
||||
#define WWSCREEN_OUTSIDE_ONLY 2
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
@ -72,8 +66,7 @@ int WWScreen_SetDrawY( WWScreen s, int n);
|
||||
int WWScreen_SetDrawWidth( WWScreen s, int n);
|
||||
int WWScreen_SetDrawHeight(WWScreen s, int n);
|
||||
|
||||
int WWScreen_GetPixel(WWScreen screen, int x, int y,
|
||||
WWDisplay display, WWCursor cursor);
|
||||
int WWScreen_GetPixel(WWScreen screen, int x, int y);
|
||||
|
||||
WWScreen WWScreen_Create(int number,
|
||||
int width, int height,
|
||||
|
||||
@ -33,7 +33,7 @@ typedef struct _WWScreen {
|
||||
int enable; /* 表示/非表示のフラグ */
|
||||
|
||||
int mode; /* 表示モード */
|
||||
/* WW_SCREEN_DRAW_ALL, WW_SCREEN_INSIDE_ONLY, WW_SCREEN_OUTSIDE_ONLY の */
|
||||
/* WWSCREEN_DRAW_ALL, WWSCREEN_INSIDE_ONLY, WWSCREEN_OUTSIDE_ONLY の */
|
||||
/* いずれかの値を取る */
|
||||
|
||||
/* 表示領域(スクリーン2のウインドウ機能用.スクリーン1では未使用) */
|
||||
|
||||
@ -1,86 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWSerialPortP.h"
|
||||
#include "WonX.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
int WWSerialPort_Open( WWSerialPort s) { return (s->opened = 1); }
|
||||
int WWSerialPort_Close( WWSerialPort s) { return (s->opened = 0); }
|
||||
int WWSerialPort_IsOpened(WWSerialPort s) { return (s->opened != 0); }
|
||||
int WWSerialPort_IsClosed(WWSerialPort s) { return (s->opened == 0); }
|
||||
|
||||
int WWSerialPort_GetBaudrate(WWSerialPort s) { return (s->baudrate); }
|
||||
int WWSerialPort_SetBaudrate(WWSerialPort s, int baudrate)
|
||||
{ return (s->baudrate = baudrate); }
|
||||
|
||||
int WWSerialPort_SetBaudrate9600(WWSerialPort s)
|
||||
{ return (WWSerialPort_SetBaudrate(s, WW_SERIAL_PORT_BAUDRATE_9600)); }
|
||||
int WWSerialPort_SetBaudrate38400(WWSerialPort s)
|
||||
{ return (WWSerialPort_SetBaudrate(s, WW_SERIAL_PORT_BAUDRATE_38400)); }
|
||||
int WWSerialPort_IsBaudrate9600(WWSerialPort s)
|
||||
{ return (WWSerialPort_GetBaudrate(s) == WW_SERIAL_PORT_BAUDRATE_9600); }
|
||||
int WWSerialPort_IsBaudrate38400(WWSerialPort s)
|
||||
{ return (WWSerialPort_GetBaudrate(s) == WW_SERIAL_PORT_BAUDRATE_38400); }
|
||||
|
||||
int WWSerialPort_GetSendTimeout(WWSerialPort s)
|
||||
{ return (s->send_timeout); }
|
||||
int WWSerialPort_SetSendTimeout(WWSerialPort s, int timeout)
|
||||
{ return (s->send_timeout = timeout); }
|
||||
int WWSerialPort_GetReceiveTimeout(WWSerialPort s)
|
||||
{ return (s->receive_timeout); }
|
||||
int WWSerialPort_SetReceiveTimeout(WWSerialPort s, int timeout)
|
||||
{ return (s->receive_timeout = timeout); }
|
||||
|
||||
unsigned int WWSerialPort_GetCancelKey(WWSerialPort s)
|
||||
{ return (s->cancel_key); }
|
||||
unsigned int WWSerialPort_SetCancelKey(WWSerialPort s, int cancel_key)
|
||||
{ return (s->cancel_key = cancel_key); }
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの作成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
WWSerialPort WWSerialPort_Create()
|
||||
{
|
||||
WWSerialPort ww_serial_port;
|
||||
|
||||
ww_serial_port = (WWSerialPort)malloc(sizeof(_WWSerialPort));
|
||||
if (ww_serial_port == NULL)
|
||||
WonX_Error("WWSerialPort_Create", "Cannot allocate memory.");
|
||||
|
||||
WWSerialPort_Close(ww_serial_port);
|
||||
WWSerialPort_SetBaudrate38400(ww_serial_port);
|
||||
WWSerialPort_SetSendTimeout(ww_serial_port, 100);
|
||||
WWSerialPort_SetReceiveTimeout(ww_serial_port, 100);
|
||||
|
||||
return (ww_serial_port);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
WWSerialPort WWSerialPort_Destroy(WWSerialPort ww_serial_port)
|
||||
{
|
||||
if (ww_serial_port == NULL)
|
||||
WonX_Error("WWSerialPort_Destroy", "Object is not created.");
|
||||
|
||||
WWSerialPort_Close(ww_serial_port);
|
||||
|
||||
free(ww_serial_port);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
@ -1,75 +0,0 @@
|
||||
#ifndef _WWSerialPort_h_INCLUDED_
|
||||
#define _WWSerialPort_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWSerialPort * WWSerialPort;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wonx/comm.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 定数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define WW_SERIAL_PORT_BAUDRATE_9600 0
|
||||
#define WW_SERIAL_PORT_BAUDRATE_38400 1
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
int WWSerialPort_Open( WWSerialPort s);
|
||||
int WWSerialPort_Close( WWSerialPort s);
|
||||
int WWSerialPort_IsOpened(WWSerialPort s);
|
||||
int WWSerialPort_IsClosed(WWSerialPort s);
|
||||
|
||||
int WWSerialPort_GetBaudrate(WWSerialPort s);
|
||||
int WWSerialPort_SetBaudrate(WWSerialPort s, int baudrate);
|
||||
|
||||
int WWSerialPort_SetBaudrate9600(WWSerialPort s);
|
||||
int WWSerialPort_SetBaudrate38400(WWSerialPort s);
|
||||
int WWSerialPort_IsBaudrate9600(WWSerialPort s);
|
||||
int WWSerialPort_IsBaudrate38400(WWSerialPort s);
|
||||
|
||||
int WWSerialPort_GetSendTimeout(WWSerialPort s);
|
||||
int WWSerialPort_SetSendTimeout(WWSerialPort s, int timeout);
|
||||
int WWSerialPort_GetReceiveTimeout(WWSerialPort s);
|
||||
int WWSerialPort_SetReceiveTimeout(WWSerialPort s, int timeout);
|
||||
|
||||
unsigned int WWSerialPort_GetCancelKey(WWSerialPort s);
|
||||
unsigned int WWSerialPort_SetCancelKey(WWSerialPort s, int cancel_key);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの作成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
WWSerialPort WWSerialPort_Create();
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
WWSerialPort WWSerialPort_Destroy(WWSerialPort ww_serial_port);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
72
WWSprite.c
72
WWSprite.c
@ -3,7 +3,6 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWSpriteP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
@ -38,45 +37,20 @@ int WWSprite_SetPosition(WWSprite sprite, int x, int y)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* スプライトのピクセル値を返す.(透明色は-1を返す) */
|
||||
int WWSprite_GetPixel(WWSprite sprite, int x, int y, WWDisplay display)
|
||||
int WWSprite_GetPixel(WWSprite sprite, int x, int y)
|
||||
{
|
||||
WWPalette palette;
|
||||
WWCharacter character;
|
||||
WWPalette p;
|
||||
WWCharacter c;
|
||||
int pixel;
|
||||
|
||||
palette = WWSprite_GetPalette(sprite);
|
||||
character = WWSprite_GetCharacter(sprite);
|
||||
p = WWSprite_GetPalette(sprite);
|
||||
c = WWSprite_GetCharacter(sprite);
|
||||
|
||||
if (WWSprite_GetHorizontal(sprite)) x = 7 - x;
|
||||
if (WWSprite_GetVertical( sprite)) y = 7 - y;
|
||||
|
||||
pixel = WWCharacter_GetPixel(character, x, y, display);
|
||||
|
||||
/* カラー対応 */
|
||||
switch (WWDisplay_GetColorMode(display)) {
|
||||
case COLOR_MODE_GRAYSCALE:
|
||||
/*
|
||||
* WonX-2.0 以降では,透明色の処理は WWDisplay クラスで行うように
|
||||
* 変更したので,WWPalette_GetMappedColor() が -1 を返すことは無い.
|
||||
*/
|
||||
pixel = WWPalette_GetMappedColor(palette, pixel);
|
||||
break;
|
||||
case COLOR_MODE_4COLOR:
|
||||
case COLOR_MODE_16COLOR:
|
||||
case COLOR_MODE_16PACKED:
|
||||
pixel =
|
||||
((unsigned short int)WWPalette_GetRed( palette, pixel) << 8) |
|
||||
((unsigned short int)WWPalette_GetGreen(palette, pixel) << 4) |
|
||||
((unsigned short int)WWPalette_GetBlue( palette, pixel) << 0);
|
||||
break;
|
||||
default:
|
||||
WonX_Error("WWSprite_GetPixel", "Unknown color mode.");
|
||||
}
|
||||
|
||||
/* 透明色の場合には -1 を返す */
|
||||
if (WWDisplay_IsTransparent(display, palette, pixel))
|
||||
pixel = -1;
|
||||
pixel = WWCharacter_GetPixel(c, x, y);
|
||||
pixel = WWPalette_GetMappedColor(p, pixel);
|
||||
|
||||
return (pixel);
|
||||
}
|
||||
@ -89,8 +63,7 @@ WWSprite WWSprite_Create(int number, int x, int y,
|
||||
WWSprite sprite;
|
||||
|
||||
sprite = (WWSprite)malloc(sizeof(_WWSprite));
|
||||
if (sprite == NULL)
|
||||
WonX_Error("WWSprite_Create", "Cannot allocate memory.");
|
||||
if (sprite == NULL) Error("WWSprite_Create", "Cannot allocate memory.");
|
||||
|
||||
WWSprite_SetNumber(sprite, number);
|
||||
WWSprite_SetHorizontal(sprite, horizontal);
|
||||
@ -107,8 +80,7 @@ WWSprite WWSprite_Create(int number, int x, int y,
|
||||
|
||||
WWSprite WWSprite_Destroy(WWSprite sprite)
|
||||
{
|
||||
if (sprite == NULL)
|
||||
WonX_Error("WWSprite_Destroy", "Object is not created.");
|
||||
if (sprite == NULL) return (NULL);
|
||||
free(sprite);
|
||||
return (NULL);
|
||||
}
|
||||
@ -121,21 +93,21 @@ int WWSprite_PrintData(WWSprite s, FILE * f)
|
||||
|
||||
fprintf(f, "\n");
|
||||
|
||||
fprintf(f, "sprite[%03d] :\tnumber = %d\n", n, WWSprite_GetNumber(s));
|
||||
fprintf(f, "sprite[%03d] :\thorizontal = %s\n",
|
||||
n, wonx_true_false(WWSprite_GetHorizontal(s)));
|
||||
fprintf(f, "sprite[%03d] :\tvertical = %s\n",
|
||||
n, wonx_true_false(WWSprite_GetVertical( s)));
|
||||
fprintf(f, "sprite[%03d] :\tpriority = %s\n",
|
||||
n, wonx_true_false(WWSprite_GetPriority( s)));
|
||||
fprintf(f, "sprite[%03d] :\tclipping = %s\n",
|
||||
n, wonx_true_false(WWSprite_GetClipping( s)));
|
||||
fprintf(f, "sprite[%03d] :\tpalette number = %d\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[%03d] :\tcharacter number = %d\n",
|
||||
fprintf(f, "sprite[%d] :\tcharacter number = %d\n",
|
||||
n, WWCharacter_GetNumber(WWSprite_GetCharacter(s)));
|
||||
fprintf(f, "sprite[%03d] :\tx = %d\n", n, WWSprite_GetX(s));
|
||||
fprintf(f, "sprite[%03d] :\ty = %d\n", n, WWSprite_GetY(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);
|
||||
|
||||
|
||||
17
WWSprite.h
17
WWSprite.h
@ -5,22 +5,17 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "WWPalette.h"
|
||||
#include "WWCharacter.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWSprite * WWSprite;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "WWPalette.h"
|
||||
#include "WWCharacter.h"
|
||||
#include "WWDisplay.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
@ -44,7 +39,7 @@ WWCharacter WWSprite_SetCharacter(WWSprite s, WWCharacter c);
|
||||
int WWSprite_GetX(WWSprite sprite);
|
||||
int WWSprite_GetY(WWSprite sprite);
|
||||
int WWSprite_SetPosition(WWSprite sprite, int x, int y);
|
||||
int WWSprite_GetPixel(WWSprite sprite, int x, int y, WWDisplay display);
|
||||
int WWSprite_GetPixel(WWSprite sprite, int x, int y);
|
||||
|
||||
WWSprite WWSprite_Create(int number, int x, int y,
|
||||
int horizontal, int vertical,
|
||||
|
||||
88
WWText.c
88
WWText.c
@ -3,7 +3,7 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWTextP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/* フォントのビットマップデータ */
|
||||
#include "WWTextFonts.c"
|
||||
@ -55,9 +55,9 @@ int WWText_SetTextWindow(WWText ww_text, int x, int y,
|
||||
c = WWText_GetBase(ww_text);
|
||||
for (ty = 0; ty < WWText_GetHeight(ww_text); ty++) {
|
||||
for (tx = 0; tx < WWText_GetWidth(ww_text); tx++) {
|
||||
if (c >= 512) WonX_Error("WWText_SetTextWindow", "Over character.");
|
||||
if (c >= 512) Error("WWText_SetTextWindow", "Over character.");
|
||||
ww_character = WWDisplay_GetCharacter(ww_display, c);
|
||||
WWCharacter_ClearAllPixels(ww_character);
|
||||
WWCharacter_SetBitmap(ww_character, NULL);
|
||||
WWScreen_SetCharacter(WWText_GetScreen(ww_text),
|
||||
WWText_GetX(ww_text) + tx,
|
||||
WWText_GetY(ww_text) + ty,
|
||||
@ -72,15 +72,9 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
|
||||
WWDisplay ww_display)
|
||||
{
|
||||
WWCharacter ww_character;
|
||||
int j, k, n;
|
||||
int f, b;
|
||||
unsigned short int pixel;
|
||||
unsigned short int bitmap;
|
||||
|
||||
if ((character < 0) || (character > 127)) {
|
||||
WonX_Warning("WWText_PutCharacter", "Character number is out of range.");
|
||||
return (-1);
|
||||
}
|
||||
if ((character < 0) || (character > 127))
|
||||
Error("WWText_PutCharacter", "Character number is out of range.");
|
||||
|
||||
/*
|
||||
* テキスト表示は,text_window_init() で指定したテキストウインドウの
|
||||
@ -88,10 +82,8 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
|
||||
*/
|
||||
|
||||
if ( (x < 0) || (x > WWText_GetWidth( ww_text) - 1) ||
|
||||
(y < 0) || (y > WWText_GetHeight(ww_text) - 1) ) {
|
||||
WonX_Warning("WWText_PutCharacter", "Position is out of range.");
|
||||
return (-1);
|
||||
}
|
||||
(y < 0) || (y > WWText_GetHeight(ww_text) - 1) )
|
||||
Error("WWText_PutCharacter", "Position is out of range.");
|
||||
|
||||
#if 0
|
||||
n = WWText_GetBase(ww_text) +
|
||||
@ -104,34 +96,7 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
|
||||
WWText_GetY(ww_text) + y);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* テキストフォントは
|
||||
* f = WWDisplay_GetForegroundColor(ww_display);
|
||||
* b = WWDisplay_GetBackgroundColor(ww_display);
|
||||
* で描画する必要があるため,描画のたびにビットマップをコピーする必要がある.
|
||||
* で,カラー化の際に,そのように修正した.
|
||||
* よって,テキストの初期化時に WWCharacter の配列を作成する必要は
|
||||
* 無くなったので,WWCharacter の配列はいずれ削除すること.
|
||||
*/
|
||||
|
||||
#if 0
|
||||
WWCharacter_CopyAllPixels(ww_character, WWText_GetFont(ww_text, character));
|
||||
#else
|
||||
f = WWDisplay_GetForegroundColor(ww_display);
|
||||
b = WWDisplay_GetBackgroundColor(ww_display);
|
||||
|
||||
n = character * 8;
|
||||
for (j = 0; j < 8; j++) {
|
||||
bitmap = 0;
|
||||
for (k = 0; k < 8; k++) {
|
||||
pixel = (fonts[n] & (1 << k)) ? f : b;
|
||||
bitmap |= ( pixel & 1) << k;
|
||||
bitmap |= ((pixel >> 1) & 1) << (k + 8);
|
||||
}
|
||||
WWCharacter_SetBitmapAsShortInt(ww_character, j, bitmap);
|
||||
n++;
|
||||
}
|
||||
#endif
|
||||
WWCharacter_CopyBitmap(ww_character, WWText_GetFont(ww_text, character));
|
||||
|
||||
/* 表示時にパレットを設定するのでいいのか? 不明 */
|
||||
WWScreen_SetPalette(WWText_GetScreen(ww_text),
|
||||
@ -151,44 +116,20 @@ WWText WWText_Create(WWScreen screen,
|
||||
WWPalette palette)
|
||||
{
|
||||
WWText ww_text;
|
||||
WWCharacter ww_character;
|
||||
int i, j, k, n;
|
||||
int f, b;
|
||||
unsigned short int pixel;
|
||||
unsigned short int bitmap;
|
||||
int i;
|
||||
|
||||
ww_text = (WWText)malloc(sizeof(_WWText));
|
||||
if (ww_text == NULL) WonX_Error("WWText_Create", "Cannot allocate memory.");
|
||||
if (ww_text == NULL) Error("WWText_Create", "Cannot allocate memory.");
|
||||
|
||||
WWText_SetScreen(ww_text, screen);
|
||||
WWText_SetX(ww_text, x);
|
||||
WWText_SetY(ww_text, y);
|
||||
WWText_SetX(ww_text, 0);
|
||||
WWText_SetY(ww_text, 0);
|
||||
WWText_SetWidth( ww_text, width );
|
||||
WWText_SetHeight(ww_text, height);
|
||||
WWText_SetPalette(ww_text, palette);
|
||||
|
||||
/* 以下は,
|
||||
f = WWDisplay_GetForegroundColor(ww_display);
|
||||
b = WWDisplay_GetBackgroundColor(ww_display);
|
||||
で取得すべきかもしれない
|
||||
*/
|
||||
f = 3;
|
||||
b = 0;
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < 128; i++) {
|
||||
ww_character = WWCharacter_Create(i);
|
||||
for (j = 0; j < 8; j++) {
|
||||
bitmap = 0;
|
||||
for (k = 0; k < 8; k++) {
|
||||
pixel = (fonts[n] & (1 << k)) ? f : b;
|
||||
bitmap |= ( pixel & 1) << k;
|
||||
bitmap |= ((pixel >> 1) & 1) << (k + 8);
|
||||
}
|
||||
WWCharacter_SetBitmapAsShortInt(ww_character, j, bitmap);
|
||||
n++;
|
||||
}
|
||||
WWText_SetFont(ww_text, i, ww_character);
|
||||
WWText_SetFont(ww_text, i, WWCharacter_Create(i, &(fonts[i * 16])));
|
||||
}
|
||||
|
||||
return (ww_text);
|
||||
@ -198,8 +139,7 @@ WWText WWText_Destroy(WWText ww_text)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (ww_text == NULL)
|
||||
WonX_Error("WWText_Destroy", "Object is not created.");
|
||||
if (ww_text == NULL) Error("WWText_Destroy", "Object is not created.");
|
||||
|
||||
for (i = 0; i < 128; i++) {
|
||||
if (WWText_GetFont(ww_text, i))
|
||||
|
||||
27
WWText.h
27
WWText.h
@ -5,20 +5,16 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWDisplay.h"
|
||||
#include "WWScreen.h"
|
||||
#include "WWPalette.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWText * WWText;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWDisplay.h"
|
||||
#include "WWScreen.h"
|
||||
#include "WWPalette.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* メンバの取得 */
|
||||
/*===========================================================================*/
|
||||
@ -57,6 +53,21 @@ WWText WWText_Create(WWScreen screen, int x, int y, int width, int height,
|
||||
WWPalette palette);
|
||||
WWText WWText_Destroy(WWText text);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ¤³¤³¤Þ¤Ç */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
256
WWTextFonts.c
256
WWTextFonts.c
@ -1,130 +1,130 @@
|
||||
static unsigned char fonts[] = {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0 空白文字 */
|
||||
0x00, 0x00, 0x14, 0x00, 0x22, 0x1c, 0x00, 0x00, /* 1 笑顔 */
|
||||
0x00, 0x3e, 0x6b, 0x7f, 0x5d, 0x63, 0x3e, 0x00, /* 2 笑顔 */
|
||||
0x22, 0x77, 0x7f, 0x7f, 0x3e, 0x1c, 0x08, 0x00, /* 3 ハート */
|
||||
0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x1c, 0x08, 0x00, /* 4 ダイヤ */
|
||||
0x08, 0x1c, 0x1c, 0x77, 0x77, 0x08, 0x1c, 0x00, /* 5 クローバー */
|
||||
0x08, 0x1c, 0x3e, 0x7f, 0x3e, 0x08, 0x1c, 0x00, /* 6 スペード */
|
||||
0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, /* 7 点 */
|
||||
0x00, 0x00, 0x3c, 0x24, 0x24, 0x3c, 0x00, 0x00, /* 8 小さい□ */
|
||||
0x00, 0x00, 0x18, 0x24, 0x24, 0x18, 0x00, 0x00, /* 9 小さい○ */
|
||||
0x00, 0x7e, 0x42, 0x5a, 0x5a, 0x42, 0x7e, 0x00, /* 10 2重四角 */
|
||||
0x0f, 0x03, 0x05, 0x39, 0x48, 0x48, 0x30, 0x00, /* 11 ♂ */
|
||||
0x1c, 0x22, 0x22, 0x1c, 0x08, 0x3e, 0x08, 0x00, /* 12 ♀ */
|
||||
0x18, 0x1c, 0x16, 0x12, 0x12, 0x70, 0x60, 0x00, /* 13 ♪ */
|
||||
0x18, 0x1e, 0x16, 0x12, 0x62, 0x6e, 0x0c, 0x00, /* 14 音符 */
|
||||
0x08, 0x2a, 0x1c, 0x77, 0x1c, 0x2a, 0x08, 0x00, /* 15 爆発? */
|
||||
0x10, 0x18, 0x1c, 0x1e, 0x1c, 0x18, 0x10, 0x00, /* 16 右向き▲ */
|
||||
0x04, 0x0c, 0x1c, 0x3c, 0x1c, 0x0c, 0x04, 0x00, /* 17 左向き▲ */
|
||||
0x08, 0x1c, 0x3e, 0x08, 0x3e, 0x1c, 0x08, 0x00, /* 18 上下矢印 */
|
||||
0x36, 0x36, 0x36, 0x36, 0x36, 0x00, 0x36, 0x00, /* 19 !! */
|
||||
0x00, 0x00, 0x02, 0x06, 0x2c, 0x38, 0x10, 0x00, /* 20 チェック */
|
||||
0x00, 0x00, 0x18, 0x3c, 0x3c, 0x18, 0x00, 0x00, /* 21 小さい● */
|
||||
0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, /* 22 ・・ */
|
||||
0x08, 0x1c, 0x3e, 0x08, 0x3e, 0x1c, 0x3e, 0x00, /* 23 矢印? */
|
||||
0x08, 0x1c, 0x3e, 0x08, 0x08, 0x08, 0x08, 0x00, /* 24 ↑ */
|
||||
0x08, 0x08, 0x08, 0x08, 0x3e, 0x1c, 0x08, 0x00, /* 25 ↓ */
|
||||
0x00, 0x04, 0x06, 0x7f, 0x06, 0x04, 0x00, 0x00, /* 26 → */
|
||||
0x00, 0x10, 0x30, 0x7f, 0x30, 0x10, 0x00, 0x00, /* 27 ← */
|
||||
0x3c, 0x42, 0x9d, 0xa1, 0xa1, 0x9d, 0x42, 0x3c, /* 28 (C) */
|
||||
0x00, 0x14, 0x36, 0x7f, 0x36, 0x14, 0x00, 0x00, /* 29 ←→ */
|
||||
0x00, 0x08, 0x1c, 0x3e, 0x7f, 0x00, 0x00, 0x00, /* 30 上向き▲ */
|
||||
0x00, 0x00, 0x7f, 0x3e, 0x1c, 0x08, 0x00, 0x00, /* 31 下向き▲ */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 32 空白 */
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x00, /* 33 ! */
|
||||
0x36, 0x36, 0x12, 0x24, 0x00, 0x00, 0x00, 0x00, /* 34 " */
|
||||
0x14, 0x14, 0x7f, 0x14, 0x7f, 0x14, 0x14, 0x00, /* 35 # */
|
||||
0x08, 0x3e, 0x68, 0x3e, 0x0b, 0x3e, 0x08, 0x00, /* 36 $ */
|
||||
0x21, 0x52, 0x24, 0x08, 0x12, 0x25, 0x42, 0x00, /* 37 % */
|
||||
0x18, 0x24, 0x24, 0x39, 0x4e, 0x44, 0x3b, 0x00, /* 38 & */
|
||||
0x0c, 0x0c, 0x04, 0x08, 0x00, 0x00, 0x00, 0x00, /* 39 ' */
|
||||
0x04, 0x08, 0x10, 0x10, 0x10, 0x08, 0x04, 0x00, /* 40 ( */
|
||||
0x10, 0x08, 0x04, 0x04, 0x04, 0x08, 0x10, 0x00, /* 41 ) */
|
||||
0x00, 0x08, 0x2a, 0x1c, 0x2a, 0x08, 0x00, 0x00, /* 42 * */
|
||||
0x08, 0x08, 0x08, 0x7f, 0x08, 0x08, 0x08, 0x00, /* 43 + */
|
||||
0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x20, 0x40, /* 44 , */
|
||||
0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, /* 45 - */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, /* 46 . */
|
||||
0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x00, /* 47 / */
|
||||
0x3c, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3c, 0x00, /* 48 0 */
|
||||
0x0c, 0x3c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x00, /* 49 1 */
|
||||
0x3c, 0x66, 0x06, 0x0c, 0x18, 0x30, 0x7e, 0x00, /* 50 2 */
|
||||
0x3c, 0x66, 0x06, 0x3c, 0x06, 0x66, 0x3c, 0x00, /* 51 3 */
|
||||
0x0e, 0x1e, 0x36, 0x66, 0x66, 0x7f, 0x06, 0x00, /* 52 4 */
|
||||
0x7e, 0x60, 0x60, 0x7c, 0x06, 0x66, 0x3c, 0x00, /* 53 5 */
|
||||
0x3c, 0x66, 0x60, 0x7c, 0x66, 0x66, 0x3c, 0x00, /* 54 6 */
|
||||
0x7e, 0x66, 0x06, 0x0c, 0x18, 0x18, 0x18, 0x00, /* 55 7 */
|
||||
0x3c, 0x66, 0x66, 0x3c, 0x66, 0x66, 0x3c, 0x00, /* 56 8 */
|
||||
0x3c, 0x66, 0x66, 0x3e, 0x06, 0x66, 0x3c, 0x00, /* 57 9 */
|
||||
0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, /* 58 : */
|
||||
0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x08, 0x10, /* 59 ; */
|
||||
0x04, 0x08, 0x10, 0x20, 0x10, 0x08, 0x04, 0x00, /* 60 < */
|
||||
0x00, 0x00, 0x7f, 0x00, 0x7f, 0x00, 0x00, 0x00, /* 61 = */
|
||||
0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, /* 62 > */
|
||||
0x3c, 0x66, 0x66, 0x0c, 0x18, 0x00, 0x18, 0x00, /* 63 ? */
|
||||
0x3e, 0x45, 0x5d, 0x55, 0x5f, 0x40, 0x3e, 0x00, /* 64 @ */
|
||||
0x1c, 0x36, 0x63, 0x63, 0x7f, 0x63, 0x63, 0x00, /* 65 A */
|
||||
0x7e, 0x63, 0x63, 0x7e, 0x63, 0x63, 0x7e, 0x00, /* 66 B */
|
||||
0x3e, 0x63, 0x60, 0x60, 0x60, 0x63, 0x3e, 0x00, /* 67 C */
|
||||
0x7c, 0x66, 0x63, 0x63, 0x63, 0x66, 0x7c, 0x00, /* 68 D */
|
||||
0x7e, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x7e, 0x00, /* 69 E */
|
||||
0x7e, 0x60, 0x60, 0x7c, 0x60, 0x60, 0x60, 0x00, /* 70 F */
|
||||
0x3e, 0x63, 0x60, 0x67, 0x63, 0x63, 0x3e, 0x00, /* 71 G */
|
||||
0x63, 0x63, 0x63, 0x7f, 0x63, 0x63, 0x63, 0x00, /* 72 H */
|
||||
0x3c, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, /* 73 I */
|
||||
0x0f, 0x03, 0x03, 0x63, 0x63, 0x63, 0x3e, 0x00, /* 74 J */
|
||||
0x63, 0x66, 0x6c, 0x78, 0x6c, 0x66, 0x63, 0x00, /* 75 K */
|
||||
0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x7f, 0x00, /* 76 L */
|
||||
0x63, 0x77, 0x7f, 0x6b, 0x63, 0x63, 0x63, 0x00, /* 77 M */
|
||||
0x63, 0x73, 0x7b, 0x6f, 0x67, 0x63, 0x63, 0x00, /* 78 N */
|
||||
0x3e, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3e, 0x00, /* 79 O */
|
||||
0x7e, 0x63, 0x63, 0x7e, 0x60, 0x60, 0x60, 0x00, /* 80 P */
|
||||
0x3e, 0x63, 0x63, 0x6b, 0x6f, 0x67, 0x3e, 0x00, /* 81 Q */
|
||||
0x7e, 0x63, 0x63, 0x7e, 0x6c, 0x66, 0x63, 0x00, /* 82 R */
|
||||
0x3e, 0x63, 0x60, 0x3e, 0x03, 0x63, 0x3e, 0x00, /* 83 S */
|
||||
0x7e, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, /* 84 T */
|
||||
0x63, 0x63, 0x63, 0x63, 0x63, 0x63, 0x3e, 0x00, /* 85 U */
|
||||
0x63, 0x63, 0x63, 0x36, 0x36, 0x1c, 0x08, 0x00, /* 86 V */
|
||||
0x63, 0x6b, 0x6b, 0x6b, 0x7f, 0x36, 0x22, 0x00, /* 87 W */
|
||||
0x63, 0x63, 0x36, 0x1c, 0x36, 0x63, 0x63, 0x00, /* 88 X */
|
||||
0x66, 0x66, 0x66, 0x3c, 0x18, 0x18, 0x18, 0x00, /* 89 Y */
|
||||
0x7f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x7f, 0x00, /* 90 Z */
|
||||
0x1c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x1c, 0x00, /* 91 [ */
|
||||
0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01, 0x00, /* 92 \ */
|
||||
0x1c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x1c, 0x00, /* 93 ] */
|
||||
0x08, 0x1c, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, /* 94 ^ */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, /* 95 _ */
|
||||
0x18, 0x18, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, /* 96 ` */
|
||||
0x00, 0x00, 0x3e, 0x66, 0x66, 0x66, 0x3f, 0x00, /* 97 a */
|
||||
0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x7c, 0x00, /* 98 b */
|
||||
0x00, 0x00, 0x3c, 0x66, 0x60, 0x66, 0x3c, 0x00, /* 99 c */
|
||||
0x06, 0x06, 0x3e, 0x66, 0x66, 0x66, 0x3e, 0x00, /* 100 d */
|
||||
0x00, 0x00, 0x3c, 0x66, 0x7e, 0x60, 0x3c, 0x00, /* 101 e */
|
||||
0x1c, 0x32, 0x30, 0x7c, 0x30, 0x30, 0x30, 0x00, /* 102 f */
|
||||
0x00, 0x00, 0x3e, 0x66, 0x66, 0x1e, 0x66, 0x3c, /* 103 g */
|
||||
0x60, 0x60, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x00, /* 104 h */
|
||||
0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, /* 105 i */
|
||||
0x06, 0x00, 0x06, 0x06, 0x06, 0x06, 0x66, 0x3c, /* 106 j */
|
||||
0x60, 0x60, 0x66, 0x6c, 0x70, 0x6c, 0x66, 0x00, /* 107 k */
|
||||
0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3c, 0x00, /* 108 l */
|
||||
0x00, 0x00, 0x76, 0x6b, 0x6b, 0x6b, 0x6b, 0x00, /* 109 m */
|
||||
0x00, 0x00, 0x7c, 0x66, 0x66, 0x66, 0x66, 0x00, /* 110 n */
|
||||
0x00, 0x00, 0x3c, 0x66, 0x66, 0x66, 0x3c, 0x00, /* 111 o */
|
||||
0x00, 0x00, 0x7c, 0x66, 0x66, 0x7c, 0x60, 0x60, /* 112 p */
|
||||
0x00, 0x00, 0x3e, 0x66, 0x66, 0x1e, 0x06, 0x06, /* 113 q */
|
||||
0x00, 0x00, 0x6e, 0x70, 0x60, 0x60, 0x60, 0x00, /* 114 r */
|
||||
0x00, 0x00, 0x3e, 0x70, 0x3c, 0x0e, 0x7c, 0x00, /* 115 s */
|
||||
0x18, 0x18, 0x3e, 0x18, 0x18, 0x18, 0x0e, 0x00, /* 116 t */
|
||||
0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3f, 0x00, /* 117 u */
|
||||
0x00, 0x00, 0x66, 0x66, 0x24, 0x3c, 0x18, 0x00, /* 118 v */
|
||||
0x00, 0x00, 0x63, 0x6b, 0x2a, 0x3e, 0x14, 0x00, /* 119 w */
|
||||
0x00, 0x00, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0x00, /* 120 x */
|
||||
0x00, 0x00, 0x66, 0x66, 0x3c, 0x18, 0x30, 0x60, /* 121 y */
|
||||
0x00, 0x00, 0x7e, 0x0c, 0x18, 0x30, 0x7e, 0x00, /* 122 z */
|
||||
0x0c, 0x18, 0x18, 0x30, 0x18, 0x18, 0x0c, 0x00, /* 123 { */
|
||||
0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x00, /* 124 | */
|
||||
0x18, 0x0c, 0x0c, 0x06, 0x0c, 0x0c, 0x18, 0x00, /* 125 } */
|
||||
0x32, 0x3c, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, /* 126 ~ */
|
||||
0x08, 0x08, 0x14, 0x14, 0x22, 0x22, 0x3e, 0x00 /* 127 △ */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0 空白文字 */
|
||||
0x00,0x00,0x00,0x00,0xc0,0x0c,0x00,0x00,0x30,0x30,0xc0,0x0f,0x00,0x00,0x00,0x00, /* 1 笑顔 */
|
||||
0x00,0x00,0xf0,0x3f,0x3c,0xf3,0xfc,0xff,0xcc,0xcf,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 2 笑顔 */
|
||||
0x30,0x30,0xfc,0xfc,0xfc,0xff,0xfc,0xff,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 3 ハート */
|
||||
0x00,0x03,0xc0,0x0f,0xf0,0x3f,0xfc,0xff,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 4 ダイヤ */
|
||||
0x00,0x03,0xc0,0x0f,0xc0,0x0f,0xfc,0xfc,0xfc,0xfc,0x00,0x03,0xc0,0x0f,0x00,0x00, /* 5 クローバー */
|
||||
0x00,0x03,0xc0,0x0f,0xf0,0x3f,0xfc,0xff,0xf0,0x3f,0x00,0x03,0xc0,0x0f,0x00,0x00, /* 6 スペード */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x00,0x00,0x00,0x00,0x00, /* 7 点 */
|
||||
0x00,0x00,0x00,0x00,0xf0,0x0f,0x30,0x0c,0x30,0x0c,0xf0,0x0f,0x00,0x00,0x00,0x00, /* 8 小さい□ */
|
||||
0x00,0x00,0x00,0x00,0xc0,0x03,0x30,0x0c,0x30,0x0c,0xc0,0x03,0x00,0x00,0x00,0x00, /* 9 小さい○ */
|
||||
0x00,0x00,0xfc,0x3f,0x0c,0x30,0xcc,0x33,0xcc,0x33,0x0c,0x30,0xfc,0x3f,0x00,0x00, /* 10 2重四角 */
|
||||
0x00,0xff,0x00,0xf0,0x00,0xcc,0xf0,0xc3,0x0c,0x03,0x0c,0x03,0xf0,0x00,0x00,0x00, /* 11 ♂ */
|
||||
0xc0,0x0f,0x30,0x30,0x30,0x30,0xc0,0x0f,0x00,0x03,0xf0,0x3f,0x00,0x03,0x00,0x00, /* 12 ♀ */
|
||||
0xc0,0x03,0xc0,0x0f,0xc0,0x3c,0xc0,0x30,0xc0,0x30,0xfc,0x00,0x3c,0x00,0x00,0x00, /* 13 ♪ */
|
||||
0xc0,0x03,0xc0,0x3f,0xc0,0x3c,0xc0,0x30,0x3c,0x30,0x3c,0x3f,0x00,0x0f,0x00,0x00, /* 14 音符 */
|
||||
0x00,0x03,0x30,0x33,0xc0,0x0f,0xfc,0xfc,0xc0,0x0f,0x30,0x33,0x00,0x03,0x00,0x00, /* 15 爆発? */
|
||||
0xc0,0x00,0xc0,0x03,0xc0,0x0f,0xc0,0x3f,0xc0,0x0f,0xc0,0x03,0xc0,0x00,0x00,0x00, /* 16 右向き▲ */
|
||||
0x00,0x0c,0x00,0x0f,0xc0,0x0f,0xf0,0x0f,0xc0,0x0f,0x00,0x0f,0x00,0x0c,0x00,0x00, /* 17 左向き▲ */
|
||||
0x00,0x03,0xc0,0x0f,0xf0,0x3f,0x00,0x03,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 18 上下矢印 */
|
||||
0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0x00,0x00,0xf0,0x3c,0x00,0x00, /* 19 !! */
|
||||
0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x3c,0x30,0x0f,0xf0,0x03,0xc0,0x00,0x00,0x00, /* 20 チェック */
|
||||
0x00,0x00,0x00,0x00,0xc0,0x03,0xf0,0x0f,0xf0,0x0f,0xc0,0x03,0x00,0x00,0x00,0x00, /* 21 小さい● */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x00,0x00,0x00,0x00,0x00,0x00, /* 22 ・・ */
|
||||
0x00,0x03,0xc0,0x0f,0xf0,0x3f,0x00,0x03,0xf0,0x3f,0xc0,0x0f,0xf0,0x3f,0x00,0x00, /* 23 矢印? */
|
||||
0x00,0x03,0xc0,0x0f,0xf0,0x3f,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x00, /* 24 ↑ */
|
||||
0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x03,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 25 ↓ */
|
||||
0x00,0x00,0x00,0x0c,0x00,0x3c,0xfc,0xff,0x00,0x3c,0x00,0x0c,0x00,0x00,0x00,0x00, /* 26 → */
|
||||
0x00,0x00,0xc0,0x00,0xf0,0x00,0xfc,0xff,0xf0,0x00,0xc0,0x00,0x00,0x00,0x00,0x00, /* 27 ← */
|
||||
0xf0,0x0f,0x0c,0x30,0xc3,0xcf,0x33,0xc0,0x33,0xc0,0xc3,0xcf,0x0c,0x30,0xf0,0x0f, /* 28 (C) */
|
||||
0x00,0x00,0xc0,0x0c,0xf0,0x3c,0xfc,0xff,0xf0,0x3c,0xc0,0x0c,0x00,0x00,0x00,0x00, /* 29 ←→ */
|
||||
0x00,0x00,0x00,0x03,0xc0,0x0f,0xf0,0x3f,0xfc,0xff,0x00,0x00,0x00,0x00,0x00,0x00, /* 30 上向き▲ */
|
||||
0x00,0x00,0x00,0x00,0xfc,0xff,0xf0,0x3f,0xc0,0x0f,0x00,0x03,0x00,0x00,0x00,0x00, /* 31 下向き▲ */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 32 空白 */
|
||||
0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00,0xc0,0x03,0x00,0x00, /* 33 ! */
|
||||
0xf0,0x3c,0xf0,0x3c,0xc0,0x30,0x30,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 34 " */
|
||||
0xc0,0x0c,0xc0,0x0c,0xfc,0xff,0xc0,0x0c,0xfc,0xff,0xc0,0x0c,0xc0,0x0c,0x00,0x00, /* 35 # */
|
||||
0x00,0x03,0xf0,0x3f,0x3c,0x03,0xf0,0x3f,0x00,0xf3,0xf0,0x3f,0x00,0x03,0x00,0x00, /* 36 $ */
|
||||
0x30,0xc0,0xcc,0x30,0x30,0x0c,0x00,0x03,0xc0,0x30,0x30,0xcc,0x0c,0x30,0x00,0x00, /* 37 % */
|
||||
0xc0,0x03,0x30,0x0c,0x30,0x0c,0xf0,0xc3,0x0c,0x3f,0x0c,0x0c,0xf0,0xf3,0x00,0x00, /* 38 & */
|
||||
0x00,0x0f,0x00,0x0f,0x00,0x0c,0x00,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 39 ' */
|
||||
0x00,0x0c,0x00,0x03,0xc0,0x00,0xc0,0x00,0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x00, /* 40 ( */
|
||||
0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x03,0xc0,0x00,0x00,0x00, /* 41 ) */
|
||||
0x00,0x00,0x00,0x03,0x30,0x33,0xc0,0x0f,0x30,0x33,0x00,0x03,0x00,0x00,0x00,0x00, /* 42 * */
|
||||
0x00,0x03,0x00,0x03,0x00,0x03,0xfc,0xff,0x00,0x03,0x00,0x03,0x00,0x03,0x00,0x00, /* 43 + */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x3c,0x00,0x30,0x00,0x0c,0x00, /* 44 , */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 45 - */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3c,0x00,0x3c,0x00,0x00,0x00, /* 46 . */
|
||||
0x00,0xc0,0x00,0x30,0x00,0x0c,0x00,0x03,0xc0,0x00,0x30,0x00,0x0c,0x00,0x00,0x00, /* 47 / */
|
||||
0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 48 0 */
|
||||
0x00,0x0f,0xf0,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x0f,0x00,0x00, /* 49 1 */
|
||||
0xf0,0x0f,0x3c,0x3c,0x00,0x3c,0x00,0x0f,0xc0,0x03,0xf0,0x00,0xfc,0x3f,0x00,0x00, /* 50 2 */
|
||||
0xf0,0x0f,0x3c,0x3c,0x00,0x3c,0xf0,0x0f,0x00,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 51 3 */
|
||||
0x00,0x3f,0xc0,0x3f,0xf0,0x3c,0x3c,0x3c,0x3c,0x3c,0xfc,0xff,0x00,0x3c,0x00,0x00, /* 52 4 */
|
||||
0xfc,0x3f,0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x00,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 53 5 */
|
||||
0xf0,0x0f,0x3c,0x3c,0x3c,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 54 6 */
|
||||
0xfc,0x3f,0x3c,0x3c,0x00,0x3c,0x00,0x0f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 55 7 */
|
||||
0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 56 8 */
|
||||
0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0xf0,0x3f,0x00,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 57 9 */
|
||||
0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x00,0x00,0x00, /* 58 : */
|
||||
0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x00,0xc0,0x03,0xc0,0x03,0x00,0x03,0xc0,0x00, /* 59 ; */
|
||||
0x00,0x0c,0x00,0x03,0xc0,0x00,0x30,0x00,0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x00, /* 60 < */
|
||||
0x00,0x00,0x00,0x00,0xfc,0xff,0x00,0x00,0xfc,0xff,0x00,0x00,0x00,0x00,0x00,0x00, /* 61 = */
|
||||
0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x30,0x00,0x0c,0x00,0x03,0xc0,0x00,0x00,0x00, /* 62 > */
|
||||
0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0x00,0x0f,0xc0,0x03,0x00,0x00,0xc0,0x03,0x00,0x00, /* 63 ? */
|
||||
0xf0,0x3f,0x0c,0xcc,0xcc,0xcf,0xcc,0xcc,0xcc,0xff,0x0c,0x00,0xf0,0x3f,0x00,0x00, /* 64 @ */
|
||||
0xc0,0x0f,0xf0,0x3c,0x3c,0xf0,0x3c,0xf0,0xfc,0xff,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 65 A */
|
||||
0xfc,0x3f,0x3c,0xf0,0x3c,0xf0,0xfc,0x3f,0x3c,0xf0,0x3c,0xf0,0xfc,0x3f,0x00,0x00, /* 66 B */
|
||||
0xf0,0x3f,0x3c,0xf0,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 67 C */
|
||||
0xfc,0x0f,0x3c,0x3c,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0x3c,0xfc,0x0f,0x00,0x00, /* 68 D */
|
||||
0xfc,0x3f,0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x3c,0x00,0x3c,0x00,0xfc,0x3f,0x00,0x00, /* 69 E */
|
||||
0xfc,0x3f,0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x00,0x00, /* 70 F */
|
||||
0xf0,0x3f,0x3c,0xf0,0x3c,0x00,0x3c,0xfc,0x3c,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 71 G */
|
||||
0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xfc,0xff,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 72 H */
|
||||
0xf0,0x0f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xf0,0x0f,0x00,0x00, /* 73 I */
|
||||
0x00,0xff,0x00,0xf0,0x00,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 74 J */
|
||||
0x3c,0xf0,0x3c,0x3c,0x3c,0x0f,0xfc,0x03,0x3c,0x0f,0x3c,0x3c,0x3c,0xf0,0x00,0x00, /* 75 K */
|
||||
0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0xfc,0xff,0x00,0x00, /* 76 L */
|
||||
0x3c,0xf0,0xfc,0xfc,0xfc,0xff,0x3c,0xf3,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 77 M */
|
||||
0x3c,0xf0,0xfc,0xf0,0xfc,0xf3,0x3c,0xff,0x3c,0xfc,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 78 N */
|
||||
0xf0,0x3f,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 79 O */
|
||||
0xfc,0x3f,0x3c,0xf0,0x3c,0xf0,0xfc,0x3f,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x00,0x00, /* 80 P */
|
||||
0xf0,0x3f,0x3c,0xf0,0x3c,0xf0,0x3c,0xf3,0x3c,0xff,0x3c,0xfc,0xf0,0x3f,0x00,0x00, /* 81 Q */
|
||||
0xfc,0x3f,0x3c,0xf0,0x3c,0xf0,0xfc,0x3f,0x3c,0x0f,0x3c,0x3c,0x3c,0xf0,0x00,0x00, /* 82 R */
|
||||
0xf0,0x3f,0x3c,0xf0,0x3c,0x00,0xf0,0x3f,0x00,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 83 S */
|
||||
0xfc,0x3f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 84 T */
|
||||
0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xf0,0x3f,0x00,0x00, /* 85 U */
|
||||
0x3c,0xf0,0x3c,0xf0,0x3c,0xf0,0xf0,0x3c,0xf0,0x3c,0xc0,0x0f,0x00,0x03,0x00,0x00, /* 86 V */
|
||||
0x3c,0xf0,0x3c,0xf3,0x3c,0xf3,0x3c,0xf3,0xfc,0xff,0xf0,0x3c,0x30,0x30,0x00,0x00, /* 87 W */
|
||||
0x3c,0xf0,0x3c,0xf0,0xf0,0x3c,0xc0,0x0f,0xf0,0x3c,0x3c,0xf0,0x3c,0xf0,0x00,0x00, /* 88 X */
|
||||
0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 89 Y */
|
||||
0xfc,0xff,0x00,0xf0,0x00,0x3c,0x00,0x0f,0xc0,0x03,0xf0,0x00,0xfc,0xff,0x00,0x00, /* 90 Z */
|
||||
0xc0,0x0f,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x0f,0x00,0x00, /* 91 [ */
|
||||
0x0c,0x00,0x30,0x00,0xc0,0x00,0x00,0x03,0x00,0x0c,0x00,0x30,0x00,0xc0,0x00,0x00, /* 92 \ */
|
||||
0xc0,0x0f,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0x00,0x0c,0xc0,0x0f,0x00,0x00, /* 93 ] */
|
||||
0x00,0x03,0xc0,0x0f,0xf0,0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 94 ^ */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfc,0xff,0x00,0x00, /* 95 _ */
|
||||
0xc0,0x03,0xc0,0x03,0x00,0x03,0x00,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 96 ` */
|
||||
0x00,0x00,0x00,0x00,0xf0,0x3f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0xff,0x00,0x00, /* 97 a */
|
||||
0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xfc,0x0f,0x00,0x00, /* 98 b */
|
||||
0x00,0x00,0x00,0x00,0xf0,0x0f,0x3c,0x3c,0x3c,0x00,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 99 c */
|
||||
0x00,0x3c,0x00,0x3c,0xf0,0x3f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0x3f,0x00,0x00, /* 100 d */
|
||||
0x00,0x00,0x00,0x00,0xf0,0x0f,0x3c,0x3c,0xfc,0x3f,0x3c,0x00,0xf0,0x0f,0x00,0x00, /* 101 e */
|
||||
0xc0,0x0f,0xf0,0x30,0xf0,0x00,0xfc,0x0f,0xf0,0x00,0xf0,0x00,0xf0,0x00,0x00,0x00, /* 102 f */
|
||||
0x00,0x00,0x00,0x00,0xf0,0x3f,0x3c,0x3c,0x3c,0x3c,0xc0,0x3f,0x3c,0x3c,0xf0,0x0f, /* 103 g */
|
||||
0x3c,0x00,0x3c,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x00,0x00, /* 104 h */
|
||||
0xc0,0x03,0x00,0x00,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 105 i */
|
||||
0x00,0x3c,0x00,0x00,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x3c,0x3c,0xf0,0x0f, /* 106 j */
|
||||
0x3c,0x00,0x3c,0x00,0x3c,0x3c,0x3c,0x0f,0xfc,0x00,0x3c,0x0f,0x3c,0x3c,0x00,0x00, /* 107 k */
|
||||
0xf0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xc0,0x03,0xf0,0x0f,0x00,0x00, /* 108 l */
|
||||
0x00,0x00,0x00,0x00,0xfc,0x3c,0x3c,0xf3,0x3c,0xf3,0x3c,0xf3,0x3c,0xf3,0x00,0x00, /* 109 m */
|
||||
0x00,0x00,0x00,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x00,0x00, /* 110 n */
|
||||
0x00,0x00,0x00,0x00,0xf0,0x0f,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0x00,0x00, /* 111 o */
|
||||
0x00,0x00,0x00,0x00,0xfc,0x0f,0x3c,0x3c,0x3c,0x3c,0xfc,0x0f,0x3c,0x00,0x3c,0x00, /* 112 p */
|
||||
0x00,0x00,0x00,0x00,0xf0,0x3f,0x3c,0x3c,0x3c,0x3c,0xc0,0x3f,0x00,0x3c,0x00,0x3c, /* 113 q */
|
||||
0x00,0x00,0x00,0x00,0x3c,0x3f,0xfc,0x00,0x3c,0x00,0x3c,0x00,0x3c,0x00,0x00,0x00, /* 114 r */
|
||||
0x00,0x00,0x00,0x00,0xf0,0x3f,0xfc,0x00,0xf0,0x0f,0x00,0x3f,0xfc,0x0f,0x00,0x00, /* 115 s */
|
||||
0xc0,0x03,0xc0,0x03,0xf0,0x3f,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x3f,0x00,0x00, /* 116 t */
|
||||
0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0x3c,0xf0,0xff,0x00,0x00, /* 117 u */
|
||||
0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0x30,0x0c,0xf0,0x0f,0xc0,0x03,0x00,0x00, /* 118 v */
|
||||
0x00,0x00,0x00,0x00,0x3c,0xf0,0x3c,0xf3,0x30,0x33,0xf0,0x3f,0xc0,0x0c,0x00,0x00, /* 119 w */
|
||||
0x00,0x00,0x00,0x00,0x3c,0x3c,0xf0,0x0f,0xc0,0x03,0xf0,0x0f,0x3c,0x3c,0x00,0x00, /* 120 x */
|
||||
0x00,0x00,0x00,0x00,0x3c,0x3c,0x3c,0x3c,0xf0,0x0f,0xc0,0x03,0xf0,0x00,0x3c,0x00, /* 121 y */
|
||||
0x00,0x00,0x00,0x00,0xfc,0x3f,0x00,0x0f,0xc0,0x03,0xf0,0x00,0xfc,0x3f,0x00,0x00, /* 122 z */
|
||||
0x00,0x0f,0xc0,0x03,0xc0,0x03,0xf0,0x00,0xc0,0x03,0xc0,0x03,0x00,0x0f,0x00,0x00, /* 123 { */
|
||||
0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00,0xc0,0x03,0xc0,0x03,0xc0,0x03,0x00,0x00, /* 124 | */
|
||||
0xc0,0x03,0x00,0x0f,0x00,0x0f,0x00,0x3c,0x00,0x0f,0x00,0x0f,0xc0,0x03,0x00,0x00, /* 125 } */
|
||||
0xf0,0x30,0xf0,0x0f,0x0c,0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 126 ~ */
|
||||
0x00,0x03,0x00,0x03,0xc0,0x0c,0xc0,0x0c,0x30,0x30,0x30,0x30,0xf0,0x3f,0x00,0x00 /* 127 △ */
|
||||
};
|
||||
|
||||
11
WWTextP.h
11
WWTextP.h
@ -21,17 +21,6 @@ typedef struct _WWText {
|
||||
int base; /* 使用するキャラクタのベース */
|
||||
|
||||
WWPalette palette;
|
||||
|
||||
/*
|
||||
* テキストフォントは
|
||||
* f = WWDisplay_GetForegroundColor(ww_display);
|
||||
* b = WWDisplay_GetBackgroundColor(ww_display);
|
||||
* で描画する必要があるため,描画のたびにビットマップをコピーする必要がある.
|
||||
* で,カラー化の際に,そのように修正した.
|
||||
* よって,テキストの初期化時に WWCharacter の配列を作成する必要は
|
||||
* 無くなったので,WWCharacter の配列はいずれ削除すること.
|
||||
* (WWText_PutCharacter() 参照)
|
||||
*/
|
||||
WWCharacter font[128]; /* フォント */
|
||||
|
||||
} _WWText;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWTimerP.h"
|
||||
#include "WonX.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
@ -81,7 +81,7 @@ WWTimer WWTimer_Create(int auto_preset, int preset)
|
||||
|
||||
ww_timer = (WWTimer)malloc(sizeof(_WWTimer));
|
||||
if (ww_timer == NULL)
|
||||
WonX_Error("WWTimer_Create", "Cannot allocate memory.");
|
||||
Error("WWTimer_Create", "Cannot allocate memory.");
|
||||
|
||||
WWTimer_OFF(ww_timer);
|
||||
WWTimer_SetAutoPreset(ww_timer, auto_preset);
|
||||
@ -98,9 +98,7 @@ WWTimer WWTimer_Create(int auto_preset, int preset)
|
||||
WWTimer WWTimer_Destroy(WWTimer ww_timer)
|
||||
{
|
||||
if (ww_timer == NULL)
|
||||
WonX_Error("WWTimer_Destroy", "Object is not created.");
|
||||
|
||||
WWTimer_OFF(ww_timer);
|
||||
Error("WWTimer_Destroy", "Object is not created.");
|
||||
|
||||
free(ww_timer);
|
||||
|
||||
|
||||
14
WWTimer.h
14
WWTimer.h
@ -5,21 +5,17 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sys/timer.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWTimer * WWTimer;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wonx/timer.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
126
WonX.c
126
WonX.c
@ -1,126 +0,0 @@
|
||||
#include "WonXP.h"
|
||||
#include "etc.h"
|
||||
|
||||
#include "wonx/disp.h"
|
||||
#include "wonx/system.h"
|
||||
#include "wonx/comm.h"
|
||||
|
||||
static WonX wonx = NULL;
|
||||
|
||||
int WonX_IsCreated(void)
|
||||
{
|
||||
return (wonx != NULL);
|
||||
}
|
||||
|
||||
void WonX_Create(void)
|
||||
{
|
||||
if (WonX_IsCreated())
|
||||
WonX_Error("WonX_Create", "WonX has been already created.");
|
||||
|
||||
wonx = (WonX)malloc(sizeof(_WonX));
|
||||
if (wonx == NULL) WonX_Error("WonX_Create", "Cannot allocate memory.");
|
||||
|
||||
/*
|
||||
* WonX のタイマからはディスプレイのリフレッシュなどの関数を呼び出すため,
|
||||
* WonXSystem_Create() でタイマをスタートさせる前に WonXDisplay_Create() で
|
||||
* WonXDisplay オブジェクトを作成しておく必要がある.このため
|
||||
* WonXDisplay_Create() を WonXSystem_Create() の後に持っていってはいけない.
|
||||
*/
|
||||
wonx->wonx_display =
|
||||
WonXDisplay_Create(LCD_PIXEL_WIDTH * 2, LCD_PIXEL_HEIGHT * 2,
|
||||
LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT,
|
||||
SCREEN_CHAR_WIDTH, SCREEN_CHAR_HEIGHT);
|
||||
|
||||
/*
|
||||
* WonXDisplay と同様のことが WonXSerialPort でも将来的に起きる可能性が
|
||||
* あるかもしれないので, WonXSerialPort_Create() もいちおう
|
||||
* WonXSystem_Create() の前に置いておく.
|
||||
*/
|
||||
wonx->wonx_serial_port = WonXSerialPort_Create();
|
||||
|
||||
/*
|
||||
* WonXSystem_Create() ではタイマを作成するが,タイマからはいろいろな
|
||||
* オブジェクトが呼ばれる可能性があるため,タイマの作成は一番最後に行う
|
||||
* べきである.このため,WonXSystem_Create() は一番最後に行う.
|
||||
* (他のオブジェクトの作成中等にタイマがかかった場合,おかしなことに
|
||||
* なってしまう)
|
||||
*/
|
||||
wonx->wonx_system = WonXSystem_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;
|
||||
}
|
||||
|
||||
WonXDisplay WonX_GetWonXDisplay(void)
|
||||
{
|
||||
return (wonx->wonx_display);
|
||||
}
|
||||
|
||||
WonXSystem WonX_GetWonXSystem(void)
|
||||
{
|
||||
return (wonx->wonx_system);
|
||||
}
|
||||
|
||||
WonXSerialPort WonX_GetWonXSerialPort(void)
|
||||
{
|
||||
return (wonx->wonx_serial_port);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* エラー処理 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WonX_Error(char * funcname, char * message)
|
||||
{
|
||||
fprintf(stderr, "error : %s(): %s\n", funcname, message);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int WonX_Warning(char * funcname, char * message)
|
||||
{
|
||||
fprintf(stderr, "warning : %s(): %s\n", funcname, message);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
26
WonX.h
26
WonX.h
@ -1,26 +0,0 @@
|
||||
#ifndef _wonx_h_INCLUDED_
|
||||
#define _wonx_h_INCLUDED_
|
||||
|
||||
#include "WonXDisplay.h"
|
||||
#include "WonXSystem.h"
|
||||
#include "WonXSerialPort.h"
|
||||
|
||||
int WonX_IsCreated(void);
|
||||
void WonX_Create(void);
|
||||
void WonX_Destroy(void);
|
||||
WonXDisplay WonX_GetWonXDisplay(void);
|
||||
WonXSystem WonX_GetWonXSystem(void);
|
||||
WonXSerialPort WonX_GetWonXSerialPort(void);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ¥¨¥é¡¼½èÍý */
|
||||
/*===========================================================================*/
|
||||
|
||||
int WonX_Error(char * funcname, char * message);
|
||||
int WonX_Warning(char * funcname, char * message);
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
@ -1,44 +0,0 @@
|
||||
#ifndef _WonXDisplay_h_INCLUDED_
|
||||
#define _WonXDisplay_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WonXDisplay * WonXDisplay;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "XDisplay.h"
|
||||
#include "WWDisplay.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
XDisplay WonXDisplay_GetXDisplay(WonXDisplay wonx_display);
|
||||
WWDisplay WonXDisplay_GetWWDisplay(WonXDisplay wonx_display);
|
||||
WonXDisplay WonXDisplay_Create(int x_width, int x_height,
|
||||
int ww_lcd_panel_width, int ww_lcd_panel_height,
|
||||
int ww_screen_width, int ww_screen_height);
|
||||
WonXDisplay WonXDisplay_Destroy(WonXDisplay wonx_display);
|
||||
int WonXDisplay_PrintData(WonXDisplay wonx_display);
|
||||
int WonXDisplay_DrawLCDWindow(WonXDisplay wonx_display);
|
||||
int WonXDisplay_Sync(WonXDisplay wonx_display);
|
||||
int WonXDisplay_Flush(WonXDisplay wonx_display);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
@ -1,78 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WonXSerialPortP.h"
|
||||
#include "WonX.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
WWSerialPort WonXSerialPort_GetWWSerialPort(WonXSerialPort wonx_sp)
|
||||
{ return (wonx_sp->ww_serial_port); }
|
||||
WWSerialPort WonXSerialPort_SetWWSerialPort(WonXSerialPort wonx_sp,
|
||||
WWSerialPort ww_sp)
|
||||
{ return (wonx_sp->ww_serial_port = ww_sp); }
|
||||
|
||||
UNIXSerialPort WonXSerialPort_GetUNIXSerialPort(WonXSerialPort wonx_sp)
|
||||
{ return (wonx_sp->unix_serial_port); }
|
||||
UNIXSerialPort WonXSerialPort_SetUNIXSerialPort(WonXSerialPort wonx_sp,
|
||||
UNIXSerialPort unix_sp)
|
||||
{ return (wonx_sp->unix_serial_port = unix_sp); }
|
||||
|
||||
WonXSerialPort WonXSerialPort_Create()
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
|
||||
wonx_serial_port = (WonXSerialPort)malloc(sizeof(_WonXSerialPort));
|
||||
if (wonx_serial_port == NULL)
|
||||
WonX_Error("WonXSerialPort_Create", "Cannot allocate memory.");
|
||||
|
||||
ww_serial_port = WWSerialPort_Create();
|
||||
if (ww_serial_port == NULL)
|
||||
WonX_Error("WonXSerialPort_Create",
|
||||
"Cannot create WonderWitch serial port.");
|
||||
WonXSerialPort_SetWWSerialPort(wonx_serial_port, ww_serial_port);
|
||||
|
||||
unix_serial_port = UNIXSerialPort_Create();
|
||||
if (unix_serial_port == NULL)
|
||||
WonX_Error("WonXSerialPort_Create",
|
||||
"Cannot create UNIX serial port.");
|
||||
WonXSerialPort_SetUNIXSerialPort(wonx_serial_port, unix_serial_port);
|
||||
|
||||
return (wonx_serial_port);
|
||||
}
|
||||
|
||||
WonXSerialPort WonXSerialPort_Destroy(WonXSerialPort wonx_serial_port)
|
||||
{
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
|
||||
if (wonx_serial_port == NULL)
|
||||
WonX_Error("WonXSerialPort_Destroy", "Object is not created.");
|
||||
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
if (ww_serial_port)
|
||||
WonXSerialPort_SetWWSerialPort(wonx_serial_port,
|
||||
WWSerialPort_Destroy(ww_serial_port));
|
||||
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
if (unix_serial_port)
|
||||
WonXSerialPort_SetUNIXSerialPort(wonx_serial_port,
|
||||
UNIXSerialPort_Destroy(unix_serial_port));
|
||||
|
||||
free(wonx_serial_port);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
@ -1,44 +0,0 @@
|
||||
#ifndef _WonXSerialPort_h_INCLUDED_
|
||||
#define _WonXSerialPort_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WonXSerialPort * WonXSerialPort;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWSerialPort.h"
|
||||
#include "UNIXSerialPort.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
WWSerialPort WonXSerialPort_GetWWSerialPort(WonXSerialPort wonx_sp);
|
||||
WWSerialPort WonXSerialPort_SetWWSerialPort(WonXSerialPort wonx_sp,
|
||||
WWSerialPort ww_sp);
|
||||
|
||||
UNIXSerialPort WonXSerialPort_GetUNIXSerialPort(WonXSerialPort wonx_sp);
|
||||
UNIXSerialPort WonXSerialPort_SetUNIXSerialPort(WonXSerialPort wonx_sp,
|
||||
UNIXSerialPort unix_sp);
|
||||
|
||||
WonXSerialPort WonXSerialPort_Create();
|
||||
WonXSerialPort WonXSerialPort_Destroy(WonXSerialPort wonx_serial_port);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
221
WonXSystem.c
221
WonXSystem.c
@ -1,221 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "wonx_configure.h"
|
||||
|
||||
#include "WonXSystemP.h"
|
||||
#include "WonX.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
WWInterrupt WonXSystem_GetWWInterrupt(WonXSystem wonx_system)
|
||||
{ return (wonx_system->ww_interrupt); }
|
||||
WWInterrupt WonXSystem_SetWWInterrupt(WonXSystem wonx_system,
|
||||
WWInterrupt ww_interrupt)
|
||||
{ return (wonx_system->ww_interrupt = ww_interrupt); }
|
||||
|
||||
WWTimer WonXSystem_GetWWTimer(WonXSystem wonx_system, int type)
|
||||
{ return (wonx_system->ww_timer[type]); }
|
||||
WWTimer WonXSystem_SetWWTimer(WonXSystem wonx_system, int type, WWTimer t)
|
||||
{ return (wonx_system->ww_timer[type] = t); }
|
||||
|
||||
WWTimer WonXSystem_GetWWVBlankTimer(WonXSystem wonx_system)
|
||||
{ return (WonXSystem_GetWWTimer(wonx_system, 0)); }
|
||||
WWTimer WonXSystem_SetWWVBlankTimer(WonXSystem wonx_system, WWTimer t)
|
||||
{ return (WonXSystem_SetWWTimer(wonx_system, 0, t)); }
|
||||
|
||||
WWTimer WonXSystem_GetWWVBlankCountUpTimer(WonXSystem wonx_system)
|
||||
{ return (WonXSystem_GetWWTimer(wonx_system, 1)); }
|
||||
WWTimer WonXSystem_SetWWVBlankCountUpTimer(WonXSystem wonx_system, WWTimer t)
|
||||
{ return (WonXSystem_SetWWTimer(wonx_system, 1, t)); }
|
||||
|
||||
WWTimer WonXSystem_GetWWHBlankCountUpTimer(WonXSystem wonx_system)
|
||||
{ return (WonXSystem_GetWWTimer(wonx_system, 2)); }
|
||||
WWTimer WonXSystem_SetWWHBlankCountUpTimer(WonXSystem wonx_system, WWTimer t)
|
||||
{ return (WonXSystem_SetWWTimer(wonx_system, 2, t)); }
|
||||
|
||||
UNIXTimer WonXSystem_GetUNIXTimer(WonXSystem wonx_system)
|
||||
{ return (wonx_system->unix_timer); }
|
||||
UNIXTimer WonXSystem_SetUNIXTimer(WonXSystem wonx_system,
|
||||
UNIXTimer unix_timer)
|
||||
{ return (wonx_system->unix_timer = unix_timer); }
|
||||
|
||||
static int WonXTimer_Callback(WonXSystem wonx_system)
|
||||
{
|
||||
WWTimer ww_timer;
|
||||
WWInterrupt ww_interrupt;
|
||||
WonXDisplay wonx_display;
|
||||
XDisplay x_display;
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
|
||||
unsigned int old_key;
|
||||
unsigned int new_key;
|
||||
|
||||
ww_interrupt = WonXSystem_GetWWInterrupt(wonx_system);
|
||||
|
||||
wonx_display = WonX_GetWonXDisplay();
|
||||
x_display = WonXDisplay_GetXDisplay(wonx_display);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
ww_timer = WonXSystem_GetWWVBlankTimer(wonx_system);
|
||||
if (WWTimer_IsON(ww_timer)) {
|
||||
if (WWTimer_Count(ww_timer))
|
||||
WWInterrupt_ExecuteVBlankCallback(ww_interrupt);
|
||||
}
|
||||
|
||||
ww_timer = WonXSystem_GetWWVBlankCountUpTimer(wonx_system);
|
||||
if (WWTimer_IsON(ww_timer)) {
|
||||
if (WWTimer_Count(ww_timer))
|
||||
WWInterrupt_ExecuteTimerCountUpCallback(ww_interrupt);
|
||||
}
|
||||
|
||||
ww_timer = WonXSystem_GetWWHBlankCountUpTimer(wonx_system);
|
||||
if (WWTimer_IsON(ww_timer)) {
|
||||
if (WWTimer_Count(ww_timer))
|
||||
WWInterrupt_ExecuteHBlankCountUpCallback(ww_interrupt);
|
||||
}
|
||||
|
||||
/* キー入力割り込み */
|
||||
/*
|
||||
* XDisplay_Flush() が他のところから呼ばれた場合に割り込みをとり
|
||||
* こぼしてしまうので,XDisplay クラスのほうで割り込みの処理をするか,
|
||||
* フラグを立てるように改良する必要が有るかも.
|
||||
* (別の場所で頻繁に XDisplay_Flush() が呼ばれていると,キー割り込みが
|
||||
* 発生しなくなってしまう)
|
||||
* とりあえずは簡易的にこのような実装にしておいて問題無いだろう.
|
||||
*/
|
||||
old_key = XDisplay_GetKeyPress(x_display);
|
||||
XDisplay_Flush(x_display);
|
||||
new_key = XDisplay_GetKeyPress(x_display);
|
||||
/* 新しいキーが押された場合 */
|
||||
/*
|
||||
* WonderWitch で実験したところ,キーを離した場合には割り込みは
|
||||
* かからないようだったので,押されたときのみコールバック関数を呼び出す.
|
||||
*/
|
||||
if (new_key & (~old_key)) {
|
||||
WWInterrupt_ExecuteKeyCallback(ww_interrupt);
|
||||
}
|
||||
|
||||
/* シリアル受信割り込み */
|
||||
/*
|
||||
* 上と同じ理由で割り込みをとりこぼす可能性が有るので,UNIXSerialPort の
|
||||
* ほうで割り込みの処理をするか,フラグを立てるように改良する必要が有るかも.
|
||||
* とりあえずは簡易的にこのような実装にしておいて問題無いだろう.
|
||||
*/
|
||||
if (WWSerialPort_IsOpened(ww_serial_port) &&
|
||||
UNIXSerialPort_IsOpened(unix_serial_port)) {
|
||||
if (UNIXSerialPort_IsDataExisting(unix_serial_port, 0))
|
||||
WWInterrupt_ExecuteReceiveReadyCallback(ww_interrupt);
|
||||
}
|
||||
|
||||
WonXDisplay_PrintData(wonx_display);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
WonXSystem WonXSystem_Create()
|
||||
{
|
||||
WonXSystem wonx_system;
|
||||
WWInterrupt ww_interrupt;
|
||||
WWTimer ww_timer;
|
||||
UNIXTimer unix_timer;
|
||||
|
||||
wonx_system = (WonXSystem)malloc(sizeof(_WonXSystem));
|
||||
if (wonx_system == NULL)
|
||||
WonX_Error("WonXSystem_Create", "Cannot allocate memory.");
|
||||
|
||||
ww_interrupt = WWInterrupt_Create();
|
||||
if (ww_interrupt == NULL)
|
||||
WonX_Error("WonXSystem_Create", "Cannot create WonderWitch interrupt.");
|
||||
WonXSystem_SetWWInterrupt(wonx_system, ww_interrupt);
|
||||
|
||||
ww_timer = WWTimer_Create(1, WONX_VBLANK_INTERVAL);
|
||||
if (ww_timer == NULL)
|
||||
WonX_Error("WonXSystem_Create", "Cannot create WonderWitch VBlank timer.");
|
||||
WonXSystem_SetWWVBlankTimer(wonx_system, ww_timer);
|
||||
|
||||
ww_timer = WWTimer_Create(0, WONX_VBLANK_INTERVAL);
|
||||
if (ww_timer == NULL)
|
||||
WonX_Error("WonXSystem_Create",
|
||||
"Cannot create WonderWitch VBlank count up timer.");
|
||||
WonXSystem_SetWWVBlankCountUpTimer(wonx_system, ww_timer);
|
||||
|
||||
ww_timer = WWTimer_Create(0, WONX_HBLANK_INTERVAL);
|
||||
if (ww_timer == NULL)
|
||||
WonX_Error("WonXSystem_Create",
|
||||
"Cannot create WonderWitch HBlank count up timer.");
|
||||
WonXSystem_SetWWHBlankCountUpTimer(wonx_system, ww_timer);
|
||||
|
||||
WWTimer_Reset(WonXSystem_GetWWVBlankTimer( wonx_system));
|
||||
WWTimer_Reset(WonXSystem_GetWWVBlankCountUpTimer(wonx_system));
|
||||
WWTimer_Reset(WonXSystem_GetWWHBlankCountUpTimer(wonx_system));
|
||||
|
||||
WWTimer_ON( WonXSystem_GetWWVBlankTimer( wonx_system));
|
||||
WWTimer_OFF(WonXSystem_GetWWVBlankCountUpTimer(wonx_system));
|
||||
WWTimer_OFF(WonXSystem_GetWWHBlankCountUpTimer(wonx_system));
|
||||
|
||||
unix_timer = UNIXTimer_Create(1, WONX_TIMER_INTERVAL, wonx_system,
|
||||
(UNIXTimerCallBack)WonXTimer_Callback);
|
||||
if (unix_timer == NULL)
|
||||
WonX_Error("WonXSystem_Create", "Cannot create UNIX timer.");
|
||||
WonXSystem_SetUNIXTimer(wonx_system, unix_timer);
|
||||
|
||||
UNIXTimer_ON(unix_timer);
|
||||
|
||||
return (wonx_system);
|
||||
}
|
||||
|
||||
WonXSystem WonXSystem_Destroy(WonXSystem wonx_system)
|
||||
{
|
||||
WWInterrupt wi;
|
||||
WWTimer wt;
|
||||
UNIXTimer unix_timer;
|
||||
|
||||
if (wonx_system == NULL)
|
||||
WonX_Error("WonXSystem_Destroy", "Object is not created.");
|
||||
|
||||
unix_timer = WonXSystem_GetUNIXTimer(wonx_system);
|
||||
|
||||
if (unix_timer)
|
||||
UNIXTimer_OFF(unix_timer);
|
||||
|
||||
wt = WonXSystem_GetWWVBlankTimer(wonx_system);
|
||||
if (wt) WWTimer_OFF(wt);
|
||||
wt = WonXSystem_GetWWVBlankCountUpTimer(wonx_system);
|
||||
if (wt) WWTimer_OFF(wt);
|
||||
wt = WonXSystem_GetWWHBlankCountUpTimer(wonx_system);
|
||||
if (wt) WWTimer_OFF(wt);
|
||||
|
||||
if (unix_timer)
|
||||
WonXSystem_SetUNIXTimer(wonx_system, UNIXTimer_Destroy(unix_timer));
|
||||
|
||||
wt = WonXSystem_GetWWVBlankTimer(wonx_system);
|
||||
if (wt) WonXSystem_SetWWVBlankTimer(wonx_system, WWTimer_Destroy(wt));
|
||||
wt = WonXSystem_GetWWVBlankCountUpTimer(wonx_system);
|
||||
if (wt) WonXSystem_SetWWVBlankCountUpTimer(wonx_system, WWTimer_Destroy(wt));
|
||||
wt = WonXSystem_GetWWHBlankCountUpTimer(wonx_system);
|
||||
if (wt) WonXSystem_SetWWHBlankCountUpTimer(wonx_system, WWTimer_Destroy(wt));
|
||||
|
||||
wi = WonXSystem_GetWWInterrupt(wonx_system);
|
||||
if (wi) WonXSystem_SetWWInterrupt(wonx_system, WWInterrupt_Destroy(wi));
|
||||
|
||||
free(wonx_system);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
60
Wonx.c
Normal file
60
Wonx.c
Normal file
@ -0,0 +1,60 @@
|
||||
#include "WonxP.h"
|
||||
#include "etc.h"
|
||||
|
||||
#include "sys/disp.h"
|
||||
#include "sys/text.h"
|
||||
#include "sys/system.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ディスプレイの確保 */
|
||||
/*****************************************************************************/
|
||||
|
||||
static Wonx wonx = NULL;
|
||||
|
||||
int Wonx_IsCreated(void)
|
||||
{
|
||||
return (wonx != NULL);
|
||||
}
|
||||
|
||||
void Wonx_Create(void)
|
||||
{
|
||||
WWScreen screen;
|
||||
WWPalette palette;
|
||||
|
||||
wonx = (Wonx)malloc(sizeof(_Wonx));
|
||||
if (wonx == NULL) Error("Wonx_Create", "Cannot allocate memory.");
|
||||
|
||||
wonx->wonx_display =
|
||||
WonxDisplay_Create(LCD_PIXEL_WIDTH * 2, LCD_PIXEL_HEIGHT * 2,
|
||||
LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT,
|
||||
SCREEN_CHAR_WIDTH, SCREEN_CHAR_HEIGHT);
|
||||
screen =
|
||||
WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx->wonx_display), SCREEN2);
|
||||
/* デフォルトのテキスト表示用パレットは0 */
|
||||
palette =
|
||||
WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx->wonx_display), 0);
|
||||
|
||||
wonx->wonx_text =
|
||||
WonxText_Create(screen, 0, 0, TEXT_SCREEN_WIDTH, TEXT_SCREEN_HEIGHT,
|
||||
palette);
|
||||
|
||||
wonx->wonx_system = WonxSystem_Create();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
WonxDisplay Wonx_GetWonxDisplay(void)
|
||||
{
|
||||
return (wonx->wonx_display);
|
||||
}
|
||||
|
||||
WonxText Wonx_GetWonxText(void)
|
||||
{
|
||||
return (wonx->wonx_text);
|
||||
}
|
||||
|
||||
WonxSystem Wonx_GetWonxSystem(void)
|
||||
{
|
||||
return (wonx->wonx_system);
|
||||
}
|
||||
|
||||
18
Wonx.h
Normal file
18
Wonx.h
Normal file
@ -0,0 +1,18 @@
|
||||
#ifndef _wonx_h_INCLUDED_
|
||||
#define _wonx_h_INCLUDED_
|
||||
|
||||
#include "WonxDisplay.h"
|
||||
#include "WonxText.h"
|
||||
#include "WonxSystem.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ¥Ç¥£¥¹¥×¥ì¥¤¤Î³ÎÊÝ */
|
||||
/*****************************************************************************/
|
||||
|
||||
int Wonx_IsCreated(void);
|
||||
void Wonx_Create(void);
|
||||
WonxDisplay Wonx_GetWonxDisplay(void);
|
||||
WonxText Wonx_GetWonxText(void);
|
||||
WonxSystem Wonx_GetWonxSystem(void);
|
||||
|
||||
#endif
|
||||
@ -2,99 +2,73 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WonXDisplayP.h"
|
||||
#include "WonX.h"
|
||||
#include "WonxDisplayP.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
XDisplay WonXDisplay_GetXDisplay(WonXDisplay wonx_display)
|
||||
XDisplay WonxDisplay_GetXDisplay(WonxDisplay wonx_display)
|
||||
{ return (wonx_display->x_display); }
|
||||
WWDisplay WonXDisplay_GetWWDisplay(WonXDisplay wonx_display)
|
||||
WWDisplay WonxDisplay_GetWWDisplay(WonxDisplay wonx_display)
|
||||
{ return (wonx_display->ww_display); }
|
||||
|
||||
static XDisplay WonXDisplay_SetXDisplay(WonXDisplay wonx_d, XDisplay xd)
|
||||
static XDisplay WonxDisplay_SetXDisplay(WonxDisplay wonx_d, XDisplay xd)
|
||||
{ return (wonx_d->x_display = xd); }
|
||||
static WWDisplay WonXDisplay_SetWWDisplay(WonXDisplay wonx_d, WWDisplay wd)
|
||||
static WWDisplay WonxDisplay_SetWWDisplay(WonxDisplay wonx_d, WWDisplay wd)
|
||||
{ return (wonx_d->ww_display = wd); }
|
||||
|
||||
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_screen_width, int ww_screen_height)
|
||||
{
|
||||
WonXDisplay wonx_display;
|
||||
WonxDisplay wonx_display;
|
||||
WWDisplay ww_display;
|
||||
XDisplay x_display;
|
||||
|
||||
wonx_display = (WonXDisplay)malloc(sizeof(_WonXDisplay));
|
||||
wonx_display = (WonxDisplay)malloc(sizeof(_WonxDisplay));
|
||||
if (wonx_display == NULL)
|
||||
WonX_Error("WonXDisplay_Create", "Cannot allocate memory.");
|
||||
Error("WonxDisplay_Create", "Cannot allocate memory.");
|
||||
|
||||
ww_display = WWDisplay_Create(ww_lcd_panel_width, ww_lcd_panel_height,
|
||||
ww_screen_width, ww_screen_height);
|
||||
if (ww_display == NULL)
|
||||
WonX_Error("WonXDisplay_Create", "Cannot create WonderWitch display.");
|
||||
WonXDisplay_SetWWDisplay(wonx_display, ww_display);
|
||||
Error("WonxDisplay_Create", "Cannot create WonderWitch display.");
|
||||
WonxDisplay_SetWWDisplay(wonx_display, ww_display);
|
||||
|
||||
x_display = XDisplay_Create(x_width, x_height);
|
||||
if (x_display == NULL)
|
||||
WonX_Error("WonXDisplay_Create", "Cannot create X display.");
|
||||
WonXDisplay_SetXDisplay(wonx_display, x_display);
|
||||
Error("WonxDisplay_Create", "Cannot create X display.");
|
||||
WonxDisplay_SetXDisplay(wonx_display, x_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_Sync(WonxDisplay wonx_display)
|
||||
{
|
||||
int i;
|
||||
XDisplay x_display;
|
||||
WWDisplay ww_display;
|
||||
|
||||
x_display = WonXDisplay_GetXDisplay(wonx_display);
|
||||
ww_display = WonXDisplay_GetWWDisplay(wonx_display);
|
||||
x_display = WonxDisplay_GetXDisplay(wonx_display);
|
||||
ww_display = WonxDisplay_GetWWDisplay(wonx_display);
|
||||
|
||||
if (XDisplay_GetColorMapPrint(x_display)) {
|
||||
WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout);
|
||||
fflush(stdout);
|
||||
XDisplay_SetColorMapPrint(x_display, 0);
|
||||
}
|
||||
|
||||
if (XDisplay_GetPalettePrint(x_display)) {
|
||||
for (i = 0; i < 16; i++) {
|
||||
WWPalette_PrintData(WWDisplay_GetPalette(ww_display, i),
|
||||
ww_display, stdout);
|
||||
fflush(stdout);
|
||||
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),
|
||||
ww_display, stdout);
|
||||
fflush(stdout);
|
||||
WWCharacter_PrintData(WWDisplay_GetCharacter(ww_display, i), stdout);
|
||||
}
|
||||
XDisplay_SetCharacterPrint(x_display, 0);
|
||||
}
|
||||
@ -102,48 +76,31 @@ int WonXDisplay_PrintData(WonXDisplay wonx_display)
|
||||
if (XDisplay_GetSpritePrint(x_display)) {
|
||||
for (i = 0; i < 128; i++) {
|
||||
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, i), stdout);
|
||||
fflush(stdout);
|
||||
}
|
||||
XDisplay_SetSpritePrint(x_display, 0);
|
||||
}
|
||||
|
||||
XDisplay_Sync(x_display);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int WonXDisplay_DrawLCDWindow(WonXDisplay wonx_display)
|
||||
int WonxDisplay_Flush(WonxDisplay wonx_display)
|
||||
{
|
||||
XDisplay x_display;
|
||||
WWDisplay ww_display;
|
||||
WWLCDPanel ww_lcd_panel;
|
||||
|
||||
x_display = WonXDisplay_GetXDisplay(wonx_display);
|
||||
ww_display = WonXDisplay_GetWWDisplay(wonx_display);
|
||||
x_display = WonxDisplay_GetXDisplay(wonx_display);
|
||||
ww_display = WonxDisplay_GetWWDisplay(wonx_display);
|
||||
|
||||
/* 表示レベルが1以上のときだけ描画する */
|
||||
if (XDisplay_GetLCDDrawLevel(x_display) > 0) {
|
||||
if (XDisplay_GetLCDDraw(x_display)) {
|
||||
WWDisplay_DrawLCDPanel(ww_display);
|
||||
ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
|
||||
XDisplay_DrawLCDWindow(x_display, ww_display, ww_lcd_panel);
|
||||
XDisplay_DrawLCDWindow(x_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);
|
||||
}
|
||||
@ -1,32 +1,26 @@
|
||||
#ifndef _WWSerialPortP_h_INCLUDED_
|
||||
#define _WWSerialPortP_h_INCLUDED_
|
||||
#ifndef _WonxDisplay_h_INCLUDED_
|
||||
#define _WonxDisplay_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWSerialPort.h"
|
||||
#include "XDisplay.h"
|
||||
#include "WWDisplay.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WWSerialPort {
|
||||
typedef struct _WonxDisplay * WonxDisplay;
|
||||
|
||||
int opened; /* ポートの状態(open/close) */
|
||||
int baudrate; /* ボーレート */
|
||||
|
||||
/*
|
||||
* タイムアウト時間
|
||||
* 本来は VBLANK 単位で指定するのだが,wonx では
|
||||
* WONX_SERIAL_PORT_TIMETICKS 単位で指定することにする.
|
||||
*/
|
||||
int send_timeout;
|
||||
int receive_timeout;
|
||||
|
||||
unsigned int cancel_key;
|
||||
|
||||
} _WWSerialPort;
|
||||
XDisplay WonxDisplay_GetXDisplay(WonxDisplay wonx_display);
|
||||
WWDisplay WonxDisplay_GetWWDisplay(WonxDisplay wonx_display);
|
||||
WonxDisplay WonxDisplay_Create(int x_width, int x_height,
|
||||
int ww_lcd_panel_width, int ww_lcd_panel_height,
|
||||
int ww_screen_width, int ww_screen_height);
|
||||
int WonxDisplay_Sync(WonxDisplay wonx_display);
|
||||
int WonxDisplay_Flush(WonxDisplay wonx_display);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
@ -1,20 +1,20 @@
|
||||
#ifndef _WonXDisplayP_h_INCLUDED_
|
||||
#define _WonXDisplayP_h_INCLUDED_
|
||||
#ifndef _WonxDisplayP_h_INCLUDED_
|
||||
#define _WonxDisplayP_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WonXDisplay.h"
|
||||
#include "WonxDisplay.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WonXDisplay {
|
||||
typedef struct _WonxDisplay {
|
||||
XDisplay x_display;
|
||||
WWDisplay ww_display;
|
||||
} _WonXDisplay;
|
||||
} _WonxDisplay;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
@ -1,20 +1,23 @@
|
||||
#ifndef _WonXSerialPortP_h_INCLUDED_
|
||||
#define _WonXSerialPortP_h_INCLUDED_
|
||||
#ifndef _WonxP_h_INCLUDED_
|
||||
#define _WonxP_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WonXSerialPort.h"
|
||||
#include "Wonx.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WonXSerialPort {
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
} _WonXSerialPort;
|
||||
typedef struct _Wonx {
|
||||
WonxDisplay wonx_display;
|
||||
WonxText wonx_text;
|
||||
WonxSystem wonx_system;
|
||||
} _Wonx;
|
||||
|
||||
typedef struct _Wonx * Wonx;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
172
WonxSystem.c
Normal file
172
WonxSystem.c
Normal file
@ -0,0 +1,172 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WonxSystemP.h"
|
||||
#include "configure.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
WWInterrupt WonxSystem_GetWWInterrupt(WonxSystem wonx_system)
|
||||
{ return (wonx_system->ww_interrupt); }
|
||||
WWInterrupt WonxSystem_SetWWInterrupt(WonxSystem wonx_system,
|
||||
WWInterrupt ww_interrupt)
|
||||
{ return (wonx_system->ww_interrupt = ww_interrupt); }
|
||||
|
||||
WWTimer WonxSystem_GetWWTimer(WonxSystem wonx_system, int type)
|
||||
{ return (wonx_system->ww_timer[type]); }
|
||||
WWTimer WonxSystem_SetWWTimer(WonxSystem wonx_system, int type, WWTimer t)
|
||||
{ return (wonx_system->ww_timer[type] = t); }
|
||||
|
||||
WWTimer WonxSystem_GetWWVBlankTimer(WonxSystem wonx_system)
|
||||
{ return (WonxSystem_GetWWTimer(wonx_system, 0)); }
|
||||
WWTimer WonxSystem_SetWWVBlankTimer(WonxSystem wonx_system, WWTimer t)
|
||||
{ return (WonxSystem_SetWWTimer(wonx_system, 0, t)); }
|
||||
|
||||
WWTimer WonxSystem_GetWWVBlankCountUpTimer(WonxSystem wonx_system)
|
||||
{ return (WonxSystem_GetWWTimer(wonx_system, 1)); }
|
||||
WWTimer WonxSystem_SetWWVBlankCountUpTimer(WonxSystem wonx_system, WWTimer t)
|
||||
{ return (WonxSystem_SetWWTimer(wonx_system, 1, t)); }
|
||||
|
||||
WWTimer WonxSystem_GetWWHBlankCountUpTimer(WonxSystem wonx_system)
|
||||
{ return (WonxSystem_GetWWTimer(wonx_system, 2)); }
|
||||
WWTimer WonxSystem_SetWWHBlankCountUpTimer(WonxSystem wonx_system, WWTimer t)
|
||||
{ return (WonxSystem_SetWWTimer(wonx_system, 2, t)); }
|
||||
|
||||
UNIXTimer WonxSystem_GetUNIXTimer(WonxSystem wonx_system)
|
||||
{ return (wonx_system->unix_timer); }
|
||||
UNIXTimer WonxSystem_SetUNIXTimer(WonxSystem wonx_system,
|
||||
UNIXTimer unix_timer)
|
||||
{ return (wonx_system->unix_timer = unix_timer); }
|
||||
|
||||
static int WonxTimer_Callback(WonxSystem wonx_system)
|
||||
{
|
||||
WWTimer ww_timer;
|
||||
WWInterrupt ww_interrupt;
|
||||
|
||||
ww_interrupt = WonxSystem_GetWWInterrupt(wonx_system);
|
||||
|
||||
ww_timer = WonxSystem_GetWWVBlankTimer(wonx_system);
|
||||
if (WWTimer_IsON(ww_timer)) {
|
||||
if (WWTimer_Count(ww_timer))
|
||||
WWInterrupt_ExecuteVBlankCallback(ww_interrupt);
|
||||
}
|
||||
|
||||
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(wonx_system);
|
||||
if (WWTimer_IsON(ww_timer)) {
|
||||
if (WWTimer_Count(ww_timer))
|
||||
WWInterrupt_ExecuteTimerCountUpCallback(ww_interrupt);
|
||||
}
|
||||
|
||||
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(wonx_system);
|
||||
if (WWTimer_IsON(ww_timer)) {
|
||||
if (WWTimer_Count(ww_timer))
|
||||
WWInterrupt_ExecuteHBlankCountUpCallback(ww_interrupt);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
WonxSystem WonxSystem_Create()
|
||||
{
|
||||
WonxSystem wonx_system;
|
||||
WWInterrupt ww_interrupt;
|
||||
WWTimer ww_timer;
|
||||
UNIXTimer unix_timer;
|
||||
|
||||
wonx_system = (WonxSystem)malloc(sizeof(_WonxSystem));
|
||||
if (wonx_system == NULL)
|
||||
Error("WonxSystem_Create", "Cannot allocate memory.");
|
||||
|
||||
ww_interrupt = WWInterrupt_Create();
|
||||
if (ww_interrupt == NULL)
|
||||
Error("WonxSystem_Create", "Cannot create WonderWitch interrupt.");
|
||||
WonxSystem_SetWWInterrupt(wonx_system, ww_interrupt);
|
||||
|
||||
/* VBlank は WONX_VBLANK_INTERVAL * 0.1 秒毎とする */
|
||||
ww_timer = WWTimer_Create(1, WONX_VBLANK_INTERVAL);
|
||||
if (ww_timer == NULL)
|
||||
Error("WonxSystem_Create", "Cannot create WonderWitch VBlank timer.");
|
||||
WonxSystem_SetWWVBlankTimer(wonx_system, ww_timer);
|
||||
|
||||
ww_timer = WWTimer_Create(0, WONX_VBLANK_INTERVAL);
|
||||
if (ww_timer == NULL)
|
||||
Error("WonxSystem_Create",
|
||||
"Cannot create WonderWitch VBlank count up timer.");
|
||||
WonxSystem_SetWWVBlankCountUpTimer(wonx_system, ww_timer);
|
||||
|
||||
ww_timer = WWTimer_Create(0, WONX_HBLANK_INTERVAL);
|
||||
if (ww_timer == NULL)
|
||||
Error("WonxSystem_Create",
|
||||
"Cannot create WonderWitch HBlank count up timer.");
|
||||
WonxSystem_SetWWHBlankCountUpTimer(wonx_system, ww_timer);
|
||||
|
||||
WWTimer_Reset(WonxSystem_GetWWVBlankTimer( wonx_system));
|
||||
WWTimer_Reset(WonxSystem_GetWWVBlankCountUpTimer(wonx_system));
|
||||
WWTimer_Reset(WonxSystem_GetWWHBlankCountUpTimer(wonx_system));
|
||||
|
||||
WWTimer_ON( WonxSystem_GetWWVBlankTimer( wonx_system));
|
||||
WWTimer_OFF(WonxSystem_GetWWVBlankCountUpTimer(wonx_system));
|
||||
WWTimer_OFF(WonxSystem_GetWWHBlankCountUpTimer(wonx_system));
|
||||
|
||||
/* タイマのインターバルは,0.1 秒単位とする */
|
||||
unix_timer = UNIXTimer_Create(1, WONX_TIMER_INTERVAL, wonx_system,
|
||||
(UNIXTimerCallBack)WonxTimer_Callback);
|
||||
if (unix_timer == NULL)
|
||||
Error("WonxSystem_Create", "Cannot create UNIX timer.");
|
||||
WonxSystem_SetUNIXTimer(wonx_system, unix_timer);
|
||||
|
||||
UNIXTimer_ON(unix_timer);
|
||||
|
||||
return (wonx_system);
|
||||
}
|
||||
|
||||
WonxSystem WonxSystem_Destroy(WonxSystem wonx_system)
|
||||
{
|
||||
WWInterrupt wi;
|
||||
WWTimer wt;
|
||||
UNIXTimer unix_timer;
|
||||
|
||||
if (wonx_system == NULL)
|
||||
Error("WonxSystem_Destroy", "Object is not created.");
|
||||
|
||||
unix_timer = WonxSystem_GetUNIXTimer(wonx_system);
|
||||
|
||||
if (unix_timer)
|
||||
UNIXTimer_OFF(unix_timer);
|
||||
|
||||
wt = WonxSystem_GetWWVBlankTimer(wonx_system);
|
||||
if (wt) WWTimer_OFF(wt);
|
||||
wt = WonxSystem_GetWWVBlankCountUpTimer(wonx_system);
|
||||
if (wt) WWTimer_OFF(wt);
|
||||
wt = WonxSystem_GetWWHBlankCountUpTimer(wonx_system);
|
||||
if (wt) WWTimer_OFF(wt);
|
||||
|
||||
if (unix_timer)
|
||||
WonxSystem_SetUNIXTimer(wonx_system, UNIXTimer_Destroy(unix_timer));
|
||||
|
||||
wt = WonxSystem_GetWWVBlankTimer(wonx_system);
|
||||
if (wt) WonxSystem_SetWWVBlankTimer(wonx_system, WWTimer_Destroy(wt));
|
||||
wt = WonxSystem_GetWWVBlankCountUpTimer(wonx_system);
|
||||
if (wt) WonxSystem_SetWWVBlankCountUpTimer(wonx_system, WWTimer_Destroy(wt));
|
||||
wt = WonxSystem_GetWWHBlankCountUpTimer(wonx_system);
|
||||
if (wt) WonxSystem_SetWWHBlankCountUpTimer(wonx_system, WWTimer_Destroy(wt));
|
||||
|
||||
wi = WonxSystem_GetWWInterrupt(wonx_system);
|
||||
if (wi) WonxSystem_SetWWInterrupt(wonx_system, WWInterrupt_Destroy(wi));
|
||||
|
||||
free(wonx_system);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
@ -1,50 +1,46 @@
|
||||
#ifndef _WonXSystem_h_INCLUDED_
|
||||
#define _WonXSystem_h_INCLUDED_
|
||||
#ifndef _WonxSystem_h_INCLUDED_
|
||||
#define _WonxSystem_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WonXSystem * WonXSystem;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WWInterrupt.h"
|
||||
#include "WWTimer.h"
|
||||
#include "UNIXTimer.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ¥¯¥é¥¹¤ÎÄêµÁ */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WonxSystem * WonxSystem;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
WWInterrupt WonXSystem_GetWWInterrupt(WonXSystem wonx_system);
|
||||
WWInterrupt WonXSystem_SetWWInterrupt(WonXSystem wonx_system,
|
||||
WWInterrupt WonxSystem_GetWWInterrupt(WonxSystem wonx_system);
|
||||
WWInterrupt WonxSystem_SetWWInterrupt(WonxSystem wonx_system,
|
||||
WWInterrupt ww_interrupt);
|
||||
|
||||
WWTimer WonXSystem_GetWWTimer(WonXSystem wonx_system, int type);
|
||||
WWTimer WonXSystem_SetWWTimer(WonXSystem wonx_system, int type, WWTimer t);
|
||||
WWTimer WonxSystem_GetWWTimer(WonxSystem wonx_system, int type);
|
||||
WWTimer WonxSystem_SetWWTimer(WonxSystem wonx_system, int type, WWTimer t);
|
||||
|
||||
WWTimer WonXSystem_GetWWVBlankTimer(WonXSystem wonx_system);
|
||||
WWTimer WonXSystem_SetWWVBlankTimer(WonXSystem wonx_system, WWTimer t);
|
||||
WWTimer WonxSystem_GetWWVBlankTimer(WonxSystem wonx_system);
|
||||
WWTimer WonxSystem_SetWWVBlankTimer(WonxSystem wonx_system, WWTimer t);
|
||||
|
||||
WWTimer WonXSystem_GetWWVBlankCountUpTimer(WonXSystem wonx_system);
|
||||
WWTimer WonXSystem_SetWWVBlankCountUpTimer(WonXSystem wonx_system, WWTimer t);
|
||||
WWTimer WonxSystem_GetWWVBlankCountUpTimer(WonxSystem wonx_system);
|
||||
WWTimer WonxSystem_SetWWVBlankCountUpTimer(WonxSystem wonx_system, WWTimer t);
|
||||
|
||||
WWTimer WonXSystem_GetWWHBlankCountUpTimer(WonXSystem wonx_system);
|
||||
WWTimer WonXSystem_SetWWHBlankCountUpTimer(WonXSystem wonx_system, WWTimer t);
|
||||
WWTimer WonxSystem_GetWWHBlankCountUpTimer(WonxSystem wonx_system);
|
||||
WWTimer WonxSystem_SetWWHBlankCountUpTimer(WonxSystem wonx_system, WWTimer t);
|
||||
|
||||
UNIXTimer WonXSystem_GetUNIXTimer(WonXSystem wonx_system);
|
||||
UNIXTimer WonXSystem_SetUNIXTimer(WonXSystem wonx_system,
|
||||
UNIXTimer WonxSystem_GetUNIXTimer(WonxSystem wonx_system);
|
||||
UNIXTimer WonxSystem_SetUNIXTimer(WonxSystem wonx_system,
|
||||
UNIXTimer unix_timer);
|
||||
|
||||
WonXSystem WonXSystem_Create();
|
||||
WonXSystem WonXSystem_Destroy(WonXSystem wonx_system);
|
||||
WonxSystem WonxSystem_Create();
|
||||
WonxSystem WonxSystem_Destroy(WonxSystem wonx_system);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
@ -1,17 +1,17 @@
|
||||
#ifndef _WonXSystemP_h_INCLUDED_
|
||||
#define _WonXSystemP_h_INCLUDED_
|
||||
#ifndef _WonxSystemP_h_INCLUDED_
|
||||
#define _WonxSystemP_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WonXSystem.h"
|
||||
#include "WonxSystem.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WonXSystem {
|
||||
typedef struct _WonxSystem {
|
||||
|
||||
WWInterrupt ww_interrupt;
|
||||
|
||||
@ -24,7 +24,7 @@ typedef struct _WonXSystem {
|
||||
|
||||
UNIXTimer unix_timer;
|
||||
|
||||
} _WonXSystem;
|
||||
} _WonxSystem;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
55
WonxText.c
Normal file
55
WonxText.c
Normal file
@ -0,0 +1,55 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WonxTextP.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
WWText WonxText_GetWWText(WonxText wonx_text)
|
||||
{ return (wonx_text->ww_text); }
|
||||
WWText WonxText_SetWWText(WonxText wonx_text, WWText ww_text)
|
||||
{ return (wonx_text->ww_text = ww_text); }
|
||||
|
||||
WonxText WonxText_Create(WWScreen screen, int x, int y, int width, int height,
|
||||
WWPalette palette)
|
||||
{
|
||||
WonxText wonx_text;
|
||||
WWText ww_text;
|
||||
|
||||
wonx_text = (WonxText)malloc(sizeof(_WonxText));
|
||||
if (wonx_text == NULL)
|
||||
Error("WonxText_Create", "Cannot allocate memory.");
|
||||
|
||||
ww_text = WWText_Create(screen, x, y, width, height, palette);
|
||||
if (ww_text == NULL)
|
||||
Error("WonxText_Create", "Cannot create WonderWitch text.");
|
||||
WonxText_SetWWText(wonx_text, ww_text);
|
||||
|
||||
return (wonx_text);
|
||||
}
|
||||
|
||||
WonxText WonxText_Destroy(WonxText wonx_text)
|
||||
{
|
||||
if (wonx_text == NULL)
|
||||
Error("WonxText_Destroy", "Object is not created.");
|
||||
|
||||
if (WonxText_GetWWText(wonx_text))
|
||||
WonxText_SetWWText(wonx_text,
|
||||
WWText_Destroy(WonxText_GetWWText(wonx_text)));
|
||||
|
||||
free(wonx_text);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
@ -1,23 +1,25 @@
|
||||
#ifndef _WonXP_h_INCLUDED_
|
||||
#define _WonXP_h_INCLUDED_
|
||||
#ifndef _WonxText_h_INCLUDED_
|
||||
#define _WonxText_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "WonX.h"
|
||||
#include "WWText.h"
|
||||
#include "WWScreen.h"
|
||||
#include "WWPalette.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _WonX {
|
||||
WonXDisplay wonx_display;
|
||||
WonXSystem wonx_system;
|
||||
WonXSerialPort wonx_serial_port;
|
||||
} _WonX;
|
||||
typedef struct _WonxText * WonxText;
|
||||
|
||||
typedef struct _WonX * WonX;
|
||||
WWText WonxText_GetWWText(WonxText wonx_text);
|
||||
WWText WonxText_SetWWText(WonxText wonx_text, WWText ww_text);
|
||||
WonxText WonxText_Create(WWScreen screen, int x, int y, int width, int height,
|
||||
WWPalette palette);
|
||||
WonxText WonxText_Destroy(WonxText wonx_text);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
@ -1,19 +1,19 @@
|
||||
#ifndef _UNIXSerialPortP_h_INCLUDED_
|
||||
#define _UNIXSerialPortP_h_INCLUDED_
|
||||
#ifndef _WonxTextP_h_INCLUDED_
|
||||
#define _WonxTextP_h_INCLUDED_
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "UNIXSerialPort.h"
|
||||
#include "WonxText.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct _UNIXSerialPort {
|
||||
int opened; /* open/close */
|
||||
} _UNIXSerialPort;
|
||||
typedef struct _WonxText {
|
||||
WWText ww_text;
|
||||
} _WonxText;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
743
XColorGC.c
743
XColorGC.c
@ -1,743 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* XColorGC GCと色の管理・問い合わせ用のライブラリ */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "XColorGCP.h"
|
||||
|
||||
#include "WonX.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/*===========================================================================*/
|
||||
/* XColorGCInstance 関連 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの作成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCInstance XColorGCInstance_Create(XDisplay x_display,
|
||||
XColor color)
|
||||
{
|
||||
XColorGCInstance instance;
|
||||
|
||||
instance = (XColorGCInstance)malloc(sizeof(_XColorGCInstance));
|
||||
if (instance == NULL)
|
||||
WonX_Error("XColorGCInstance_Create", "Cannot allocate memory");
|
||||
|
||||
instance->x_display = x_display;
|
||||
instance->color = color;
|
||||
|
||||
XAllocColor(XDisplay_GetDisplay(instance->x_display),
|
||||
XDisplay_GetColormap(instance->x_display),
|
||||
&(instance->color));
|
||||
|
||||
/* XAllocColor で instance->color.red などの内容が変わってしまうので, */
|
||||
/* もとに戻す.でないと,あとで同じ色をRGB値で検索しても,違った色として */
|
||||
/* 解釈されてしまい,検索できないので,色情報を保存する意味が無くなって */
|
||||
/* しまう. */
|
||||
instance->color.red = color.red;
|
||||
instance->color.green = color.green;
|
||||
instance->color.blue = color.blue;
|
||||
|
||||
instance->gc = XDisplay_CreateGC(instance->x_display);
|
||||
|
||||
XSetForeground(XDisplay_GetDisplay(instance->x_display), instance->gc,
|
||||
instance->color.pixel);
|
||||
XSetBackground(XDisplay_GetDisplay(instance->x_display), instance->gc,
|
||||
instance->color.pixel);
|
||||
|
||||
return (instance);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCInstance XColorGCInstance_Destroy(XColorGCInstance instance)
|
||||
{
|
||||
unsigned long pixel;
|
||||
|
||||
if (instance == NULL) return (NULL);
|
||||
if (instance->gc) XDisplay_DestroyGC(instance->x_display, instance->gc);
|
||||
pixel = instance->color.pixel;
|
||||
XFreeColors(XDisplay_GetDisplay(instance->x_display),
|
||||
XDisplay_GetColormap(instance->x_display),
|
||||
&pixel, 1, 0);
|
||||
free(instance);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* XColorGCList 関連 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの作成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCList XColorGCList_Create(XDisplay x_display, int studying_flag)
|
||||
{
|
||||
XColorGCList list;
|
||||
|
||||
list = (XColorGCList)malloc(sizeof(_XColorGCList));
|
||||
if (list == NULL) WonX_Error("XColorGCList_Create", "Cannot allocate memory");
|
||||
|
||||
list->x_display = x_display;
|
||||
list->studying_flag = studying_flag;
|
||||
list->list = ObjList_Create();
|
||||
|
||||
return (list);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCList XColorGCList_Destroy(XColorGCList list)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
|
||||
if (list->list) ObjList_Destroy(list->list);
|
||||
|
||||
free(list);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* XColorGCList 中での XColorGCInstance のソート用の比較関数 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static int XColorGCInstance_CmpToColor(XColorGCInstance gci, XColor color)
|
||||
{
|
||||
if (gci->color.red > color.red ) return ( 1);
|
||||
if (gci->color.red < color.red ) return (-1);
|
||||
if (gci->color.green > color.green) return ( 1);
|
||||
if (gci->color.green < color.green) return (-1);
|
||||
if (gci->color.blue > color.blue ) return ( 1);
|
||||
if (gci->color.blue < color.blue ) return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* リストから XColorGCInstance を得る. */
|
||||
/* GC の取得要求に対して,GC のリストを検索して返す. */
|
||||
/* 存在しない場合には,作成してリストに追加する. */
|
||||
/* (常に RGB 値でソートされた状態で追加する) */
|
||||
/* 線形探索なので,O(n^2)で遅くなる. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCInstance XColorGCList_GetXColorGCInstance(XColorGCList list,
|
||||
XColor color)
|
||||
{
|
||||
XColorGCInstance instance;
|
||||
ObjListData current;
|
||||
int cmp;
|
||||
|
||||
for (current = ObjList_GetStart(list->list);
|
||||
!ObjList_IsEndEdge(list->list, current);
|
||||
current = ObjListData_GetNext(current)) {
|
||||
|
||||
instance = (XColorGCInstance)ObjListData_GetObj(current);
|
||||
cmp = XColorGCInstance_CmpToColor(instance, color);
|
||||
|
||||
if (cmp == 0) { /* 見つかれば,それを返す */
|
||||
#ifdef HIT_LIST
|
||||
fprintf(stderr, "S");
|
||||
#endif
|
||||
if (list->studying_flag) ObjList_MoveObjToStart(list->list, current);
|
||||
return (instance);
|
||||
} else if (cmp > 0) {
|
||||
if (!list->studying_flag) break;
|
||||
}
|
||||
}
|
||||
|
||||
/* 見つからなかった場合は,作成してリストに追加する */
|
||||
instance = XColorGCInstance_Create(list->x_display, color);
|
||||
|
||||
if (list->studying_flag)
|
||||
ObjList_InsertObjToStart(list->list, instance,
|
||||
(ObjDestructor)XColorGCInstance_Destroy);
|
||||
else
|
||||
ObjList_InsertObjToPrev(list->list, current, instance,
|
||||
(ObjDestructor)XColorGCInstance_Destroy);
|
||||
|
||||
#ifdef HIT_LIST
|
||||
fprintf(stderr, "A");
|
||||
#endif
|
||||
|
||||
return (instance);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* XColorGCCache 関連 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* キャッシュ用バッファ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCCacheBuffer XColorGCCacheBuffer_Create(XColorGCInstance instance)
|
||||
{
|
||||
XColorGCCacheBuffer buffer;
|
||||
buffer = (XColorGCCacheBuffer)malloc(sizeof(_XColorGCCacheBuffer));
|
||||
if (buffer == NULL) WonX_Error("XColorGCCacheBuffer_Create",
|
||||
"Cannot allocate memory.");
|
||||
buffer->instance = instance;
|
||||
return (buffer);
|
||||
}
|
||||
|
||||
static XColorGCCacheBuffer XColorGCCacheBuffer_Destroy(XColorGCCacheBuffer buffer)
|
||||
{
|
||||
if (buffer == NULL) return (NULL);
|
||||
free(buffer);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* キャッシュ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCCache XColorGCCache_Create(XColorGCList color_gc_list, int size)
|
||||
{
|
||||
XColorGCCache cache;
|
||||
|
||||
cache = (XColorGCCache)malloc(sizeof(_XColorGCCache));
|
||||
if (cache == NULL) WonX_Error("XColorGCCache_Create",
|
||||
"Cannot allocate memory.");
|
||||
|
||||
cache->size = size;
|
||||
cache->color_gc_list = color_gc_list;
|
||||
cache->buffer_list = ObjList_Create();
|
||||
|
||||
return (cache);
|
||||
}
|
||||
|
||||
static XColorGCCache XColorGCCache_Destroy(XColorGCCache cache)
|
||||
{
|
||||
if (cache == NULL) return (NULL);
|
||||
|
||||
if (cache->buffer_list) ObjList_Destroy(cache->buffer_list);
|
||||
free(cache);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* キャッシュから XColorGCInstance を得る. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCInstance XColorGCCache_GetXColorGCInstance(XColorGCCache cache,
|
||||
XColor color)
|
||||
{
|
||||
ObjListData current;
|
||||
XColorGCCacheBuffer buffer;
|
||||
XColorGCInstance instance;
|
||||
int cmp;
|
||||
|
||||
/* キャッシュの中を検索 */
|
||||
for (current = ObjList_GetStart(cache->buffer_list);
|
||||
!ObjList_IsEndEdge(cache->buffer_list, current);
|
||||
current = ObjListData_GetNext(current)) {
|
||||
|
||||
buffer = (XColorGCCacheBuffer)ObjListData_GetObj(current);
|
||||
cmp = XColorGCInstance_CmpToColor(buffer->instance, color);
|
||||
|
||||
if (cmp == 0) { /* キャッシュ中に見つけた場合 */
|
||||
#ifdef HIT_CACHE
|
||||
fprintf(stderr, "H"); /* Hit! */
|
||||
#endif
|
||||
ObjList_MoveObjToStart(cache->buffer_list, current);
|
||||
return (buffer->instance);
|
||||
}
|
||||
}
|
||||
|
||||
/* キャッシュ中に見つけられなかった場合 */
|
||||
|
||||
/* リストから検索する */
|
||||
instance = XColorGCList_GetXColorGCInstance(cache->color_gc_list, color);
|
||||
|
||||
/* キャッシュに追加する */
|
||||
if (ObjList_GetLength(cache->buffer_list) < cache->size) {
|
||||
buffer = XColorGCCacheBuffer_Create(instance);
|
||||
ObjList_InsertObjToStart(cache->buffer_list, buffer,
|
||||
(ObjDestructor)XColorGCCacheBuffer_Destroy);
|
||||
} else {
|
||||
current = ObjList_GetEnd(cache->buffer_list);
|
||||
buffer = (XColorGCCacheBuffer)ObjListData_GetObj(current);
|
||||
buffer->instance = instance;
|
||||
ObjList_MoveObjToStart(cache->buffer_list, current);
|
||||
}
|
||||
|
||||
#ifdef HIT_CACHE
|
||||
fprintf(stderr, "F"); /* False! */
|
||||
#endif
|
||||
|
||||
return (instance);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* XColorGCHash 関連 */
|
||||
/*===========================================================================*/
|
||||
|
||||
static XColorGCHash XColorGCHash_Create(XDisplay x_display,
|
||||
int studying_flag,
|
||||
int cache_flag,
|
||||
int cache_size,
|
||||
int hash_number)
|
||||
{
|
||||
XColorGCHash hash;
|
||||
int i;
|
||||
|
||||
hash = (XColorGCHash)malloc(sizeof(_XColorGCHash));
|
||||
if (hash == NULL)
|
||||
WonX_Error("XColorGCHash_Create", "Cannot allocate memory.");
|
||||
|
||||
hash->number = hash_number;
|
||||
hash->cache_flag = cache_flag;
|
||||
|
||||
if (cache_flag) {
|
||||
hash->color_gc_cache =
|
||||
(XColorGCCache *)malloc(sizeof(XColorGCCache) * hash->number);
|
||||
if (hash->color_gc_cache == NULL)
|
||||
WonX_Error("XColorGCHash_Create", "Cannot allocate memory.");
|
||||
} else {
|
||||
hash->color_gc_cache = NULL;
|
||||
}
|
||||
|
||||
hash->color_gc_list =
|
||||
(XColorGCList *)malloc(sizeof(XColorGCList) * hash->number);
|
||||
if (hash->color_gc_list == NULL)
|
||||
WonX_Error("XColorGCHash_Create", "Cannot allocate memory.");
|
||||
|
||||
for (i = 0; i < hash->number; i++) {
|
||||
hash->color_gc_list[i] = XColorGCList_Create(x_display, studying_flag);
|
||||
if (cache_flag) {
|
||||
hash->color_gc_cache[i] = XColorGCCache_Create(hash->color_gc_list[i],
|
||||
cache_size);
|
||||
}
|
||||
}
|
||||
|
||||
return (hash);
|
||||
}
|
||||
|
||||
static XColorGCHash XColorGCHash_Destroy(XColorGCHash hash)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (hash == NULL) return (NULL);
|
||||
|
||||
if (hash->color_gc_cache) {
|
||||
for (i = 0; i < hash->number; i++) {
|
||||
if (hash->color_gc_cache[i])
|
||||
XColorGCCache_Destroy(hash->color_gc_cache[i]);
|
||||
}
|
||||
free(hash->color_gc_cache);
|
||||
}
|
||||
|
||||
if (hash->color_gc_list) {
|
||||
for (i = 0; i < hash->number; i++) {
|
||||
if (hash->color_gc_list[i])
|
||||
XColorGCList_Destroy(hash->color_gc_list[i]);
|
||||
}
|
||||
free(hash->color_gc_list);
|
||||
}
|
||||
|
||||
free(hash);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static void XColorGCHash_OutputHashStatus(XColorGCHash hash)
|
||||
{
|
||||
int i;
|
||||
printf ("\nHash :");
|
||||
for (i = 0; i < hash->number; i++) {
|
||||
printf("%d ", ObjList_GetLength(hash->color_gc_list[i]->list));
|
||||
}
|
||||
printf ("\n");
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ハッシュ関数 */
|
||||
/* 色を減色している場合,特定の位置だけ頻繁に使用されたりしないように注意. */
|
||||
/* (たとえば, */
|
||||
/* ((int)color.red*3 + (int)color.green*2 + (int)color.blue) % hash->number */
|
||||
/* のようなハッシュ関数だと,16階調に減色したときに,4096 の倍数の位置だけ */
|
||||
/* 頻繁に使用されてしまう. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static int HashFunction(XColorGCHash hash, XColor color)
|
||||
{
|
||||
return ((
|
||||
(((int)color.red) / 3000) * 11 +
|
||||
(((int)color.green) % 3000) / 7 +
|
||||
(((int)color.blue) % 1000) / 3
|
||||
) % hash->number);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ハッシュから XColorGCInstance を得る. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColorGCInstance XColorGCHash_GetXColorGCInstance(XColorGCHash hash,
|
||||
XColor color)
|
||||
{
|
||||
int n;
|
||||
|
||||
n = HashFunction(hash, color);
|
||||
|
||||
if (hash->cache_flag)
|
||||
return (XColorGCCache_GetXColorGCInstance(hash->color_gc_cache[n], color));
|
||||
else
|
||||
return (XColorGCList_GetXColorGCInstance(hash->color_gc_list[n], color));
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ColorName 関連 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの生成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static ColorName ColorName_Create(XDisplay x_display, char * name)
|
||||
{
|
||||
ColorName color_name;
|
||||
|
||||
color_name = (ColorName)malloc(sizeof(_ColorName));
|
||||
if (color_name == NULL)
|
||||
WonX_Error("ColorName_Create", "Cannot allocate memory");
|
||||
|
||||
color_name->name = malloc(sizeof(char) * (strlen(name) + 1));
|
||||
if (color_name->name == NULL)
|
||||
WonX_Error("ColorName_Create", "Cannot allocate memory");
|
||||
|
||||
strcpy(color_name->name, name);
|
||||
|
||||
XParseColor(XDisplay_GetDisplay(x_display),
|
||||
XDisplay_GetColormap(x_display),
|
||||
color_name->name, &(color_name->color));
|
||||
|
||||
return (color_name);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static ColorName ColorName_Destroy(ColorName color_name)
|
||||
{
|
||||
if (color_name == NULL) return (NULL);
|
||||
if (color_name->name) free(color_name->name);
|
||||
free(color_name);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの生成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static ColorNameList ColorNameList_Create(XDisplay x_display)
|
||||
{
|
||||
ColorNameList list;
|
||||
|
||||
list = (ColorNameList)malloc(sizeof(_ColorNameList));
|
||||
if (list == NULL)
|
||||
WonX_Error("ColorNameList_Create", "Cannot allocate memory");
|
||||
|
||||
list->x_display = x_display;
|
||||
list->list = ObjList_Create();
|
||||
|
||||
return (list);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static ColorNameList ColorNameList_Destroy(ColorNameList list)
|
||||
{
|
||||
if (list == NULL) return (NULL);
|
||||
if (list->list) ObjList_Destroy(list->list);
|
||||
free(list);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 文字列で与えられた色名から,RGB値を検索する. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColor ColorNameList_GetColor(ColorNameList list, char * name)
|
||||
{
|
||||
ObjListData current;
|
||||
ColorName color_name;
|
||||
|
||||
for (current = ObjList_GetStart(list->list);
|
||||
!ObjList_IsEndEdge(list->list, current);
|
||||
current = ObjListData_GetNext(current)) {
|
||||
color_name = (ColorName)ObjListData_GetObj(current);
|
||||
if (!strcmp(color_name->name, name)) {
|
||||
ObjList_MoveObjToStart(list->list, current);
|
||||
return (color_name->color);
|
||||
}
|
||||
}
|
||||
|
||||
color_name = ColorName_Create(list->x_display, name);
|
||||
if (color_name == NULL)
|
||||
WonX_Error("ColorNameList_GetColor", "Cannot create ColorName");
|
||||
|
||||
ObjList_InsertObjToStart(list->list, color_name,
|
||||
(ObjDestructor)ColorName_Destroy);
|
||||
|
||||
return (color_name->color);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* XColorGC 関連 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの生成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColorGC XColorGC_Create(XColorGCDatabase database, XColor color)
|
||||
{
|
||||
XColorGC color_gc;
|
||||
|
||||
color_gc = (XColorGC)malloc(sizeof(_XColorGC));
|
||||
|
||||
/* ハッシュから色とGCを検索 */
|
||||
color_gc->instance = XColorGCHash_GetXColorGCInstance(database->hash, color);
|
||||
|
||||
return (color_gc);
|
||||
}
|
||||
|
||||
XColorGC XColorGC_CreateFromXColorGC(XColorGCDatabase database, XColorGC c)
|
||||
{
|
||||
XColorGC color_gc;
|
||||
|
||||
color_gc = (XColorGC)malloc(sizeof(_XColorGC));
|
||||
|
||||
color_gc->instance = c->instance;
|
||||
|
||||
return (color_gc);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RGB 値から生成する. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColorGC XColorGC_CreateFromRGB(XColorGCDatabase database,
|
||||
int red, int green, int blue)
|
||||
{
|
||||
XColor color;
|
||||
|
||||
color.red = red;
|
||||
color.green = green;
|
||||
color.blue = blue;
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
return (XColorGC_Create(database, color));
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColorGC XColorGC_Destroy(XColorGC color_gc)
|
||||
{
|
||||
if (!color_gc) return (NULL);
|
||||
|
||||
free(color_gc);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 文字列読み込み用関数 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 色の節約のための,減色用の関数. */
|
||||
/* 減色すると,色の共有化が進み,キャッシングの効果が大きくなる. */
|
||||
/* あるていど減色しないと,色が共有できないので,無駄が多くなる. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static XColor DecreaseColor(XColor color, int gradation)
|
||||
{
|
||||
int div = RGB_MAX_VALUE / gradation + 1;
|
||||
|
||||
color.red /= div;
|
||||
if (color.red >= gradation - 1) color.red = RGB_MAX_VALUE;
|
||||
else color.red *= div;
|
||||
|
||||
color.green /= div;
|
||||
if (color.green >= gradation - 1) color.green = RGB_MAX_VALUE;
|
||||
else color.green *= div;
|
||||
|
||||
color.blue /= div;
|
||||
if (color.blue >= gradation - 1) color.blue = RGB_MAX_VALUE;
|
||||
else color.blue *= div;
|
||||
|
||||
return (color);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 色とGCのデータベースから name で与えられた名前の色を検索する. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColorGC XColorGC_CreateFromCharacters(XColorGCDatabase database, char * name)
|
||||
{
|
||||
XColor color;
|
||||
|
||||
if (!strcmp(name, "none") ||
|
||||
!strcmp(name, "None") ||
|
||||
!strcmp(name, "NONE") ||
|
||||
!strcmp(name, "back") ||
|
||||
!strcmp(name, "Back") ||
|
||||
!strcmp(name, "BACK") ||
|
||||
!strcmp(name, "background") ||
|
||||
!strcmp(name, "Background") ||
|
||||
!strcmp(name, "BACKGROUND")) {
|
||||
if (database->background_color_gc)
|
||||
return (XColorGC_CreateFromXColorGC(database,
|
||||
database->background_color_gc));
|
||||
else
|
||||
#if 1
|
||||
name = "none";
|
||||
#else
|
||||
name = "black";
|
||||
#endif
|
||||
}
|
||||
|
||||
color = ColorNameList_GetColor(database->color_name_list, name);
|
||||
|
||||
/* 色の節約のため,減色する */
|
||||
color = DecreaseColor(color, database->gradation);
|
||||
|
||||
return (XColorGC_Create(database, color));
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* XColor 構造体の取得 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColor XColorGC_GetColor(XColorGC color_gc)
|
||||
{
|
||||
return (color_gc->instance->color);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ピクセル値の取得 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
unsigned long XColorGC_GetPixel(XColorGC color_gc)
|
||||
{
|
||||
return (color_gc->instance->color.pixel);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* GC の取得 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
GC XColorGC_GetGC(XColorGC color_gc)
|
||||
{
|
||||
return (color_gc->instance->gc);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 色の明るさの取得 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int GetBrightness(XColor color)
|
||||
{
|
||||
long int br;
|
||||
|
||||
#if 0
|
||||
br = color.red > color.green ? color.red : color.green;
|
||||
br = br > color.blue ? br : color.blue;
|
||||
br = br * 100 / RGB_MAX_VALUE;
|
||||
#else
|
||||
br = color.red + color.green + color.blue;
|
||||
br = br * 100 / RGB_MAX_VALUE;
|
||||
#endif
|
||||
|
||||
if (br > 100) br = 100;
|
||||
|
||||
return ((int)br);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* GC のデータベース */
|
||||
/*===========================================================================*/
|
||||
|
||||
XColorGCDatabase XColorGCDatabase_Create(XDisplay x_display,
|
||||
int studying_flag,
|
||||
int cache_flag,
|
||||
int cache_size,
|
||||
int hash_number,
|
||||
char * background,
|
||||
int gradation)
|
||||
{
|
||||
XColorGCDatabase database;
|
||||
|
||||
database = (XColorGCDatabase)malloc(sizeof(_XColorGCDatabase));
|
||||
if (database == NULL)
|
||||
WonX_Error("XColorGCDatabase_Create", "Cannot allocate memory.");
|
||||
|
||||
database->x_display = x_display;
|
||||
database->gradation = gradation;
|
||||
|
||||
database->hash = XColorGCHash_Create(database->x_display,
|
||||
studying_flag,
|
||||
cache_flag,
|
||||
cache_size,
|
||||
hash_number);
|
||||
database->color_name_list = ColorNameList_Create(database->x_display);
|
||||
|
||||
/* background が "none" の場合にも正常動作するように, */
|
||||
/* XColorGC_CreateFromCharacters()を呼び出す前に,NULL で初期化する. */
|
||||
database->background_color_gc = NULL;
|
||||
|
||||
/* 引数に database を入れて呼び出すので,必ず最後に置くこと */
|
||||
database->background_color_gc =
|
||||
XColorGC_CreateFromCharacters(database, background);
|
||||
/* この直後に return() が来るようにすること */
|
||||
|
||||
return (database);
|
||||
}
|
||||
|
||||
XColorGCDatabase XColorGCDatabase_Destroy(XColorGCDatabase database)
|
||||
{
|
||||
if (database == NULL) return (NULL);
|
||||
|
||||
if (database->background_color_gc)
|
||||
XColorGC_Destroy(database->background_color_gc);
|
||||
|
||||
if (database->color_name_list)
|
||||
ColorNameList_Destroy(database->color_name_list);
|
||||
if (database->hash) XColorGCHash_Destroy(database->hash);
|
||||
free(database);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
XColorGC XColorGCDatabase_GetBackgroundXColorGC(XColorGCDatabase database)
|
||||
{
|
||||
return (database->background_color_gc);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* チューニング用 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void XColorGCDatabase_OutputHashStatus(XColorGCDatabase database)
|
||||
{
|
||||
XColorGCHash_OutputHashStatus(database->hash);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File */
|
||||
/*****************************************************************************/
|
||||
98
XColorGC.h
98
XColorGC.h
@ -1,98 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* XColorGC GCと色の管理・問い合わせ用のライブラリ */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _XColorGC_h_INCLUDED_
|
||||
#define _XColorGC_h_INCLUDED_
|
||||
|
||||
typedef struct _XColorGCDatabase * XColorGCDatabase;
|
||||
typedef struct _XColorGC * XColorGC;
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "XDisplay.h"
|
||||
#include "Obj.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* XColorGC 関連 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの生成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColorGC XColorGC_Create(XColorGCDatabase database, XColor color);
|
||||
XColorGC XColorGC_CreateFromXColorGC(XColorGCDatabase database, XColorGC c);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* RGB 値から生成する. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColorGC XColorGC_CreateFromRGB(XColorGCDatabase database,
|
||||
int red, int green, int blue);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* オブジェクトの削除 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColorGC XColorGC_Destroy(XColorGC color_gc);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 文字列読み込み用関数 */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 色とGCのデータベースから name で与えられた名前の色を検索する. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColorGC XColorGC_CreateFromCharacters(XColorGCDatabase database, char * name);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* XColor 構造体の取得 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
XColor XColorGC_GetColor(XColorGC color_gc);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* ピクセル値の取得 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
unsigned long XColorGC_GetPixel(XColorGC color_gc);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* GC の取得 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
GC XColorGC_GetGC(XColorGC color_gc);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 色の明るさの取得 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int GetBrightness(XColor color);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* GC のデータベース */
|
||||
/*===========================================================================*/
|
||||
|
||||
XColorGCDatabase XColorGCDatabase_Create(XDisplay x_display,
|
||||
int studying_flag,
|
||||
int cache_flag,
|
||||
int cache_size,
|
||||
int hash_number,
|
||||
char * background,
|
||||
int gradation);
|
||||
XColorGCDatabase XColorGCDatabase_Destroy(XColorGCDatabase database);
|
||||
XColorGC XColorGCDatabase_GetBackgroundXColorGC(XColorGCDatabase database);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* チューニング用 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
void XColorGCDatabase_OutputHashStatus(XColorGCDatabase database);
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File */
|
||||
/*****************************************************************************/
|
||||
148
XColorGCP.h
148
XColorGCP.h
@ -1,148 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* XColorGC GCと色の管理・問い合わせ用のライブラリ */
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifndef _XColorGCP_h_INCLUDED_
|
||||
#define _XColorGCP_h_INCLUDED_
|
||||
|
||||
#include "XColorGC.h"
|
||||
|
||||
#define RGB_MAX_VALUE 65535
|
||||
|
||||
/*===========================================================================*/
|
||||
/* XFireworks は,描画の高速化のために,描画に必要な色と GC は,起動時に */
|
||||
/* すべて確保するのですが,無駄な X サーバへのリクエストとメモリの浪費を */
|
||||
/* 減らすために,いったん確保した色と GC はデータベースに記憶しておき, */
|
||||
/* 同じ色が必要になったときには,共有するようにします. */
|
||||
/* (XColorGCDatabase はそのためのクラスです) */
|
||||
/* これにより,XAllocColor() による色の問い合わせ待ちが減るため, */
|
||||
/* 起動が格段に高速になります. */
|
||||
/* データベースの検索には,ハッシュ,キャッシュ,学習機能を使用することが */
|
||||
/* できます. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 以下を有効にすると,同じ色のGCがどれくらい共有されているか調べることが */
|
||||
/* できます. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/* #define HIT_LIST */
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 以下を有効にすると,キャッシュのヒット率を調べることができます. */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
/* #define HIT_CACHE */
|
||||
|
||||
/*===========================================================================*/
|
||||
/* GC の実体を管理するクラス */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct _XColorGCInstance * XColorGCInstance;
|
||||
|
||||
typedef struct _XColorGCInstance {
|
||||
XDisplay x_display;
|
||||
GC gc;
|
||||
XColor color;
|
||||
} _XColorGCInstance;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* GC の実体のリストを管理するクラス */
|
||||
/* 同一の色のGCは共有したいため,GCの実体をリストで管理し,GCの取得要求に */
|
||||
/* 対して,適切な XColorGCInstance を返す. */
|
||||
/* (すでに存在するのならそれを返し,無ければ Create する) */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct _XColorGCList * XColorGCList;
|
||||
|
||||
typedef struct _XColorGCList { /* GC の管理用 */
|
||||
XDisplay x_display;
|
||||
int studying_flag; /* 学習機能のON/OFFのフラグ */
|
||||
ObjList list; /* XColorGCInstance のリスト */
|
||||
} _XColorGCList;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* キャッシュ */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct _XColorGCCacheBuffer * XColorGCCacheBuffer;
|
||||
typedef struct _XColorGCCache * XColorGCCache;
|
||||
|
||||
/* キャッシュ用バッファ */
|
||||
typedef struct _XColorGCCacheBuffer {
|
||||
XColorGCInstance instance;
|
||||
} _XColorGCCacheBuffer;
|
||||
|
||||
/* キャッシュ */
|
||||
typedef struct _XColorGCCache {
|
||||
int size; /* キャッシュサイズ */
|
||||
|
||||
XColorGCList color_gc_list;
|
||||
ObjList buffer_list;
|
||||
} _XColorGCCache;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ハッシュ */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct _XColorGCHash * XColorGCHash;
|
||||
|
||||
typedef struct _XColorGCHash {
|
||||
int number; /* ハッシュの個数 */
|
||||
int cache_flag; /* キャッシュの使用・未使用のフラグ */
|
||||
XColorGCCache * color_gc_cache;
|
||||
XColorGCList * color_gc_list;
|
||||
} _XColorGCHash;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 色の名前とRGB値の対応を管理するためのクラス */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct _ColorName * ColorName;
|
||||
typedef struct _ColorNameList * ColorNameList;
|
||||
|
||||
typedef struct _ColorName {
|
||||
char * name;
|
||||
XColor color;
|
||||
} _ColorName;
|
||||
|
||||
typedef struct _ColorNameList {
|
||||
XDisplay x_display;
|
||||
ObjList list; /* ColorName のリスト */
|
||||
} _ColorNameList;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 色と GC のデータベース */
|
||||
/* GC の検索には,ハッシュを用いる. */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct _XColorGCDatabase { /* GC の管理用 */
|
||||
XDisplay x_display;
|
||||
XColorGCHash hash; /* ハッシュ */
|
||||
|
||||
ColorNameList color_name_list; /* 色名 → RGB値の変換用 */
|
||||
|
||||
/* 背景色.色名で"none"を指定すると,この色が使用される. */
|
||||
XColorGC background_color_gc;
|
||||
|
||||
/* 減色数.16階調にするときには16を指定 */
|
||||
/* 10階調や20階調も指定可能 */
|
||||
int gradation;
|
||||
|
||||
} _XColorGCDatabase;
|
||||
|
||||
/*===========================================================================*/
|
||||
/* GC を管理するクラス */
|
||||
/* 同じ色の GC が重複しない用に,XColorGCList で GC を管理して, */
|
||||
/* 色の要求時には,XColorGCList から GC をもらうようにする. */
|
||||
/*===========================================================================*/
|
||||
|
||||
typedef struct _XColorGC {
|
||||
XColorGCInstance instance;
|
||||
} _XColorGC;
|
||||
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File */
|
||||
/*****************************************************************************/
|
||||
505
XDisplay.c
505
XDisplay.c
@ -2,39 +2,21 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "XDisplayP.h"
|
||||
#include "Wonx.h"
|
||||
#include "etc.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "XDisplayP.h"
|
||||
#include "WonX.h"
|
||||
#include "WonXDisplay.h"
|
||||
#include "etc.h"
|
||||
#include <sys/types.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
Display * XDisplay_GetDisplay(XDisplay d) { return (d->display); }
|
||||
Colormap XDisplay_GetColormap(XDisplay d) { return (d->colormap); }
|
||||
|
||||
XColorGCDatabase XDisplay_GetColorGCDatabase(XDisplay x_display)
|
||||
{ return (x_display->color_gc_database); }
|
||||
|
||||
unsigned int XDisplay_GetKeyPress(XDisplay d) { return (d->key_press); }
|
||||
|
||||
int XDisplay_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_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); }
|
||||
@ -73,7 +55,7 @@ static void quit(Widget w, XEvent * event, String * params, Cardinal * num)
|
||||
static void wm_protocols_proc(Widget w, XEvent * event, String * params,
|
||||
Cardinal * num)
|
||||
{
|
||||
if ((event->type == ClientMessage) &&
|
||||
if ((event->type == ClientMessage) &&
|
||||
(event->xclient.data.l[0] != wm_delete_window)) {
|
||||
XBell(XtDisplay(w), 0);
|
||||
} else {
|
||||
@ -86,16 +68,16 @@ static void iconify(Widget w, XEvent * event, String * params, Cardinal * num)
|
||||
XIconifyWindow(XtDisplay(w), XtWindow(w), DefaultScreen(XtDisplay(w)));
|
||||
}
|
||||
|
||||
static void sleep_10(Widget w, XEvent * event, String * params, Cardinal * num)
|
||||
static void sleep_3(Widget w, XEvent * event, String * params, Cardinal * num)
|
||||
{
|
||||
time_t old_t;
|
||||
time_t t;
|
||||
int i;
|
||||
/* UNIXTimer.c 内部で SIGALRM を使用しているので,sleep() は使用できない */
|
||||
#if 0
|
||||
sleep(10);
|
||||
sleep(3);
|
||||
#else
|
||||
for (i = 0; i < 10; i++) {
|
||||
for (i = 0; i < 3; i++) {
|
||||
time(&t);
|
||||
old_t = t;
|
||||
while (t == old_t)
|
||||
@ -108,22 +90,20 @@ static XtActionsRec actions[] = {
|
||||
{"quit", quit},
|
||||
{"wm_protocols_proc", wm_protocols_proc},
|
||||
{"iconify", iconify},
|
||||
{"pause", sleep_10}
|
||||
{"pause", sleep_3}
|
||||
};
|
||||
|
||||
static char * translations =
|
||||
"<Message>WM_PROTOCOLS: wm_protocols_proc()\n"
|
||||
"None<Key>F11: pause()\n"
|
||||
"None<Key>p: pause()\n"
|
||||
"Ctrl<Key>i: iconify()\n"
|
||||
"Ctrl<Key>c: quit()\n"
|
||||
"None<Key>F12: quit()\n"
|
||||
"None<Key>q: quit()";
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 色名からピクセル値を取得する */
|
||||
/*===========================================================================*/
|
||||
|
||||
#ifdef USE_X_FONT
|
||||
static unsigned long XDisplay_GetPixelFromColorName(XDisplay x_display,
|
||||
char * color_name)
|
||||
{
|
||||
@ -132,27 +112,11 @@ static unsigned long XDisplay_GetPixelFromColorName(XDisplay x_display,
|
||||
&c0, &c1);
|
||||
return (c0.pixel);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* イベントハンドラ */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* イクスポーズ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void ExposeHandler(Widget w, XtPointer p, XEvent * event,
|
||||
Boolean * dispatch)
|
||||
{
|
||||
XDisplay x_display = (XDisplay)p;
|
||||
|
||||
XCopyArea(x_display->display, x_display->lcd_pixmap,
|
||||
x_display->lcd_window, x_display->copy_gc,
|
||||
0, 0, x_display->width, x_display->height, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* キーの押下 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -171,107 +135,64 @@ static void KeyHandler(Widget w, XtPointer p, XEvent * event,
|
||||
switch (key_sym) {
|
||||
|
||||
/* WonderSwan用 */
|
||||
case XK_Up : press = KEY_UP1; printf("key : Up1 " ); break;
|
||||
case XK_Right : press = KEY_RIGHT1; printf("key : Right1 "); break;
|
||||
case XK_Down : press = KEY_DOWN1; printf("key : Down1 " ); break;
|
||||
case XK_Left : press = KEY_LEFT1; printf("key : Left1 " ); break;
|
||||
case XK_i : press = KEY_UP2; printf("key : Up2 " ); break;
|
||||
case XK_l : press = KEY_RIGHT2; printf("key : Right2 "); break;
|
||||
case XK_k : press = KEY_DOWN2; printf("key : Down2 " ); break;
|
||||
case XK_j : press = KEY_LEFT2; printf("key : Left2 " ); break;
|
||||
case XK_s : press = KEY_START; printf("key : Start " ); break;
|
||||
case XK_space : press = KEY_A; printf("key : A " ); break;
|
||||
case XK_Shift_L : press = KEY_B; printf("key : B " ); break;
|
||||
case XK_Up : press = KEY_UP1; break;
|
||||
case XK_Right : press = KEY_RIGHT1; break;
|
||||
case XK_Down : press = KEY_DOWN1; break;
|
||||
case XK_Left : press = KEY_LEFT1; break;
|
||||
case XK_i : press = KEY_UP2; break;
|
||||
case XK_l : press = KEY_RIGHT2; break;
|
||||
case XK_k : press = KEY_DOWN2; break;
|
||||
case XK_j : press = KEY_LEFT2; break;
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
switch (key_sym) {
|
||||
|
||||
/* 表示モード変更 */
|
||||
case XK_F9 :
|
||||
case XK_F10 :
|
||||
|
||||
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
|
||||
/*
|
||||
* 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());
|
||||
#else
|
||||
ExposeHandler(w, p, event, dispatch);
|
||||
#endif
|
||||
}
|
||||
case XK_p :
|
||||
x_display->lcd_draw = !(x_display->lcd_draw);
|
||||
if (x_display->lcd_draw)
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
break;
|
||||
|
||||
/* データのダンプ操作 */
|
||||
case XK_F1 :
|
||||
printf("key : F1 Pressed\n");
|
||||
x_display->color_map_print = 1;
|
||||
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;
|
||||
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) {
|
||||
if (event->type == KeyPress) x_display->key_press |= press;
|
||||
else x_display->key_press &= ~press;
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* イクスポーズ */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
static void ExposeHandler(Widget w, XtPointer p, XEvent * event,
|
||||
Boolean * dispatch)
|
||||
{
|
||||
XDisplay x_display = (XDisplay)p;
|
||||
|
||||
XCopyArea(x_display->display, x_display->lcd_pixmap,
|
||||
x_display->lcd_window, x_display->copy_gc,
|
||||
0, 0, x_display->width, x_display->height, 0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* マウスがウインドウを離れたら,キーを初期化する */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
@ -305,18 +226,17 @@ XDisplay XDisplay_Create(int width, int height)
|
||||
int i;
|
||||
|
||||
x_display = (XDisplay)malloc(sizeof(_XDisplay));
|
||||
if (x_display == NULL)
|
||||
WonX_Error("XDisplay_Create", "Cannot allocate memory.");
|
||||
if (x_display == NULL) Error("XDisplay_Create", "Cannot allocate memory.");
|
||||
|
||||
x_display->width = width;
|
||||
x_display->height = height;
|
||||
|
||||
x_display->toplevel = XtAppInitialize(&(x_display->app_context),
|
||||
"WonX",
|
||||
"Wonx",
|
||||
NULL, 0, &argc, argv, NULL, NULL, 0);
|
||||
|
||||
XtVaSetValues(x_display->toplevel, XtNinput, True, NULL);
|
||||
XtVaSetValues(x_display->toplevel, XtNtitle, "WonX", NULL);
|
||||
XtVaSetValues(x_display->toplevel, XtNtitle, "Wonx", NULL);
|
||||
XtVaSetValues(x_display->toplevel, XtNwidth , x_display->width , NULL);
|
||||
XtVaSetValues(x_display->toplevel, XtNminWidth , x_display->width , NULL);
|
||||
XtVaSetValues(x_display->toplevel, XtNmaxWidth , x_display->width , NULL);
|
||||
@ -325,7 +245,7 @@ XDisplay XDisplay_Create(int width, int height)
|
||||
XtVaSetValues(x_display->toplevel, XtNmaxHeight, x_display->height, NULL);
|
||||
|
||||
x_display->key_press = 0;
|
||||
x_display->lcd_draw_level = 1;
|
||||
x_display->lcd_draw = 1;
|
||||
|
||||
XtRealizeWidget(x_display->toplevel);
|
||||
while (!XtIsRealized(x_display->toplevel)) { /* None */ }
|
||||
@ -359,7 +279,6 @@ XDisplay XDisplay_Create(int width, int height)
|
||||
XSetFunction(x_display->display, x_display->color_gc[i], GXcopy);
|
||||
}
|
||||
|
||||
#ifdef USE_X_FONT
|
||||
/* フォントの確保 */
|
||||
x_display->font = XLoadFont(x_display->display, "8x16");
|
||||
x_display->font_gc = XCreateGC(x_display->display,
|
||||
@ -370,24 +289,6 @@ XDisplay XDisplay_Create(int width, int height)
|
||||
XDisplay_GetPixelFromColorName(x_display, "white"));
|
||||
XSetBackground(x_display->display, x_display->font_gc,
|
||||
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,
|
||||
x_display->color_gc[0],
|
||||
@ -437,87 +338,17 @@ XDisplay XDisplay_Destroy(XDisplay x_display)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (x_display == NULL)
|
||||
WonX_Error("XDisplay_Destroy", "Object is not created.");
|
||||
if (x_display == NULL) return (NULL);
|
||||
|
||||
/* 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
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (x_display->color_gc[i]) {
|
||||
XFreeGC(x_display->display, x_display->color_gc[i]);
|
||||
/* あとでリソースの解放を追加すること */
|
||||
if (x_display->color_gc != NULL) {
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (x_display->color_gc[i])
|
||||
XFreeGC(x_display->display, x_display->color_gc[i]);
|
||||
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);
|
||||
|
||||
return (NULL);
|
||||
@ -529,21 +360,14 @@ XDisplay XDisplay_Destroy(XDisplay x_display)
|
||||
|
||||
int XDisplay_Sync(XDisplay x_display)
|
||||
{
|
||||
XEvent event;
|
||||
|
||||
XFlush(x_display->display);
|
||||
|
||||
/* Xサーバと同期をとる */
|
||||
/* 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)) {
|
||||
XtAppNextEvent(x_display->app_context, &event);
|
||||
@ -557,182 +381,89 @@ int XDisplay_Flush(XDisplay x_display)
|
||||
/* 描画 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int XDisplay_DrawLCDWindow(XDisplay x_display, WWDisplay ww_display,
|
||||
WWLCDPanel ww_lcd_panel)
|
||||
int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel)
|
||||
{
|
||||
int x, y;
|
||||
int px, py, ph;
|
||||
int num;
|
||||
int n[16];
|
||||
XRectangle rectangle;
|
||||
XRectangle * rectangles[16];
|
||||
unsigned short int pixel;
|
||||
int pixel;
|
||||
int ww_lcd_width, ww_lcd_height;
|
||||
int red, green, blue;
|
||||
XColorGCDatabase database;
|
||||
XColorGC x_color_gc;
|
||||
GC gc;
|
||||
|
||||
/* 隣接しているピクセルはまとめて描画するので,ピクセル数の最大値は */
|
||||
/* 最悪の場合(縞々模様のとき)で,width * height / 2 になる. */
|
||||
num =
|
||||
WWLCDPanel_GetHeight(ww_lcd_panel) * WWLCDPanel_GetWidth(ww_lcd_panel) / 2;
|
||||
|
||||
/*
|
||||
* この malloc() は,実際にはメモリはほとんど使用されていないので,
|
||||
* そのうちなんとかする必要がある
|
||||
*/
|
||||
for (pixel = 0; pixel < 16; pixel++) {
|
||||
n[pixel] = 0;
|
||||
rectangles[pixel] = (XRectangle *)malloc(sizeof(XRectangle) * num);
|
||||
}
|
||||
if (rectangles == NULL)
|
||||
Error("XDisplay_DrawLCDWindow", "Cannot allocate memory.");
|
||||
|
||||
ww_lcd_width = WWLCDPanel_GetWidth( ww_lcd_panel);
|
||||
ww_lcd_height = WWLCDPanel_GetHeight(ww_lcd_panel);
|
||||
|
||||
switch (WWDisplay_GetColorMode(ww_display)) {
|
||||
/* ここの処理はホットスポットになるので,のちのちにチューニングすること */
|
||||
|
||||
case COLOR_MODE_GRAYSCALE:
|
||||
for (y = 0; y < ww_lcd_height; y++) {
|
||||
py = (y * x_display->height) / ww_lcd_height;
|
||||
ph = (y+1) * x_display->height / ww_lcd_height- py;
|
||||
for (x = 0; x < ww_lcd_width; x++) {
|
||||
if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
|
||||
continue;
|
||||
}
|
||||
pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
|
||||
px = (x * x_display->width ) / ww_lcd_width;
|
||||
rectangles[pixel][n[pixel]].x = px;
|
||||
rectangles[pixel][n[pixel]].y = py;
|
||||
rectangles[pixel][n[pixel]].width =
|
||||
(x+1) * x_display->width / ww_lcd_width - px;
|
||||
rectangles[pixel][n[pixel]].height = ph;
|
||||
|
||||
/* 隣接しているピクセルはまとめて描画するので,ピクセル数の最大値は */
|
||||
/* 最悪の場合(縞々模様のとき)で,width * height / 2 になる. */
|
||||
num =
|
||||
WWLCDPanel_GetHeight(ww_lcd_panel) *
|
||||
WWLCDPanel_GetWidth(ww_lcd_panel) / 2;
|
||||
|
||||
/*
|
||||
* この malloc() は,実際にはメモリはほとんど使用されていないので,
|
||||
* そのうちなんとかする必要がある
|
||||
*/
|
||||
for (pixel = 0; pixel < 16; pixel++) {
|
||||
n[pixel] = 0;
|
||||
rectangles[pixel] = (XRectangle *)malloc(sizeof(XRectangle) * num);
|
||||
}
|
||||
if (rectangles == NULL)
|
||||
WonX_Error("XDisplay_DrawLCDWindow", "Cannot allocate memory.");
|
||||
|
||||
/* ここの処理はホットスポットになるので,のちのちにチューニングすること */
|
||||
|
||||
for (y = 0; y < ww_lcd_height; y++) {
|
||||
py = (y * x_display->height) / ww_lcd_height;
|
||||
ph = (y+1) * x_display->height / ww_lcd_height- py;
|
||||
for (x = 0; x < ww_lcd_width; x++) {
|
||||
if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
|
||||
continue;
|
||||
}
|
||||
pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
|
||||
px = (x * x_display->width ) / ww_lcd_width;
|
||||
rectangles[pixel][n[pixel]].x = px;
|
||||
rectangles[pixel][n[pixel]].y = py;
|
||||
rectangles[pixel][n[pixel]].width =
|
||||
(x+1) * x_display->width / ww_lcd_width - px;
|
||||
rectangles[pixel][n[pixel]].height = ph;
|
||||
|
||||
/* 隣接してる同色のピクセルは,極力いっしょに描画する */
|
||||
/* 隣接してる同色のピクセルは,極力いっしょに描画する */
|
||||
x++;
|
||||
while ( (x < ww_lcd_width) &&
|
||||
(pixel == WWLCDPanel_GetPixel(ww_lcd_panel, x, y)) &&
|
||||
(WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) ) {
|
||||
rectangles[pixel][n[pixel]].width =
|
||||
(x+1) * x_display->width / ww_lcd_width - px;
|
||||
x++;
|
||||
while ( (x < ww_lcd_width) &&
|
||||
(pixel == WWLCDPanel_GetPixel(ww_lcd_panel, x, y)) &&
|
||||
(WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) ) {
|
||||
rectangles[pixel][n[pixel]].width =
|
||||
(x+1) * x_display->width / ww_lcd_width - px;
|
||||
x++;
|
||||
}
|
||||
x--;
|
||||
|
||||
n[pixel]++;
|
||||
}
|
||||
x--;
|
||||
|
||||
n[pixel]++;
|
||||
}
|
||||
}
|
||||
|
||||
for (pixel = 0; pixel < 16; pixel++) {
|
||||
if (n[pixel] > 0) {
|
||||
XFillRectangles(x_display->display,
|
||||
x_display->lcd_pixmap,
|
||||
x_display->color_gc[pixel],
|
||||
rectangles[pixel], n[pixel]);
|
||||
}
|
||||
for (pixel = 0; pixel < 16; pixel++) {
|
||||
if (n[pixel] > 0) {
|
||||
XFillRectangles(x_display->display,
|
||||
x_display->lcd_pixmap,
|
||||
x_display->color_gc[pixel],
|
||||
rectangles[pixel], n[pixel]);
|
||||
}
|
||||
|
||||
for (pixel = 0; pixel < 16; pixel++) {
|
||||
free(rectangles[pixel]);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case COLOR_MODE_4COLOR:
|
||||
case COLOR_MODE_16COLOR:
|
||||
case COLOR_MODE_16PACKED:
|
||||
|
||||
database = XDisplay_GetColorGCDatabase(x_display);
|
||||
|
||||
for (y = 0; y < ww_lcd_height; y++) {
|
||||
py = (y * x_display->height) / ww_lcd_height;
|
||||
ph = (y+1) * x_display->height / ww_lcd_height- py;
|
||||
for (x = 0; x < ww_lcd_width; x++) {
|
||||
if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
|
||||
continue;
|
||||
}
|
||||
pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
|
||||
px = (x * x_display->width ) / ww_lcd_width;
|
||||
rectangle.x = px;
|
||||
rectangle.y = py;
|
||||
rectangle.width = (x+1) * x_display->width / ww_lcd_width - px;
|
||||
rectangle.height = ph;
|
||||
|
||||
/* 隣接してる同色のピクセルは,極力いっしょに描画する */
|
||||
x++;
|
||||
while ( (x < ww_lcd_width) &&
|
||||
(pixel == WWLCDPanel_GetPixel(ww_lcd_panel, x, y)) &&
|
||||
(WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) ) {
|
||||
rectangle.width =
|
||||
(x+1) * x_display->width / ww_lcd_width - px;
|
||||
x++;
|
||||
}
|
||||
x--;
|
||||
|
||||
red = (pixel >> 8) & 0xf;
|
||||
green = (pixel >> 4) & 0xf;
|
||||
blue = (pixel >> 0) & 0xf;
|
||||
|
||||
red = (red == 15) ? 65535 : red * 4096;
|
||||
green = (green == 15) ? 65535 : green * 4096;
|
||||
blue = (blue == 15) ? 65535 : blue * 4096;
|
||||
|
||||
x_color_gc = XColorGC_CreateFromRGB(database, red, green, blue);
|
||||
gc = XColorGC_GetGC(x_color_gc);
|
||||
|
||||
XFillRectangle(x_display->display,
|
||||
x_display->lcd_pixmap,
|
||||
gc,
|
||||
rectangle.x,
|
||||
rectangle.y,
|
||||
rectangle.width,
|
||||
rectangle.height);
|
||||
XColorGC_Destroy(x_color_gc);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
WonX_Error("XDisplay_DrawLCDWindow", "Unknown color mode.");
|
||||
}
|
||||
|
||||
XCopyArea(x_display->display, x_display->lcd_pixmap,
|
||||
x_display->lcd_window, x_display->copy_gc,
|
||||
0, 0, x_display->width, x_display->height, 0, 0);
|
||||
0, 0, x_display->width, x_display->height, 0, 0);
|
||||
|
||||
WWLCDPanel_ResetAllDraw(ww_lcd_panel);
|
||||
WWLCDPanel_ReverseCurrent(ww_lcd_panel);
|
||||
|
||||
XDisplay_Sync(x_display);
|
||||
|
||||
return (0);
|
||||
}
|
||||
for (pixel = 0; pixel < 16; pixel++) {
|
||||
free(rectangles[pixel]);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* GC の作成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
GC XDisplay_CreateGC(XDisplay x_display)
|
||||
{
|
||||
GC gc;
|
||||
gc = XCreateGC(x_display->display, x_display->lcd_window, 0, 0);
|
||||
return (gc);
|
||||
}
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* GC の解放 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int XDisplay_DestroyGC(XDisplay x_display, GC gc)
|
||||
{
|
||||
XFreeGC(x_display->display, gc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
45
XDisplay.h
45
XDisplay.h
@ -5,6 +5,10 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include "sys/key.h"
|
||||
|
||||
#include "WWLCDPanel.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
@ -12,32 +16,11 @@
|
||||
typedef struct _XDisplay * XDisplay;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ヘッダファイルのインクルード */
|
||||
/* メンバ関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
#include "wonx/key.h"
|
||||
|
||||
#include "WWDisplay.h"
|
||||
#include "WWLCDPanel.h"
|
||||
#include "XColorGC.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* メンバ関数の宣言 */
|
||||
/*****************************************************************************/
|
||||
|
||||
Display * XDisplay_GetDisplay(XDisplay x_display);
|
||||
Colormap XDisplay_GetColormap(XDisplay x_display);
|
||||
|
||||
XColorGCDatabase XDisplay_GetColorGCDatabase(XDisplay x_display);
|
||||
|
||||
unsigned int XDisplay_GetKeyPress(XDisplay x_display);
|
||||
|
||||
int XDisplay_GetLCDDrawLevel(XDisplay d);
|
||||
int XDisplay_SetLCDDrawLevel(XDisplay d, int level);
|
||||
int XDisplay_LCDDrawLevelDown(XDisplay d);
|
||||
int XDisplay_LCDDrawLevelUp( XDisplay d);
|
||||
int XDisplay_GetLCDDraw(XDisplay x_display);
|
||||
|
||||
int XDisplay_GetColorMapPrint(XDisplay d);
|
||||
int XDisplay_GetPalettePrint(XDisplay d);
|
||||
@ -70,26 +53,12 @@ XDisplay XDisplay_Destroy(XDisplay x_display);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int XDisplay_Sync(XDisplay x_display);
|
||||
int XDisplay_Flush(XDisplay x_display);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* 描画 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int XDisplay_DrawLCDWindow(XDisplay x_display, WWDisplay ww_display,
|
||||
WWLCDPanel ww_lcd_panel);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* GC の作成 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
GC XDisplay_CreateGC(XDisplay x_display);
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/* GC の解放 */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
||||
int XDisplay_DestroyGC(XDisplay x_display, GC gc);
|
||||
int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
|
||||
17
XDisplayP.h
17
XDisplayP.h
@ -9,17 +9,13 @@
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Intrinsic.h>
|
||||
#include <X11/StringDefs.h>
|
||||
#include <X11/Shell.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <X11/keysym.h>
|
||||
|
||||
/*
|
||||
* X のフォントを利用する.
|
||||
*/
|
||||
#define USE_X_FONT
|
||||
|
||||
/*****************************************************************************/
|
||||
/* クラスの定義 */
|
||||
/*****************************************************************************/
|
||||
@ -41,22 +37,17 @@ typedef struct _XDisplay {
|
||||
Pixmap lcd_pixmap;
|
||||
|
||||
GC copy_gc;
|
||||
GC color_gc[16]; /* 白黒表示用のGC */
|
||||
GC color_gc[16];
|
||||
|
||||
/* 4096色表示用のGCのデータベース(XFireworks から流用) */
|
||||
XColorGCDatabase color_gc_database;
|
||||
|
||||
#ifdef USE_X_FONT
|
||||
/* テキストスクリーンへの文字表示用のフォント */
|
||||
Font font;
|
||||
GC font_gc;
|
||||
#endif
|
||||
|
||||
/* キーの状態 */
|
||||
unsigned int key_press;
|
||||
|
||||
/* LCD描画のレベル */
|
||||
int lcd_draw_level;
|
||||
/* LCD描画のフラグ */
|
||||
int lcd_draw;
|
||||
|
||||
/* ダンプ出力のフラグ */
|
||||
int color_map_print;
|
||||
|
||||
18
bank.c
18
bank.c
@ -5,9 +5,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wonx/bank.h"
|
||||
#include "sys/bank.h"
|
||||
|
||||
#include "WonX.h"
|
||||
#include "Wonx.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 高垂簇眶の年盗 */
|
||||
@ -39,39 +39,39 @@ int bank_get_map(int bank)
|
||||
return (0);
|
||||
}
|
||||
|
||||
unsigned char bank_read_byte(int bank, unsigned int off)
|
||||
unsigned char bank_read_byte(int bank, unsigned int offset)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
void bank_write_byte(int bank, unsigned int off, unsigned int data)
|
||||
void bank_write_byte(int bank, unsigned int offset, unsigned int data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int bank_read_word(int bank, unsigned int off)
|
||||
unsigned int bank_read_word(int bank, unsigned int offset)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
void bank_write_word(int bank, unsigned int off, unsigned int data)
|
||||
void bank_write_word(int bank, unsigned int offset, unsigned int data)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void bank_read_block(int bank, unsigned int off,
|
||||
void bank_read_block(int bank, unsigned int offset,
|
||||
void * buffer, unsigned int size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void bank_write_block(int bank, unsigned int off,
|
||||
void bank_write_block(int bank, unsigned int offset,
|
||||
void * buffer, unsigned int size)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void bank_fill_block(int bank, unsigned int off,
|
||||
void bank_fill_block(int bank, unsigned int offset,
|
||||
unsigned int size, unsigned int data)
|
||||
{
|
||||
return;
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ -x ./filters.pl ] ; then
|
||||
./filters.pl "qkc -e -u" ./sys2wonx.pl ./int2sint.pl -f $*
|
||||
else
|
||||
filters.pl "qkc -e -u" sys2wonx.pl int2sint.pl -f $*
|
||||
fi
|
||||
525
comm.c
525
comm.c
@ -4,20 +4,10 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "wonx/comm.h"
|
||||
#include "sys/comm.h"
|
||||
|
||||
#include "wonx_configure.h"
|
||||
#include "WonX.h"
|
||||
#include "WonXSerialPort.h"
|
||||
#include "WWSerialPort.h"
|
||||
#include "UNIXSerialPort.h"
|
||||
#include "etc.h"
|
||||
#include "Wonx.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 高垂簇眶の年盗 */
|
||||
@ -40,546 +30,69 @@
|
||||
*/
|
||||
|
||||
void comm_open(void)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_open() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
if (WWSerialPort_IsOpened(ww_serial_port))
|
||||
WonX_Warning("comm_open", "WW serial port has already opened.");
|
||||
WWSerialPort_Open(ww_serial_port);
|
||||
|
||||
if (UNIXSerialPort_IsOpened(unix_serial_port))
|
||||
WonX_Warning("comm_open", "UNIX serial port has already opened.");
|
||||
UNIXSerialPort_Open(unix_serial_port);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_open() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
{}
|
||||
|
||||
void comm_close(void)
|
||||
{}
|
||||
|
||||
int comm_send_char(unsigned char byte)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_close() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
if (!WWSerialPort_IsClosed(ww_serial_port))
|
||||
WonX_Warning("comm_close", "WW serial port is not opened.");
|
||||
WWSerialPort_Close(ww_serial_port);
|
||||
|
||||
if (!UNIXSerialPort_IsClosed(unix_serial_port))
|
||||
WonX_Warning("comm_close", "UNIX serial port is not opened.");
|
||||
UNIXSerialPort_Close(unix_serial_port);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_close() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static void comm_output(unsigned char c)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
UNIXSerialPort_SendCharacter(unix_serial_port, c);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int comm_input(int timeout)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
int c;
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
c = UNIXSerialPort_ReceiveCharacter(unix_serial_port,
|
||||
WONX_SERIAL_PORT_TIMETICKS * timeout);
|
||||
|
||||
return (c);
|
||||
}
|
||||
|
||||
int comm_send_char(unsigned char c)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_send_char() : character = \'");
|
||||
wonx_print_character(stdout, c);
|
||||
printf("\'\n");
|
||||
fflush(stdout);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
if (!WWSerialPort_IsOpened(ww_serial_port))
|
||||
WonX_Error("comm_send_char", "WW serial port is not opened.");
|
||||
if (!UNIXSerialPort_IsOpened(unix_serial_port))
|
||||
WonX_Error("comm_send_char", "UNIX serial port is not opened.");
|
||||
|
||||
printf("output to serial port : \"");
|
||||
comm_output(c);
|
||||
printf("\"\n");
|
||||
fflush(stdout);
|
||||
ret = 0;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_send_char() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int comm_receive_char(void)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
int c;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_receive_char() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
if (!WWSerialPort_IsOpened(ww_serial_port))
|
||||
WonX_Error("comm_receive_char", "WW serial port is not opened.");
|
||||
if (!UNIXSerialPort_IsOpened(unix_serial_port))
|
||||
WonX_Error("comm_receive_char", "UNIX serial port is not opened.");
|
||||
|
||||
c = comm_input(WWSerialPort_GetReceiveTimeout(ww_serial_port));
|
||||
|
||||
if (c == -1) ret = ERR_SIO_TIMEOUT;
|
||||
else ret = c;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_receive_char() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int comm_receive_with_timeout(int timeout)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
int c;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_receive_with_timeout() : timeout = %d\n", timeout);
|
||||
fflush(stdout);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
if (!WWSerialPort_IsOpened(ww_serial_port))
|
||||
WonX_Error("comm_receive_with_timeout", "WW serial port is not opened.");
|
||||
if (!UNIXSerialPort_IsOpened(unix_serial_port))
|
||||
WonX_Error("comm_receive_with_timeout", "UNIX serial port is not opened.");
|
||||
|
||||
c = comm_input(timeout);
|
||||
|
||||
if (c == -1) ret = ERR_SIO_TIMEOUT;
|
||||
else ret = c;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_receive_with_timeout() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int comm_send_string(char * string)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
int ret;
|
||||
char * p;
|
||||
int i;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_send_string() : string = \"");
|
||||
for (p = string; *p != '\0'; p++) wonx_print_character(stdout, *p);
|
||||
printf("\"\n");
|
||||
fflush(stdout);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
if (!WWSerialPort_IsOpened(ww_serial_port))
|
||||
WonX_Error("comm_send_string", "WW serial port is not opened.");
|
||||
if (!UNIXSerialPort_IsOpened(unix_serial_port))
|
||||
WonX_Error("comm_send_string", "UNIX serial port is not opened.");
|
||||
|
||||
printf("output to serial port : \"");
|
||||
for (i = 0; string[i]; i++) {
|
||||
comm_output(string[i]);
|
||||
}
|
||||
printf("\"\n");
|
||||
fflush(stdout);
|
||||
ret = 0;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_send_string() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int comm_send_block(void * buffer, int size)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_send_block() : buffer = %p, size = %d\n", buffer, size);
|
||||
fflush(stdout);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
if (!WWSerialPort_IsOpened(ww_serial_port))
|
||||
WonX_Error("comm_send_block", "WW serial port is not opened.");
|
||||
if (!UNIXSerialPort_IsOpened(unix_serial_port))
|
||||
WonX_Error("comm_send_block", "UNIX serial port is not opened.");
|
||||
|
||||
printf("output to serial port : \"");
|
||||
for (i = 0; i < size; i++) {
|
||||
comm_output(((char *)buffer)[i]);
|
||||
}
|
||||
printf("\"\n");
|
||||
fflush(stdout);
|
||||
ret = 0;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_send_block() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int comm_receive_block(void * buffer, int size)
|
||||
{
|
||||
WonXSerialPort wonx_serial_port;
|
||||
WWSerialPort ww_serial_port;
|
||||
UNIXSerialPort unix_serial_port;
|
||||
int ret;
|
||||
int c;
|
||||
int i;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_receive_block() : buffer = %p, size = %d\n",
|
||||
buffer, size);
|
||||
fflush(stdout);
|
||||
|
||||
wonx_serial_port = WonX_GetWonXSerialPort();
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
|
||||
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
|
||||
|
||||
if (!WWSerialPort_IsOpened(ww_serial_port))
|
||||
WonX_Error("comm_receive_block", "WW serial port is not opened.");
|
||||
if (!UNIXSerialPort_IsOpened(unix_serial_port))
|
||||
WonX_Error("comm_receive_block", "UNIX serial port is not opened.");
|
||||
|
||||
ret = 0;
|
||||
for (i = 0; i < size; i++) {
|
||||
c = comm_input(WWSerialPort_GetReceiveTimeout(ww_serial_port));
|
||||
if (c == -1) {
|
||||
ret = ERR_SIO_TIMEOUT;
|
||||
break;
|
||||
}
|
||||
((char *)buffer)[i] = c;
|
||||
}
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_receive_block() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void comm_set_timeout(int recv_timeout, int send_timeout)
|
||||
void comm_set_timeout(int receive_timeout, int send_timeout)
|
||||
{
|
||||
WWSerialPort ww_serial_port;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_set_timeout() : receive_timeout = %d, send_timeout = %d\n", recv_timeout, send_timeout);
|
||||
fflush(stdout);
|
||||
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
|
||||
|
||||
WWSerialPort_SetReceiveTimeout(ww_serial_port, recv_timeout);
|
||||
WWSerialPort_SetSendTimeout( ww_serial_port, send_timeout);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_set_timeout() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void comm_set_baudrate(int baudrate)
|
||||
void comm_set_baudrate(int speed)
|
||||
{
|
||||
WWSerialPort ww_serial_port;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_set_baudrate() : baudrate = %d\n", baudrate);
|
||||
fflush(stdout);
|
||||
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
|
||||
|
||||
switch (baudrate) {
|
||||
case COMM_SPEED_9600: WWSerialPort_SetBaudrate9600( ww_serial_port); break;
|
||||
case COMM_SPEED_38400: WWSerialPort_SetBaudrate38400(ww_serial_port); break;
|
||||
default: WonX_Error("comm_set_baudrate", "Invalid baudrate");
|
||||
}
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_set_baudrate() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int comm_get_baudrate(void)
|
||||
{
|
||||
WWSerialPort ww_serial_port;
|
||||
int ret = 0;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_get_baudrate() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
|
||||
|
||||
if (WWSerialPort_IsBaudrate9600(ww_serial_port))
|
||||
ret = COMM_SPEED_9600;
|
||||
else if (WWSerialPort_IsBaudrate38400(ww_serial_port))
|
||||
ret = COMM_SPEED_38400;
|
||||
else WonX_Error("comm_get_baudrate", "Invalid baudrate");
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_get_baudrate() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void comm_set_cancel_key(unsigned int pattern)
|
||||
{
|
||||
WWSerialPort ww_serial_port;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_set_cancel_key() : pattern = %u\n", (int)pattern);
|
||||
fflush(stdout);
|
||||
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
|
||||
|
||||
WWSerialPort_SetCancelKey(ww_serial_port, pattern);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_set_cancel_key() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int comm_get_cancel_key(void)
|
||||
{
|
||||
WWSerialPort ww_serial_port;
|
||||
unsigned int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_get_cancel_key() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
|
||||
|
||||
/* ここに処理を書く */
|
||||
ret = WWSerialPort_GetCancelKey(ww_serial_port);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_get_cancel_key() : return value = %u\n", (int)ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int comm_xmodem(void * xmodem)
|
||||
{
|
||||
WWSerialPort ww_serial_port;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : comm_xmodem() : xmodem = %p\n", xmodem);
|
||||
fflush(stdout);
|
||||
|
||||
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
|
||||
|
||||
/* 未サポート */
|
||||
printf("call : comm_xmodem() : not supported.\n");
|
||||
fflush(stdout);
|
||||
ret = 0;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : comm_xmodem() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
|
||||
15
configure.h
Normal file
15
configure.h
Normal file
@ -0,0 +1,15 @@
|
||||
/* configure.h for configuration of xfireworks */
|
||||
|
||||
#ifndef _WONX_CONFIGURE_H_INCLUDED_
|
||||
#define _WONX_CONFIGURE_H_INCLUDED_
|
||||
|
||||
/* Wonx でのタイマ割り込みの周期(単位はマイクロ秒) */
|
||||
#define WONX_TIMER_INTERVAL 100000 /* 0.1 秒*/
|
||||
|
||||
/* HBLANK, VBLANK 割り込みのデフォルトのインターバル(0.1秒単位) */
|
||||
#define WONX_HBLANK_INTERVAL ( 3 * 10) /* 3 秒毎 */
|
||||
#define WONX_VBLANK_INTERVAL (20 * 10) /* 20 秒毎 */
|
||||
|
||||
#endif /* _WONX_CONFIGURE_H_INCLUDED_ */
|
||||
|
||||
/* End of configure.h */
|
||||
44
etc.c
44
etc.c
@ -1,44 +1,26 @@
|
||||
#include "etc.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ¥¨¥é¡¼½èÍý */
|
||||
/*===========================================================================*/
|
||||
|
||||
int Error(char * funcname, char * message)
|
||||
{
|
||||
fprintf(stderr, "%s(): %s\n", funcname, message);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* "true", "false" の矢机误を手す */
|
||||
/*===========================================================================*/
|
||||
|
||||
char * wonx_true_false(int b)
|
||||
char * true_false(int b)
|
||||
{
|
||||
char * s[] = {"false", "true"};
|
||||
b = b ? 1 : 0;
|
||||
return (s[b]);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 文字の出力 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int wonx_print_character(FILE * fp, unsigned char c)
|
||||
{
|
||||
if (c == '\n') fprintf(fp, "\\n");
|
||||
else if (c == '\r') fprintf(fp, "\\r");
|
||||
else if (c == '\t') fprintf(fp, "\\t");
|
||||
else if (c == '\"') fprintf(fp, "\\\"");
|
||||
else if (c == '\'') fprintf(fp, "\\\'");
|
||||
else if (c == '\\') fprintf(fp, "\\\\");
|
||||
else if (c == ' ' ) fprintf(fp, "\\s");
|
||||
else if (isprint(c)) fputc(c, fp);
|
||||
else fprintf(fp, "^%02x", (int)c);
|
||||
fflush(fp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 10進→16進文字への変換 */
|
||||
/*===========================================================================*/
|
||||
|
||||
char wonx_dec_to_hex(int dec)
|
||||
{
|
||||
static char * dec2hex = "0123456789abcdef";
|
||||
return (dec2hex[dec]);
|
||||
}
|
||||
|
||||
|
||||
22
etc.h
22
etc.h
@ -1,25 +1,17 @@
|
||||
#ifndef _etc_h_INCLUDED_
|
||||
#define _etc_h_INCLUDED_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/*===========================================================================*/
|
||||
/* エラー処理 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int Error(char * funcname, char * message);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* "true", "false" の矢机误を手す */
|
||||
/*===========================================================================*/
|
||||
|
||||
char * wonx_true_false(int b);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 文字の出力 */
|
||||
/*===========================================================================*/
|
||||
|
||||
int wonx_print_character(FILE * fp, unsigned char c);
|
||||
|
||||
/*===========================================================================*/
|
||||
/* 10進→16進文字への変換 */
|
||||
/*===========================================================================*/
|
||||
|
||||
char wonx_dec_to_hex(int dec);
|
||||
char * true_false(int b);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
105
fcntl.c
105
fcntl.c
@ -1,105 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#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 するようにする.
|
||||
*/
|
||||
|
||||
/*
|
||||
* タイマの一時停止の2重解除の問題が出てくるので,
|
||||
* 互換関数から互換関数を呼んではいけない.
|
||||
* (一時停止はネストされるが,いちおう)
|
||||
* 似たような処理をする関数の場合は,必ず 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. */
|
||||
/*****************************************************************************/
|
||||
20
filters.perl
20
filters.perl
@ -1,20 +0,0 @@
|
||||
#!PATH_TO_PERL
|
||||
|
||||
while ($_ = shift(@ARGV)) {
|
||||
if ($_ eq "-f" ) { last; }
|
||||
if ($_ eq "-file") { last; }
|
||||
$filters = "$filters | $_";
|
||||
}
|
||||
|
||||
while ($filename = shift(@ARGV)) {
|
||||
$command = "cat $filename$filters > $filename.tmp";
|
||||
print STDERR "$command\n";
|
||||
$ret = system($command);
|
||||
if ($ret != 0) { die "Command not found. Install perl scripts.\n"; }
|
||||
$command = "mv $filename.tmp $filename";
|
||||
print STDERR "$command\n";
|
||||
$ret = system($command);
|
||||
if ($ret != 0) { die "Command not found.\n"; }
|
||||
}
|
||||
|
||||
exit (0);
|
||||
26
findperl.sh
26
findperl.sh
@ -1,26 +0,0 @@
|
||||
#!/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
|
||||
@ -1,21 +0,0 @@
|
||||
#!PATH_TO_PERL
|
||||
|
||||
while (<STDIN>) {
|
||||
s/([\s;\}\/])uint(\s)/$1unsigned int$2/g;
|
||||
s/^uint(\s)/unsigned int$1/g;
|
||||
|
||||
s/([\s;\}\/\(\)])long(\s+)int([\s\)\+\-\*\/])/$1_WONX_LONG_$2_WONX_INT_$3/g;
|
||||
s/([\s;\}\/\(\)])short(\s+)int([\s\)\+\-\*\/])/$1_WONX_SHORT_$2_WONX_INT_$3/g;
|
||||
s/^long(\s+)int([\s\)\+\-\*\/])/_WONX_LONG_$1_WONX_INT_$2/g;
|
||||
s/^short(\s+)int([\s\)\+\-\*\/])/_WONX_SHORT_$1_WONX_INT_$2/g;
|
||||
|
||||
s/([\s;\}\/\(\)])int([\s\)\+\-\*\/])/$1_WONX_SHORT_ _WONX_INT_$2/g;
|
||||
s/^int([\s\)\+\-\*\/])/_WONX_SHORT_ _WONX_INT_$1/g;
|
||||
|
||||
s/_WONX_LONG_/long/g;
|
||||
s/_WONX_SHORT_/short/g;
|
||||
s/_WONX_INT_/int/g;
|
||||
print $_;
|
||||
}
|
||||
|
||||
exit (0);
|
||||
114
key.c
114
key.c
@ -5,9 +5,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wonx/key.h"
|
||||
#include "sys/key.h"
|
||||
|
||||
#include "WonX.h"
|
||||
#include "Wonx.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 互換関数の定義 */
|
||||
@ -34,25 +34,24 @@ int key_press_check(void)
|
||||
XDisplay x_display;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : key_press_check() : \n"); fflush(stdout);
|
||||
printf("call : key_press_check() : "); fflush(stdout);
|
||||
|
||||
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
|
||||
XDisplay_Flush(x_display);
|
||||
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay());
|
||||
XDisplay_Sync(x_display);
|
||||
|
||||
ret = XDisplay_GetKeyPress(x_display);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Sync(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : key_press_check() : return value = 0x%04x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
@ -62,25 +61,24 @@ int key_hit_check(void)
|
||||
XDisplay x_display;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : key_hit_check() : \n"); fflush(stdout);
|
||||
printf("call : key_hit_check() : "); fflush(stdout);
|
||||
|
||||
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
|
||||
XDisplay_Flush(x_display);
|
||||
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay());
|
||||
XDisplay_Sync(x_display);
|
||||
|
||||
ret = XDisplay_GetKeyPress(x_display);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Sync(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : key_hit_check() : return value = 0x%04x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
@ -88,66 +86,53 @@ int key_hit_check(void)
|
||||
int key_wait(void)
|
||||
{
|
||||
XDisplay x_display;
|
||||
volatile int ret;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : key_wait() : \n"); fflush(stdout);
|
||||
printf("call : key_wait() : "); fflush(stdout);
|
||||
|
||||
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
|
||||
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
/*
|
||||
* 以下はホットスポットになり得るので注意!
|
||||
* key_wait() 中に割り込みを受け付けるために一時的にタイマを Unpause する.
|
||||
* タイマ割り込みのコールバック関数中でキー入力の割り込み処理も行われるため,
|
||||
* do~while ループ中での XDisplay_Flush() は必要無し.
|
||||
*/
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
/*
|
||||
* タイマ割り込みによるキー入力処理に期待していったん Unpause するため,
|
||||
* 再び Pause するまでは XDisplay の描画関連の関数などを呼び出しては
|
||||
* いけないので注意.
|
||||
* (XDisplay_GetKeyPress() は単に変数の値を返すだけなので問題無い)
|
||||
*/
|
||||
|
||||
ret = 0;
|
||||
do {
|
||||
#if 0 /* タイマを Unpause しない場合には必要 */
|
||||
XDisplay_Flush(x_display);
|
||||
#endif
|
||||
XDisplay_Sync(x_display);
|
||||
ret = XDisplay_GetKeyPress(x_display);
|
||||
} while (ret == 0);
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Sync(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : key_wait() : return value = 0x%04x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void key_set_repeat(int rate, int delay)
|
||||
{
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : key_set_repeat() : rate = %d, delay = %d\n", rate, delay);
|
||||
printf("call : key_set_repeat() : rate = %d, delay = %d, ", rate, delay);
|
||||
fflush(stdout);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Sync(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : key_set_repeat() : return value = none\n"); fflush(stdout);
|
||||
printf("return value = none\n"); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -156,22 +141,21 @@ int key_get_repeat(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : key_get_repeat() : \n"); fflush(stdout);
|
||||
printf("call : key_get_repeat() : "); fflush(stdout);
|
||||
|
||||
ret = 0;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Sync(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : key_get_repeat() : return value = 0x%04x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
@ -181,26 +165,24 @@ int key_hit_check_with_repeat(void)
|
||||
XDisplay x_display;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : key_hit_check_with_repeat() : \n"); fflush(stdout);
|
||||
printf("call : key_hit_check_with_repeat() : "); fflush(stdout);
|
||||
|
||||
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
|
||||
XDisplay_Flush(x_display);
|
||||
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay());
|
||||
XDisplay_Sync(x_display);
|
||||
|
||||
ret = XDisplay_GetKeyPress(x_display);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Sync(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : key_hit_check_with_repeat() : return value = 0x%04x\n",
|
||||
(int)ret);
|
||||
fflush(stdout);
|
||||
printf("return value = 0x%04x\n", (int)ret); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
327
libwwc.c
327
libwwc.c
@ -1,327 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wonx_configure.h"
|
||||
|
||||
#include "wonx/libwwc.h"
|
||||
|
||||
#include "WonX.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 互換関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*
|
||||
* void * でデータを渡す関数は,型を間違えるバグが入る可能性があるので,
|
||||
* void * を適切な型に置き換えてある.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Xサーバとの同期の整合性がとれなくなるなどの問題が考えられるので,
|
||||
* 互換関数の内部は UNIXTimer_Pause(), UNIXTimer_Unpause() でくくり,
|
||||
* タイマ割り込みを一時停止して処理を行う.また,unpause するまえに,
|
||||
* かならず sync するようにする.
|
||||
*/
|
||||
|
||||
/*
|
||||
* タイマの一時停止の2重解除の問題が出てくるので,
|
||||
* 互換関数から互換関数を呼んではいけない.
|
||||
* (一時停止はネストされるが,いちおう)
|
||||
* 似たような処理をする関数の場合は,必ず static な別関数に処理をまとめ,
|
||||
* そっちを呼び出すようにすること.
|
||||
* 引数の表示の問題もあるしね.
|
||||
*/
|
||||
|
||||
unsigned int wwc_set_color_mode(unsigned int mode)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
unsigned int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : wwc_set_color_mode() : mode = 0x%04x\n", (int)mode);
|
||||
fflush(stdout);
|
||||
|
||||
switch (mode) {
|
||||
case COLOR_MODE_GRAYSCALE :
|
||||
case COLOR_MODE_4COLOR :
|
||||
case COLOR_MODE_16COLOR :
|
||||
case COLOR_MODE_16PACKED :
|
||||
break;
|
||||
default :
|
||||
WonX_Error("wwc_set_color_mode", "unknown color mode.");
|
||||
}
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
|
||||
ret = WWDisplay_SetColorMode(ww_display, mode);
|
||||
|
||||
/* 次回の描画時には,全描画する */
|
||||
WWLCDPanel_SetAllDraw(WWDisplay_GetLCDPanel(ww_display));
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : wwc_set_color_mode() : return value = 0x%04x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
unsigned int wwc_get_color_mode(void)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
unsigned int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : wwc_get_color_mode() : \n"); fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
|
||||
ret = WWDisplay_GetColorMode(ww_display);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : wwc_get_color_mode() : return value = 0x%04x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void wwc_palette_set_color(unsigned int palette_num, unsigned int color_num, unsigned int rgb)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWPalette ww_palette;
|
||||
unsigned short int red, green, blue;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : wwc_palette_set_color() : palette_num = %u, color_num = %u, rgb = 0x%04x\n",
|
||||
(int)palette_num, (int)color_num, (int)rgb);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_palette = WWDisplay_GetPalette(ww_display, palette_num);
|
||||
red = (rgb >> 8) & 0x0f;
|
||||
green = (rgb >> 4) & 0x0f;
|
||||
blue = (rgb >> 0) & 0x0f;
|
||||
WWPalette_SetRed( ww_palette, color_num, red );
|
||||
WWPalette_SetGreen(ww_palette, color_num, green);
|
||||
WWPalette_SetBlue( ww_palette, color_num, blue );
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : wwc_palette_set_color() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int wwc_palette_get_color(unsigned int palette_num, unsigned int color_num)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWPalette ww_palette;
|
||||
unsigned short int red, green, blue;
|
||||
unsigned short int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : wwc_palette_get_color() : palette_num = %u, color_num = %u\n",
|
||||
(int)palette_num, (int)color_num);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_palette = WWDisplay_GetPalette(ww_display, palette_num);
|
||||
|
||||
red = WWPalette_GetRed( ww_palette, color_num);
|
||||
green = WWPalette_GetGreen(ww_palette, color_num);
|
||||
blue = WWPalette_GetBlue( ww_palette, color_num);
|
||||
|
||||
ret = (red << 8) | (green << 4) | (blue << 0);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : wwc_palette_get_color() : return value = 0x%04x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*
|
||||
* data は long int × 8 で 32 バイト.
|
||||
*/
|
||||
|
||||
void wwc_font_set_colordata(unsigned int number, unsigned int count,
|
||||
unsigned long int * data)
|
||||
{
|
||||
WWCharacter ww_character;
|
||||
WWDisplay ww_display;
|
||||
int i, j, n;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : wwc_font_set_colordata() : number = %u, count = %u, data = %p\n",
|
||||
(int)number, (int)count, (void *)data);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
ww_character = WWDisplay_GetCharacter(ww_display, number + i);
|
||||
for (j = 0; j < 8; j++) {
|
||||
WWCharacter_SetBitmapAsLongInt(ww_character, j, data[n]);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : wwc_font_set_colordata() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* data は long int × 8 で 32 バイト.
|
||||
*/
|
||||
|
||||
void wwc_font_get_colordata(unsigned int number, unsigned int count,
|
||||
unsigned long int * data)
|
||||
{
|
||||
WWCharacter ww_character;
|
||||
WWDisplay ww_display;
|
||||
int i, j, n;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : wwc_font_get_colordata() : number = %u, count = %u, data = %p\n",
|
||||
(int)number, (int)count, (void *)data);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
|
||||
n = 0;
|
||||
for (i = 0; i < count; i++) {
|
||||
ww_character = WWDisplay_GetCharacter(ww_display, number + i);
|
||||
for (j = 0; j < 8; j++) {
|
||||
data[n] = WWCharacter_GetBitmapAsLongInt(ww_character, j);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : wwc_font_get_colordata() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int wwc_get_hardarch(void)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
unsigned int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : wwc_get_hardarch() : \n"); fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
|
||||
ret = WONX_DEFAULT_ARCH;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : wwc_get_hardarch() : return value = %u\n", (int)ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void wwc_clear_font(void)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWCharacter ww_character;
|
||||
int i;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : wwc_clear_font() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
|
||||
for (i = 0; i < 512; i++) {
|
||||
ww_character = WWDisplay_GetCharacter(ww_display, i);
|
||||
WWCharacter_ClearAllPixels(ww_character);
|
||||
}
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : wwc_clear_font() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
@ -1,38 +0,0 @@
|
||||
SOURCES = chara.c game.c man.c mansub.c mansub2.c map.c mapsub.c menu.c monster.c picture.c player.c smac.c stage.c dsp.c etc.c
|
||||
|
||||
# コマンドラインの長さには制限があるので,長さに注意すること
|
||||
OBJS = chara.o game.o man.o mansub.o mansub2.o map.o mapsub.o menu.o monster.o picture.o player.o smac.o stage.o dsp.o etc.o main.o
|
||||
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
all : smac
|
||||
|
||||
smac : $(OBJS)
|
||||
gcc -g -o smac $(OBJS) -lwonx -lX11 -lXt -L. -L/usr/X11R6/lib
|
||||
|
||||
# xsmac
|
||||
|
||||
#smac : smac.fx
|
||||
|
||||
#smac.fx : smac.bin
|
||||
# doscmd mkfent16 smac.cf
|
||||
|
||||
#smac.bin : $(OBJS)
|
||||
# echo $(OBJS) > objs
|
||||
# doscmd lcc86 -o smac.bin -O @objs
|
||||
|
||||
.c.o : $*.c
|
||||
gcc -c $*.c -g -I.
|
||||
|
||||
clean :
|
||||
rm -f smac.fx smac.bin smac $(OBJS)
|
||||
|
||||
package : smac.fx
|
||||
rm -fR smac-b02
|
||||
mkdir -p smac-b02
|
||||
cp -R copying copyrigh readme history makefile doscmdrc *.c *.h \
|
||||
smac.bin smac.cf smac.fx pic8 \
|
||||
smac-b02
|
||||
zip -r smac-b02 smac-b02
|
||||
|
||||
xsmac :
|
||||
@ -1,36 +0,0 @@
|
||||
VERSION = WWTerm-b05
|
||||
PKGNAME = wwterm-b05
|
||||
|
||||
#OBJS = terminal.obj termlib.obj lib.obj keyboard.obj keymap.obj com.obj screen.obj escape.obj esclib.obj
|
||||
#OBJS_FULL = D:\\terminal.obj D:\\termlib.obj D:\\lib.obj D:\\keyboard.obj D:\\keymap.obj D:\\com.obj D:\\screen.obj D:\\escape.obj D:\\esclib.obj
|
||||
OBJS = terminal.o termlib.o lib.o keyboard.o keymap.o com.o screen.o escape.o esclib.o
|
||||
|
||||
#.SUFFIXES: .c .obj
|
||||
.SUFFIXES: .c .o
|
||||
|
||||
#terminal.fx : terminal.bin
|
||||
# doscmd mkfent16 D:\\terminal.cf
|
||||
|
||||
#terminal.bin : $(OBJS)
|
||||
# echo $(OBJS_FULL) > objs
|
||||
# doscmd lcc86 -O -o D:\\terminal.bin @D:\\objs
|
||||
|
||||
terminal : $(OBJS)
|
||||
$(CC) -O -o terminal $(OBJS) -L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
|
||||
|
||||
#.c.obj : $*.c
|
||||
# doscmd lcc86 -c D:\\$*.c -O -I.
|
||||
|
||||
.c.o : $*.c
|
||||
$(CC) -c $*.c -O -I.
|
||||
|
||||
clean :
|
||||
# rm -f terminal.fx terminal.bin *.obj $(PKGNAME).zip
|
||||
rm -f terminal *.o $(PKGNAME).zip
|
||||
|
||||
package : terminal.bin terminal.fx
|
||||
mkdir -p $(PKGNAME)
|
||||
rm -fR $(PKGNAME)/*
|
||||
cp COPYING COPYRIGHT OMAKE.jpn makefile \
|
||||
*.h *.c *.bin *.cf *.fx $(PKGNAME)
|
||||
zip -r $(PKGNAME) $(PKGNAME)
|
||||
23
sample1.c
23
sample1.c
@ -1,23 +0,0 @@
|
||||
#include "wonx/text.h"
|
||||
#include "wonx/key.h"
|
||||
|
||||
main()
|
||||
{
|
||||
text_screen_init();
|
||||
text_put_string(0, 1, " WonX - WonderWitch on X. ");
|
||||
text_put_string(0, 3, " This is test program ");
|
||||
text_put_string(0, 4, " for WonX. ");
|
||||
text_put_string(0, 6, " WonX is an emulator for ");
|
||||
text_put_string(0, 7, " WonderWitch on X. It is ");
|
||||
text_put_string(0, 8, " linked to program for ");
|
||||
text_put_string(0, 9, " WonderWitch and behave as ");
|
||||
text_put_string(0, 10, " WonderWitch. ");
|
||||
text_put_string(0, 12, "WonX Copyright (c) 2000-2002");
|
||||
text_put_string(0, 13, " Sakai Hiroaki. ");
|
||||
text_put_string(0, 14, " All Rights Reserved. ");
|
||||
text_put_string(0, 16, " Hit space key to exit. ");
|
||||
|
||||
key_wait();
|
||||
|
||||
bios_exit();
|
||||
}
|
||||
47
sample2.c
47
sample2.c
@ -1,47 +0,0 @@
|
||||
#include "wonx/disp.h"
|
||||
#include "wonx/key.h"
|
||||
|
||||
static unsigned char clear[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
static unsigned char block[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
|
||||
main()
|
||||
{
|
||||
int x, y, f, k;
|
||||
|
||||
display_control(DCM_SCR2 | DCM_SPR);
|
||||
|
||||
lcd_set_color(0, 0xffff);
|
||||
palette_set_color(0, 0);
|
||||
palette_set_color(8, (0xf << 12));
|
||||
|
||||
font_set_color(0x03);
|
||||
|
||||
font_set_monodata(0, 1, clear);
|
||||
font_set_monodata(1, 1, block);
|
||||
|
||||
sprite_set_char(0,
|
||||
CFM_SPR_UPPER |
|
||||
((0 << 9) & CFM_SPR_PALETTE) |
|
||||
(1 & CFM_FONT)
|
||||
);
|
||||
|
||||
sprite_set_range(0, 1);
|
||||
|
||||
x = 14;
|
||||
y = 9;
|
||||
f = 0;
|
||||
|
||||
while (!f) {
|
||||
sprite_set_location(0, x * 8, y * 8);
|
||||
|
||||
k = key_hit_check();
|
||||
if (k & KEY_START) f = 1;
|
||||
if (k & KEY_A) f = 1;
|
||||
if ((k & KEY_LEFT1) && (x > 0)) x--;
|
||||
if ((k & KEY_RIGHT1) && (x < LCD_PIXEL_WIDTH/8 - 1)) x++;
|
||||
if ((k & KEY_UP1) && (y > 0)) y--;
|
||||
if ((k & KEY_DOWN1) && (y < LCD_PIXEL_HEIGHT/8 - 1)) y++;
|
||||
}
|
||||
|
||||
bios_exit();
|
||||
}
|
||||
35
sample3.c
35
sample3.c
@ -1,35 +0,0 @@
|
||||
#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();
|
||||
}
|
||||
53
service.c
53
service.c
@ -1,53 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "wonx/service.h"
|
||||
|
||||
#include "WonX.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ダミー関数の定義 */
|
||||
/*****************************************************************************/
|
||||
|
||||
int _asm_inline(char * code) { return (0); }
|
||||
int _asm_int(char * code, int ax) { return (0); }
|
||||
int _asm_intb(char * code, int ax, unsigned char bl) { return (0); }
|
||||
int _asm_intbb(char * code, int ax, unsigned char bl, unsigned char cl) { return (0); }
|
||||
int _asm_intw(char * code, int ax, int bx) { return (0); }
|
||||
int _asm_intww(char * code, int ax, int bx, int cx) { return (0); }
|
||||
int _asm_intwww(char * code, int ax, int bx, int cx, int dx) { return (0); }
|
||||
int _asm_intwwww(char * code, int ax, int bx, int cx, int dx, int si) { return (0); }
|
||||
int _asm_intwp(char * code, int ax, int bx, int (*dummy)(void), void * dx) { return (0); }
|
||||
int _asm_intwwp(char * code, int ax, int bx, int cx, void * dx) { return (0); }
|
||||
int _asm_intwwwp(char * code, int ax, int bx, int cx, int dx, void * si) { return (0); }
|
||||
int _asm_intwfp(char * code, int ax, int bx, void * dsdx) { return (0); }
|
||||
int _asm_intfp(char * code, int ax, void * bxdx) { return (0); }
|
||||
|
||||
long int _asm_intl(char * code, int ax) { return (0); }
|
||||
long int _asm_intlw(char * code, int ax, int bx) { return (0); }
|
||||
long int _asm_intlww(char * code, int ax, int bx, int cx) { return (0); }
|
||||
long int _asm_intlwww(char * code, int ax, int bx, int cx, int dx) { return (0); }
|
||||
long int _asm_intlwwww(char * code, int ax, int bx, int cx, int dx, int si) { return (0); }
|
||||
long int _asm_intlwp(char * code, int ax, int bx, int (*dummy)(void), void * dx) { return (0); }
|
||||
long int _asm_intlwwp(char * code, int ax, int bx, int cx, void * dx) { return (0); }
|
||||
long int _asm_intlwwwp(char * code, int ax, int bx, int cx, int dx, void * si) { return (0); }
|
||||
long int _asm_intlwfp(char * code, int ax, int bx, void * dsdx) { return (0); }
|
||||
|
||||
void bios_exit()
|
||||
{
|
||||
printf("call : bios_exit() : \n");
|
||||
fflush(stdout);
|
||||
if (WonX_IsCreated()) WonX_Destroy();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* ここまで */
|
||||
/*****************************************************************************/
|
||||
|
||||
/*****************************************************************************/
|
||||
/* End of File. */
|
||||
/*****************************************************************************/
|
||||
BIN
smac-b02.zip
BIN
smac-b02.zip
Binary file not shown.
4
sound.c
4
sound.c
@ -5,9 +5,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wonx/sound.h"
|
||||
#include "sys/sound.h"
|
||||
|
||||
#include "WonX.h"
|
||||
#include "Wonx.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 高垂簇眶の年盗 */
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
#!PATH_TO_PERL
|
||||
|
||||
use FileHandle;
|
||||
|
||||
while (<STDIN>) {
|
||||
if (/output to serial port : /) {
|
||||
($string) = /output to serial port : \"(.*)\"\n$/;
|
||||
$string =~ s/\\n/\n/g;
|
||||
$string =~ s/\\r/\n/g;
|
||||
$string =~ s/\\t/\t/g;
|
||||
$string =~ s/\\\"/\"/g;
|
||||
$string =~ s/\\\'/\'/g;
|
||||
$string =~ s/\\\\/\\/g;
|
||||
$string =~ s/\\s/ /g;
|
||||
print "$string";
|
||||
STDOUT->autoflush();
|
||||
}
|
||||
}
|
||||
|
||||
exit (0);
|
||||
@ -1,8 +0,0 @@
|
||||
#!PATH_TO_PERL
|
||||
|
||||
while (<STDIN>) {
|
||||
s/^(\s*\#\s*include\s*)[\<\"]sys\/(.+\.h)[\>\"]/$1\"wonx\/$2\"/i;
|
||||
print $_;
|
||||
}
|
||||
|
||||
exit (0);
|
||||
67
system.c
67
system.c
@ -2,12 +2,11 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "wonx/system.h"
|
||||
#include "sys/system.h"
|
||||
|
||||
#include "WonX.h"
|
||||
#include "Wonx.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 互換関数の定義 */
|
||||
@ -29,66 +28,66 @@
|
||||
* 引数の表示の問題もあるしね.
|
||||
*/
|
||||
|
||||
void sys_interrupt_set_hook(int type, intvector_t * vector,
|
||||
intvector_t * old_vector)
|
||||
void sys_interrupt_set_hook(int type, intvector_t * intvector,
|
||||
intvector_t * last_intvector)
|
||||
{
|
||||
WWInterrupt ww_interrupt;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : sys_interrupt_set_hook() : type = %d, vector = %p, old_vector = %p\n", type, vector, old_vector);
|
||||
printf("call : sys_interrupt_set_hook() : type = %d, intvector = %p, last_intvector = %p\n", type, intvector, last_intvector);
|
||||
fflush(stdout);
|
||||
|
||||
ww_interrupt = WonXSystem_GetWWInterrupt(WonX_GetWonXSystem());
|
||||
ww_interrupt = WonxSystem_GetWWInterrupt(Wonx_GetWonxSystem());
|
||||
|
||||
old_vector->callback = WWInterrupt_GetCallback(ww_interrupt, type);
|
||||
old_vector->cs = WWInterrupt_GetCS(ww_interrupt, type);
|
||||
old_vector->ds = WWInterrupt_GetDS(ww_interrupt, type);
|
||||
last_intvector->callback = WWInterrupt_GetCallback(ww_interrupt, type);
|
||||
last_intvector->cs = WWInterrupt_GetCS(ww_interrupt, type);
|
||||
last_intvector->ds = WWInterrupt_GetDS(ww_interrupt, type);
|
||||
|
||||
WWInterrupt_SetCallback(ww_interrupt, type, vector->callback);
|
||||
WWInterrupt_SetCS(ww_interrupt, type, vector->cs);
|
||||
WWInterrupt_SetDS(ww_interrupt, type, vector->ds);
|
||||
WWInterrupt_SetCallback(ww_interrupt, type, intvector->callback);
|
||||
WWInterrupt_SetCS(ww_interrupt, type, intvector->cs);
|
||||
WWInterrupt_SetDS(ww_interrupt, type, intvector->ds);
|
||||
|
||||
printf("call : sys_interrupt_set_hook() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void sys_interrupt_reset_hook(int type, intvector_t * old_vector)
|
||||
void sys_interrupt_reset_hook(int type, intvector_t * last_intvector)
|
||||
{
|
||||
WWInterrupt ww_interrupt;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : sys_interrupt_reset_hook() : type = %d, old_vector = %p\n", type, old_vector);
|
||||
printf("call : sys_interrupt_reset_hook() : type = %d, last_intvector = %p\n", type, last_intvector);
|
||||
fflush(stdout);
|
||||
|
||||
ww_interrupt = WonXSystem_GetWWInterrupt(WonX_GetWonXSystem());
|
||||
ww_interrupt = WonxSystem_GetWWInterrupt(Wonx_GetWonxSystem());
|
||||
|
||||
WWInterrupt_SetCallback(ww_interrupt, type, old_vector->callback);
|
||||
WWInterrupt_SetCS(ww_interrupt, type, old_vector->cs);
|
||||
WWInterrupt_SetDS(ww_interrupt, type, old_vector->ds);
|
||||
WWInterrupt_SetCallback(ww_interrupt, type, last_intvector->callback);
|
||||
WWInterrupt_SetCS(ww_interrupt, type, last_intvector->cs);
|
||||
WWInterrupt_SetDS(ww_interrupt, type, last_intvector->ds);
|
||||
|
||||
printf("call : sys_interrupt_reset_hook() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void sys_wait(unsigned int wait_time)
|
||||
void sys_wait(unsigned int time)
|
||||
{
|
||||
}
|
||||
|
||||
@ -105,29 +104,29 @@ void sys_set_sleep_time(int sleep_time)
|
||||
{
|
||||
}
|
||||
|
||||
int sys_get_sleep_time(void)
|
||||
int sys_get_sleep_time(void)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
void sys_set_awake_key(int pattern)
|
||||
void sys_set_awake_key(int awake_key_pattern)
|
||||
{
|
||||
}
|
||||
|
||||
int sys_get_awake_key(void)
|
||||
int sys_get_awake_key(void)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
|
||||
void sys_set_keepalive_int(int pattern)
|
||||
void sys_set_keepalive_int(int keepalive_pattern)
|
||||
{
|
||||
}
|
||||
|
||||
void sys_get_ownerinfo(int size, char * buffer)
|
||||
void sys_get_ownerinfo(int size, char *buffer)
|
||||
{
|
||||
}
|
||||
|
||||
int sys_suspend(int core)
|
||||
int sys_suspend(int core)
|
||||
{
|
||||
return (0);
|
||||
}
|
||||
@ -136,7 +135,7 @@ void sys_resume(int core)
|
||||
{
|
||||
}
|
||||
|
||||
void sys_set_remote(int remote)
|
||||
void sys_set_remote(int remote_enable)
|
||||
{
|
||||
}
|
||||
|
||||
@ -145,7 +144,7 @@ unsigned int sys_get_remote(void)
|
||||
return (0);
|
||||
}
|
||||
|
||||
void * sys_alloc_iram(void * p, unsigned int size)
|
||||
void * sys_alloc_iram(void *pointer, unsigned size)
|
||||
{
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
412
text.c
412
text.c
@ -2,17 +2,13 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "wonx/text.h"
|
||||
#include "sys/text.h"
|
||||
|
||||
#include "WonX.h"
|
||||
#include "Wonx.h"
|
||||
#include "WWText.h"
|
||||
#include "WWDisplay.h"
|
||||
#include "WWCursor.h"
|
||||
#include "etc.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 互換関数の定義 */
|
||||
@ -34,15 +30,15 @@
|
||||
* 引数の表示の問題もあるしね.
|
||||
*/
|
||||
|
||||
static void _text_window_init(int x, int y, int w, int h, unsigned int base)
|
||||
static void _text_window_init(int x, int y, int w, int h, unsigned font_base)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWText ww_text;
|
||||
WWDisplay ww_display;
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_text = WWDisplay_GetText(ww_display);
|
||||
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
WWText_SetTextWindow(ww_text, x, y, w, h, base, ww_display);
|
||||
WWText_SetTextWindow(ww_text, x, y, w, h, font_base, ww_display);
|
||||
|
||||
WWScreen_SetRollX(WWText_GetScreen(ww_text), 0);
|
||||
WWScreen_SetRollY(WWText_GetScreen(ww_text), 0);
|
||||
@ -55,51 +51,51 @@ void text_screen_init(void)
|
||||
WWDisplay ww_display;
|
||||
WWLCDPanel ww_lcd_panel;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_screen_init() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
|
||||
|
||||
_text_window_init(0, 0, TEXT_SCREEN_WIDTH, TEXT_SCREEN_HEIGHT, 8);
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_screen_init() : return value = none\n"); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void text_window_init(int x, int y, int w, int h, unsigned int base)
|
||||
void text_window_init(int x, int y, int w, int h, unsigned int font_base)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_window_init() : x = %d, y = %d, width = %d, height = %d, base = %u\n", x, y, w, h, (int)base);
|
||||
printf("call : text_window_init() : x = %d, y = %d, width = %d, height = %d, base = %u\n", x, y, w, h, (int)font_base);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
_text_window_init(x, y, w, h, base);
|
||||
_text_window_init(x, y, w, h, font_base);
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_window_init() : return value = none\n"); fflush(stdout);
|
||||
printf("call : text_screen_init() : return value = none\n"); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -113,13 +109,13 @@ int text_get_mode(void)
|
||||
return (0);
|
||||
}
|
||||
|
||||
static void _text_put_char(int x, int y, unsigned int c)
|
||||
void _text_put_char(int x, int y, unsigned int c)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWText ww_text;
|
||||
WWDisplay ww_display;
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_text = WWDisplay_GetText(ww_display);
|
||||
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
WWText_PutCharacter(ww_text, x, y, c, ww_display);
|
||||
|
||||
@ -128,128 +124,121 @@ static void _text_put_char(int x, int y, unsigned int c)
|
||||
|
||||
void text_put_char(int x, int y, unsigned int c)
|
||||
{
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_put_char() : x = %d, y = %d, character = \'", x, y);
|
||||
wonx_print_character(stdout, c);
|
||||
printf("\'\n");
|
||||
printf("call : text_put_char() : x = %d, y = %d, character = %u\n", x, y, (int)c);
|
||||
fflush(stdout);
|
||||
|
||||
_text_put_char(x, y, c);
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_put_char() : return value = none\n"); fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static int _text_put_string(int x, int y, char * string)
|
||||
static int _text_put_string(int x, int y, char * s)
|
||||
{
|
||||
int i, len, ret;
|
||||
WWDisplay ww_display;
|
||||
WWText ww_text;
|
||||
WWDisplay ww_display;
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_text = WWDisplay_GetText(ww_display);
|
||||
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
len = strlen(string);
|
||||
len = strlen(s);
|
||||
ret = 0;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (WWText_PutCharacter(ww_text, x + i, y, string[i], ww_display) >= 0)
|
||||
if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0)
|
||||
ret++;
|
||||
}
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int text_put_string(int x, int y, char * string)
|
||||
int text_put_string(int x, int y, char * s)
|
||||
{
|
||||
int ret;
|
||||
char * p;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_put_string() : x = %d, y = %d, string = \"", x, y);
|
||||
for (p = string; *p != '\0'; p++) wonx_print_character(stdout, *p);
|
||||
printf("\"\n");
|
||||
printf("call : text_put_string() : x = %d, y = %d, string = %s\n", x, y, s);
|
||||
fflush(stdout);
|
||||
|
||||
ret = _text_put_string(x, y, string);
|
||||
ret = _text_put_string(x, y, s);
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_put_string() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
int text_put_substring(int x, int y, char * s, int length)
|
||||
int text_put_substring(int x, int y, char * s, int len)
|
||||
{
|
||||
int i, ret;
|
||||
WWDisplay ww_display;
|
||||
WWText ww_text;
|
||||
WWDisplay ww_display;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_put_substring() : x = %d, y = %d, length = %d, string = \"", x, y, length);
|
||||
for (i = 0; i < length; i++) wonx_print_character(stdout, s[i]);
|
||||
printf("\"\n");
|
||||
printf("call : text_put_substring() : x = %d, y = %d, string = %s, length = %d\n", x, y, s, len);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_text = WWDisplay_GetText(ww_display);
|
||||
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
ret = 0;
|
||||
for (i = 0; i < length; i++) {
|
||||
for (i = 0; i < len; i++) {
|
||||
if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0)
|
||||
ret++;
|
||||
}
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_put_substring() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void text_put_numeric(int x, int y, int length, int format, int number)
|
||||
void text_put_numeric(int x, int y, int len, int format, int number)
|
||||
{
|
||||
char buf[20];
|
||||
char f[20];
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_put_numeric() : x = %d, y = %d, length = %d, format = %04x, number = %d\n", x, y, length, format, number);
|
||||
printf("call : text_put_numeric() : x = %d, y = %d, len = %d, format = %04x, number = %d\n", x, y, len, format, number);
|
||||
fflush(stdout);
|
||||
|
||||
strcpy(f, "%");
|
||||
|
||||
if (format & NUM_PADZERO) strcat(f, "0");
|
||||
sprintf(f + strlen(f), "%d", length);
|
||||
sprintf(f + strlen(f), "%d", len);
|
||||
if (format & NUM_HEXA) strcat(f, "x");
|
||||
else if (format & NUM_SIGNED) strcat(f, "d");
|
||||
else strcat(f, "u");
|
||||
@ -258,393 +247,200 @@ void text_put_numeric(int x, int y, int length, int format, int number)
|
||||
sprintf(buf, f, number);
|
||||
_text_put_string(x, y, buf);
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_put_numeric() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void text_store_numeric(char * buffer, int length, int format, int number)
|
||||
void text_store_numeric(char * buffer, int len, int format, int number)
|
||||
{
|
||||
}
|
||||
|
||||
void text_fill_char(int x, int y, int length, int c)
|
||||
void text_fill_char(int x, int y, int len, int code)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_fill_char() : x = %d, y = %d, length = %d, character = %d\n", x, y, length, c);
|
||||
printf("call : text_fill_char() : x = %d, y = %d, length = %d, code = %d\n", x, y, len, code);
|
||||
fflush(stdout);
|
||||
|
||||
for (i = 0; i < length; i++) {
|
||||
_text_put_char(x + i, y, c);
|
||||
for (i = 0; i < len; i++) {
|
||||
_text_put_char(x + i, y, code);
|
||||
}
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_fill_char() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void text_set_palette(int palette_num)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWText ww_text;
|
||||
WWDisplay ww_display;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_set_palette() : palette = %d\n", palette_num);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_text = WWDisplay_GetText(ww_display);
|
||||
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
WWText_SetPalette(ww_text, WWDisplay_GetPalette(ww_display, palette_num));
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_set_palette() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int text_get_palette(void)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWText ww_text;
|
||||
int num;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_get_palette() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_text = WWDisplay_GetText(ww_display);
|
||||
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
|
||||
|
||||
num = WWPalette_GetNumber(WWText_GetPalette(ww_text));
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Sync(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_get_palette() : return value = %d\n", num);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (num);
|
||||
}
|
||||
|
||||
void text_set_ank_font(int base, int color, int count, void * font)
|
||||
void text_set_ank_font(int font_base_num, int is_color, int font_count,
|
||||
void * font)
|
||||
{
|
||||
}
|
||||
|
||||
void text_set_sjis_font(void * p)
|
||||
void text_set_sjis_font(void * font_address)
|
||||
{
|
||||
}
|
||||
|
||||
void text_get_fontdata(int c, void * buffer)
|
||||
void text_get_fontdata(int char_code, void * fontdata_buffer)
|
||||
{
|
||||
}
|
||||
|
||||
void text_set_screen(int screen)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWText ww_text;
|
||||
WWDisplay ww_display;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_set_screen() : screen = %d\n", screen);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_text = WWDisplay_GetText(ww_display);
|
||||
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
|
||||
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
|
||||
|
||||
WWText_SetScreen(ww_text, WWDisplay_GetScreen(ww_display, screen));
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_set_screen() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int text_get_screen(void)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWText ww_text;
|
||||
int n;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : text_get_screen() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_text = WWDisplay_GetText(ww_display);
|
||||
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
|
||||
|
||||
n = WWScreen_GetNumber(WWText_GetScreen(ww_text));
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
WonxDisplay_Flush(Wonx_GetWonxDisplay());
|
||||
|
||||
printf("call : text_set_screen() : return value = %d\n", n);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (n);
|
||||
}
|
||||
|
||||
void cursor_display(int flag)
|
||||
void cursor_display(int cursor_enable)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWCursor ww_cursor;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : cursor_display() : flag = %d\n", flag);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_cursor = WWDisplay_GetCursor(ww_display);
|
||||
|
||||
switch (flag) {
|
||||
case 0: WWCursor_OFF(ww_cursor); break;
|
||||
case 1: WWCursor_ON( ww_cursor); break;
|
||||
default:
|
||||
WonX_Warning("cursor_display", "Cursor flag is 0 or 1.");
|
||||
WWCursor_ON(ww_cursor); /* 一応 ON にしとく */
|
||||
}
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : cursor_display() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int cursor_status(void)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWCursor ww_cursor;
|
||||
int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : cursor_status() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_cursor = WWDisplay_GetCursor(ww_display);
|
||||
|
||||
ret = WWCursor_IsON(ww_cursor) ? 1 : 0;
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : cursor_status() : return value = %d\n", ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void cursor_set_location(int x, int y, int w, int h)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWCursor ww_cursor;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : cursor_set_location() : x = %d, y = %d, w = %d, h = %d\n",
|
||||
x, y, w, h);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_cursor = WWDisplay_GetCursor(ww_display);
|
||||
|
||||
if (x < 0)
|
||||
WonX_Warning("cursor_set_location", "Value of x is too small.");
|
||||
if (x > TEXT_SCREEN_WIDTH - 1)
|
||||
WonX_Warning("cursor_set_location", "Value of x is too large.");
|
||||
if (y < 0)
|
||||
WonX_Warning("cursor_set_location", "Value of y is too small.");
|
||||
if (y > TEXT_SCREEN_HEIGHT - 1)
|
||||
WonX_Warning("cursor_set_location", "Value of y is too large.");
|
||||
if (w <= 0)
|
||||
WonX_Warning("cursor_set_location", "Value of w is too small.");
|
||||
if (h <= 0)
|
||||
WonX_Warning("cursor_set_location", "Value of h is too small.");
|
||||
|
||||
WWCursor_SetX(ww_cursor, x);
|
||||
WWCursor_SetY(ww_cursor, y);
|
||||
WWCursor_SetWidth( ww_cursor, w);
|
||||
WWCursor_SetHeight(ww_cursor, h);
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : cursor_set_location() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long int cursor_get_location(void)
|
||||
unsigned long cursor_get_location(void)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWCursor ww_cursor;
|
||||
unsigned long int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : cursor_get_location() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_cursor = WWDisplay_GetCursor(ww_display);
|
||||
|
||||
ret = 0;
|
||||
ret |= (((unsigned long int)WWCursor_GetX( ww_cursor) & 0xff) << 0);
|
||||
ret |= (((unsigned long int)WWCursor_GetY( ww_cursor) & 0xff) << 8);
|
||||
ret |= (((unsigned long int)WWCursor_GetWidth( ww_cursor) & 0xff) << 16);
|
||||
ret |= (((unsigned long int)WWCursor_GetHeight(ww_cursor) & 0xff) << 24);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : cursor_get_location() : return value = 0x%08x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void cursor_set_type(int palette_num, int interval)
|
||||
void cursor_set_type(int palette_num, int blink_interval)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWCursor ww_cursor;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : cursor_set_type() : palette = %d, interval = %d\n",
|
||||
palette_num, interval);
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_cursor = WWDisplay_GetCursor(ww_display);
|
||||
|
||||
if (palette_num < 0)
|
||||
WonX_Error("cursor_set_type", "Palette number is too small.");
|
||||
if (palette_num > 15)
|
||||
WonX_Error("cursor_set_type", "Palette number is too large.");
|
||||
if (interval < 0)
|
||||
WonX_Warning("cursor_set_type", "Value of interval is too small.");
|
||||
if (interval > 255)
|
||||
WonX_Warning("cursor_set_type", "Value of interval is too small.");
|
||||
|
||||
WWCursor_SetPalette(ww_cursor,
|
||||
WWDisplay_GetPalette(ww_display, palette_num));
|
||||
WWCursor_SetInterval(ww_cursor, interval);
|
||||
|
||||
WonXDisplay_Flush(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : cursor_set_type() : return value = none\n");
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned long int cursor_get_type(void)
|
||||
unsigned long cursor_get_type(void)
|
||||
{
|
||||
WWDisplay ww_display;
|
||||
WWCursor ww_cursor;
|
||||
unsigned long int ret;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
printf("call : cursor_get_type() : \n");
|
||||
fflush(stdout);
|
||||
|
||||
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
|
||||
ww_cursor = WWDisplay_GetCursor(ww_display);
|
||||
|
||||
ret = WWPalette_GetNumber(WWCursor_GetPalette(ww_cursor));
|
||||
ret |= (((unsigned long int)WWCursor_GetInterval(ww_cursor) & 0xff) << 8);
|
||||
|
||||
WonXDisplay_Sync(WonX_GetWonXDisplay());
|
||||
|
||||
printf("call : cursor_get_type() : return value = 0x%08x\n", (int)ret);
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
|
||||
return (ret);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int text_printf(int x, int y, const char *format, ...)
|
||||
|
||||
104
timer.c
104
timer.c
@ -2,15 +2,24 @@
|
||||
/* ここから */
|
||||
/*****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "wonx/timer.h"
|
||||
#include "sys/timer.h"
|
||||
|
||||
#include "wonx_configure.h"
|
||||
#include "WonX.h"
|
||||
#include "Wonx.h"
|
||||
#include "etc.h"
|
||||
#include "configure.h"
|
||||
|
||||
typedef struct {
|
||||
unsigned char year;
|
||||
unsigned char month;
|
||||
unsigned char date;
|
||||
unsigned char day_of_week;
|
||||
unsigned char hour;
|
||||
unsigned char minute;
|
||||
unsigned char second;
|
||||
} datetime_t;
|
||||
|
||||
/* int tm_year; year - 1900 */
|
||||
static int get_year(struct tm * tblock) { return (tblock->tm_year - 100); }
|
||||
@ -47,10 +56,10 @@ static int get_second(struct tm * tblock) { return (tblock->tm_sec); }
|
||||
* 引数の表示の問題もあるしね.
|
||||
*/
|
||||
|
||||
void rtc_set_datetime(int type, unsigned int value)
|
||||
void rtc_set_datetime(int field, unsigned int value)
|
||||
{
|
||||
printf("call : rtc_set_datetime() : type = %d, value = %d\n",
|
||||
type, (int)value);
|
||||
printf("call : rtc_set_datetime() : field = %d, value = %d\n",
|
||||
field, (int)value);
|
||||
fflush(stdout);
|
||||
|
||||
/* 未サポート */
|
||||
@ -62,19 +71,19 @@ void rtc_set_datetime(int type, unsigned int value)
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned int rtc_get_datetime(int type)
|
||||
unsigned int rtc_get_datetime(int field)
|
||||
{
|
||||
unsigned int ret = 0;
|
||||
time_t timer;
|
||||
struct tm * tblock;
|
||||
|
||||
printf("call : rtc_get_datetime() : type = %d\n", type);
|
||||
printf("call : rtc_get_datetime() : field = %d\n", field);
|
||||
fflush(stdout);
|
||||
|
||||
time(&timer);
|
||||
tblock = localtime(&timer);
|
||||
|
||||
switch (type) {
|
||||
switch (field) {
|
||||
case RTC_YEAR : ret = get_year( tblock); break;
|
||||
case RTC_MONTH : ret = get_month( tblock); break;
|
||||
case RTC_DATE : ret = get_day( tblock); break;
|
||||
@ -82,7 +91,7 @@ unsigned int rtc_get_datetime(int type)
|
||||
case RTC_HOUR : ret = get_hour( tblock); break;
|
||||
case RTC_MIN : ret = get_minute(tblock); break;
|
||||
case RTC_SEC : ret = get_second(tblock); break;
|
||||
default : WonX_Error("rtc_get_datetime", "Unknown parameter.");
|
||||
default : Error("rtc_get_datetime", "Unknown parameter.");
|
||||
}
|
||||
|
||||
printf("call : rtc_get_datetime() : return value = %d\n", (int)ret);
|
||||
@ -91,9 +100,9 @@ unsigned int rtc_get_datetime(int type)
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void rtc_set_datetime_struct(datetime_t * d)
|
||||
void rtc_set_datetime_struct(void * buffer)
|
||||
{
|
||||
printf("call : rtc_set_datetime_struct() : buffer = %p\n", (void *)d);
|
||||
printf("call : rtc_set_datetime_struct() : buffer = %p\n", buffer);
|
||||
fflush(stdout);
|
||||
|
||||
/* 未サポート */
|
||||
@ -105,24 +114,27 @@ void rtc_set_datetime_struct(datetime_t * d)
|
||||
return;
|
||||
}
|
||||
|
||||
void rtc_get_datetime_struct(datetime_t * d)
|
||||
void rtc_get_datetime_struct(void * buffer)
|
||||
{
|
||||
time_t timer;
|
||||
struct tm * tblock;
|
||||
datetime_t * p;
|
||||
|
||||
printf("call : rtc_get_datetime_struct() : buffer = %p\n", (void *)d);
|
||||
printf("call : rtc_get_datetime_struct() : buffer = %p\n", buffer);
|
||||
fflush(stdout);
|
||||
|
||||
time(&timer);
|
||||
tblock = localtime(&timer);
|
||||
|
||||
d->year = get_year(tblock);
|
||||
d->month = get_month(tblock);
|
||||
d->date = get_day(tblock);
|
||||
d->day_of_week = get_week(tblock);
|
||||
d->hour = get_hour(tblock);
|
||||
d->minute = get_minute(tblock);
|
||||
d->second = get_second(tblock);
|
||||
p = (datetime_t *)buffer;
|
||||
|
||||
p->year = get_year(tblock);
|
||||
p->month = get_month(tblock);
|
||||
p->date = get_day(tblock);
|
||||
p->day_of_week = get_week(tblock);
|
||||
p->hour = get_hour(tblock);
|
||||
p->minute = get_minute(tblock);
|
||||
p->second = get_second(tblock);
|
||||
|
||||
printf("call : rtc_get_datetime_struct() : return value = none\n");
|
||||
fflush(stdout);
|
||||
@ -158,17 +170,17 @@ void rtc_disable_alarm(void)
|
||||
return;
|
||||
}
|
||||
|
||||
void timer_enable(int type, unsigned int auto_preset, unsigned int count)
|
||||
void timer_enable(int type, unsigned int auto_preset, unsigned int preset)
|
||||
{
|
||||
WWTimer ww_timer;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : timer_enable() : type = %d, auto_preset = %u, count = %u\n",
|
||||
type, (int)auto_preset, (int)count);
|
||||
printf("call : timer_enable() : type = %d, auto_preset = %u, preset = %u\n",
|
||||
type, (int)auto_preset, (int)preset);
|
||||
fflush(stdout);
|
||||
|
||||
/*
|
||||
@ -180,12 +192,12 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int count)
|
||||
|
||||
switch (type) {
|
||||
case TIMER_VBLANK:
|
||||
ww_timer = WonXSystem_GetWWVBlankCountUpTimer(WonX_GetWonXSystem());
|
||||
WWTimer_SetPresetCounter(ww_timer, count * WONX_VBLANK_INTERVAL);
|
||||
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(Wonx_GetWonxSystem());
|
||||
WWTimer_SetPresetCounter(ww_timer, preset * WONX_VBLANK_INTERVAL);
|
||||
break;
|
||||
case TIMER_HBLANK:
|
||||
ww_timer = WonXSystem_GetWWHBlankCountUpTimer(WonX_GetWonXSystem());
|
||||
WWTimer_SetPresetCounter(ww_timer, count * WONX_HBLANK_INTERVAL);
|
||||
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(Wonx_GetWonxSystem());
|
||||
WWTimer_SetPresetCounter(ww_timer, preset * WONX_HBLANK_INTERVAL);
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
@ -193,13 +205,13 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int count)
|
||||
* NULL に初期化する.
|
||||
*/
|
||||
ww_timer = NULL;
|
||||
WonX_Error("timer_enable", "Invalid timer type.");
|
||||
Error("timer_enable", "Invalid timer type.");
|
||||
}
|
||||
|
||||
switch (auto_preset) {
|
||||
case TIMER_ONESHOT: WWTimer_SetAutoPresetOFF(ww_timer); break;
|
||||
case TIMER_AUTOPRESET: WWTimer_SetAutoPresetON( ww_timer); break;
|
||||
default: WonX_Error("timer_enable", "Invalid auto preset type.");
|
||||
default: Error("timer_enable", "Invalid auto preset type.");
|
||||
}
|
||||
|
||||
WWTimer_Reset(ww_timer);
|
||||
@ -209,7 +221,7 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int count)
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -218,20 +230,20 @@ void timer_disable(int type)
|
||||
{
|
||||
WWTimer ww_timer;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : timer_disable() : type = %d\n", type);
|
||||
fflush(stdout);
|
||||
|
||||
switch (type) {
|
||||
case TIMER_VBLANK:
|
||||
ww_timer = WonXSystem_GetWWVBlankCountUpTimer(WonX_GetWonXSystem());
|
||||
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(Wonx_GetWonxSystem());
|
||||
break;
|
||||
case TIMER_HBLANK:
|
||||
ww_timer = WonXSystem_GetWWHBlankCountUpTimer(WonX_GetWonXSystem());
|
||||
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(Wonx_GetWonxSystem());
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
@ -239,7 +251,7 @@ void timer_disable(int type)
|
||||
* NULL に初期化する.
|
||||
*/
|
||||
ww_timer = NULL;
|
||||
WonX_Error("timer_disable", "Invalid timer type.");
|
||||
Error("timer_disable", "Invalid timer type.");
|
||||
}
|
||||
|
||||
WWTimer_OFF(ww_timer);
|
||||
@ -248,7 +260,7 @@ void timer_disable(int type)
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -258,20 +270,20 @@ unsigned int timer_get_count(int type)
|
||||
WWTimer ww_timer;
|
||||
unsigned int ret = 0;
|
||||
|
||||
if (!WonX_IsCreated()) WonX_Create();
|
||||
if (!Wonx_IsCreated()) Wonx_Create();
|
||||
|
||||
/* タイマを一時停止する */
|
||||
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
printf("call : timer_get_count() : type = %d\n", type);
|
||||
fflush(stdout);
|
||||
|
||||
switch (type) {
|
||||
case TIMER_VBLANK:
|
||||
ww_timer = WonXSystem_GetWWVBlankCountUpTimer(WonX_GetWonXSystem());
|
||||
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(Wonx_GetWonxSystem());
|
||||
break;
|
||||
case TIMER_HBLANK:
|
||||
ww_timer = WonXSystem_GetWWHBlankCountUpTimer(WonX_GetWonXSystem());
|
||||
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(Wonx_GetWonxSystem());
|
||||
break;
|
||||
default:
|
||||
/*
|
||||
@ -279,7 +291,7 @@ unsigned int timer_get_count(int type)
|
||||
* NULL に初期化する.
|
||||
*/
|
||||
ww_timer = NULL;
|
||||
WonX_Error("timer_get_count", "Invalid timer type.");
|
||||
Error("timer_get_count", "Invalid timer type.");
|
||||
}
|
||||
|
||||
ret = WWTimer_GetCounter(ww_timer);
|
||||
@ -288,7 +300,7 @@ unsigned int timer_get_count(int type)
|
||||
fflush(stdout);
|
||||
|
||||
/* タイマをもとに戻す */
|
||||
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
|
||||
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
366
wonx.c
366
wonx.c
@ -1,366 +0,0 @@
|
||||
#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 するようにする.
|
||||
*/
|
||||
|
||||
/*
|
||||
* タイマの一時停止の2重解除の問題が出てくるので,
|
||||
* 互換関数から互換関数を呼んではいけない.
|
||||
* (一時停止はネストされるが,いちおう)
|
||||
* 似たような処理をする関数の場合は,必ず 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. */
|
||||
/*****************************************************************************/
|
||||
39
wonx/bank.h
39
wonx/bank.h
@ -1,39 +0,0 @@
|
||||
#ifndef _WONX_SYS_BANK_H_
|
||||
#define _WONX_SYS_BANK_H_
|
||||
|
||||
#include "service.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 年眶の年盗 */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define BANK_SRAM 0
|
||||
#define BANK_ROM0 1
|
||||
#define BANK_ROM1 2
|
||||
|
||||
#define sram_get_map() bank_get_map(BANK_SRAM)
|
||||
#define rom0_get_map() bank_get_map(BANK_ROM0)
|
||||
#define rom1_get_map() bank_get_map(BANK_ROM1)
|
||||
#define sram_set_map(bank) bank_set_map(BANK_SRAM, bank)
|
||||
#define rom0_set_map(bank) bank_set_map(BANK_ROM0, bank)
|
||||
#define rom1_set_map(bank) bank_set_map(BANK_ROM1, bank)
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 高垂簇眶の离咐 */
|
||||
/*****************************************************************************/
|
||||
|
||||
void bank_set_map(int bank, int bank_num);
|
||||
int bank_get_map(int bank);
|
||||
unsigned char bank_read_byte(int bank, unsigned int off);
|
||||
void bank_write_byte(int bank, unsigned int off, unsigned int data);
|
||||
unsigned int bank_read_word(int bank, unsigned int off);
|
||||
void bank_write_word(int bank, unsigned int off, unsigned int data);
|
||||
void bank_read_block(int bank, unsigned int off,
|
||||
void * buffer, unsigned int size);
|
||||
void bank_write_block(int bank, unsigned int off,
|
||||
void * buffer, unsigned int size);
|
||||
void bank_fill_block(int bank, unsigned int off,
|
||||
unsigned int size, unsigned int data);
|
||||
void bank_erase_flash(int bank);
|
||||
|
||||
#endif
|
||||
13
wonx/bios.h
13
wonx/bios.h
@ -1,13 +0,0 @@
|
||||
#ifndef _WONX_SYS_BIOS_H_
|
||||
#define _WONX_SYS_BIOS_H_
|
||||
|
||||
#include "bank.h"
|
||||
#include "comm.h"
|
||||
#include "disp.h"
|
||||
#include "key.h"
|
||||
#include "sound.h"
|
||||
#include "system.h"
|
||||
#include "text.h"
|
||||
#include "timer.h"
|
||||
|
||||
#endif
|
||||
71
wonx/comm.h
71
wonx/comm.h
@ -1,71 +0,0 @@
|
||||
#ifndef _WONX_SYS_COMM_H_
|
||||
#define _WONX_SYS_COMM_H_
|
||||
|
||||
#include "service.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 年眶の年盗 */
|
||||
/*****************************************************************************/
|
||||
|
||||
#define COMM_SPEED_9600 0
|
||||
#define COMM_SPEED_38400 1
|
||||
|
||||
#define XMODE_SEND 0
|
||||
#define XMODE_RECEIVE 1
|
||||
#define XMODE_SEND_ENCRYPTED 2
|
||||
#define XMODE_RECEIVE_ENCRYPTED 3
|
||||
#define XMODE_AUTO_ERASE 4
|
||||
|
||||
#define ERR_SIO_OK 0x0000
|
||||
#define ERR_SIO_BUSY 0x8100
|
||||
#define ERR_SIO_TIMEOUT 0x8101
|
||||
#define ERR_SIO_OVERRUN 0x8102
|
||||
#define ERR_SIO_CANCEL 0x8103
|
||||
#define ERR_XM_STATECODE 0x8104
|
||||
#define ERR_XM_CANCELED 0x8105
|
||||
#define ERR_XM_BLOCK_LOST 0x8106
|
||||
#define ERR_XM_TOO_LARGE 0x8107
|
||||
|
||||
enum {
|
||||
XM_START = 1,
|
||||
XM_NEGO,
|
||||
XM_BLOCK,
|
||||
XM_BLOCK_RETRY,
|
||||
XM_CLOSE,
|
||||
XM_ABORT,
|
||||
XM_DONE,
|
||||
XM_ERASE_BANK
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
int state;
|
||||
char mode;
|
||||
char retry_c;
|
||||
int block_c;
|
||||
int block_max;
|
||||
int block_size;
|
||||
int bank;
|
||||
int offset;
|
||||
int timeout_c;
|
||||
} xmodeminfo;
|
||||
|
||||
/*****************************************************************************/
|
||||
/* 高垂簇眶の离咐 */
|
||||
/*****************************************************************************/
|
||||
|
||||
void comm_open(void);
|
||||
void comm_close(void);
|
||||
int comm_send_char(unsigned char c);
|
||||
int comm_receive_char(void);
|
||||
int comm_receive_with_timeout(int timeout);
|
||||
int comm_send_string(char * string);
|
||||
int comm_send_block(void * buffer, int size);
|
||||
int comm_receive_block(void * buffer, int size);
|
||||
void comm_set_timeout(int recv_timeout, int send_timeout);
|
||||
void comm_set_baudrate(int baudrate);
|
||||
int comm_get_baudrate(void);
|
||||
void comm_set_cancel_key(unsigned int pattern);
|
||||
unsigned int comm_get_cancel_key(void);
|
||||
int comm_xmodem(void * xmodem);
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user