Compare commits

..

5 Commits

Author SHA1 Message Date
Hiroaki Sakai
103ffe29f1 We implemented mmap (). Specifically, see README.
Added service function.  (A service function dumping information for debugging,
Added service function for screen drawing ON / OFF control) Specifically, see README.

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

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

Some timer interrupts are improved.  (UNIXTimer.c)

Change the wonx_include directory to wonx.

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

Makefile review, improvement.

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

Fixed to display message when pressing key.

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

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

Version 2.2 - from wonx-2.2.tar.gz
2018-03-07 23:07:30 +00:00
Hiroaki Sakai
d1cde9116a Added dump of RGB value when dumping palette data.
Fixed a part of the data dump part.

Changed the line of perl script from / usr / bin / perl to / usr / local / bin / perl.
(On FreeBSD, Japanese perl is in / usr / local / bin)

For disp.c, libwwc.c, a function for reading and acquiring bitmap data of characters,
The type of bitmap data is not unsigned char *, but instead of short int *, long int *
It was modified to an appropriate type.
Let the bitmap of the WWCharacter class be union of uchar, ushort, ulong,
By accessing with an appropriate type in WWCharacter_GetPixel ()
The endian dependence of bitmap data is eliminated.  (i386, confirmed by SPARC)

Fixed how to get the value of WWCharacter_GetPixel () in 16 PACKED color mode.
(The bug that the character was displayed inverted horizontally was resolved)

Stop for 10 seconds at F11, forcibly end with Ctrl-c or F12,
Added iconization with Ctrl-i.  (It was a function that was originally, but I forgot that,
We modified it somewhat to make it formal support)

Move display / non-display change key from p to F10.  Manual correction.

XDisplay.c: generated with XColorGC_CreateFromRGB () with XDisplay_DrawLCDWindow ()
Since we did not Destroy () the XColorGC object, we made a bug that caused memory flow
Fix.  (XColorGC_Destroy (x_color_gc) addition)

Add wonx_include / fcntl.h.  The contents are / usr / include / fcntl.h,
Just include /usr/include/sys/fcntl.h.

Format change of serial output message (output to serial port:).
(I tried to enclose it with "".)
etc.c: wonx_print_character () Fixed.  (Add \ ", \ \ and others)
Fix sout2str.pl.  (Add \ ", \ \ etc .... The above message for serial output
It was modified according to format change)

Added int2sint.pl, filters.pl, challsrc.sh.
Change sys2wonx.pl.

in wonx_include / types.h
typedef unsigned short WORD;
typedef unsigned long DWORD;
To
typedef unsigned short int WORD;
typedef unsigned long int DWORD;
change to.

Fixed README.

Version 2.1 - from wonx-2.1.tar.gz
2018-03-07 23:07:23 +00:00
Hiroaki Sakai
d3f3c6903d Corresponding to colorization. Added XColorGC class for GC management. (It diverted from XFireworks)
Corresponding to colorization, transparent (transparent color) judgment processing from the WWPalette class
I moved to the WWDisplay class.

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

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

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

Added palette of border color to WWDisplay class.

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

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

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

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

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

Version 2.0 - from wonx-2.0.tar.gz
2018-03-07 23:07:10 +00:00
Hiroaki Sakai
c0b964b4f4 Added dummy function of _asm_*().
Set FP_OFF ​(), FP_SEG() for the callback function at interrupt setting in WonderWitch
Adjust appropriately according to the setting method.  (Fit to wwterm)

UNIXTimer.c: UNIXTimer_Unpause()
((unix_timer -> pause == 1) && (unix_timer -> interrupt_in_pause == 0))
Fixed a bug that was not unix_timer-> pause--; when it was.
(It was not unposted when interrupt was not applied during pause)

Serial receive interrupt, keyboard interrupt added.  (corresponding to wwterm, operation confirmed)
Added UNIXSerialPort class.

With this, at 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);
Interrupt setting like that shown in Fig.

For warning, add WonX_Warning ().
Move WonX_Error () to WonX.c.

comm_send_string (), text_put_string (), text_put_substring () When executed
Fix output message.

Implement cursor display function.  (Add WWCursor class) (Do not blink. Display only)
When displaying the cursor, text information inside WWDisplay_DrawLCDPanel ()
Since we need to be able to read it, we will discontinue the WonXText class and add the WWText class
I moved to a member of the WWDisplay class.

In palette_get_color (), transparent color is displayed when executing WWPalette_GetMappedColors ()
Since it was not considered to be returned as -1, palette_get_color ()
Fixed a bug where return value was wrong value.

Character color palette, LCD color palette initial value, with WonderWitch
It was made to coincide with the initial value.

As a sample, add wwterm - b 05.  (Add wwterm target to Makefile)

Version 1.1 - from wonx-1.1.tar.gz
2018-03-07 23:07:04 +00:00
Hiroaki Sakai
f25d7235fb Changed official name from Wonx to WonX.
Add MANUAL file.

Added sentences to OMAKE.jpn.

Version 1.0 - from wonx-1.0.tar.gz
2018-03-07 23:06:54 +00:00
118 changed files with 8289 additions and 1841 deletions

View File

@ -1,7 +1,7 @@
/*****************************************************************************/
/* Wonx - WonderWitch on X. */
/* WonX - WonderWitch on X. */
/* */
/* Wonx Copyright (c) 2000 Sakai Hiroaki. */
/* WonX Copyright (c) 2000-2002 Sakai Hiroaki. */
/* All Rights Reserved. */
/*===========================================================================*/
/* This program is free software; you can redistribute it and/or modify */
@ -37,10 +37,14 @@
/* あるものとします. */
/*===========================================================================*/
/* 坂井弘亮の連絡先のメールアドレスは, */
/* sakai@seki.ee.kagu.sut.ac.jp */
/* hsakai@pfu.co.jp */
/* hsakai@m8.people.or.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 */
/* ミラーサイトは,坂井が気が向いたときにアップデートするので,常に最新, */
/* というわけではありません.あくまでバックアップ用です. */
/* ご意見,ご感想がありましたら,ぜひ連絡ください. */
/*****************************************************************************/

199
HISTORY
View File

@ -1,3 +1,202 @@
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 ク<>

76
MANUAL Normal file
View File

@ -0,0 +1,76 @@
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() という名前になっています.
■ このファイルはここまでです

View File

@ -2,28 +2,41 @@ XINCLUDEDIR = /usr/X11R6/include
INCLUDEDIR = .
XLIBDIR = /usr/X11R6/lib
VERSION = Wonx-b05
PKGNAME = wonx-b05
VERSION = WonX-2.2
PKGNAME = wonx-2.2
SMAC = smac-b02
WWTERM = wwterm-b05
OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWText.o WWInterrupt.o WWTimer.o WWSerialPort.o Wonx.o WonxDisplay.o WonxText.o WonxSystem.o WonxSerialPort.o XDisplay.o UNIXTimer.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o etc.o
OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWCursor.o WWText.o WWInterrupt.o WWTimer.o WWSerialPort.o WonX.o WonXDisplay.o WonXSystem.o WonXSerialPort.o XDisplay.o XColorGC.o UNIXTimer.o UNIXSerialPort.o Obj.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o libwwc.o service.o fcntl.o etc.o wonx.o
CC = gcc
PERLS = filters.pl int2sint.pl sout2str.pl sys2wonx.pl
#PERL = /usr/bin/perl
CC ?= gcc
AR ?= ar
RANLIB ?= ranlib
CFLAGS += -O
#CFLAGS += -g
CFLAGS += -Wall
PREFIX ?= /usr/local
.SUFFIXES: .c .o
.SUFFIXES: .perl .pl
all : libwonx.a
all : libwonx.a $(PERLS)
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 -O -Wall -I$(INCLUDEDIR) -I$(XINCLUDEDIR)
$(CC) -c $*.c $(CFLAGS) -I$(INCLUDEDIR) -I$(XINCLUDEDIR)
clean :
rm -f libwonx.a sample1 sample2 *.o
rm -f libwonx.a sample1 sample2 sample3 *.o *.pl
rm -fR $(SMAC) $(WWTERM)
sample1 : libwonx.a sample1.o
$(CC) sample1.o -o sample1 \
@ -33,25 +46,63 @@ sample2 : libwonx.a sample2.o
$(CC) sample2.o -o sample2 \
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
smac : libwonx.a
sample3 : libwonx.a sample3.o
$(CC) sample3.o -o sample3 \
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
smac : libwonx.a $(SMAC)
cd $(SMAC) ; $(MAKE)
$(SMAC) : $(SMAC).zip $(PERLS)
unzip $(SMAC).zip
cp -R wonx_include $(SMAC)
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 sys2wonx.pl $(SMAC)
echo "ここで止まったときはsys2wonx.pl の行目に適切なperlを指定してください"
cd $(SMAC) ; ./sys2wonx.pl *.[ch]
cd $(SMAC) ; $(MAKE)
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
package :
mkdir -p $(PKGNAME)
rm -fR $(PKGNAME)/*
mkdir -p $(PKGNAME)/wonx_include
cp COPYING COPYRIGHT HISTORY README OMAKE.jpn Makefile \
makefile_for_smac sys2wonx.pl \
*.h *.c smac*.zip $(PKGNAME)
cp wonx_include/*.h $(PKGNAME)/wonx_include
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
tar cvzf $(PKGNAME).tar.gz $(PKGNAME)
# End of Makefile.

1046
OMAKE.jpn

File diff suppressed because it is too large Load Diff

396
Obj.c Normal file
View File

@ -0,0 +1,396 @@
/*****************************************************************************/
/* Obj.c - A library for object list. */
/* */
/* Obj.c Copyright (c) 2000 Sakai Hiroaki. */
/* All Rights Reserved. */
/*****************************************************************************/
#include "ObjP.h"
/*****************************************************************************/
/* ObjListData 型の操作 */
/*****************************************************************************/
static ObjListData ObjListData_Create(Obj obj, Obj (*destructor)())
{
ObjListData list_data;
list_data = (ObjListData)malloc(sizeof(_ObjListData));
list_data->obj = obj;
list_data->destructor = destructor;
return (list_data);
}
static ObjListData ObjListData_Destroy(ObjListData list_data)
{
if (list_data == NULL) return (NULL);
/* デストラクタの実行 */
if (list_data->destructor)
(*(list_data->destructor))(list_data->obj);
free(list_data);
return (NULL);
}
/*****************************************************************************/
/* ObjList 型オブジェクトの操作 */
/*****************************************************************************/
Obj ObjListData_GetObj(ObjListData data)
{
if (data == NULL) return (NULL);
return (data->obj);
}
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 Normal file
View File

@ -0,0 +1,76 @@
/*****************************************************************************/
/* Obj.h - A library for object list. */
/* */
/* Obj.h Copyright (c) 2000 Sakai Hiroaki. */
/* All Rights Reserved. */
/*****************************************************************************/
#ifndef _SAKAILIB_OBJ_H_INCLUDED_
#define _SAKAILIB_OBJ_H_INCLUDED_
typedef void * Obj;
typedef struct _ObjListData * ObjListData;
typedef struct _ObjList * ObjList;
typedef Obj (*ObjDestructor)(Obj);
#include <stdio.h>
#include <stdlib.h>
/*****************************************************************************/
/* ObjList 型オブジェクトの操作 */
/*****************************************************************************/
Obj ObjListData_GetObj(ObjListData data);
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 Normal file
View File

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

863
README

File diff suppressed because it is too large Load Diff

182
UNIXSerialPort.c Normal file
View File

@ -0,0 +1,182 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#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. */
/*****************************************************************************/

82
UNIXSerialPort.h Normal file
View File

@ -0,0 +1,82 @@
#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. */
/*****************************************************************************/

View File

@ -1,19 +1,19 @@
#ifndef _WonxTextP_h_INCLUDED_
#define _WonxTextP_h_INCLUDED_
#ifndef _UNIXSerialPortP_h_INCLUDED_
#define _UNIXSerialPortP_h_INCLUDED_
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WonxText.h"
#include "UNIXSerialPort.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonxText {
WWText ww_text;
} _WonxText;
typedef struct _UNIXSerialPort {
int opened; /* open/close */
} _UNIXSerialPort;
/*****************************************************************************/
/* ここまで */

View File

@ -6,7 +6,7 @@
#include <signal.h>
#include "UNIXTimerP.h"
#include "etc.h"
#include "WonX.h"
/*****************************************************************************/
/* メンバ関数の定義 */
@ -23,6 +23,7 @@ volatile static UNIXTimer pointed_unix_timer = NULL;
static void UNIXTimer_CallBackFunction(int argument)
{
int ret;
int old;
/*
* static
@ -34,6 +35,9 @@ static void UNIXTimer_CallBackFunction(int argument)
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;
@ -44,13 +48,15 @@ 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_*
@ -170,7 +176,9 @@ int UNIXTimer_Pause(UNIXTimer unix_timer)
int UNIXTimer_Unpause(UNIXTimer unix_timer)
{
if (unix_timer->pause == 0)
Wonx_Error("UNIXTimer_Unpause", "Duplicated unpause.");
WonX_Error("UNIXTimer_Unpause", "Duplicated unpause.");
if (unix_timer->pause < 0)
WonX_Error("UNIXTimer_Unpause", "Invalid pause.");
if (unix_timer->pause == 1) {
if (unix_timer->interrupt_in_pause > 0) {
@ -198,6 +206,10 @@ 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--; /* ポーズはネストできる */
@ -259,7 +271,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.");
WonX_Error("UNIXTimer_Create", "Cannot allocate memory.");
unix_timer->timer_on = 0;
unix_timer->pause = 0;
@ -291,7 +303,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.");
WonX_Error("UNIXTimer_Destroy", "Object is not created.");
UNIXTimer_OFF(unix_timer);

View File

@ -5,9 +5,6 @@
/* ここから */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
@ -15,6 +12,13 @@
typedef struct _UNIXTimer * UNIXTimer;
typedef int (*UNIXTimerCallBack)(void *);
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/*****************************************************************************/
/* メンバ関数の宣言 */
/*****************************************************************************/

View File

@ -19,7 +19,7 @@ typedef struct _UNIXTimer {
*
*
*
* Wonx X X
* WonX X X
*
*
*/

View File

@ -2,38 +2,136 @@
/* ここから */
/*****************************************************************************/
#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) WonX_Error("WWCharacter_GetNumber", "WWCharacter is NULL.");
return (c->number);
}
int WWCharacter_SetNumber(WWCharacter c, int n)
{
if ((n < 0) || (n >= 512))
Wonx_Error("WWCharacter_SetNumber()", "Invalid range.");
if (c == NULL) WonX_Error("WWCharacter_SetNumber", "WWCharacter is NULL.");
if ((n < 0) || (n > 512 - 1))
WonX_Error("WWCharacter_SetNumber", "Invalid range.");
return (c->number = n);
}
WWCharacter WWCharacter_Create(int number, unsigned char * bitmap)
/*===========================================================================*/
/* ビットマップの操作 */
/*===========================================================================*/
/*---------------------------------------------------------------------------*/
/* 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 character;
character = (WWCharacter)malloc(sizeof(_WWCharacter));
if (character == NULL)
Wonx_Error("WWCharacter_Create", "Cannot allocate memory.");
WonX_Error("WWCharacter_Create", "Cannot allocate memory.");
WWCharacter_SetNumber(character, number);
WWCharacter_SetBitmap(character, bitmap);
WWCharacter_ClearAllPixels(character);
return (character);
}
@ -41,99 +139,135 @@ WWCharacter WWCharacter_Create(int number, unsigned char * bitmap)
WWCharacter WWCharacter_Destroy(WWCharacter character)
{
if (character == NULL)
Wonx_Error("WWCharacter_Destroy()", "WWCharacter is NULL.");
WonX_Error("WWCharacter_Destroy", "Object is not created.");
free(character);
return (NULL);
}
unsigned char * WWCharacter_GetBitmap(WWCharacter character)
{
return (character->bitmap);
}
/*===========================================================================*/
/* ピクセルの操作 */
/*===========================================================================*/
int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap)
int WWCharacter_GetPixel(WWCharacter character, int x, int y,
WWDisplay display)
{
int i;
unsigned short int pixel;
unsigned short int spixel;
unsigned long int lpixel;
if (character == NULL)
Wonx_Error("WWCharacter_SetBitmap()", "WWCharacter is NULL.");
WonX_Error("WWCharacter_GetPixel", "WWCharacter is NULL.");
for (i = 0; i < 16; i++) {
if (bitmap == NULL) {
character->bitmap[i] = 0x00;
} else {
character->bitmap[i] = bitmap[i];
}
if ((x < 0) || (x > 7))
WonX_Error("WWCharacter_GetPixel", "x is out of range.");
if ((y < 0) || (y > 7))
WonX_Error("WWCharacter_GetPixel", "y is out of range.");
/* パレット色を返す */
pixel = 0;
switch (WWDisplay_GetColorMode(display)) {
case COLOR_MODE_GRAYSCALE:
case COLOR_MODE_4COLOR:
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.");
}
return (0);
}
int WWCharacter_GetPixel(WWCharacter character, int x, int y)
{
if (character == NULL)
Wonx_Error("WWCharacter_GetPixel()", "WWCharacter is NULL.");
if ((x < 0) || (x > 7))
Wonx_Error("WWCharacter_GetPixel()", "x is invalid value.");
if ((y < 0) || (y > 7))
Wonx_Error("WWCharacter_GetPixel()", "y is invalid value.");
/* ビットマップは2ビットでぴとつのピクセルに対応する */
/* 2ビットの値がpalette の色に対応する. */
/* bitmap は unsigned char bitmap[16]; に定義してある. */
/* パレット色(03)を返す */
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)
Wonx_Error("WWCharacter_SetPixel()", "WWCharacter is NULL.");
if ((x < 0) || (x > 7))
Wonx_Error("WWCharacter_SetPixel()", "x is invalid value.");
if ((y < 0) || (y > 7))
Wonx_Error("WWCharacter_SetPixel()", "y is invalid value.");
if ((pixel < 0) || (pixel > 3))
Wonx_Error("WWCharacter_SetPixel()", "Invalid pixel.");
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_CopyBitmap(WWCharacter dst, WWCharacter src)
int WWCharacter_ClearAllPixels(WWCharacter character)
{
return (WWCharacter_SetBitmap(dst, src->bitmap));
if (character == NULL)
WonX_Error("WWCharacter_ClearAllPixels", "WWCharacter is NULL.");
memset(character->bitmap.bitmap_char, 0, 32);
return (0);
}
int WWCharacter_PrintData(WWCharacter character, FILE * f)
int WWCharacter_CopyAllPixels(WWCharacter dst, WWCharacter src)
{
int x, y, i, n;
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.");
n = WWCharacter_GetNumber(character);
fprintf(f, "\n");
fprintf(f, "character[%d] :\tnumber = %d\n",
fprintf(f, "character[%03d] :\tnumber = %d\n",
n, WWCharacter_GetNumber(character));
for (i = 0; i < 16; i++) {
fprintf(f, "character[%d] :\tbitmap[%d] = 0x%02x\n",
n, i, (int)(WWCharacter_GetBitmap(character)[i]));
for (i = 0; i < 32; i += 8) {
fprintf(f, "character[%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[%d] :\tbitmap : ", n);
fprintf(f, "character[%03d] :\tpixels : %01d ", n, y);
for (x = 0; x < 8; x++) {
fprintf(f, "%d", WWCharacter_GetPixel(character, x, y));
pixel = WWCharacter_GetPixel(character, x, y, display);
fprintf(f, "%c", wonx_dec_to_hex(pixel));
}
fprintf(f, "\n");
}

View File

@ -5,29 +5,82 @@
/* ここから */
/*****************************************************************************/
#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);
WWCharacter WWCharacter_Create(int number, unsigned char * bitmap);
/*===========================================================================*/
/* ビットマップの操作 */
/*===========================================================================*/
/*---------------------------------------------------------------------------*/
/* 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_Destroy(WWCharacter character);
unsigned char * WWCharacter_GetBitmap(WWCharacter character);
int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap);
int WWCharacter_GetPixel(WWCharacter character, int x, int y);
int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel);
int WWCharacter_CopyBitmap(WWCharacter dst, WWCharacter src);
int WWCharacter_PrintData(WWCharacter character, FILE * f);
/*===========================================================================*/
/* ピクセルの操作 */
/*===========================================================================*/
int WWCharacter_GetPixel(WWCharacter character, int x, int y,
WWDisplay display);
int WWCharacter_ClearAllPixels(WWCharacter character);
int WWCharacter_CopyAllPixels(WWCharacter dst, WWCharacter src);
/*===========================================================================*/
/* 内部データ出力 */
/*===========================================================================*/
int WWCharacter_PrintData(WWCharacter character, WWDisplay display, FILE * f);
/*****************************************************************************/
/* ここまで */

View File

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

View File

@ -3,7 +3,7 @@
/*****************************************************************************/
#include "WWColorMapP.h"
#include "etc.h"
#include "WonX.h"
/*****************************************************************************/
/* ĽáĽóĽĐ´Řżô¤ÎÄęľÁ */
@ -15,7 +15,7 @@ WWColorMap WWColorMap_Create(int * lcd_colors)
color_map = (WWColorMap)malloc(sizeof(_WWColorMap));
if (color_map == NULL)
Wonx_Error("WWColorMap_Create", "Cannot allocate memory");
WonX_Error("WWColorMap_Create", "Cannot allocate memory");
WWColorMap_SetLCDColors(color_map, lcd_colors);
@ -24,7 +24,8 @@ WWColorMap WWColorMap_Create(int * lcd_colors)
WWColorMap WWColorMap_Destroy(WWColorMap color_map)
{
if (color_map == NULL) return (NULL);
if (color_map == NULL)
WonX_Error("WWColorMap_Destroy", "Object is not created.");
free(color_map);
return (NULL);
}
@ -72,7 +73,7 @@ int WWColorMap_PrintData(WWColorMap c, FILE * f)
fprintf(f, "\n");
for (i = 0; i < 8; i++) {
fprintf(f, "colormap :\tcolor[%d] = %d\n",
fprintf(f, "colormap :\tcolor[%01d] = %d\n",
i, WWColorMap_GetLCDColor(c, i));
}

View File

@ -5,15 +5,19 @@
/* ここから */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WWColorMap * WWColorMap;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/*****************************************************************************/
/* メンバ関数の宣言 */
/*****************************************************************************/

68
WWCursor.c Normal file
View File

@ -0,0 +1,68 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#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 Normal file
View File

@ -0,0 +1,57 @@
#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 Normal file
View File

@ -0,0 +1,30 @@
#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. */
/*****************************************************************************/

View File

@ -2,8 +2,12 @@
/* ここから */
/*****************************************************************************/
#include "wonx/disp.h"
#include "wonx/text.h"
#include "wonx/libwwc.h"
#include "WWDisplayP.h"
#include "etc.h"
#include "WonX.h"
/*****************************************************************************/
/* メンバ関数の定義 */
@ -20,6 +24,10 @@ 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)
@ -34,7 +42,10 @@ int WWDisplay_GetSpriteWindowWidth(WWDisplay d)
int WWDisplay_GetSpriteWindowHeight(WWDisplay d)
{ return (d->sprite_window_height); }
int WWDisplay_GetBorder(WWDisplay d) { return (d->border); }
WWPalette WWDisplay_GetBorderPalette(WWDisplay d)
{ return (d->border_palette); }
int WWDisplay_GetBorderColor(WWDisplay d)
{ return (d->border_color); }
int WWDisplay_GetForegroundColor(WWDisplay d) { return (d->foreground_color); }
int WWDisplay_GetBackgroundColor(WWDisplay d) { return (d->background_color); }
@ -58,6 +69,13 @@ 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); }
@ -73,7 +91,10 @@ int WWDisplay_SetSpriteWindowWidth(WWDisplay d, int n)
int WWDisplay_SetSpriteWindowHeight(WWDisplay d, int n)
{ return (d->sprite_window_height = n); }
int WWDisplay_SetBorder(WWDisplay d, int b) { return (d->border = b); }
WWPalette WWDisplay_SetBorderPalette(WWDisplay d, WWPalette p)
{ return (d->border_palette = p); }
int WWDisplay_SetBorderColor(WWDisplay d, int b)
{ return (d->border_color = b); }
int WWDisplay_SetForegroundColor(WWDisplay d, int c)
{ return (d->foreground_color = c); }
@ -94,20 +115,42 @@ 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.");
WonX_Error("WWDisplay_Create", "Cannot allocate memory.");
WWDisplay_SetColorMap(display, WWColorMap_Create(NULL));
WWDisplay_SetColorMap(display, WWColorMap_Create(default_lcd_colors));
for (i = 0; i < 16; i++) {
/*
* WonX-2.0 WWPalette
*
*/
#if 1
WWDisplay_SetPalette(display, i,
WWPalette_Create(i, NULL, ((i / 4) % 2) ? 1 : 0));
WWPalette_Create(i,default_palette_colors[i].colors));
#else /* WonX-2.0 以前では,透明色の設定が必要だった.一応コードを残しておく */
WWDisplay_SetPalette(display, i,
WWPalette_Create(i,
default_palette_colors[i].colors,
((i / 4) % 2) ? 1 : 0));
#endif
}
for (i = 0; i < 512; i++) {
WWDisplay_SetCharacter(display, i, WWCharacter_Create(i, NULL));
WWDisplay_SetCharacter(display, i, WWCharacter_Create(i));
}
for (i = 0; i < 128; i++) {
@ -129,6 +172,24 @@ 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()
*
*
*/
WWDisplay_SetCursor(display,
WWCursor_Create(WWDisplay_GetPalette(display, 1)));
/* デフォルトのカラーモードは白黒モード */
WWDisplay_SetColorMode(display, COLOR_MODE_GRAYSCALE);
WWDisplay_SetSpriteEnable(display, 0);
WWDisplay_SetSpriteWindowEnable(display, 0);
@ -137,7 +198,8 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
WWDisplay_SetSpriteWindowWidth( display, lcd_panel_width);
WWDisplay_SetSpriteWindowHeight(display, lcd_panel_height);
WWDisplay_SetBorder(display, 0);
WWDisplay_SetBorderPalette(display, WWDisplay_GetPalette(display, 0));
WWDisplay_SetBorderColor(display, 0);
WWDisplay_SetForegroundColor(display, 3);
WWDisplay_SetBackgroundColor(display, 0);
@ -152,7 +214,8 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
{
int i;
if (display == NULL) return (NULL);
if (display == NULL)
WonX_Error("WWDisplay_Destroy", "Object is not created.");
if (WWDisplay_GetColorMap(display) != NULL)
WWDisplay_SetColorMap(display,
@ -188,6 +251,14 @@ 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);
@ -197,7 +268,8 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
/* LCDパネルの描画 */
/*===========================================================================*/
static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen)
static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen,
WWCursor cursor)
{
WWLCDPanel lcd_panel;
int lcd_panel_width;
@ -267,12 +339,25 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen)
px = x + WWScreen_GetRollX(screen);
pixel = WWScreen_GetPixel(screen, px, py);
/* 透明色の場合には,-1が返ってくる */
pixel = WWScreen_GetPixel(screen, px, py, display, cursor);
/* 透明色の場合 */
if (pixel == -1) continue;
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
/* カラー対応 */
switch (WWDisplay_GetColorMode(display)) {
case COLOR_MODE_GRAYSCALE:
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
break;
case COLOR_MODE_4COLOR:
case COLOR_MODE_16COLOR:
case COLOR_MODE_16PACKED:
break;
default:
WonX_Error("WWDisplay_DrawSprite", "Unknown color mode.");
}
WWLCDPanel_SetPixel(lcd_panel, x, y, pixel);
}
}
@ -300,7 +385,9 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite)
for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) {
pixel = WWSprite_GetPixel(sprite, x, y);
/* 透明色は-1が返ってくる */
pixel = WWSprite_GetPixel(sprite, x, y, display);
/* 透明色の場合 */
if (pixel == -1) continue;
@ -321,7 +408,19 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite)
}
}
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
/* カラー対応 */
switch (WWDisplay_GetColorMode(display)) {
case COLOR_MODE_GRAYSCALE:
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel);
break;
case COLOR_MODE_4COLOR:
case COLOR_MODE_16COLOR:
case COLOR_MODE_16PACKED:
break;
default:
WonX_Error("WWDisplay_DrawSprite", "Unknown color mode.");
}
WWLCDPanel_SetPixel(WWDisplay_GetLCDPanel(display), lcd_x, lcd_y, pixel);
}
}
@ -336,25 +435,58 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
int lcd_panel_width;
int lcd_panel_height;
WWColorMap color_map;
int border;
WWPalette border_palette;
int border_color;
WWScreen screen;
WWSprite sprite;
WWCursor cursor;
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 = WWDisplay_GetBorder(display);
border_palette = WWDisplay_GetBorderPalette(display);
border_color = WWDisplay_GetBorderColor(display);
/* カラー対応 */
switch (WWDisplay_GetColorMode(display)) {
case COLOR_MODE_GRAYSCALE:
border_color &= (DCM_BORDER_COLOR >> 8);
border_color = WWColorMap_GetLCDColor(color_map, border_color);
break;
case COLOR_MODE_4COLOR:
border_color &= 0x03;
border_color =
((unsigned short int)WWPalette_GetRed( border_palette,border_color)<<8)|
((unsigned short int)WWPalette_GetGreen(border_palette,border_color)<<4)|
((unsigned short int)WWPalette_GetBlue( border_palette,border_color)<<0);
break;
case COLOR_MODE_16COLOR:
case COLOR_MODE_16PACKED:
border_color &= 0x0f;
border_color =
((unsigned short int)WWPalette_GetRed( border_palette,border_color)<<8)|
((unsigned short int)WWPalette_GetGreen(border_palette,border_color)<<4)|
((unsigned short int)WWPalette_GetBlue( border_palette,border_color)<<0);
break;
default:
WonX_Error("WWDisplay_DrawLCDPanel", "Unknown color mode.");
}
/* ボーダーカラーで埋める */
for (x = 0; x < lcd_panel_width; x++) {
for (y = 0; y < lcd_panel_height; y++) {
WWLCDPanel_SetPixel(lcd_panel, x, y,
WWColorMap_GetLCDColor(color_map, border));
WWLCDPanel_SetPixel(lcd_panel, x, y, border_color);
}
}
/* スクリーン1描画 */
WWDisplay_DrawScreen(display, WWDisplay_GetScreen(display, 0));
screen = WWDisplay_GetScreen(display, 0);
if (WWText_GetScreen(WWDisplay_GetText(display)) == screen)
cursor = WWDisplay_GetCursor(display);
else
cursor = NULL;
WWDisplay_DrawScreen(display, screen, cursor);
/* スプライト描画(スクリーン2より優先でないもの) */
/* 重なった場合は,番号の若いものが手前に表示される */
@ -369,7 +501,12 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
}
/* スクリーン2描画 */
WWDisplay_DrawScreen(display, WWDisplay_GetScreen(display, 1));
screen = WWDisplay_GetScreen(display, 1);
if (WWText_GetScreen(WWDisplay_GetText(display)) == screen)
cursor = WWDisplay_GetCursor(display);
else
cursor = NULL;
WWDisplay_DrawScreen(display, screen, cursor);
/* スプライト描画(スクリーン2より優先なもの) */
/* 重なった場合は,番号の若いものが手前に表示される */
@ -386,6 +523,38 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
return (0);
}
/*===========================================================================*/
/* 透明色かどうか調べる */
/*===========================================================================*/
int WWDisplay_IsTransparent(WWDisplay display, WWPalette palette, int color)
{
int mode;
int palette_num;
int ret;
if (color != 0) return (0);
mode = WWDisplay_GetColorMode(display);
palette_num = WWPalette_GetNumber(palette);
ret = 0;
switch (mode) {
case COLOR_MODE_GRAYSCALE :
case COLOR_MODE_4COLOR :
ret = ((palette_num / 4) % 2) ? 1 : 0;
break;
case COLOR_MODE_16COLOR :
case COLOR_MODE_16PACKED :
ret = 1;
break;
default :
WonX_Error("WWDisplay_IsTransparent", "Unknown color mode.");
}
return (ret);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/

View File

@ -5,13 +5,6 @@
/* ここから */
/*****************************************************************************/
#include "WWColorMap.h"
#include "WWPalette.h"
#include "WWCharacter.h"
#include "WWSprite.h"
#include "WWScreen.h"
#include "WWLCDPanel.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
@ -19,7 +12,20 @@
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"
/*****************************************************************************/
/* メンバ関数の宣言 */
/*****************************************************************************/
/*===========================================================================*/
@ -32,6 +38,11 @@ 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);
@ -40,7 +51,8 @@ int WWDisplay_GetSpriteWindowY(WWDisplay d);
int WWDisplay_GetSpriteWindowWidth(WWDisplay d);
int WWDisplay_GetSpriteWindowHeight(WWDisplay d);
int WWDisplay_GetBorder(WWDisplay d);
WWPalette WWDisplay_GetBorderPalette(WWDisplay d);
int WWDisplay_GetBorderColor(WWDisplay d);
int WWDisplay_GetForegroundColor(WWDisplay d);
int WWDisplay_GetBackgroundColor(WWDisplay d);
@ -58,6 +70,10 @@ 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);
@ -67,7 +83,8 @@ int WWDisplay_SetSpriteWindowY(WWDisplay d, int n);
int WWDisplay_SetSpriteWindowWidth(WWDisplay d, int n);
int WWDisplay_SetSpriteWindowHeight(WWDisplay d, int n);
int WWDisplay_SetBorder(WWDisplay d, int b);
WWPalette WWDisplay_SetBorderPalette(WWDisplay d, WWPalette p);
int WWDisplay_SetBorderColor(WWDisplay d, int b);
int WWDisplay_SetForegroundColor(WWDisplay d, int c);
int WWDisplay_SetBackgroundColor(WWDisplay d, int c);
@ -89,6 +106,12 @@ WWDisplay WWDisplay_Destroy(WWDisplay display);
int WWDisplay_DrawLCDPanel(WWDisplay display);
/*===========================================================================*/
/* 透明色かどうか調べる */
/*===========================================================================*/
int WWDisplay_IsTransparent(WWDisplay display, WWPalette palette, int color);
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/

View File

@ -19,8 +19,12 @@ 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; /* スプライトウインドウ用 */
@ -28,14 +32,16 @@ typedef struct _WWDisplay {
int sprite_window_width; /* スプライトウインドウ用 */
int sprite_window_height; /* スプライトウインドウ用 */
int border; /* ボーダーカラー07のカラーマップ番号 */
/* ボーダーカラーのパレット.カラーで必要 */
WWPalette border_palette;
/* ボーダーカラー白黒の場合には07のカラーマップ番号 */
int border_color;
int foreground_color; /* モノクロフォント展開時の色 */
int background_color; /* モノクロフォント展開時の色 */
int sprite_start; /* スプライトの描画の指定 */
int sprite_count; /* スプライトの描画の指定 */
} _WWDisplay;
/*****************************************************************************/

View File

@ -3,7 +3,7 @@
/*****************************************************************************/
#include "WWInterruptP.h"
#include "etc.h"
#include "WonX.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.");
WonX_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.");
WonX_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.");
WonX_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.");
WonX_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.");
WonX_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.");
WonX_Error("WWInterrupt_Destroy", "Object is not created.");
for (i = 0; i < 8; i++) {
vector = WWInterrupt_GetVector(interrupt, i);

View File

@ -5,11 +5,6 @@
/* ここから */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "wonx_include/system.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
@ -17,6 +12,15 @@
typedef struct _WWInterrupt * WWInterrupt;
typedef void (*WWInterruptCallback)();
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "wonx/system.h"
/*****************************************************************************/
/* メンバ関数の宣言 */
/*****************************************************************************/

View File

@ -3,7 +3,7 @@
/*****************************************************************************/
#include "WWLCDPanelP.h"
#include "etc.h"
#include "WonX.h"
/*****************************************************************************/
/* ¥á¥ó¥Ð´Ø¿ô¤ÎÄêµÁ */
@ -28,56 +28,59 @@ int WWLCDPanel_ResetAllDraw(WWLCDPanel p) { return (p->all_draw = 0); }
int WWLCDPanel_SetAllDraw(WWLCDPanel p) { return (p->all_draw = 1); }
int WWLCDPanel_IsAllDraw(WWLCDPanel p) { return (p->all_draw); }
unsigned char * WWLCDPanel_GetPixelMap(WWLCDPanel p)
unsigned short int * WWLCDPanel_GetPixelMap(WWLCDPanel p)
{
return (p->pixel[p->current]);
}
/* LCDはピクセル16色(4ビット必要) */
static int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel, int current,
int x, int y)
/* LCDはピクセル4096色(12ビット必要) */
static unsigned short int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel,
int current,
int x, int y)
{
unsigned char pixel;
unsigned short int pixel;
if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
return (-1);
pixel = lcd_panel->pixel[current][y * WWLCDPanel_GetWidth(lcd_panel) + x];
pixel &= 0x0f;
return ((int)pixel);
}
static int WWLCDPanel_GetOldPixel(WWLCDPanel lcd_panel, int x, int y)
static unsigned short int WWLCDPanel_GetOldPixel(WWLCDPanel lcd_panel,
int x, int y)
{
return (WWLCDPanel_GetPixelByCurrent(lcd_panel, 1 - lcd_panel->current, x, y));
return (WWLCDPanel_GetPixelByCurrent(lcd_panel,
1 - lcd_panel->current, x, y));
}
int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y)
unsigned short int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y)
{
return (WWLCDPanel_GetPixelByCurrent(lcd_panel, lcd_panel->current, x, y));
}
int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y, int pixel)
unsigned short int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y,
unsigned short int pixel)
{
unsigned char p;
unsigned short int p;
int n;
if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
return (-1);
p = ((unsigned char)pixel) & 0x0f;
p = pixel & 0x0fff;
n = y * WWLCDPanel_GetWidth(lcd_panel) + x;
lcd_panel->pixel[lcd_panel->current][n] = p;
return (pixel);
return (p);
}
int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y)
{
int old_pixel;
int current_pixel;
unsigned short int old_pixel;
unsigned short int current_pixel;
if (WWLCDPanel_IsAllDraw(lcd_panel)) return (1);
old_pixel = WWLCDPanel_GetOldPixel(lcd_panel, x, y);
@ -90,24 +93,26 @@ 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.");
WonX_Error("WWLCDPanel_Create", "Cannot allocate memory.");
WWLCDPanel_SetWidth( lcd_panel, width);
WWLCDPanel_SetHeight(lcd_panel, height);
for (i = 0; i < 2; i++) {
lcd_panel->pixel[i] =
(unsigned char *)malloc(sizeof(unsigned char) *
WWLCDPanel_GetWidth(lcd_panel) *
WWLCDPanel_GetHeight(lcd_panel));
p = (unsigned short int *)malloc(sizeof(unsigned short int) *
WWLCDPanel_GetWidth(lcd_panel) *
WWLCDPanel_GetHeight(lcd_panel));
if (p == NULL) WonX_Error("WWLCDPanel_Create", "Cannot allocate memory.");
lcd_panel->pixel[i] = p;
}
for (y = 0; y < lcd_panel->height; y++) {
for (x = 0; x < lcd_panel->width / 2; x++) {
WWLCDPanel_SetPixel(lcd_panel, x, y, 0x00);
WWLCDPanel_SetPixel(lcd_panel, x, y, 0);
}
}
@ -120,11 +125,16 @@ WWLCDPanel WWLCDPanel_Create(int width, int height)
WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel)
{
int i;
if (lcd_panel == NULL) return (NULL);
if (lcd_panel == NULL)
WonX_Error("WWLCDPanel_Destroy", "Object is not created.");
for (i = 0; i < 2; i++) {
if (lcd_panel->pixel[i]) free(lcd_panel->pixel[i]);
}
free(lcd_panel);
return (NULL);
}

View File

@ -5,14 +5,18 @@
/* ここから */
/*****************************************************************************/
#include <stdlib.h>
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WWLCDPanel * WWLCDPanel;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdlib.h>
/*****************************************************************************/
/* メンバ関数の宣言 */
/*****************************************************************************/
@ -28,9 +32,10 @@ int WWLCDPanel_ResetAllDraw(WWLCDPanel p);
int WWLCDPanel_SetAllDraw(WWLCDPanel p);
int WWLCDPanel_IsAllDraw(WWLCDPanel p);
unsigned char * WWLCDPanel_GetPixelMap(WWLCDPanel p);
int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y);
int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y, int pixel);
unsigned short int * WWLCDPanel_GetPixelMap(WWLCDPanel p);
unsigned short int WWLCDPanel_GetPixel(WWLCDPanel lcd_panel, int x, int y);
unsigned short int WWLCDPanel_SetPixel(WWLCDPanel lcd_panel, int x, int y,
unsigned short int pixel);
int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y);
WWLCDPanel WWLCDPanel_Create(int width, int height);
WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel);

View File

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

View File

@ -3,6 +3,7 @@
/*****************************************************************************/
#include "WWPaletteP.h"
#include "WonX.h"
#include "etc.h"
/*****************************************************************************/
@ -12,20 +13,57 @@
int WWPalette_GetNumber(WWPalette p) { return (p->number); }
int WWPalette_SetNumber(WWPalette p, int n) { return (p->number = n); }
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
int WWPalette_GetTransparent(WWPalette p) { return (p->transparent); }
int WWPalette_SetTransparent(WWPalette p, int f)
{ return (p->transparent = f); }
#endif
WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent)
int WWPalette_GetRed( WWPalette p, int n) { return (p->red[ n]); }
int WWPalette_GetGreen(WWPalette p, int n) { return (p->green[n]); }
int WWPalette_GetBlue( WWPalette p, int n) { return (p->blue[ n]); }
int WWPalette_SetRed( WWPalette p, int n, int value)
{ return (p->red[ n] = value); }
int WWPalette_SetGreen(WWPalette p, int n, int value)
{ return (p->green[n] = value); }
int WWPalette_SetBlue( WWPalette p, int n, int value)
{ return (p->blue[ n] = value); }
/*
* WonX-2.0 WWDisplay
* WWPalette
*
* WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent)
* transparent
*/
WWPalette WWPalette_Create(int number, int * mapped_colors)
{
WWPalette palette;
int i;
palette = (WWPalette)malloc(sizeof(_WWPalette));
if (palette == NULL)
Wonx_Error("WWPalette_Create", "Cannot allocate memory");
WonX_Error("WWPalette_Create", "Cannot allocate memory");
WWPalette_SetNumber(palette, number);
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
WWPalette_SetTransparent(palette, transparent);
#endif
for (i = 0; i < 16; i++) {
WWPalette_SetRed( palette, i, 0);
WWPalette_SetGreen(palette, i, 0);
WWPalette_SetBlue( palette, i, 0);
}
WWPalette_SetMappedColors(palette, mapped_colors);
return (palette);
@ -33,7 +71,8 @@ WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent)
WWPalette WWPalette_Destroy(WWPalette palette)
{
if (palette == NULL) return (NULL);
if (palette == NULL)
WonX_Error("WWPalette_Destroy", "Object is not created.");
free(palette);
return (NULL);
}
@ -69,35 +108,73 @@ int WWPalette_GetMappedColor(WWPalette palette, int color)
int pixel;
pixel = palette->mapped_color[color];
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
if (WWPalette_GetTransparent(palette) && (pixel == 0)) {
pixel = -1;
}
#endif
return (pixel);
}
int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_color)
{
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
if (mapped_color == -1) mapped_color = 0;
#endif
return (palette->mapped_color[color] = mapped_color);
}
int WWPalette_PrintData(WWPalette p, FILE * f)
int WWPalette_PrintData(WWPalette p, WWDisplay display, FILE * f)
{
int i, n;
int transparent;
int red, green, blue;
n = WWPalette_GetNumber(p);
fprintf(f, "\n");
fprintf(f, "palette[%d] :\tnumber = %d\n", n, WWPalette_GetNumber(p));
fprintf(f, "palette[%d] :\ttransparent = %s\n",
n, true_false(WWPalette_GetTransparent(p)));
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
for (i = 0; i < 4; i++) {
fprintf(f, "palette[%d] :\tcolor[%d] = %d\n",
fprintf(f, "palette[%02d] :\tcolor[%01d] = %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);

View File

@ -5,30 +5,59 @@
/* ここから */
/*****************************************************************************/
#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, FILE * f);
int WWPalette_PrintData(WWPalette p, WWDisplay display, FILE * f);
/*****************************************************************************/
/* ここまで */

View File

@ -12,12 +12,28 @@
/*****************************************************************************/
typedef struct _WWPalette {
int number;
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
int transparent; /* 0 は透明色になるかどうかのフラグ */
#endif
/* カラーマップの8色中から4色を選択 */
int mapped_color[4]; /* カラーマップの番号(07)を持つ */
/* 白黒モードの場合にはカラーマップの8色中から4色を選択 */
int mapped_color[4]; /* 白黒モードでは,カラーマップの番号(07)を持つ */
/*
* 416rgb 使
* 403使
* 16015使
*/
int red[16];
int green[16];
int blue[16];
} _WWPalette;

View File

@ -3,7 +3,7 @@
/*****************************************************************************/
#include "WWScreenP.h"
#include "etc.h"
#include "WonX.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.");
WonX_Error("WWScreenCharacter", "Cannot allocate memory.");
WWScreenCharacter_SetHorizontal(screen_character, horizontal);
WWScreenCharacter_SetVertical(screen_character, vertical);
@ -54,7 +54,8 @@ static WWScreenCharacter WWScreenCharacter_Create(int horizontal, int vertical,
static WWScreenCharacter WWScreenCharacter_Destroy(WWScreenCharacter
screen_character)
{
if (screen_character == NULL) return (NULL);
if (screen_character == NULL)
WonX_Error("WWScreenCharacter_Destroy", "Object is not created.");
free(screen_character);
return (NULL);
}
@ -159,7 +160,8 @@ int WWScreen_SetDrawWidth( WWScreen s, int n) { return (s->draw_width = n); }
int WWScreen_SetDrawHeight(WWScreen s, int n) { return (s->draw_height = n); }
/* カラーマップの色(07)を返す(透明色は-1を返す) */
int WWScreen_GetPixel(WWScreen screen, int x, int y)
int WWScreen_GetPixel(WWScreen screen, int x, int y,
WWDisplay display, WWCursor cursor)
{
int cx, cy, px, py;
int pixel;
@ -180,10 +182,45 @@ 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);
pixel = WWCharacter_GetPixel(character, px, py);
pixel = WWPalette_GetMappedColor(palette, pixel);
/* カーソル表示の処理 */
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;
return (pixel);
}
@ -201,7 +238,7 @@ WWScreen WWScreen_Create(int number,
screen = (WWScreen)malloc(sizeof(_WWScreen));
if (screen == NULL)
Wonx_Error("WWScreen_Create", "Cannot allocate memory.");
WonX_Error("WWScreen_Create", "Cannot allocate memory.");
WWScreen_SetNumber(screen, number);
WWScreen_SetWidth( screen, width);
@ -236,7 +273,8 @@ WWScreen WWScreen_Destroy(WWScreen screen)
int x, y;
WWScreenCharacter sc;
if (screen == NULL) return (NULL);
if (screen == NULL)
WonX_Error("WWScreen_Destroy", "Object is not created.");
for (y = 0; y < screen->height; y++) {
for (x = 0; x < screen->width; x++) {

View File

@ -5,17 +5,23 @@
/* ここから */
/*****************************************************************************/
#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"
/*****************************************************************************/
/* 年眶の年盗 */
/*****************************************************************************/
@ -66,7 +72,8 @@ int WWScreen_SetDrawY( WWScreen s, int n);
int WWScreen_SetDrawWidth( WWScreen s, int n);
int WWScreen_SetDrawHeight(WWScreen s, int n);
int WWScreen_GetPixel(WWScreen screen, int x, int y);
int WWScreen_GetPixel(WWScreen screen, int x, int y,
WWDisplay display, WWCursor cursor);
WWScreen WWScreen_Create(int number,
int width, int height,

View File

@ -3,16 +3,16 @@
/*****************************************************************************/
#include "WWSerialPortP.h"
#include "etc.h"
#include "WonX.h"
/*****************************************************************************/
/* ¥á¥ó¥Ð´Ø¿ô¤ÎÄêµÁ */
/*****************************************************************************/
int WWSerialPort_ON( WWSerialPort s) { return (s->port_on = 1); }
int WWSerialPort_OFF( WWSerialPort s) { return (s->port_on = 0); }
int WWSerialPort_IsON( WWSerialPort s) { return (s->port_on != 0); }
int WWSerialPort_IsOFF(WWSerialPort s) { return (s->port_on == 0); }
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)
@ -51,9 +51,9 @@ WWSerialPort WWSerialPort_Create()
ww_serial_port = (WWSerialPort)malloc(sizeof(_WWSerialPort));
if (ww_serial_port == NULL)
Wonx_Error("WWSerialPort_Create", "Cannot allocate memory.");
WonX_Error("WWSerialPort_Create", "Cannot allocate memory.");
WWSerialPort_OFF(ww_serial_port);
WWSerialPort_Close(ww_serial_port);
WWSerialPort_SetBaudrate38400(ww_serial_port);
WWSerialPort_SetSendTimeout(ww_serial_port, 100);
WWSerialPort_SetReceiveTimeout(ww_serial_port, 100);
@ -68,7 +68,9 @@ WWSerialPort WWSerialPort_Create()
WWSerialPort WWSerialPort_Destroy(WWSerialPort ww_serial_port)
{
if (ww_serial_port == NULL)
Wonx_Error("WWSerialPort_Destroy", "Object is not created.");
WonX_Error("WWSerialPort_Destroy", "Object is not created.");
WWSerialPort_Close(ww_serial_port);
free(ww_serial_port);

View File

@ -5,28 +5,36 @@
/* ここから */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "wonx_include/comm.h"
#define WW_SERIAL_PORT_BAUDRATE_9600 0
#define WW_SERIAL_PORT_BAUDRATE_38400 1
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
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_ON( WWSerialPort s);
int WWSerialPort_OFF( WWSerialPort s);
int WWSerialPort_IsON( WWSerialPort s);
int WWSerialPort_IsOFF(WWSerialPort s);
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);

View File

@ -13,7 +13,7 @@
typedef struct _WWSerialPort {
int port_on; /* ポートの状態 */
int opened; /* ポートの状態(open/close) */
int baudrate; /* ボーレート */
/*

View File

@ -3,6 +3,7 @@
/*****************************************************************************/
#include "WWSpriteP.h"
#include "WonX.h"
#include "etc.h"
/*****************************************************************************/
@ -37,20 +38,45 @@ int WWSprite_SetPosition(WWSprite sprite, int x, int y)
return (0);
}
int WWSprite_GetPixel(WWSprite sprite, int x, int y)
/* スプライトのピクセル値を返す.(透明色は-1を返す) */
int WWSprite_GetPixel(WWSprite sprite, int x, int y, WWDisplay display)
{
WWPalette p;
WWCharacter c;
WWPalette palette;
WWCharacter character;
int pixel;
p = WWSprite_GetPalette(sprite);
c = WWSprite_GetCharacter(sprite);
palette = WWSprite_GetPalette(sprite);
character = WWSprite_GetCharacter(sprite);
if (WWSprite_GetHorizontal(sprite)) x = 7 - x;
if (WWSprite_GetVertical( sprite)) y = 7 - y;
pixel = WWCharacter_GetPixel(c, x, y);
pixel = WWPalette_GetMappedColor(p, pixel);
pixel = WWCharacter_GetPixel(character, x, y, display);
/* カラー対応 */
switch (WWDisplay_GetColorMode(display)) {
case COLOR_MODE_GRAYSCALE:
/*
* WonX-2.0 WWDisplay
* WWPalette_GetMappedColor() -1
*/
pixel = WWPalette_GetMappedColor(palette, pixel);
break;
case COLOR_MODE_4COLOR:
case COLOR_MODE_16COLOR:
case COLOR_MODE_16PACKED:
pixel =
((unsigned short int)WWPalette_GetRed( palette, pixel) << 8) |
((unsigned short int)WWPalette_GetGreen(palette, pixel) << 4) |
((unsigned short int)WWPalette_GetBlue( palette, pixel) << 0);
break;
default:
WonX_Error("WWSprite_GetPixel", "Unknown color mode.");
}
/* 透明色の場合には -1 を返す */
if (WWDisplay_IsTransparent(display, palette, pixel))
pixel = -1;
return (pixel);
}
@ -64,7 +90,7 @@ WWSprite WWSprite_Create(int number, int x, int y,
sprite = (WWSprite)malloc(sizeof(_WWSprite));
if (sprite == NULL)
Wonx_Error("WWSprite_Create", "Cannot allocate memory.");
WonX_Error("WWSprite_Create", "Cannot allocate memory.");
WWSprite_SetNumber(sprite, number);
WWSprite_SetHorizontal(sprite, horizontal);
@ -81,7 +107,8 @@ WWSprite WWSprite_Create(int number, int x, int y,
WWSprite WWSprite_Destroy(WWSprite sprite)
{
if (sprite == NULL) return (NULL);
if (sprite == NULL)
WonX_Error("WWSprite_Destroy", "Object is not created.");
free(sprite);
return (NULL);
}
@ -94,21 +121,21 @@ int WWSprite_PrintData(WWSprite s, FILE * f)
fprintf(f, "\n");
fprintf(f, "sprite[%d] :\tnumber = %d\n", n, WWSprite_GetNumber(s));
fprintf(f, "sprite[%d] :\thorizontal = %s\n",
n, true_false(WWSprite_GetHorizontal(s)));
fprintf(f, "sprite[%d] :\tvertical = %s\n",
n, true_false(WWSprite_GetVertical( s)));
fprintf(f, "sprite[%d] :\tpriority = %s\n",
n, true_false(WWSprite_GetPriority( s)));
fprintf(f, "sprite[%d] :\tclipping = %s\n",
n, true_false(WWSprite_GetClipping( s)));
fprintf(f, "sprite[%d] :\tpalette number = %d\n",
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",
n, WWPalette_GetNumber(WWSprite_GetPalette(s)));
fprintf(f, "sprite[%d] :\tcharacter number = %d\n",
fprintf(f, "sprite[%03d] :\tcharacter number = %d\n",
n, WWCharacter_GetNumber(WWSprite_GetCharacter(s)));
fprintf(f, "sprite[%d] :\tx = %d\n", n, WWSprite_GetX(s));
fprintf(f, "sprite[%d] :\ty = %d\n", n, WWSprite_GetY(s));
fprintf(f, "sprite[%03d] :\tx = %d\n", n, WWSprite_GetX(s));
fprintf(f, "sprite[%03d] :\ty = %d\n", n, WWSprite_GetY(s));
fflush(f);

View File

@ -5,17 +5,22 @@
/* ここから */
/*****************************************************************************/
#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"
/*****************************************************************************/
/* メンバ関数の宣言 */
/*****************************************************************************/
@ -39,7 +44,7 @@ WWCharacter WWSprite_SetCharacter(WWSprite s, WWCharacter c);
int WWSprite_GetX(WWSprite sprite);
int WWSprite_GetY(WWSprite sprite);
int WWSprite_SetPosition(WWSprite sprite, int x, int y);
int WWSprite_GetPixel(WWSprite sprite, int x, int y);
int WWSprite_GetPixel(WWSprite sprite, int x, int y, WWDisplay display);
WWSprite WWSprite_Create(int number, int x, int y,
int horizontal, int vertical,

View File

@ -3,7 +3,7 @@
/*****************************************************************************/
#include "WWTextP.h"
#include "etc.h"
#include "WonX.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) WonX_Error("WWText_SetTextWindow", "Over character.");
ww_character = WWDisplay_GetCharacter(ww_display, c);
WWCharacter_SetBitmap(ww_character, NULL);
WWCharacter_ClearAllPixels(ww_character);
WWScreen_SetCharacter(WWText_GetScreen(ww_text),
WWText_GetX(ww_text) + tx,
WWText_GetY(ww_text) + ty,
@ -72,10 +72,13 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
WWDisplay ww_display)
{
WWCharacter ww_character;
int j, k, n;
int f, b;
unsigned short int pixel;
unsigned short int bitmap;
if ((character < 0) || (character > 127)) {
printf("warning : WWText_PutCharacter() : Character number is out of range.\n");
fflush(stdout);
WonX_Warning("WWText_PutCharacter", "Character number is out of range.");
return (-1);
}
@ -86,8 +89,7 @@ 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) ) {
printf("warning : WWText_PutCharacter() : Position is out of range.\n");
fflush(stdout);
WonX_Warning("WWText_PutCharacter", "Position is out of range.");
return (-1);
}
@ -102,7 +104,34 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
WWText_GetY(ww_text) + y);
#endif
WWCharacter_CopyBitmap(ww_character, WWText_GetFont(ww_text, character));
/*
*
* f = WWDisplay_GetForegroundColor(ww_display);
* b = WWDisplay_GetBackgroundColor(ww_display);
*
*
* WWCharacter
* WWCharacter
*/
#if 0
WWCharacter_CopyAllPixels(ww_character, WWText_GetFont(ww_text, character));
#else
f = WWDisplay_GetForegroundColor(ww_display);
b = WWDisplay_GetBackgroundColor(ww_display);
n = character * 8;
for (j = 0; j < 8; j++) {
bitmap = 0;
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
/* 表示時にパレットを設定するのでいいのか? 不明 */
WWScreen_SetPalette(WWText_GetScreen(ww_text),
@ -122,20 +151,44 @@ WWText WWText_Create(WWScreen screen,
WWPalette palette)
{
WWText ww_text;
int i;
WWCharacter ww_character;
int i, j, k, n;
int f, b;
unsigned short int pixel;
unsigned short int bitmap;
ww_text = (WWText)malloc(sizeof(_WWText));
if (ww_text == NULL) Wonx_Error("WWText_Create", "Cannot allocate memory.");
if (ww_text == NULL) WonX_Error("WWText_Create", "Cannot allocate memory.");
WWText_SetScreen(ww_text, screen);
WWText_SetX(ww_text, 0);
WWText_SetY(ww_text, 0);
WWText_SetX(ww_text, x);
WWText_SetY(ww_text, y);
WWText_SetWidth( ww_text, width );
WWText_SetHeight(ww_text, height);
WWText_SetPalette(ww_text, palette);
/* 以下は,
f = WWDisplay_GetForegroundColor(ww_display);
b = WWDisplay_GetBackgroundColor(ww_display);
*/
f = 3;
b = 0;
n = 0;
for (i = 0; i < 128; i++) {
WWText_SetFont(ww_text, i, WWCharacter_Create(i, &(fonts[i * 16])));
ww_character = WWCharacter_Create(i);
for (j = 0; j < 8; j++) {
bitmap = 0;
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);
}
return (ww_text);
@ -145,7 +198,8 @@ WWText WWText_Destroy(WWText ww_text)
{
int i;
if (ww_text == NULL) Wonx_Error("WWText_Destroy", "Object is not created.");
if (ww_text == NULL)
WonX_Error("WWText_Destroy", "Object is not created.");
for (i = 0; i < 128; i++) {
if (WWText_GetFont(ww_text, i))

View File

@ -5,16 +5,20 @@
/* ここから */
/*****************************************************************************/
#include "WWDisplay.h"
#include "WWScreen.h"
#include "WWPalette.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WWText * WWText;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include "WWDisplay.h"
#include "WWScreen.h"
#include "WWPalette.h"
/*===========================================================================*/
/* メンバの取得 */
/*===========================================================================*/
@ -53,21 +57,6 @@ WWText WWText_Create(WWScreen screen, int x, int y, int width, int height,
WWPalette palette);
WWText WWText_Destroy(WWText text);
/*****************************************************************************/
/* ¤³¤³¤Þ¤Ç */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/

View File

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

View File

@ -21,6 +21,17 @@ typedef struct _WWText {
int base; /* 使用するキャラクタのベース */
WWPalette palette;
/*
*
* f = WWDisplay_GetForegroundColor(ww_display);
* b = WWDisplay_GetBackgroundColor(ww_display);
*
*
* WWCharacter
* WWCharacter
* (WWText_PutCharacter() )
*/
WWCharacter font[128]; /* フォント */
} _WWText;

View File

@ -3,7 +3,7 @@
/*****************************************************************************/
#include "WWTimerP.h"
#include "etc.h"
#include "WonX.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.");
WonX_Error("WWTimer_Create", "Cannot allocate memory.");
WWTimer_OFF(ww_timer);
WWTimer_SetAutoPreset(ww_timer, auto_preset);
@ -98,7 +98,9 @@ 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.");
WonX_Error("WWTimer_Destroy", "Object is not created.");
WWTimer_OFF(ww_timer);
free(ww_timer);

View File

@ -5,17 +5,21 @@
/* ここから */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "wonx_include/timer.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WWTimer * WWTimer;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "wonx/timer.h"
/*****************************************************************************/
/* メンバ関数の宣言 */
/*****************************************************************************/

126
WonX.c Normal file
View File

@ -0,0 +1,126 @@
#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 Normal file
View File

@ -0,0 +1,26 @@
#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. */
/*****************************************************************************/

View File

@ -2,73 +2,99 @@
/* ここから */
/*****************************************************************************/
#include "WonxDisplayP.h"
#include "etc.h"
#include "WonXDisplayP.h"
#include "WonX.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.");
WonX_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);
WonX_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);
WonX_Error("WonXDisplay_Create", "Cannot create X display.");
WonXDisplay_SetXDisplay(wonx_display, x_display);
return (wonx_display);
}
int WonxDisplay_Sync(WonxDisplay 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 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), stdout);
WWPalette_PrintData(WWDisplay_GetPalette(ww_display, i),
ww_display, stdout);
fflush(stdout);
}
XDisplay_SetPalettePrint(x_display, 0);
}
if (XDisplay_GetCharacterPrint(x_display)) {
for (i = 0; i < 512; i++) {
WWCharacter_PrintData(WWDisplay_GetCharacter(ww_display, i), stdout);
WWCharacter_PrintData(WWDisplay_GetCharacter(ww_display, i),
ww_display, stdout);
fflush(stdout);
}
XDisplay_SetCharacterPrint(x_display, 0);
}
@ -76,31 +102,48 @@ int WonxDisplay_Sync(WonxDisplay wonx_display)
if (XDisplay_GetSpritePrint(x_display)) {
for (i = 0; i < 128; i++) {
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, i), stdout);
fflush(stdout);
}
XDisplay_SetSpritePrint(x_display, 0);
}
XDisplay_Sync(x_display);
return (0);
}
int WonxDisplay_Flush(WonxDisplay wonx_display)
int WonXDisplay_DrawLCDWindow(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);
if (XDisplay_GetLCDDraw(x_display)) {
/* 表示レベルが1以上のときだけ描画する */
if (XDisplay_GetLCDDrawLevel(x_display) > 0) {
WWDisplay_DrawLCDPanel(ww_display);
ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
XDisplay_DrawLCDWindow(x_display, ww_lcd_panel);
XDisplay_DrawLCDWindow(x_display, ww_display, ww_lcd_panel);
}
WonxDisplay_Sync(wonx_display);
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);
return (0);
}

View File

@ -1,26 +1,37 @@
#ifndef _WonxDisplay_h_INCLUDED_
#define _WonxDisplay_h_INCLUDED_
#ifndef _WonXDisplay_h_INCLUDED_
#define _WonXDisplay_h_INCLUDED_
/*****************************************************************************/
/* ¤³¤³¤«¤é */
/*****************************************************************************/
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonXDisplay * WonXDisplay;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include "XDisplay.h"
#include "WWDisplay.h"
/*****************************************************************************/
/* クラスの年盗 */
/* メンバ関数の宣言 */
/*****************************************************************************/
typedef struct _WonxDisplay * WonxDisplay;
XDisplay WonxDisplay_GetXDisplay(WonxDisplay wonx_display);
WWDisplay WonxDisplay_GetWWDisplay(WonxDisplay wonx_display);
WonxDisplay WonxDisplay_Create(int x_width, int x_height,
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);
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);
/*****************************************************************************/
/* ¤³¤³¤Þ¤Ç */

View File

@ -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;
/*****************************************************************************/
/* ここまで */

View File

@ -1,24 +1,23 @@
#ifndef _WonxP_h_INCLUDED_
#define _WonxP_h_INCLUDED_
#ifndef _WonXP_h_INCLUDED_
#define _WonXP_h_INCLUDED_
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "Wonx.h"
#include "WonX.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _Wonx {
WonxDisplay wonx_display;
WonxText wonx_text;
WonxSystem wonx_system;
WonxSerialPort wonx_serial_port;
} _Wonx;
typedef struct _WonX {
WonXDisplay wonx_display;
WonXSystem wonx_system;
WonXSerialPort wonx_serial_port;
} _WonX;
typedef struct _Wonx * Wonx;
typedef struct _WonX * WonX;
/*****************************************************************************/
/* ここまで */

78
WonXSerialPort.c Normal file
View File

@ -0,0 +1,78 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#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. */
/*****************************************************************************/

View File

@ -1,28 +1,37 @@
#ifndef _WonxSerialPort_h_INCLUDED_
#define _WonxSerialPort_h_INCLUDED_
#ifndef _WonXSerialPort_h_INCLUDED_
#define _WonXSerialPort_h_INCLUDED_
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WWSerialPort.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonxSerialPort * WonxSerialPort;
typedef struct _WonXSerialPort * WonXSerialPort;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include "WWSerialPort.h"
#include "UNIXSerialPort.h"
/*****************************************************************************/
/* メンバ関数の定義 */
/*****************************************************************************/
WWSerialPort WonxSerialPort_GetWWSerialPort(WonxSerialPort wonx_serial_port);
WWSerialPort WonxSerialPort_SetWWSerialPort(WonxSerialPort wonx_serial_port,
WWSerialPort ww_serial_port);
WWSerialPort WonXSerialPort_GetWWSerialPort(WonXSerialPort wonx_sp);
WWSerialPort WonXSerialPort_SetWWSerialPort(WonXSerialPort wonx_sp,
WWSerialPort ww_sp);
WonxSerialPort WonxSerialPort_Create();
WonxSerialPort WonxSerialPort_Destroy(WonxSerialPort wonx_serial_port);
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);
/*****************************************************************************/
/* ここまで */

View File

@ -1,19 +1,20 @@
#ifndef _WonxSerialPortP_h_INCLUDED_
#define _WonxSerialPortP_h_INCLUDED_
#ifndef _WonXSerialPortP_h_INCLUDED_
#define _WonXSerialPortP_h_INCLUDED_
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WonxSerialPort.h"
#include "WonXSerialPort.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonxSerialPort {
typedef struct _WonXSerialPort {
WWSerialPort ww_serial_port;
} _WonxSerialPort;
UNIXSerialPort unix_serial_port;
} _WonXSerialPort;
/*****************************************************************************/
/* ここまで */

221
WonXSystem.c Normal file
View File

@ -0,0 +1,221 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#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. */
/*****************************************************************************/

View File

@ -1,46 +1,50 @@
#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);
/*****************************************************************************/
/* ここまで */

View File

@ -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;
/*****************************************************************************/
/* ここまで */

68
Wonx.c
View File

@ -1,68 +0,0 @@
#include "WonxP.h"
#include "etc.h"
#include "wonx_include/disp.h"
#include "wonx_include/text.h"
#include "wonx_include/system.h"
#include "wonx_include/comm.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) Wonx_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();
wonx->wonx_serial_port = WonxSerialPort_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);
}
WonxSerialPort Wonx_GetWonxSerialPort(void)
{
return (wonx->wonx_serial_port);
}

20
Wonx.h
View File

@ -1,20 +0,0 @@
#ifndef _wonx_h_INCLUDED_
#define _wonx_h_INCLUDED_
#include "WonxDisplay.h"
#include "WonxText.h"
#include "WonxSystem.h"
#include "WonxSerialPort.h"
/*****************************************************************************/
/* ¥Ç¥£¥¹¥×¥ì¥¤¤Î³ÎÊÝ */
/*****************************************************************************/
int Wonx_IsCreated(void);
void Wonx_Create(void);
WonxDisplay Wonx_GetWonxDisplay(void);
WonxText Wonx_GetWonxText(void);
WonxSystem Wonx_GetWonxSystem(void);
WonxSerialPort Wonx_GetWonxSerialPort(void);
#endif

View File

@ -1,59 +0,0 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WonxSerialPortP.h"
#include "etc.h"
/*****************************************************************************/
/* メンバ関数の定義 */
/*****************************************************************************/
WWSerialPort WonxSerialPort_GetWWSerialPort(WonxSerialPort wonx_serial_port)
{ return (wonx_serial_port->ww_serial_port); }
WWSerialPort WonxSerialPort_SetWWSerialPort(WonxSerialPort wonx_serial_port,
WWSerialPort ww_serial_port)
{ return (wonx_serial_port->ww_serial_port = ww_serial_port); }
WonxSerialPort WonxSerialPort_Create()
{
WonxSerialPort wonx_serial_port;
WWSerialPort ww_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);
return (wonx_serial_port);
}
WonxSerialPort WonxSerialPort_Destroy(WonxSerialPort wonx_serial_port)
{
WWSerialPort ww_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));
free(wonx_serial_port);
return (NULL);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

View File

@ -1,171 +0,0 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "wonx_configure.h"
#include "WonxSystemP.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)
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. */
/*****************************************************************************/

View File

@ -1,55 +0,0 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#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)
Wonx_Error("WonxText_Create", "Cannot allocate memory.");
ww_text = WWText_Create(screen, x, y, width, height, palette);
if (ww_text == NULL)
Wonx_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)
Wonx_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. */
/*****************************************************************************/

View File

@ -1,32 +0,0 @@
#ifndef _WonxText_h_INCLUDED_
#define _WonxText_h_INCLUDED_
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WWText.h"
#include "WWScreen.h"
#include "WWPalette.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonxText * WonxText;
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);
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
#endif
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

743
XColorGC.c Normal file
View File

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

98
XColorGC.h Normal file
View File

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

148
XColorGCP.h Normal file
View File

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

View File

@ -8,15 +8,33 @@
#include <unistd.h>
#include "XDisplayP.h"
#include "Wonx.h"
#include "WonX.h"
#include "WonXDisplay.h"
#include "etc.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_GetLCDDraw(XDisplay d) { return (d->lcd_draw); }
int XDisplay_GetLCDDrawLevel(XDisplay d) { return (d->lcd_draw_level); }
int XDisplay_SetLCDDrawLevel(XDisplay d, int level)
{
d->lcd_draw_level = level;
WonXDisplay_Flush(WonX_GetWonXDisplay());
return (d->lcd_draw_level);
}
int XDisplay_LCDDrawLevelDown(XDisplay d)
{ return (XDisplay_SetLCDDrawLevel(d, d->lcd_draw_level - 1)); }
int XDisplay_LCDDrawLevelUp( XDisplay d)
{ return (XDisplay_SetLCDDrawLevel(d, d->lcd_draw_level + 1)); }
int XDisplay_GetColorMapPrint(XDisplay d) {return (d->color_map_print); }
int XDisplay_GetPalettePrint(XDisplay d) {return (d->palette_print); }
@ -68,16 +86,16 @@ static void iconify(Widget w, XEvent * event, String * params, Cardinal * num)
XIconifyWindow(XtDisplay(w), XtWindow(w), DefaultScreen(XtDisplay(w)));
}
static void sleep_3(Widget w, XEvent * event, String * params, Cardinal * num)
static void sleep_10(Widget w, XEvent * event, String * params, Cardinal * num)
{
time_t old_t;
time_t t;
int i;
/* UNIXTimer.c 内部で SIGALRM を使用しているのでsleep() は使用できない */
#if 0
sleep(3);
sleep(10);
#else
for (i = 0; i < 3; i++) {
for (i = 0; i < 10; i++) {
time(&t);
old_t = t;
while (t == old_t)
@ -90,20 +108,22 @@ static XtActionsRec actions[] = {
{"quit", quit},
{"wm_protocols_proc", wm_protocols_proc},
{"iconify", iconify},
{"pause", sleep_3}
{"pause", sleep_10}
};
static char * translations =
"<Message>WM_PROTOCOLS: wm_protocols_proc()\n"
"None<Key>p: pause()\n"
"None<Key>F11: 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)
{
@ -112,11 +132,27 @@ 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;
}
/*---------------------------------------------------------------------------*/
/* キーの押下 */
/*---------------------------------------------------------------------------*/
@ -135,64 +171,107 @@ static void KeyHandler(Widget w, XtPointer p, XEvent * event,
switch (key_sym) {
/* WonderSwan用 */
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;
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;
default : press = 0; break;
}
/* Wonx 操作用 */
if (press) {
if (event->type == KeyPress) {
x_display->key_press |= press;
printf("Pressed\n");
} else {
x_display->key_press &= ~press;
printf("Released\n");
}
}
/* WonX 操作用 */
if (event->type == KeyPress) {
switch (key_sym) {
/* 表示モード変更 */
case XK_p :
x_display->lcd_draw = !(x_display->lcd_draw);
if (x_display->lcd_draw)
WonxDisplay_Flush(Wonx_GetWonxDisplay());
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
}
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;
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;
}
}
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;
}
/*---------------------------------------------------------------------------*/
/* マウスがウインドウを離れたら,キーを初期化する */
/*---------------------------------------------------------------------------*/
@ -227,17 +306,17 @@ XDisplay XDisplay_Create(int width, int height)
x_display = (XDisplay)malloc(sizeof(_XDisplay));
if (x_display == NULL)
Wonx_Error("XDisplay_Create", "Cannot allocate memory.");
WonX_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);
@ -246,7 +325,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 = 1;
x_display->lcd_draw_level = 1;
XtRealizeWidget(x_display->toplevel);
while (!XtIsRealized(x_display->toplevel)) { /* None */ }
@ -280,6 +359,7 @@ 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,
@ -290,6 +370,24 @@ 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],
@ -339,17 +437,87 @@ XDisplay XDisplay_Destroy(XDisplay x_display)
{
int i;
if (x_display == NULL) return (NULL);
if (x_display == NULL)
WonX_Error("XDisplay_Destroy", "Object is not created.");
/* あとでリソースの解放を追加すること */
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サーバと同期をとる */
/* 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]);
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);
@ -361,14 +529,21 @@ 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);
@ -382,89 +557,182 @@ int XDisplay_Sync(XDisplay x_display)
/* 描画 */
/*---------------------------------------------------------------------------*/
int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel)
int XDisplay_DrawLCDWindow(XDisplay x_display, WWDisplay ww_display,
WWLCDPanel ww_lcd_panel)
{
int x, y;
int px, py, ph;
int num;
int n[16];
XRectangle rectangle;
XRectangle * rectangles[16];
int pixel;
unsigned short int pixel;
int ww_lcd_width, ww_lcd_height;
/* 隣接しているピクセルはまとめて描画するので,ピクセル数の最大値は */
/* 最悪の場合(縞々模様のとき)でwidth * height / 2 になる. */
num =
WWLCDPanel_GetHeight(ww_lcd_panel) * WWLCDPanel_GetWidth(ww_lcd_panel) / 2;
/*
* malloc() 使
*
*/
for (pixel = 0; pixel < 16; pixel++) {
n[pixel] = 0;
rectangles[pixel] = (XRectangle *)malloc(sizeof(XRectangle) * num);
}
if (rectangles == NULL)
Wonx_Error("XDisplay_DrawLCDWindow", "Cannot allocate memory.");
int red, green, blue;
XColorGCDatabase database;
XColorGC x_color_gc;
GC gc;
ww_lcd_width = WWLCDPanel_GetWidth( ww_lcd_panel);
ww_lcd_height = WWLCDPanel_GetHeight(ww_lcd_panel);
/* ここの処理はホットスポットになるので,のちのちにチューニングすること */
switch (WWDisplay_GetColorMode(ww_display)) {
for (y = 0; y < ww_lcd_height; y++) {
py = (y * x_display->height) / ww_lcd_height;
ph = (y+1) * x_display->height / ww_lcd_height- py;
for (x = 0; x < ww_lcd_width; x++) {
if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
continue;
}
pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
px = (x * x_display->width ) / ww_lcd_width;
rectangles[pixel][n[pixel]].x = px;
rectangles[pixel][n[pixel]].y = py;
rectangles[pixel][n[pixel]].width =
(x+1) * x_display->width / ww_lcd_width - px;
rectangles[pixel][n[pixel]].height = ph;
case COLOR_MODE_GRAYSCALE:
/* 隣接してる同色のピクセルは,極力いっしょに描画する */
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;
/* 隣接しているピクセルはまとめて描画するので,ピクセル数の最大値は */
/* 最悪の場合(縞々模様のとき)でwidth * height / 2 になる. */
num =
WWLCDPanel_GetHeight(ww_lcd_panel) *
WWLCDPanel_GetWidth(ww_lcd_panel) / 2;
/*
* malloc() 使
*
*/
for (pixel = 0; pixel < 16; pixel++) {
n[pixel] = 0;
rectangles[pixel] = (XRectangle *)malloc(sizeof(XRectangle) * num);
}
if (rectangles == NULL)
WonX_Error("XDisplay_DrawLCDWindow", "Cannot allocate memory.");
/* ここの処理はホットスポットになるので,のちのちにチューニングすること */
for (y = 0; y < ww_lcd_height; y++) {
py = (y * x_display->height) / ww_lcd_height;
ph = (y+1) * x_display->height / ww_lcd_height- py;
for (x = 0; x < ww_lcd_width; x++) {
if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
continue;
}
pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
px = (x * x_display->width ) / ww_lcd_width;
rectangles[pixel][n[pixel]].x = px;
rectangles[pixel][n[pixel]].y = py;
rectangles[pixel][n[pixel]].width =
(x+1) * x_display->width / ww_lcd_width - px;
rectangles[pixel][n[pixel]].height = ph;
/* 隣接してる同色のピクセルは,極力いっしょに描画する */
x++;
while ( (x < ww_lcd_width) &&
(pixel == WWLCDPanel_GetPixel(ww_lcd_panel, x, y)) &&
(WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) ) {
rectangles[pixel][n[pixel]].width =
(x+1) * x_display->width / ww_lcd_width - px;
x++;
}
x--;
n[pixel]++;
}
x--;
n[pixel]++;
}
}
for (pixel = 0; pixel < 16; pixel++) {
if (n[pixel] > 0) {
XFillRectangles(x_display->display,
x_display->lcd_pixmap,
x_display->color_gc[pixel],
rectangles[pixel], n[pixel]);
for (pixel = 0; pixel < 16; pixel++) {
if (n[pixel] > 0) {
XFillRectangles(x_display->display,
x_display->lcd_pixmap,
x_display->color_gc[pixel],
rectangles[pixel], n[pixel]);
}
}
for (pixel = 0; pixel < 16; pixel++) {
free(rectangles[pixel]);
}
break;
case COLOR_MODE_4COLOR:
case COLOR_MODE_16COLOR:
case COLOR_MODE_16PACKED:
database = XDisplay_GetColorGCDatabase(x_display);
for (y = 0; y < ww_lcd_height; y++) {
py = (y * x_display->height) / ww_lcd_height;
ph = (y+1) * x_display->height / ww_lcd_height- py;
for (x = 0; x < ww_lcd_width; x++) {
if (!WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) {
continue;
}
pixel = WWLCDPanel_GetPixel(ww_lcd_panel, x, y);
px = (x * x_display->width ) / ww_lcd_width;
rectangle.x = px;
rectangle.y = py;
rectangle.width = (x+1) * x_display->width / ww_lcd_width - px;
rectangle.height = ph;
/* 隣接してる同色のピクセルは,極力いっしょに描画する */
x++;
while ( (x < ww_lcd_width) &&
(pixel == WWLCDPanel_GetPixel(ww_lcd_panel, x, y)) &&
(WWLCDPanel_IsPixelChanged(ww_lcd_panel, x, y)) ) {
rectangle.width =
(x+1) * x_display->width / ww_lcd_width - px;
x++;
}
x--;
red = (pixel >> 8) & 0xf;
green = (pixel >> 4) & 0xf;
blue = (pixel >> 0) & 0xf;
red = (red == 15) ? 65535 : red * 4096;
green = (green == 15) ? 65535 : green * 4096;
blue = (blue == 15) ? 65535 : blue * 4096;
x_color_gc = XColorGC_CreateFromRGB(database, red, green, blue);
gc = XColorGC_GetGC(x_color_gc);
XFillRectangle(x_display->display,
x_display->lcd_pixmap,
gc,
rectangle.x,
rectangle.y,
rectangle.width,
rectangle.height);
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);
for (pixel = 0; pixel < 16; pixel++) {
free(rectangles[pixel]);
}
return (0);
}
/*---------------------------------------------------------------------------*/
/* GC の作成 */
/*---------------------------------------------------------------------------*/
GC XDisplay_CreateGC(XDisplay x_display)
{
GC gc;
gc = XCreateGC(x_display->display, x_display->lcd_window, 0, 0);
return (gc);
}
/*---------------------------------------------------------------------------*/
/* GC の解放 */
/*---------------------------------------------------------------------------*/
int XDisplay_DestroyGC(XDisplay x_display, GC gc)
{
XFreeGC(x_display->display, gc);
return (0);
}

View File

@ -5,10 +5,6 @@
/* ここから */
/*****************************************************************************/
#include "wonx_include/key.h"
#include "WWLCDPanel.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
@ -16,11 +12,32 @@
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_GetLCDDraw(XDisplay x_display);
int XDisplay_GetLCDDrawLevel(XDisplay d);
int XDisplay_SetLCDDrawLevel(XDisplay d, int level);
int XDisplay_LCDDrawLevelDown(XDisplay d);
int XDisplay_LCDDrawLevelUp( XDisplay d);
int XDisplay_GetColorMapPrint(XDisplay d);
int XDisplay_GetPalettePrint(XDisplay d);
@ -53,12 +70,26 @@ XDisplay XDisplay_Destroy(XDisplay x_display);
/*---------------------------------------------------------------------------*/
int XDisplay_Sync(XDisplay x_display);
int XDisplay_Flush(XDisplay x_display);
/*---------------------------------------------------------------------------*/
/* 描画 */
/*---------------------------------------------------------------------------*/
int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel);
int XDisplay_DrawLCDWindow(XDisplay x_display, WWDisplay ww_display,
WWLCDPanel ww_lcd_panel);
/*---------------------------------------------------------------------------*/
/* GC の作成 */
/*---------------------------------------------------------------------------*/
GC XDisplay_CreateGC(XDisplay x_display);
/*---------------------------------------------------------------------------*/
/* GC の解放 */
/*---------------------------------------------------------------------------*/
int XDisplay_DestroyGC(XDisplay x_display, GC gc);
/*****************************************************************************/
/* ここまで */

View File

@ -9,13 +9,17 @@
#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
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
@ -37,17 +41,22 @@ typedef struct _XDisplay {
Pixmap lcd_pixmap;
GC copy_gc;
GC color_gc[16];
GC color_gc[16]; /* 白黒表示用のGC */
/* 4096色表示用のGCのデータベース(XFireworks から流用) */
XColorGCDatabase color_gc_database;
#ifdef USE_X_FONT
/* テキストスクリーンへの文字表示用のフォント */
Font font;
GC font_gc;
#endif
/* キーの状態 */
unsigned int key_press;
/* LCD描画のフラグ */
int lcd_draw;
/* LCD描画のレベル */
int lcd_draw_level;
/* ダンプ出力のフラグ */
int color_map_print;

4
bank.c
View File

@ -5,9 +5,9 @@
#include <stdio.h>
#include <stdlib.h>
#include "wonx_include/bank.h"
#include "wonx/bank.h"
#include "Wonx.h"
#include "WonX.h"
/*****************************************************************************/
/* 高垂簇眶の年盗 */

7
challsrc.sh Normal file
View File

@ -0,0 +1,7 @@
#!/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

314
comm.c
View File

@ -10,10 +10,13 @@
#include <sys/types.h>
#include <sys/time.h>
#include "wonx_include/comm.h"
#include "wonx/comm.h"
#include "wonx_configure.h"
#include "Wonx.h"
#include "WonX.h"
#include "WonXSerialPort.h"
#include "WWSerialPort.h"
#include "UNIXSerialPort.h"
#include "etc.h"
/*****************************************************************************/
@ -38,319 +41,346 @@
void comm_open(void)
{
WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
if (!Wonx_IsCreated()) Wonx_Create();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_open() : \n");
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (WWSerialPort_IsON(ww_serial_port))
Wonx_Error("comm_open", "Serial port has already opened.");
if (WWSerialPort_IsOpened(ww_serial_port))
WonX_Warning("comm_open", "WW serial port has already opened.");
WWSerialPort_Open(ww_serial_port);
WWSerialPort_ON(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());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_open() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
void comm_close(void)
{
WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
if (!Wonx_IsCreated()) Wonx_Create();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_close() : \n");
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsON(ww_serial_port))
Wonx_Error("comm_close", "Serial port is not opened.");
if (!WWSerialPort_IsClosed(ww_serial_port))
WonX_Warning("comm_close", "WW serial port is not opened.");
WWSerialPort_Close(ww_serial_port);
WWSerialPort_OFF(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());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_close() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
static void comm_output(unsigned char c)
{
if (c == '\n') printf("\\n");
else if (c == '\r') printf("\\r");
else if (c == '\t') printf("\\t");
else if (isprint(c)) fputc(c, stdout);
else printf("^%02x", (int)c);
fflush(stdout);
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)
{
int tmp;
WonXSerialPort wonx_serial_port;
UNIXSerialPort unix_serial_port;
int c;
fd_set bitmap;
struct timeval t;
struct timeval * t_p;
/*
* 0
* -1
*/
if (timeout == -1) {
t_p = NULL;
} else {
tmp = WONX_SERIAL_PORT_TIMETICKS * timeout;
t.tv_sec = tmp / 1000;
t.tv_usec = (tmp % 1000) * 1000;
t_p = &t;
}
FD_ZERO(&bitmap);
FD_SET(fileno(stdin), &bitmap);
/*
* FreeBSD3.4
* 使select()
* select()
*
* (select()
* )
*
*
*/
select(fileno(stdin) + 1, &bitmap, NULL, NULL, t_p);
c = FD_ISSET(fileno(stdin), &bitmap) ? fgetc(stdin) : -1;
c = (c == '\n') ? '\r' : 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;
WWSerialPort ww_serial_port;
if (!Wonx_IsCreated()) Wonx_Create();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_send_char() : character = 0x%02x\n", (int)c);
printf("call : comm_send_char() : character = \'");
wonx_print_character(stdout, c);
printf("\'\n");
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsON(ww_serial_port))
Wonx_Error("comm_send_char", "Serial port is not opened.");
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 : ");
printf("output to serial port : \"");
comm_output(c);
printf("\n");
printf("\"\n");
fflush(stdout);
ret = 0;
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_send_char() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
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();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_receive_char() : \n");
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsON(ww_serial_port))
Wonx_Error("comm_receive_char", "Serial port is not opened.");
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());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_receive_char() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
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();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_receive_with_timeout() : timeout = %d\n", timeout);
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsON(ww_serial_port))
Wonx_Error("comm_receive_with_timeout", "Serial port is not opened.");
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());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_receive_with_timeout() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
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();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_send_string() : string = %s\n", string);
printf("call : comm_send_string() : string = \"");
for (p = string; *p != '\0'; p++) wonx_print_character(stdout, *p);
printf("\"\n");
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsON(ww_serial_port))
Wonx_Error("comm_send_string", "Serial port is not opened.");
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 : ");
printf("output to serial port : \"");
for (i = 0; string[i]; i++) {
comm_output(string[i]);
}
printf("\n");
printf("\"\n");
fflush(stdout);
ret = 0;
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_send_string() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
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();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_send_block() : buffer = %p, size = %d\n", buffer, size);
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsON(ww_serial_port))
Wonx_Error("comm_send_block", "Serial port is not opened.");
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 : ");
printf("output to serial port : \"");
for (i = 0; i < size; i++) {
comm_output(((char *)buffer)[i]);
}
printf("\n");
printf("\"\n");
fflush(stdout);
ret = 0;
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_send_block() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
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();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_receive_block() : buffer = %p, size = %d\n",
buffer, size);
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsON(ww_serial_port))
Wonx_Error("comm_receive_block", "Serial port is not opened.");
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++) {
@ -362,13 +392,13 @@ int comm_receive_block(void * buffer, int size)
((char *)buffer)[i] = c;
}
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_receive_block() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
@ -377,26 +407,26 @@ void comm_set_timeout(int recv_timeout, int send_timeout)
{
WWSerialPort ww_serial_port;
if (!Wonx_IsCreated()) Wonx_Create();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
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());
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());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_set_timeout() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
@ -405,29 +435,29 @@ void comm_set_baudrate(int baudrate)
{
WWSerialPort ww_serial_port;
if (!Wonx_IsCreated()) Wonx_Create();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_set_baudrate() : baudrate = %d\n", baudrate);
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
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");
default: WonX_Error("comm_set_baudrate", "Invalid baudrate");
}
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_set_baudrate() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
@ -437,29 +467,29 @@ int comm_get_baudrate(void)
WWSerialPort ww_serial_port;
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 : comm_get_baudrate() : \n");
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
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");
else WonX_Error("comm_get_baudrate", "Invalid baudrate");
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_get_baudrate() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
@ -468,25 +498,25 @@ void comm_set_cancel_key(unsigned int pattern)
{
WWSerialPort ww_serial_port;
if (!Wonx_IsCreated()) Wonx_Create();
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
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());
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
WWSerialPort_SetCancelKey(ww_serial_port, pattern);
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_set_cancel_key() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
@ -496,26 +526,26 @@ unsigned int comm_get_cancel_key(void)
WWSerialPort ww_serial_port;
unsigned 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 : comm_get_cancel_key() : \n");
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
/* ここに処理を書く */
ret = WWSerialPort_GetCancelKey(ww_serial_port);
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_get_cancel_key() : return value = %u\n", (int)ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
@ -525,28 +555,28 @@ int comm_xmodem(void * xmodem)
WWSerialPort ww_serial_port;
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 : comm_xmodem() : xmodem = %p\n", xmodem);
fflush(stdout);
ww_serial_port = WonxSerialPort_GetWWSerialPort(Wonx_GetWonxSerialPort());
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
/* 未サポート */
printf("call : comm_xmodem() : not supported.\n");
fflush(stdout);
ret = 0;
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_xmodem() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}

463
disp.c

File diff suppressed because it is too large Load Diff

44
etc.c
View File

@ -1,26 +1,44 @@
#include "etc.h"
#include <stdio.h>
#include <stdlib.h>
/*===========================================================================*/
/* ¥¨¥é¡¼½èÍý */
/*===========================================================================*/
int Wonx_Error(char * funcname, char * message)
{
fprintf(stderr, "%s(): %s\n", funcname, message);
exit (1);
}
#include <ctype.h>
/*===========================================================================*/
/* "true", "false" の矢机误を手す */
/*===========================================================================*/
char * true_false(int b)
char * wonx_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
View File

@ -1,17 +1,25 @@
#ifndef _etc_h_INCLUDED_
#define _etc_h_INCLUDED_
/*===========================================================================*/
/* エラー処理 */
/*===========================================================================*/
int Wonx_Error(char * funcname, char * message);
#include <stdio.h>
#include <stdlib.h>
/*===========================================================================*/
/* "true", "false" の矢机误を手す */
/*===========================================================================*/
char * true_false(int b);
char * wonx_true_false(int b);
/*===========================================================================*/
/* 文字の出力 */
/*===========================================================================*/
int wonx_print_character(FILE * fp, unsigned char c);
/*===========================================================================*/
/* 10進→16進文字への変換 */
/*===========================================================================*/
char wonx_dec_to_hex(int dec);
#endif

105
fcntl.c Normal file
View File

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

20
filters.perl Normal file
View File

@ -0,0 +1,20 @@
#!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 Normal file
View File

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

21
int2sint.perl Normal file
View File

@ -0,0 +1,21 @@
#!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);

96
key.c
View File

@ -5,9 +5,9 @@
#include <stdio.h>
#include <stdlib.h>
#include "wonx_include/key.h"
#include "wonx/key.h"
#include "Wonx.h"
#include "WonX.h"
/*****************************************************************************/
/* 互換関数の定義 */
@ -34,25 +34,25 @@ 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() : "); fflush(stdout);
printf("call : key_press_check() : \n"); fflush(stdout);
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay());
XDisplay_Sync(x_display);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Flush(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);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
@ -62,25 +62,25 @@ 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() : "); fflush(stdout);
printf("call : key_hit_check() : \n"); fflush(stdout);
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay());
XDisplay_Sync(x_display);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Flush(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);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
@ -88,54 +88,66 @@ int key_hit_check(void)
int key_wait(void)
{
XDisplay x_display;
int ret;
volatile 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() : "); fflush(stdout);
printf("call : key_wait() : \n"); fflush(stdout);
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay());
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
/*
* !
* key_wait() Unpause
*
* dowhile XDisplay_Flush()
*/
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
/*
* Unpause
* Pause XDisplay
*
* (XDisplay_GetKeyPress() )
*/
ret = 0;
do {
XDisplay_Sync(x_display);
#if 0 /* タイマを Unpause しない場合には必要 */
XDisplay_Flush(x_display);
#endif
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);
/* タイマをもとに戻す */
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, ", rate, delay);
printf("call : key_set_repeat() : rate = %d, delay = %d\n", rate, delay);
fflush(stdout);
WonxDisplay_Sync(Wonx_GetWonxDisplay());
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : key_set_repeat() : return value = none\n"); fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
@ -144,22 +156,22 @@ 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() : "); fflush(stdout);
printf("call : key_get_repeat() : \n"); 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);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}
@ -169,26 +181,26 @@ 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() : "); fflush(stdout);
printf("call : key_hit_check_with_repeat() : \n"); fflush(stdout);
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay());
XDisplay_Sync(x_display);
x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Flush(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);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
}

327
libwwc.c Normal file
View File

@ -0,0 +1,327 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#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
*/
/*
*
*
* ()
* 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. */
/*****************************************************************************/

36
makefile_for_wwterm Normal file
View File

@ -0,0 +1,36 @@
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)

View File

@ -1,18 +1,18 @@
#include "wonx_include/text.h"
#include "wonx_include/key.h"
#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, 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, 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 ");
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. ");

View File

@ -1,5 +1,5 @@
#include "wonx_include/disp.h"
#include "wonx_include/key.h"
#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};

35
sample3.c Normal file
View File

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

53
service.c Normal file
View File

@ -0,0 +1,53 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#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. */
/*****************************************************************************/

View File

@ -5,9 +5,9 @@
#include <stdio.h>
#include <stdlib.h>
#include "wonx_include/sound.h"
#include "wonx/sound.h"
#include "Wonx.h"
#include "WonX.h"
/*****************************************************************************/
/* 高垂簇眶の年盗 */

20
sout2str.perl Normal file
View File

@ -0,0 +1,20 @@
#!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);

8
sys2wonx.perl Normal file
View File

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

View File

@ -1,14 +0,0 @@
#!/usr/bin/perl
while ($FILENAME = shift(@ARGV)) {
open (RFILE, "< $FILENAME");
open (WFILE, "> $FILENAME.tmp");
while (<RFILE>) {
s/^(\s*\#\s*include\s*)[\<\"]sys\/(.+\.h)[\>\"]/$1\"wonx_include\/$2\"/i;
print WFILE $_;
}
close (RFILE);
close (WFILE);
system("mv $FILENAME.tmp $FILENAME");
}

View File

@ -5,9 +5,9 @@
#include <stdio.h>
#include <stdlib.h>
#include "wonx_include/system.h"
#include "wonx/system.h"
#include "Wonx.h"
#include "WonX.h"
/*****************************************************************************/
/* 互換関数の定義 */
@ -34,15 +34,15 @@ void sys_interrupt_set_hook(int type, intvector_t * vector,
{
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);
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);
@ -56,7 +56,7 @@ void sys_interrupt_set_hook(int type, intvector_t * vector,
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
@ -65,15 +65,15 @@ void sys_interrupt_reset_hook(int type, intvector_t * old_vector)
{
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);
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);
@ -83,7 +83,7 @@ void sys_interrupt_reset_hook(int type, intvector_t * old_vector)
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
@ -177,13 +177,6 @@ unsigned int sys_get_resume(void)
return (0);
}
void bios_exit()
{
printf("call : bios_exit() : \n");
fflush(stdout);
exit (0);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/

352
text.c
View File

@ -6,10 +6,13 @@
#include <stdlib.h>
#include <string.h>
#include "wonx_include/text.h"
#include "wonx/text.h"
#include "Wonx.h"
#include "WonX.h"
#include "WWText.h"
#include "WWDisplay.h"
#include "WWCursor.h"
#include "etc.h"
/*****************************************************************************/
/* 互換関数の定義 */
@ -33,11 +36,11 @@
static void _text_window_init(int x, int y, int w, int h, unsigned int base)
{
WWText ww_text;
WWDisplay ww_display;
WWText ww_text;
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_text = WWDisplay_GetText(ww_display);
WWText_SetTextWindow(ww_text, x, y, w, h, base, ww_display);
@ -52,25 +55,25 @@ 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;
}
@ -79,24 +82,24 @@ void text_window_init(int x, int y, int w, int h, unsigned int 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);
fflush(stdout);
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
_text_window_init(x, y, w, h, base);
WonxDisplay_Flush(Wonx_GetWonxDisplay());
WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : text_window_init() : return value = none\n"); fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
@ -112,11 +115,11 @@ int text_get_mode(void)
static void _text_put_char(int x, int y, unsigned int c)
{
WWText ww_text;
WWDisplay ww_display;
WWText ww_text;
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_text = WWDisplay_GetText(ww_display);
WWText_PutCharacter(ww_text, x, y, c, ww_display);
@ -125,22 +128,24 @@ 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 = %u\n", x, y, (int)c);
printf("call : text_put_char() : x = %d, y = %d, character = \'", x, y);
wonx_print_character(stdout, c);
printf("\'\n");
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;
}
@ -148,11 +153,11 @@ void text_put_char(int x, int y, unsigned int c)
static int _text_put_string(int x, int y, char * string)
{
int i, len, ret;
WWText ww_text;
WWDisplay ww_display;
WWText ww_text;
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_text = WWDisplay_GetText(ww_display);
len = strlen(string);
ret = 0;
@ -167,24 +172,27 @@ static int _text_put_string(int x, int y, char * string)
int text_put_string(int x, int y, char * string)
{
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 = %s\n", x, y, string);
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");
fflush(stdout);
ret = _text_put_string(x, y, string);
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);
}
@ -192,19 +200,21 @@ int text_put_string(int x, int y, char * string)
int text_put_substring(int x, int y, char * s, int length)
{
int i, ret;
WWText ww_text;
WWDisplay ww_display;
WWText ww_text;
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, string = %s, length = %d\n", x, y, s, length);
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");
fflush(stdout);
ww_text = WonxText_GetWWText(Wonx_GetWonxText());
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_text = WWDisplay_GetText(ww_display);
ret = 0;
for (i = 0; i < length; i++) {
@ -212,13 +222,13 @@ int text_put_substring(int x, int y, char * s, int length)
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);
}
@ -228,10 +238,10 @@ void text_put_numeric(int x, int y, int length, 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);
fflush(stdout);
@ -248,13 +258,13 @@ 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;
}
@ -267,10 +277,10 @@ void text_fill_char(int x, int y, int length, int c)
{
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);
fflush(stdout);
@ -279,70 +289,72 @@ void text_fill_char(int x, int y, int length, int c)
_text_put_char(x + i, y, c);
}
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)
{
WWText ww_text;
WWDisplay ww_display;
WWText ww_text;
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_text = WonxText_GetWWText(Wonx_GetWonxText());
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_text = WWDisplay_GetText(ww_display);
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_text = WonxText_GetWWText(Wonx_GetWonxText());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_text = WWDisplay_GetText(ww_display);
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);
}
@ -361,86 +373,278 @@ void text_get_fontdata(int c, void * buffer)
void text_set_screen(int screen)
{
WWText ww_text;
WWDisplay ww_display;
WWText ww_text;
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_text = WonxText_GetWWText(Wonx_GetWonxText());
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_text = WWDisplay_GetText(ww_display);
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_text = WonxText_GetWWText(Wonx_GetWonxText());
ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_text = WWDisplay_GetText(ww_display);
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)
{
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)
{
return (0);
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);
}
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)
{
return (0);
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);
}
void cursor_set_type(int palette_num, int 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)
{
return (0);
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);
}
int text_printf(int x, int y, const char *format, ...)

44
timer.c
View File

@ -6,10 +6,10 @@
#include <stdlib.h>
#include <time.h>
#include "wonx_include/timer.h"
#include "wonx/timer.h"
#include "wonx_configure.h"
#include "Wonx.h"
#include "WonX.h"
#include "etc.h"
/* int tm_year; year - 1900 */
@ -82,7 +82,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 : WonX_Error("rtc_get_datetime", "Unknown parameter.");
}
printf("call : rtc_get_datetime() : return value = %d\n", (int)ret);
@ -162,10 +162,10 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int count)
{
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);
@ -180,11 +180,11 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int count)
switch (type) {
case TIMER_VBLANK:
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(Wonx_GetWonxSystem());
ww_timer = WonXSystem_GetWWVBlankCountUpTimer(WonX_GetWonXSystem());
WWTimer_SetPresetCounter(ww_timer, count * WONX_VBLANK_INTERVAL);
break;
case TIMER_HBLANK:
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(Wonx_GetWonxSystem());
ww_timer = WonXSystem_GetWWHBlankCountUpTimer(WonX_GetWonXSystem());
WWTimer_SetPresetCounter(ww_timer, count * WONX_HBLANK_INTERVAL);
break;
default:
@ -193,13 +193,13 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int count)
* NULL
*/
ww_timer = NULL;
Wonx_Error("timer_enable", "Invalid timer type.");
WonX_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: WonX_Error("timer_enable", "Invalid auto preset type.");
}
WWTimer_Reset(ww_timer);
@ -209,7 +209,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 +218,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 +239,7 @@ void timer_disable(int type)
* NULL
*/
ww_timer = NULL;
Wonx_Error("timer_disable", "Invalid timer type.");
WonX_Error("timer_disable", "Invalid timer type.");
}
WWTimer_OFF(ww_timer);
@ -248,7 +248,7 @@ void timer_disable(int type)
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem()));
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
@ -258,20 +258,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 +279,7 @@ unsigned int timer_get_count(int type)
* NULL
*/
ww_timer = NULL;
Wonx_Error("timer_get_count", "Invalid timer type.");
WonX_Error("timer_get_count", "Invalid timer type.");
}
ret = WWTimer_GetCounter(ww_timer);
@ -288,7 +288,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 Normal file
View File

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

View File

@ -68,9 +68,9 @@ unsigned int display_status(void);
void font_set_monodata(unsigned int number, unsigned int count,
unsigned char * data);
void font_set_colordata(unsigned int number, unsigned int count,
unsigned char * data);
unsigned short int * data);
void font_get_data(unsigned int number, unsigned int count,
unsigned char * data);
unsigned short int * data);
void font_set_color(unsigned int colors);
unsigned int font_get_color(void);
void screen_set_char(int screen, int x, int y, int w, int h,

Some files were not shown because too many files have changed in this diff Show More