Compare commits

...

8 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
Hiroaki Sakai
7630141b26 In serial communication, input \n from standard input is converted to \r and passed
Fix comm_input() in comm.c. (See the e-mail of [WitchFan 00462])

Instead of error termination when displaying text characters outside the screen,
Fix WWText_PutCharacter() to proceed with issuing a warning.
(Correspondence to one person)

Add #define _WONX_ to wonx_include/types.h. (The part you want to depend on WONX
For when you want to enclose in source)

Version 0.5 beta - from wonx-b05.tar.gz
2018-03-07 23:06:40 +00:00
Hiroaki Sakai
96b108c909 In UNIXTimer.c, callback function is called every time the callback function is called
Fix to reconfigure.
(Add signal () in UNIXTimer_ON ())
(In IRIX, coping with the fact that the callback function is cleared for each call)

Since ualarm () is BSD dependent, it is modified to use alarm ().

Unit Timer class interval time setting unit changed from microseconds to milliseconds.

Supports serial communication.  (See WonxSerialPort, WWSerialPort, comm.c)

With printf () in key.c, when the function name was not displayed when displaying the return value
Fix.

Version 0.4 beta - from wonx-b04.tar.gz
2018-03-07 23:06:28 +00:00
Hiroaki Sakai
5e1a9795b7 Create your own header file. It became compilable with only Wonx.
Since there is a possibility that the Error () function will collide with libwonx.a when linking,
It changed to Wonx_Error ().
Added bios_exit ().
sprite_set_char, sprite_get_char, palette number minus 8
Fixed bug that was not specified.
font_set_monodata (), font_set_colordata (), font_get_data (), disp.c,
The arguments of screen_set_char (), screen_get_char (), sprite_set_data ()
Changed from void * to appropriate type.
Sample program and attached SpeedMac.
I added a document.

Version 0.3 beta - from wonx-b03.tar.gz
2018-03-07 23:06:08 +00:00
118 changed files with 10005 additions and 1694 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. */ /* All Rights Reserved. */
/*===========================================================================*/ /*===========================================================================*/
/* This program is free software; you can redistribute it and/or modify */ /* This program is free software; you can redistribute it and/or modify */
@ -37,10 +37,14 @@
/* あるものとします. */ /* あるものとします. */
/*===========================================================================*/ /*===========================================================================*/
/* 坂井弘亮の連絡先のメールアドレスは, */ /* 坂井弘亮の連絡先のメールアドレスは, */
/* sakai@seki.ee.kagu.sut.ac.jp */ /* hsakai@m8.people.or.jp */
/* hsakai@pfu.co.jp */
/* です.また,本ソフトウエアの最新版を, */ /* です.また,本ソフトウエアの最新版を, */
/* http://www.seki.ee.kagu.sut.ac.jp/~sakai/WonderWitch/index.html */ /* http://www.seki.ee.kagu.sut.ac.jp/~sakai/WonderWitch/index.html */
/* で配布しています. */ /* で配布しています. */
/* 以下はミラーサイトです. */
/* http://hp.vector.co.jp/authors/VA014157/index.html */
/* http://www.people.or.jp/~hsakai/index.html */
/* ミラーサイトは,坂井が気が向いたときにアップデートするので,常に最新, */
/* というわけではありません.あくまでバックアップ用です. */
/* ご意見,ご感想がありましたら,ぜひ連絡ください. */ /* ご意見,ご感想がありましたら,ぜひ連絡ください. */
/*****************************************************************************/ /*****************************************************************************/

260
HISTORY
View File

@ -1,4 +1,262 @@
wonx-b02 2002/2/4(月)
wonx-2.2 公開
mmap() を実装した.具体的には README 参照.
サービス関数を追加.(デバッグ用の情報をダンプするサービス関数と,
画面描画ON/OFF制御用のサービス関数を追加) 具体的には README 参照.
bios_exit() からオブジェクトのデストラクタが呼ばれるようにして,
各オブジェクトに適切な Destroy 関数を追加.オブジェクトの削除が適切に
行われるように,終了処理を全般的にチェックした.
key_wait() 中にも割り込みを受け付けるように修正.
(以前はキー入力しか受け付けていなかった)
タイマ割り込みを一部改良.(UNIXTimer.c)
wonx_include ディレクトリを wonx に名前を変更.
perl へのフルパスを自動で検索して perl スクリプトの先頭に挿入するように変更.
Makefile 見直し,改良.
画面描画の ON/OFF を,表示レベルによって切替えるように変更.
(詳しくは README 参照)
またF9 で表示レベルを下げF10 で表示レベルを上げるように変更.
それにあわせて描画のON/OFF部分とキー入力イベント処理の一部見直しをした
キーの押下時にメッセージを表示するように修正.
Obj ObjListData_GetPrev(ObjListData data)
Obj ObjListData_GetNext(ObjListData data)
ObjListData ObjListData_GetPrev(ObjListData data)
ObjListData ObjListData_GetNext(ObjListData data)
に修正.
Makefile に install, uninstall ターゲットを追加challsrc.sh 修正.
2001/1/13(土)
wonx-2.1 公開
パレットデータのダンプ時にRGB値もダンプするようにした
データのダンプ部分を一部修正.
perl スクリプトの行頭を,/usr/bin/perl から /usr/local/bin/perl に変更.
(FreeBSD では,日本語 perl は /usr/local/bin に入るので)
disp.c, libwwc.c の,キャラクタのビットマップデータ読み込み用・取得用関数で,
ビットマップデータの型を unsigned char * でなく short int *, long int * などの
適切な型に修正した.
WWCharacter クラスのビットマップをuchar, ushort, ulong の union とし,
WWCharacter_GetPixel() では適切な型でアクセスすることにより,
ビットマップデータのエンディアンの依存性を無くした.(i386, SPARC で確認済)
WWCharacter_GetPixel() の 16PACKED カラーモード時の値の取得方法を修正した.
(キャラクタが左右反転表示されていたバグが解消した)
F11 で10秒間停止もしくは Ctrl-c もしくは F12 で強制終了,
Ctrl-i でアイコン化の追加.(もともとあった機能だったが,忘れてたのを,
多少修正して正式サポートにした)
表示/非表示の切替えキーを p から F10 に移動.マニュアル修正.
XDisplay.c:XDisplay_DrawLCDWindow() でXColorGC_CreateFromRGB() で生成した
XColorGC オブジェクトを Destroy() していないので,メモリフローしていたバグを
修正.(XColorGC_Destroy(x_color_gc) 追加)
wonx_include/fcntl.h 追加.内容は,/usr/include/fcntl.h,
/usr/include/sys/fcntl.h をインクルードするだけ.
シリアル出力時のメッセージ(output to serial port : )の書式変更.
("" でくくるようにした)
etc.c:wonx_print_character() 修正.(\", \\ などを追加)
sout2str.pl 修正.(\", \\ などを追加.上記のシリアル出力時のメッセージの
書式変更にあわせて修正した)
int2sint.pl, filters.pl, challsrc.sh 追加.
sys2wonx.pl 変更.
wonx_include/types.h の
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef unsigned short int WORD;
typedef unsigned long int DWORD;
に変更.
README 修正.
2001/1/3(水)
wonx-2.0 公開
カラー化対応GCの管理用にXColorGC クラスを追加.(XFireworks から流用した)
カラー化に対応させてtransparent(透過色)の判定処理を WWPalette クラスから
WWDisplay クラスに移動した.
WWLCDPanel の pixel をunsigned short int * に変更.(カラー対応)
テキストフォントの格納フォーマットを変更.(WWTextFonts.c)
テキスト表示で,表示時に WWDisplay_GetForegroundColor(),
WWDisplay_GetBackgroundColor() を見てコピーするように修正.(WWText.c)
(WWText クラス中で WWCharacter の配列を確保しているのが不要になったので,
いずれ削除すること)
WWDisplay クラスにボーダーカラーのパレット追加.
カラー化に対応させて,その他もろもろの修正を加えた.
(キャラクタデータの格納方法,テキスト表示,ボーダーカラーの処理など)
display_control(), display_status() で,ボーダーカラーのビットシフトが
7 になっていたバグを修正.(8 に修正)
while(1){/*none*/} での割り込み待ちループ中にもF1 などのキー入力を受け付ける
ように修正.(WonXSystem.c のタイマ割り込みのコールバック関数
WonXTimer_Callback() にWonXDisplay_PrintData() を追加)
fcntl_attention.h, filesys.h, indirect.h, oswork.h, process.h を追加.
(中身はカラ,もしくは適当なファイルをインクルードするだけ)
wonx_configure.h で,
#ifndef _WONX_winx_configure_h_INCLUDED_
#define _WONX_wonx_configure_h_INCLUDED_
になっていたバグを修正.
2000/12/28(木)
wonx-1.1 公開
_asm_*() のダミー関数を追加.
FP_OFF(), FP_SEG() をWonderWitch での割り込み設定時のコールバック関数の
設定方法にあわせて,適切に変更.(wwterm に合わせた)
UNIXTimer.c:UNIXTimer_Unpause() で,
((unix_timer->pause == 1) && (unix_timer->interrupt_in_pause == 0))
だったときに unix_timer->pause--; されないバグを修正.
(ポーズ中に割り込みがかからなかった場合に,アンポーズされていなかった)
シリアル受信割り込み,キーボード割り込み追加.(wwterm に対応,動作確認済)
UNIXSerialPort クラス追加.
これによりWonderWitch での,
com_intvector.callback = (void (near *)())FP_OFF(com_handler);
com_intvector.cs = _asm_inline("\tmov\tax,cs");
com_intvector.ds = _asm_inline("\tmov\tax,ds");
sys_interrupt_set_hook(SYS_INT_RECEIVEREADY,
&com_intvector, &com_last_intvector);
のような割り込みの設定が正しく実行されるようになった.
ワーニング用にWonX_Warning() 追加.
WonX_Error() を WonX.c に移動.
comm_send_string(), text_put_string(), text_put_substring() 実行時の
出力メッセージを修正.
カーソル表示機能を実装.(WWCursor クラス追加)(点滅はしない.表示のみ)
カーソル表示をする際にWWDisplay_DrawLCDPanel() 内部でテキスト情報が
読める必要があるのでWonXText クラスを廃止してWWText クラスを
WWDisplay クラスのメンバに移動した.
palette_get_color() 内でWWPalette_GetMappedColors() の実行時に透明色が
-1として返されることを考慮していなかったためにpalette_get_color() の
戻り値がおかしな値になっていたバグを修正.
キャラクタカラーパレットLCDカラーパレットの初期値をWonderWitch での
初期値と一致させた.
サンプルとしてwwterm-b05 を追加.(Makefile に wwterm ターゲットを追加)
2000/11/23(木)
wonx-1.0 公開
正式名称を Wonx から WonX に変更.
MANUAL ファイルを追加.
OMAKE.jpn に文章追加.
2000/11/23(木)
wonx-b05 公開
シリアル通信で,標準入力からの入力の \n は \r に変換して渡すように
comm.c の comm_input() を修正.([WitchFan 00462] のメール参照)
画面外へのテキスト文字の表示時に,エラー終了するのでなく,
ワーニングを出して続行するように WWText_PutCharacter() を修正.
(ワンべぇへの対応)
wonx_include/types.h に #define _WONX_ を追加.(WONX依存にしたい部分を
ソース中でくくりたいときのため)
2000/11/18(土)
wonx-b04 公開
UNIXTimer.c で,コールバック関数が呼ばれるたびにコールバック関数を
設定しなおすように修正.
(UNIXTimer_ON() 中に signal() を追加)
(IRIX ではコール毎にコールバック関数がクリアされてしまうことへの対処)
ualarm() は BSD 依存なのでalarm() を使用するように修正.
UNIXTimer クラスのインターバル時間の設定の単位をマイクロ秒からミリ秒に変更.
シリアル通信をサポート.(WonxSerialPort, WWSerialPort, comm.c 参照)
key.c 中の printf() で,戻り値の表示の際に関数名が表示されていなかったのを
修正.
2000/11/13(月)
wonx-b03 公開
ヘッダファイルを独自に作成Wonx のみでコンパイル可能になった.
libwonx.a のリンク時に Error() 関数がぶつかる可能性があるので,
Wonx_Error() に変更した.
bios_exit() を追加.
sprite_set_char, sprite_get_char で,パレット番号が8を引いた値で
指定されていないバグを修正.
disp.c の font_set_monodata(), font_set_colordata(), font_get_data(),
screen_set_char(), screen_get_char(), sprite_set_data() の引数を
void * から適切な型に変更.
サンプルプログラムと SpeedMac を添付した.
ドキュメントを追加した.
2000/11/3(金)
wonx-b02 公開
割り込み処理の追加.タイマ割り込みサポート. 割り込み処理の追加.タイマ割り込みサポート.
(UNIXTimer, WWInterrupt, WWTimer, WonxSystem 追加) (UNIXTimer, WWInterrupt, WWTimer, WonxSystem 追加)

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,30 +2,107 @@ XINCLUDEDIR = /usr/X11R6/include
INCLUDEDIR = . INCLUDEDIR = .
XLIBDIR = /usr/X11R6/lib XLIBDIR = /usr/X11R6/lib
VERSION = Wonx-b02 VERSION = WonX-2.2
PKGNAME = wonx-b02 PKGNAME = wonx-2.2
OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWText.o WWInterrupt.o WWTimer.o Wonx.o WonxDisplay.o WonxText.o WonxSystem.o XDisplay.o UNIXTimer.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o etc.o SMAC = smac-b02
WWTERM = wwterm-b05
OBJS = WWCharacter.o WWColorMap.o WWDisplay.o WWLCDPanel.o WWPalette.o WWScreen.o WWSprite.o WWCursor.o WWText.o WWInterrupt.o WWTimer.o WWSerialPort.o WonX.o WonXDisplay.o WonXSystem.o WonXSerialPort.o XDisplay.o XColorGC.o UNIXTimer.o UNIXSerialPort.o Obj.o bank.o comm.o disp.o text.o key.o sound.o system.o timer.o libwwc.o service.o fcntl.o etc.o wonx.o
PERLS = filters.pl int2sint.pl sout2str.pl sys2wonx.pl
#PERL = /usr/bin/perl
CC ?= gcc
AR ?= ar
RANLIB ?= ranlib
CFLAGS += -O
#CFLAGS += -g
CFLAGS += -Wall
PREFIX ?= /usr/local
.SUFFIXES: .c .o .SUFFIXES: .c .o
.SUFFIXES: .perl .pl
all : libwonx.a all : libwonx.a $(PERLS)
libwonx.a : $(OBJS) libwonx.a : $(OBJS)
ar ruc libwonx.a $(OBJS) $(AR) ruc libwonx.a $(OBJS)
# ranlib libwonx.a # $(RANLIB) libwonx.a
.c.o : $*.c .c.o : $*.c
gcc -c $*.c -O -Wall -I$(INCLUDEDIR) -I$(XINCLUDEDIR) $(CC) -c $*.c $(CFLAGS) -I$(INCLUDEDIR) -I$(XINCLUDEDIR)
clean : clean :
rm -f libwonx.a *.o rm -f libwonx.a sample1 sample2 sample3 *.o *.pl
rm -fR $(SMAC) $(WWTERM)
sample1 : libwonx.a sample1.o
$(CC) sample1.o -o sample1 \
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
sample2 : libwonx.a sample2.o
$(CC) sample2.o -o sample2 \
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
sample3 : libwonx.a sample3.o
$(CC) sample3.o -o sample3 \
-L. -L/usr/X11R6/lib -lwonx -lX11 -lXt
smac : libwonx.a $(SMAC)
cd $(SMAC) ; $(MAKE)
$(SMAC) : $(SMAC).zip $(PERLS)
unzip $(SMAC).zip
mkdir -p $(SMAC)/wonx
cp wonx/*.h $(SMAC)/wonx
cp libwonx.a $(SMAC)
mv $(SMAC)/makefile $(SMAC)/makefile.orig
cp makefile_for_smac $(SMAC)/makefile
cp challsrc.sh $(PERLS) $(SMAC)
cd $(SMAC) ; ./challsrc.sh *.[ch] makefile
wwterm : libwonx.a $(WWTERM)
cd $(WWTERM) ; $(MAKE)
$(WWTERM) : $(WWTERM).zip $(PERLS)
unzip $(WWTERM).zip
mkdir -p $(WWTERM)/wonx
cp wonx/*.h $(WWTERM)/wonx
cp libwonx.a $(WWTERM)
mv $(WWTERM)/makefile $(WWTERM)/makefile.orig
cp makefile_for_wwterm $(WWTERM)/makefile
cp challsrc.sh $(PERLS) $(WWTERM)
cd $(WWTERM) ; ./challsrc.sh *.[ch] makefile
.perl.pl : $*.perl
./findperl.sh $(PERL) | cat - $*.perl > $*.pl
chmod +x $*.pl
install : libwonx.a $(PERLS)
mkdir -p $(PREFIX)/include/wonx
cp wonx/*.h $(PREFIX)/include/wonx
cp libwonx.a $(PREFIX)/lib
cp challsrc.sh $(PERLS) $(PREFIX)/bin
uninstall :
rm -fR $(PREFIX)/include/wonx
rm -f $(PREFIX)/lib/libwonx.a
rm -f $(PREFIX)/bin/challsrc.sh
rm -f $(PREFIX)/bin/filters.pl
rm -f $(PREFIX)/bin/int2sint.pl
rm -f $(PREFIX)/bin/sout2str.pl
rm -f $(PREFIX)/bin/sys2wonx.pl
package : package :
mkdir -p $(PKGNAME) mkdir -p $(PKGNAME)
rm -fR $(PKGNAME)/* rm -fR $(PKGNAME)/*
cp COPYING COPYRIGHT HISTORY README OMAKE.jpn Makefile \ mkdir -p $(PKGNAME)/wonx
*.h *.c $(PKGNAME) 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) tar cvzf $(PKGNAME).tar.gz $(PKGNAME)
# End of Makefile. # 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

1096
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_ #ifndef _UNIXSerialPortP_h_INCLUDED_
#define _WonxTextP_h_INCLUDED_ #define _UNIXSerialPortP_h_INCLUDED_
/*****************************************************************************/ /*****************************************************************************/
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "WonxText.h" #include "UNIXSerialPort.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WonxText { typedef struct _UNIXSerialPort {
WWText ww_text; int opened; /* open/close */
} _WonxText; } _UNIXSerialPort;
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */

View File

@ -6,7 +6,7 @@
#include <signal.h> #include <signal.h>
#include "UNIXTimerP.h" #include "UNIXTimerP.h"
#include "etc.h" #include "WonX.h"
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の定義 */ /* メンバ関数の定義 */
@ -23,10 +23,11 @@ volatile static UNIXTimer pointed_unix_timer = NULL;
static void UNIXTimer_CallBackFunction(int argument) static void UNIXTimer_CallBackFunction(int argument)
{ {
int ret; int ret;
int old;
/* /*
static * static
*
*/ */
if (pointed_unix_timer == NULL) return; if (pointed_unix_timer == NULL) return;
@ -34,6 +35,9 @@ static void UNIXTimer_CallBackFunction(int argument)
if (pointed_unix_timer->pause) { if (pointed_unix_timer->pause) {
pointed_unix_timer->interrupt_in_pause++; pointed_unix_timer->interrupt_in_pause++;
if (pointed_unix_timer->interrupt_in_pause > 1000) {
WonX_Error("UNIXTimer_CallBackFunction", "interrupt count is too much.");
}
} else { } else {
if (pointed_unix_timer->interrupt_in_pause == 0) if (pointed_unix_timer->interrupt_in_pause == 0)
pointed_unix_timer->interrupt_in_pause = 1; pointed_unix_timer->interrupt_in_pause = 1;
@ -44,13 +48,15 @@ static void UNIXTimer_CallBackFunction(int argument)
/* /*
* UNIXTimer_Unpause() * UNIXTimer_Unpause()
* *
* * interrupt_in_pause
* (?)
* interrupt_in_pause
*/ */
pointed_unix_timer->pause++; pointed_unix_timer->pause++;
old = pointed_unix_timer->interrupt_in_pause;
ret = (*pointed_unix_timer->callback)(pointed_unix_timer->parameter); ret = (*pointed_unix_timer->callback)(pointed_unix_timer->parameter);
pointed_unix_timer->pause--; pointed_unix_timer->pause--;
pointed_unix_timer->interrupt_in_pause = old;
/* /*
* UNIXTimer_* * UNIXTimer_*
@ -101,9 +107,29 @@ static void UNIXTimer_CallBackFunction(int argument)
int UNIXTimer_ON(UNIXTimer unix_timer) int UNIXTimer_ON(UNIXTimer unix_timer)
{ {
int t;
unix_timer->timer_on = 1; unix_timer->timer_on = 1;
pointed_unix_timer = unix_timer; pointed_unix_timer = unix_timer;
ualarm(unix_timer->interval, 0);
/*
* SIGALRM 使sleep()
* sleep()
*/
signal(SIGALRM, UNIXTimer_CallBackFunction);
#if 0 /* use ualarm() */
/* ualarm(); の引数に0を用いてはダメなので */
t = unix_timer->interval * 1000;
if (t < 1) t = 1;
ualarm(t, 0);
#else /* use alarm() */
/* alarm(); の引数に0を用いてはダメなので */
t = unix_timer->interval / 1000;
if (t < 1) t = 1;
alarm(t);
#endif
return (0); return (0);
} }
@ -150,7 +176,9 @@ int UNIXTimer_Pause(UNIXTimer unix_timer)
int UNIXTimer_Unpause(UNIXTimer unix_timer) int UNIXTimer_Unpause(UNIXTimer unix_timer)
{ {
if (unix_timer->pause == 0) if (unix_timer->pause == 0)
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->pause == 1) {
if (unix_timer->interrupt_in_pause > 0) { if (unix_timer->interrupt_in_pause > 0) {
@ -178,6 +206,10 @@ int UNIXTimer_Unpause(UNIXTimer unix_timer)
/* コールバック関数の呼び出し */ /* コールバック関数の呼び出し */
UNIXTimer_CallBackFunction(0); UNIXTimer_CallBackFunction(0);
} else {
if (unix_timer->interrupt_in_pause < 0)
WonX_Error("UNIXTimer_Unpause", "Invalid interrupt_in_pause.");
unix_timer->pause--; /* ポーズはネストできる */
} }
} else { } else {
unix_timer->pause--; /* ポーズはネストできる */ unix_timer->pause--; /* ポーズはネストできる */
@ -207,11 +239,7 @@ int UNIXTimer_IsAutoPreset(UNIXTimer unix_timer)
int UNIXTimer_GetInterval(UNIXTimer unix_timer) int UNIXTimer_GetInterval(UNIXTimer unix_timer)
{ return (unix_timer->interval); } { return (unix_timer->interval); }
int UNIXTimer_SetInterval(UNIXTimer unix_timer, int interval) int UNIXTimer_SetInterval(UNIXTimer unix_timer, int interval)
{ { return (unix_timer->interval = interval); }
/* ualarm(); の引数に0を用いてはダメなので */
if (interval < 1) interval = 1;
return (unix_timer->interval = interval);
}
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* コールバック関数の呼び出し時のパラメータ */ /* コールバック関数の呼び出し時のパラメータ */
@ -243,7 +271,7 @@ UNIXTimer UNIXTimer_Create(int auto_preset, int interval, void * parameter,
unix_timer = (UNIXTimer)malloc(sizeof(_UNIXTimer)); unix_timer = (UNIXTimer)malloc(sizeof(_UNIXTimer));
if (unix_timer == NULL) if (unix_timer == NULL)
Error("UNIXTimer_Create", "Cannot allocate memory."); WonX_Error("UNIXTimer_Create", "Cannot allocate memory.");
unix_timer->timer_on = 0; unix_timer->timer_on = 0;
unix_timer->pause = 0; unix_timer->pause = 0;
@ -260,12 +288,6 @@ UNIXTimer UNIXTimer_Create(int auto_preset, int interval, void * parameter,
UNIXTimer_SetParameter(unix_timer, parameter); UNIXTimer_SetParameter(unix_timer, parameter);
UNIXTimer_SetCallBack(unix_timer, callback); UNIXTimer_SetCallBack(unix_timer, callback);
/*
* SIGALRM 使sleep()
* sleep()
*/
signal(SIGALRM, UNIXTimer_CallBackFunction);
return (unix_timer); return (unix_timer);
} }
@ -281,7 +303,7 @@ UNIXTimer UNIXTimer_Create(int auto_preset, int interval, void * parameter,
UNIXTimer UNIXTimer_Destroy(UNIXTimer unix_timer) UNIXTimer UNIXTimer_Destroy(UNIXTimer unix_timer)
{ {
if (unix_timer == NULL) if (unix_timer == NULL)
Error("UNIXTimer_Destroy", "Object is not created."); WonX_Error("UNIXTimer_Destroy", "Object is not created.");
UNIXTimer_OFF(unix_timer); 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 struct _UNIXTimer * UNIXTimer;
typedef int (*UNIXTimerCallBack)(void *); 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
* *
* *
*/ */
@ -32,7 +32,7 @@ typedef struct _UNIXTimer {
int interrupt_in_pause; int interrupt_in_pause;
int auto_preset; /* オートプリセット1 だとオートプリセットを行う */ int auto_preset; /* オートプリセット1 だとオートプリセットを行う */
int interval; /* タイマのインターバル.マイクロ秒で指定 */ int interval; /* タイマのインターバル.ミリ秒で指定 */
void * parameter; /* コールバック関数の呼び出し時のパラメータ */ void * parameter; /* コールバック関数の呼び出し時のパラメータ */
UNIXTimerCallBack callback; /* コールバック関数 */ UNIXTimerCallBack callback; /* コールバック関数 */

View File

@ -2,38 +2,136 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <string.h>
#include "WWCharacterP.h" #include "WWCharacterP.h"
#include "WonX.h"
#include "etc.h" #include "etc.h"
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の定義 */ /* メンバ関数の定義 */
/*****************************************************************************/ /*****************************************************************************/
/*===========================================================================*/
/* ナンバーの操作 */
/*===========================================================================*/
int WWCharacter_GetNumber(WWCharacter c) int WWCharacter_GetNumber(WWCharacter c)
{ {
if (c == NULL) Error("WWCharacter_GetNumber()", "WWCharacter is NULL."); if (c == NULL) WonX_Error("WWCharacter_GetNumber", "WWCharacter is NULL.");
return (c->number); return (c->number);
} }
int WWCharacter_SetNumber(WWCharacter c, int n) int WWCharacter_SetNumber(WWCharacter c, int n)
{ {
if ((n < 0) || (n >= 512)) if (c == NULL) WonX_Error("WWCharacter_SetNumber", "WWCharacter is NULL.");
Error("WWCharacter_SetNumber()", "Invalid range.");
if ((n < 0) || (n > 512 - 1))
WonX_Error("WWCharacter_SetNumber", "Invalid range.");
return (c->number = n); 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; WWCharacter character;
character = (WWCharacter)malloc(sizeof(_WWCharacter)); character = (WWCharacter)malloc(sizeof(_WWCharacter));
if (character == NULL) if (character == NULL)
Error("WWCharacter_Create", "Cannot allocate memory."); WonX_Error("WWCharacter_Create", "Cannot allocate memory.");
WWCharacter_SetNumber(character, number); WWCharacter_SetNumber(character, number);
WWCharacter_SetBitmap(character, bitmap); WWCharacter_ClearAllPixels(character);
return (character); return (character);
} }
@ -41,89 +139,135 @@ WWCharacter WWCharacter_Create(int number, unsigned char * bitmap)
WWCharacter WWCharacter_Destroy(WWCharacter character) WWCharacter WWCharacter_Destroy(WWCharacter character)
{ {
if (character == NULL) if (character == NULL)
Error("WWCharacter_Destroy()", "WWCharacter is NULL."); WonX_Error("WWCharacter_Destroy", "Object is not created.");
free(character); free(character);
return (NULL); return (NULL);
} }
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) if (character == NULL)
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];
}
}
return (0);
}
int WWCharacter_GetPixel(WWCharacter character, int x, int y)
{
if (character == NULL)
Error("WWCharacter_GetPixel()", "WWCharacter is NULL.");
if ((x < 0) || (x > 7)) if ((x < 0) || (x > 7))
Error("WWCharacter_GetPixel()", "x is invalid value."); WonX_Error("WWCharacter_GetPixel", "x is out of range.");
if ((y < 0) || (y > 7)) if ((y < 0) || (y > 7))
Error("WWCharacter_GetPixel()", "y is invalid value."); WonX_Error("WWCharacter_GetPixel", "y is out of range.");
/* ビットマップは2ビットでぴとつのピクセルに対応する */ /* パレット色を返す */
/* 2ビットの値がpalette の色に対応する. */ pixel = 0;
/* bitmap は unsigned char bitmap[16]; に定義してある. */ switch (WWDisplay_GetColorMode(display)) {
case COLOR_MODE_GRAYSCALE:
/* パレット色(03)を返す */ case COLOR_MODE_4COLOR:
return ( (character->bitmap[y * 2 + x / 4] >> ((x % 4) * 2)) & 0x03 ); 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.");
} }
int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel)
{
unsigned char p;
if (character == NULL)
Error("WWCharacter_SetPixel()", "WWCharacter is NULL.");
if ((x < 0) || (x > 7))
Error("WWCharacter_SetPixel()", "x is invalid value.");
if ((y < 0) || (y > 7))
Error("WWCharacter_SetPixel()", "y is invalid value.");
if ((pixel < 0) || (pixel > 3))
Error("WWCharacter_SetPixel()", "Invalid pixel.");
p = ((unsigned char)pixel) & 0x03;
p = p << ((x % 4) * 2);
character->bitmap[y * 2 + x / 4] &= ~(0x03 << ((x % 4) * 2));
character->bitmap[y * 2 + x / 4] |= p;
return (pixel); 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, 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); n = WWCharacter_GetNumber(character);
fprintf(f, "\n"); fprintf(f, "\n");
fprintf(f, "character[%d] :\tnumber = %d\n", fprintf(f, "character[%03d] :\tnumber = %d\n",
n, WWCharacter_GetNumber(character)); n, WWCharacter_GetNumber(character));
for (i = 0; i < 32; i += 8) {
fprintf(f, "character[%03d] :\tbitmap[%02d] =", n, i);
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i ));
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+1));
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+2));
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+3));
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+4));
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+5));
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+6));
fprintf(f, " %02x", (int)WWCharacter_GetBitmapAsChar(character, i+7));
fprintf(f, "\n");
}
fprintf(f, "character[%03d] :\tpixels : 01234567\n", n);
for (y = 0; y < 8; y++) { 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++) { 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"); fprintf(f, "\n");
} }

View File

@ -5,28 +5,82 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WWCharacter * WWCharacter; typedef struct _WWCharacter * WWCharacter;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "WWDisplay.h"
#include "wonx/libwwc.h"
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の宣言 */ /* メンバ関数の宣言 */
/*****************************************************************************/ /*****************************************************************************/
/*===========================================================================*/
/* ナンバーの操作 */
/*===========================================================================*/
int WWCharacter_GetNumber(WWCharacter c); int WWCharacter_GetNumber(WWCharacter c);
int WWCharacter_SetNumber(WWCharacter c, int n); 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); WWCharacter WWCharacter_Destroy(WWCharacter character);
int WWCharacter_SetBitmap(WWCharacter character, unsigned char * bitmap);
int WWCharacter_GetPixel(WWCharacter character, int x, int y); /*===========================================================================*/
int WWCharacter_SetPixel(WWCharacter character, int x, int y, int pixel); /* ピクセルの操作 */
int WWCharacter_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 { typedef struct _WWCharacter {
int number; int number;
/* ビットマップは2ビットでぴとつのピクセルに対応する */ /* キャラクタのビットマップ */
/* 2ビットの値がpalette の色に対応する. */ union {
unsigned char bitmap[16]; unsigned char bitmap_char[32];
unsigned short int bitmap_short_int[16];
unsigned long int bitmap_long_int[8];
} bitmap;
} _WWCharacter; } _WWCharacter;
/*****************************************************************************/ /*****************************************************************************/

View File

@ -3,7 +3,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "WWColorMapP.h" #include "WWColorMapP.h"
#include "etc.h" #include "WonX.h"
/*****************************************************************************/ /*****************************************************************************/
/* ĽáĽóĽĐ´Řżô¤ÎÄęľÁ */ /* ĽáĽóĽĐ´Řżô¤ÎÄęľÁ */
@ -14,7 +14,8 @@ WWColorMap WWColorMap_Create(int * lcd_colors)
WWColorMap color_map; WWColorMap color_map;
color_map = (WWColorMap)malloc(sizeof(_WWColorMap)); color_map = (WWColorMap)malloc(sizeof(_WWColorMap));
if (color_map == NULL) Error("WWColorMap_Create", "Cannot allocate memory"); if (color_map == NULL)
WonX_Error("WWColorMap_Create", "Cannot allocate memory");
WWColorMap_SetLCDColors(color_map, lcd_colors); WWColorMap_SetLCDColors(color_map, lcd_colors);
@ -23,7 +24,8 @@ WWColorMap WWColorMap_Create(int * lcd_colors)
WWColorMap WWColorMap_Destroy(WWColorMap color_map) WWColorMap WWColorMap_Destroy(WWColorMap color_map)
{ {
if (color_map == NULL) return (NULL); if (color_map == NULL)
WonX_Error("WWColorMap_Destroy", "Object is not created.");
free(color_map); free(color_map);
return (NULL); return (NULL);
} }
@ -71,7 +73,7 @@ int WWColorMap_PrintData(WWColorMap c, FILE * f)
fprintf(f, "\n"); fprintf(f, "\n");
for (i = 0; i < 8; i++) { 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)); i, WWColorMap_GetLCDColor(c, i));
} }

View File

@ -5,15 +5,19 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WWColorMap * WWColorMap; 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 "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]); } WWSprite WWDisplay_GetSprite(WWDisplay d, int n) { return (d->sprite[n]); }
WWScreen WWDisplay_GetScreen(WWDisplay d, int n) { return (d->screen[n]); } WWScreen WWDisplay_GetScreen(WWDisplay d, int n) { return (d->screen[n]); }
WWLCDPanel WWDisplay_GetLCDPanel(WWDisplay d) { return (d->lcd_panel); } 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_GetSpriteEnable(WWDisplay d) { return (d->sprite_enable); }
int WWDisplay_GetSpriteWindowEnable(WWDisplay d) int WWDisplay_GetSpriteWindowEnable(WWDisplay d)
@ -34,7 +42,10 @@ int WWDisplay_GetSpriteWindowWidth(WWDisplay d)
int WWDisplay_GetSpriteWindowHeight(WWDisplay d) int WWDisplay_GetSpriteWindowHeight(WWDisplay d)
{ return (d->sprite_window_height); } { 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_GetForegroundColor(WWDisplay d) { return (d->foreground_color); }
int WWDisplay_GetBackgroundColor(WWDisplay d) { return (d->background_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); } { return (d->screen[n] = s); }
WWLCDPanel WWDisplay_SetLCDPanel(WWDisplay d, WWLCDPanel p) WWLCDPanel WWDisplay_SetLCDPanel(WWDisplay d, WWLCDPanel p)
{ return (d->lcd_panel = 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) int WWDisplay_SetSpriteEnable(WWDisplay d, int f)
{ return (d->sprite_enable = f); } { return (d->sprite_enable = f); }
@ -73,7 +91,10 @@ int WWDisplay_SetSpriteWindowWidth(WWDisplay d, int n)
int WWDisplay_SetSpriteWindowHeight(WWDisplay d, int n) int WWDisplay_SetSpriteWindowHeight(WWDisplay d, int n)
{ return (d->sprite_window_height = 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) int WWDisplay_SetForegroundColor(WWDisplay d, int c)
{ return (d->foreground_color = c); } { return (d->foreground_color = c); }
@ -94,19 +115,42 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
{ {
WWDisplay display; WWDisplay display;
int i; 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)); display = (WWDisplay)malloc(sizeof(_WWDisplay));
if (display == NULL) Error("WWDisplay_Create", "Cannot allocate memory."); if (display == NULL)
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++) { for (i = 0; i < 16; i++) {
/*
* WonX-2.0 WWPalette
*
*/
#if 1
WWDisplay_SetPalette(display, i, 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++) { 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++) { for (i = 0; i < 128; i++) {
@ -128,6 +172,24 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
WWDisplay_SetLCDPanel(display, WWLCDPanel_Create(lcd_panel_width, WWDisplay_SetLCDPanel(display, WWLCDPanel_Create(lcd_panel_width,
lcd_panel_height)); 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_SetSpriteEnable(display, 0);
WWDisplay_SetSpriteWindowEnable(display, 0); WWDisplay_SetSpriteWindowEnable(display, 0);
@ -136,7 +198,8 @@ WWDisplay WWDisplay_Create(int lcd_panel_width, int lcd_panel_height,
WWDisplay_SetSpriteWindowWidth( display, lcd_panel_width); WWDisplay_SetSpriteWindowWidth( display, lcd_panel_width);
WWDisplay_SetSpriteWindowHeight(display, lcd_panel_height); 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_SetForegroundColor(display, 3);
WWDisplay_SetBackgroundColor(display, 0); WWDisplay_SetBackgroundColor(display, 0);
@ -151,7 +214,8 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
{ {
int i; int i;
if (display == NULL) return (NULL); if (display == NULL)
WonX_Error("WWDisplay_Destroy", "Object is not created.");
if (WWDisplay_GetColorMap(display) != NULL) if (WWDisplay_GetColorMap(display) != NULL)
WWDisplay_SetColorMap(display, WWDisplay_SetColorMap(display,
@ -187,6 +251,14 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
WWDisplay_SetLCDPanel(display, WWDisplay_SetLCDPanel(display,
WWLCDPanel_Destroy(WWDisplay_GetLCDPanel(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); free(display);
return (NULL); return (NULL);
@ -196,7 +268,8 @@ WWDisplay WWDisplay_Destroy(WWDisplay display)
/* LCDパネルの描画 */ /* LCDパネルの描画 */
/*===========================================================================*/ /*===========================================================================*/
static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen) static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen,
WWCursor cursor)
{ {
WWLCDPanel lcd_panel; WWLCDPanel lcd_panel;
int lcd_panel_width; int lcd_panel_width;
@ -213,8 +286,8 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen)
lcd_panel_width = WWLCDPanel_GetWidth( lcd_panel); lcd_panel_width = WWLCDPanel_GetWidth( lcd_panel);
lcd_panel_height = WWLCDPanel_GetHeight(lcd_panel); lcd_panel_height = WWLCDPanel_GetHeight(lcd_panel);
if ( (WWScreen_GetMode(screen) == WWSCREEN_INSIDE_ONLY) || if ( (WWScreen_GetMode(screen) == WW_SCREEN_INSIDE_ONLY) ||
(WWScreen_GetMode(screen) == WWSCREEN_OUTSIDE_ONLY) ) { (WWScreen_GetMode(screen) == WW_SCREEN_OUTSIDE_ONLY) ) {
sx = WWScreen_GetDrawX(screen); sx = WWScreen_GetDrawX(screen);
sy = WWScreen_GetDrawX(screen); sy = WWScreen_GetDrawX(screen);
@ -245,7 +318,7 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen)
for (y = 0; y < lcd_panel_height; y++) { for (y = 0; y < lcd_panel_height; y++) {
if (mode == WWSCREEN_INSIDE_ONLY) { if (mode == WW_SCREEN_INSIDE_ONLY) {
if (y > ey) { break; } if (y > ey) { break; }
if (y < sy) { y = sy - 1; continue; } if (y < sy) { y = sy - 1; continue; }
} }
@ -254,10 +327,10 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen)
for (x = 0; x < lcd_panel_width; x++) { for (x = 0; x < lcd_panel_width; x++) {
if (mode == WWSCREEN_INSIDE_ONLY) { if (mode == WW_SCREEN_INSIDE_ONLY) {
if (x > ex) { x = lcd_panel_width - 1; continue; } if (x > ex) { x = lcd_panel_width - 1; continue; }
if (x < sx) { x = sx - 1; continue; } if (x < sx) { x = sx - 1; continue; }
} else if (mode == WWSCREEN_OUTSIDE_ONLY) { } else if (mode == WW_SCREEN_OUTSIDE_ONLY) {
if ( (x >= sx) && (x <= ex) && (y >= sy) && (y <= ey) ) { if ( (x >= sx) && (x <= ex) && (y >= sy) && (y <= ey) ) {
x = ex; x = ex;
continue; continue;
@ -266,12 +339,25 @@ static int WWDisplay_DrawScreen(WWDisplay display, WWScreen screen)
px = x + WWScreen_GetRollX(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; if (pixel == -1) continue;
/* カラー対応 */
switch (WWDisplay_GetColorMode(display)) {
case COLOR_MODE_GRAYSCALE:
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel); 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); WWLCDPanel_SetPixel(lcd_panel, x, y, pixel);
} }
} }
@ -299,7 +385,9 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite)
for (y = 0; y < 8; y++) { for (y = 0; y < 8; y++) {
for (x = 0; x < 8; x++) { for (x = 0; x < 8; x++) {
pixel = WWSprite_GetPixel(sprite, x, y);
/* 透明色は-1が返ってくる */
pixel = WWSprite_GetPixel(sprite, x, y, display);
/* 透明色の場合 */ /* 透明色の場合 */
if (pixel == -1) continue; if (pixel == -1) continue;
@ -320,7 +408,19 @@ static int WWDisplay_DrawSprite(WWDisplay display, WWSprite sprite)
} }
} }
/* カラー対応 */
switch (WWDisplay_GetColorMode(display)) {
case COLOR_MODE_GRAYSCALE:
pixel = WWColorMap_GetLCDColor(WWDisplay_GetColorMap(display), pixel); 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); WWLCDPanel_SetPixel(WWDisplay_GetLCDPanel(display), lcd_x, lcd_y, pixel);
} }
} }
@ -335,25 +435,58 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
int lcd_panel_width; int lcd_panel_width;
int lcd_panel_height; int lcd_panel_height;
WWColorMap color_map; WWColorMap color_map;
int border; WWPalette border_palette;
int border_color;
WWScreen screen;
WWSprite sprite; WWSprite sprite;
WWCursor cursor;
lcd_panel = WWDisplay_GetLCDPanel(display); lcd_panel = WWDisplay_GetLCDPanel(display);
lcd_panel_width = WWLCDPanel_GetWidth( lcd_panel); lcd_panel_width = WWLCDPanel_GetWidth( lcd_panel);
lcd_panel_height = WWLCDPanel_GetHeight(lcd_panel); lcd_panel_height = WWLCDPanel_GetHeight(lcd_panel);
color_map = WWDisplay_GetColorMap(display); 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 (x = 0; x < lcd_panel_width; x++) {
for (y = 0; y < lcd_panel_height; y++) { for (y = 0; y < lcd_panel_height; y++) {
WWLCDPanel_SetPixel(lcd_panel, x, y, WWLCDPanel_SetPixel(lcd_panel, x, y, border_color);
WWColorMap_GetLCDColor(color_map, border));
} }
} }
/* スクリーン1描画 */ /* スクリーン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より優先でないもの) */ /* スプライト描画(スクリーン2より優先でないもの) */
/* 重なった場合は,番号の若いものが手前に表示される */ /* 重なった場合は,番号の若いものが手前に表示される */
@ -368,7 +501,12 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
} }
/* スクリーン2描画 */ /* スクリーン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より優先なもの) */ /* スプライト描画(スクリーン2より優先なもの) */
/* 重なった場合は,番号の若いものが手前に表示される */ /* 重なった場合は,番号の若いものが手前に表示される */
@ -385,6 +523,38 @@ int WWDisplay_DrawLCDPanel(WWDisplay display)
return (0); 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; 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); WWSprite WWDisplay_GetSprite(WWDisplay d, int n);
WWScreen WWDisplay_GetScreen(WWDisplay d, int n); WWScreen WWDisplay_GetScreen(WWDisplay d, int n);
WWLCDPanel WWDisplay_GetLCDPanel(WWDisplay d); 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_GetSpriteEnable(WWDisplay d);
int WWDisplay_GetSpriteWindowEnable(WWDisplay d); int WWDisplay_GetSpriteWindowEnable(WWDisplay d);
@ -40,7 +51,8 @@ int WWDisplay_GetSpriteWindowY(WWDisplay d);
int WWDisplay_GetSpriteWindowWidth(WWDisplay d); int WWDisplay_GetSpriteWindowWidth(WWDisplay d);
int WWDisplay_GetSpriteWindowHeight(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_GetForegroundColor(WWDisplay d);
int WWDisplay_GetBackgroundColor(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); WWSprite WWDisplay_SetSprite(WWDisplay d, int n, WWSprite s);
WWScreen WWDisplay_SetScreen(WWDisplay d, int n, WWScreen s); WWScreen WWDisplay_SetScreen(WWDisplay d, int n, WWScreen s);
WWLCDPanel WWDisplay_SetLCDPanel(WWDisplay d, WWLCDPanel p); 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_SetSpriteEnable(WWDisplay d, int f);
int WWDisplay_SetSpriteWindowEnable(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_SetSpriteWindowWidth(WWDisplay d, int n);
int WWDisplay_SetSpriteWindowHeight(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_SetForegroundColor(WWDisplay d, int c);
int WWDisplay_SetBackgroundColor(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_DrawLCDPanel(WWDisplay display);
/*===========================================================================*/
/* 透明色かどうか調べる */
/*===========================================================================*/
int WWDisplay_IsTransparent(WWDisplay display, WWPalette palette, int color);
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */
/*****************************************************************************/ /*****************************************************************************/

View File

@ -19,8 +19,12 @@ typedef struct _WWDisplay {
WWSprite sprite[128]; WWSprite sprite[128];
WWScreen screen[2]; WWScreen screen[2];
WWLCDPanel lcd_panel; WWLCDPanel lcd_panel;
WWText text;
WWCursor cursor;
/* ディスプレイの属性情報 */ /* ディスプレイの属性情報 */
unsigned int color_mode; /* カラーモード */
int sprite_enable; /* スプライト表示イネーブルフラグ */ int sprite_enable; /* スプライト表示イネーブルフラグ */
int sprite_window_enable; /* スプライトウインドウ機能イネーブルフラグ */ int sprite_window_enable; /* スプライトウインドウ機能イネーブルフラグ */
int sprite_window_x; /* スプライトウインドウ用 */ int sprite_window_x; /* スプライトウインドウ用 */
@ -28,14 +32,16 @@ typedef struct _WWDisplay {
int sprite_window_width; /* スプライトウインドウ用 */ int sprite_window_width; /* スプライトウインドウ用 */
int sprite_window_height; /* スプライトウインドウ用 */ int sprite_window_height; /* スプライトウインドウ用 */
int border; /* ボーダーカラー07のカラーマップ番号 */ /* ボーダーカラーのパレット.カラーで必要 */
WWPalette border_palette;
/* ボーダーカラー白黒の場合には07のカラーマップ番号 */
int border_color;
int foreground_color; /* モノクロフォント展開時の色 */ int foreground_color; /* モノクロフォント展開時の色 */
int background_color; /* モノクロフォント展開時の色 */ int background_color; /* モノクロフォント展開時の色 */
int sprite_start; /* スプライトの描画の指定 */ int sprite_start; /* スプライトの描画の指定 */
int sprite_count; /* スプライトの描画の指定 */ int sprite_count; /* スプライトの描画の指定 */
} _WWDisplay; } _WWDisplay;
/*****************************************************************************/ /*****************************************************************************/

View File

@ -3,7 +3,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "WWInterruptP.h" #include "WWInterruptP.h"
#include "etc.h" #include "WonX.h"
/*****************************************************************************/ /*****************************************************************************/
/* ¥á¥ó¥Ð´Ø¿ô¤ÎÄêµÁ */ /* ¥á¥ó¥Ð´Ø¿ô¤ÎÄêµÁ */
@ -45,7 +45,7 @@ static WWInterruptVector WWInterruptVector_Create(int number)
vector = (WWInterruptVector)malloc(sizeof(_WWInterruptVector)); vector = (WWInterruptVector)malloc(sizeof(_WWInterruptVector));
if (vector == NULL) if (vector == NULL)
Error("WWInterruptVector_Create", "Cannot allocate memory."); WonX_Error("WWInterruptVector_Create", "Cannot allocate memory.");
WWInterruptVector_SetNumber(vector, number); WWInterruptVector_SetNumber(vector, number);
WWInterruptVector_SetCallback(vector, NULL); WWInterruptVector_SetCallback(vector, NULL);
@ -58,7 +58,7 @@ static WWInterruptVector WWInterruptVector_Create(int number)
static WWInterruptVector WWInterruptVector_Destroy(WWInterruptVector vector) static WWInterruptVector WWInterruptVector_Destroy(WWInterruptVector vector)
{ {
if (vector == NULL) if (vector == NULL)
Error("WWInterruptVector_Destroy", "Object is not created."); WonX_Error("WWInterruptVector_Destroy", "Object is not created.");
free(vector); free(vector);
return (NULL); return (NULL);
} }
@ -71,7 +71,7 @@ static WWInterruptVector WWInterrupt_GetVector(WWInterrupt interrupt,
int number) int number)
{ {
if ((number < 0) || (number > 7)) if ((number < 0) || (number > 7))
Error("WWInterrupt_SetVector", "Invalid interrupt number."); WonX_Error("WWInterrupt_SetVector", "Invalid interrupt number.");
return (interrupt->vector[number]); return (interrupt->vector[number]);
} }
@ -80,7 +80,7 @@ static WWInterruptVector WWInterrupt_SetVector(WWInterrupt interrupt,
WWInterruptVector vector) WWInterruptVector vector)
{ {
if ((number < 0) || (number > 7)) if ((number < 0) || (number > 7))
Error("WWInterrupt_SetVector", "Invalid interrupt number."); WonX_Error("WWInterrupt_SetVector", "Invalid interrupt number.");
return (interrupt->vector[number] = vector); return (interrupt->vector[number] = vector);
} }
@ -313,7 +313,7 @@ WWInterrupt WWInterrupt_Create()
interrupt = (WWInterrupt)malloc(sizeof(_WWInterrupt)); interrupt = (WWInterrupt)malloc(sizeof(_WWInterrupt));
if (interrupt == NULL) if (interrupt == NULL)
Error("WWInterrupt_Create", "Cannot allocate memory."); WonX_Error("WWInterrupt_Create", "Cannot allocate memory.");
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
WWInterrupt_SetVector(interrupt, i, WWInterruptVector_Create(i)); WWInterrupt_SetVector(interrupt, i, WWInterruptVector_Create(i));
@ -331,7 +331,7 @@ WWInterrupt WWInterrupt_Destroy(WWInterrupt interrupt)
WWInterruptVector vector; WWInterruptVector vector;
if (interrupt == NULL) if (interrupt == NULL)
Error("WWInterrupt_Destroy", "Object is not created."); WonX_Error("WWInterrupt_Destroy", "Object is not created.");
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {
vector = WWInterrupt_GetVector(interrupt, i); vector = WWInterrupt_GetVector(interrupt, i);

View File

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

View File

@ -3,7 +3,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "WWLCDPanelP.h" #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_SetAllDraw(WWLCDPanel p) { return (p->all_draw = 1); }
int WWLCDPanel_IsAllDraw(WWLCDPanel p) { return (p->all_draw); } 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]); return (p->pixel[p->current]);
} }
/* LCDはピクセル16色(4ビット必要) */ /* LCDはピクセル4096色(12ビット必要) */
static int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel, int current, static unsigned short int WWLCDPanel_GetPixelByCurrent(WWLCDPanel lcd_panel,
int current,
int x, int y) int x, int y)
{ {
unsigned char pixel; unsigned short int pixel;
if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) || if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) ) (y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
return (-1); return (-1);
pixel = lcd_panel->pixel[current][y * WWLCDPanel_GetWidth(lcd_panel) + x]; pixel = lcd_panel->pixel[current][y * WWLCDPanel_GetWidth(lcd_panel) + x];
pixel &= 0x0f;
return ((int)pixel); 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)); 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; int n;
if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) || if ( (x < 0) || (x > WWLCDPanel_GetWidth( lcd_panel) - 1) ||
(y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) ) (y < 0) || (y > WWLCDPanel_GetHeight(lcd_panel) - 1) )
return (-1); return (-1);
p = ((unsigned char)pixel) & 0x0f; p = pixel & 0x0fff;
n = y * WWLCDPanel_GetWidth(lcd_panel) + x; n = y * WWLCDPanel_GetWidth(lcd_panel) + x;
lcd_panel->pixel[lcd_panel->current][n] = p; lcd_panel->pixel[lcd_panel->current][n] = p;
return (pixel); return (p);
} }
int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y) int WWLCDPanel_IsPixelChanged(WWLCDPanel lcd_panel, int x, int y)
{ {
int old_pixel; unsigned short int old_pixel;
int current_pixel; unsigned short int current_pixel;
if (WWLCDPanel_IsAllDraw(lcd_panel)) return (1); if (WWLCDPanel_IsAllDraw(lcd_panel)) return (1);
old_pixel = WWLCDPanel_GetOldPixel(lcd_panel, x, y); old_pixel = WWLCDPanel_GetOldPixel(lcd_panel, x, y);
@ -90,23 +93,26 @@ WWLCDPanel WWLCDPanel_Create(int width, int height)
{ {
WWLCDPanel lcd_panel; WWLCDPanel lcd_panel;
int x, y, i; int x, y, i;
unsigned short int * p;
lcd_panel = (WWLCDPanel)malloc(sizeof(_WWLCDPanel)); lcd_panel = (WWLCDPanel)malloc(sizeof(_WWLCDPanel));
if (lcd_panel == NULL) Error("WWLCDPanel_Create", "Cannot allocate memory."); if (lcd_panel == NULL)
WonX_Error("WWLCDPanel_Create", "Cannot allocate memory.");
WWLCDPanel_SetWidth( lcd_panel, width); WWLCDPanel_SetWidth( lcd_panel, width);
WWLCDPanel_SetHeight(lcd_panel, height); WWLCDPanel_SetHeight(lcd_panel, height);
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
lcd_panel->pixel[i] = p = (unsigned short int *)malloc(sizeof(unsigned short int) *
(unsigned char *)malloc(sizeof(unsigned char) *
WWLCDPanel_GetWidth(lcd_panel) * WWLCDPanel_GetWidth(lcd_panel) *
WWLCDPanel_GetHeight(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 (y = 0; y < lcd_panel->height; y++) {
for (x = 0; x < lcd_panel->width / 2; x++) { for (x = 0; x < lcd_panel->width / 2; x++) {
WWLCDPanel_SetPixel(lcd_panel, x, y, 0x00); WWLCDPanel_SetPixel(lcd_panel, x, y, 0);
} }
} }
@ -119,11 +125,16 @@ WWLCDPanel WWLCDPanel_Create(int width, int height)
WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel) WWLCDPanel WWLCDPanel_Destroy(WWLCDPanel lcd_panel)
{ {
int i; int i;
if (lcd_panel == NULL) return (NULL);
if (lcd_panel == NULL)
WonX_Error("WWLCDPanel_Destroy", "Object is not created.");
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (lcd_panel->pixel[i]) free(lcd_panel->pixel[i]); if (lcd_panel->pixel[i]) free(lcd_panel->pixel[i]);
} }
free(lcd_panel); free(lcd_panel);
return (NULL); return (NULL);
} }

View File

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

View File

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

View File

@ -3,6 +3,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "WWPaletteP.h" #include "WWPaletteP.h"
#include "WonX.h"
#include "etc.h" #include "etc.h"
/*****************************************************************************/ /*****************************************************************************/
@ -12,19 +13,57 @@
int WWPalette_GetNumber(WWPalette p) { return (p->number); } int WWPalette_GetNumber(WWPalette p) { return (p->number); }
int WWPalette_SetNumber(WWPalette p, int n) { return (p->number = n); } 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_GetTransparent(WWPalette p) { return (p->transparent); }
int WWPalette_SetTransparent(WWPalette p, int f) int WWPalette_SetTransparent(WWPalette p, int f)
{ return (p->transparent = 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; WWPalette palette;
int i;
palette = (WWPalette)malloc(sizeof(_WWPalette)); palette = (WWPalette)malloc(sizeof(_WWPalette));
if (palette == NULL) Error("WWPalette_Create", "Cannot allocate memory"); if (palette == NULL)
WonX_Error("WWPalette_Create", "Cannot allocate memory");
WWPalette_SetNumber(palette, number); WWPalette_SetNumber(palette, number);
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
WWPalette_SetTransparent(palette, transparent); 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); WWPalette_SetMappedColors(palette, mapped_colors);
return (palette); return (palette);
@ -32,7 +71,8 @@ WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent)
WWPalette WWPalette_Destroy(WWPalette palette) WWPalette WWPalette_Destroy(WWPalette palette)
{ {
if (palette == NULL) return (NULL); if (palette == NULL)
WonX_Error("WWPalette_Destroy", "Object is not created.");
free(palette); free(palette);
return (NULL); return (NULL);
} }
@ -68,35 +108,73 @@ int WWPalette_GetMappedColor(WWPalette palette, int color)
int pixel; int pixel;
pixel = palette->mapped_color[color]; pixel = palette->mapped_color[color];
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
if (WWPalette_GetTransparent(palette) && (pixel == 0)) { if (WWPalette_GetTransparent(palette) && (pixel == 0)) {
pixel = -1; pixel = -1;
} }
#endif
return (pixel); return (pixel);
} }
int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_color) int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_color)
{ {
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
if (mapped_color == -1) mapped_color = 0; if (mapped_color == -1) mapped_color = 0;
#endif
return (palette->mapped_color[color] = mapped_color); 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 i, n;
int transparent;
int red, green, blue;
n = WWPalette_GetNumber(p); n = WWPalette_GetNumber(p);
fprintf(f, "\n"); fprintf(f, "\n");
fprintf(f, "palette[%d] :\tnumber = %d\n", n, WWPalette_GetNumber(p)); fprintf(f, "palette[%02d] :\tnumber = %d\n", n, WWPalette_GetNumber(p));
fprintf(f, "palette[%d] :\ttransparent = %s\n",
n, true_false(WWPalette_GetTransparent(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++) { 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)); 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); fflush(f);
return (0); return (0);

View File

@ -5,30 +5,59 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WWPalette * WWPalette; typedef struct _WWPalette * WWPalette;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "WWDisplay.h"
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の宣言 */ /* メンバ関数の宣言 */
/*****************************************************************************/ /*****************************************************************************/
int WWPalette_GetNumber(WWPalette p); int WWPalette_GetNumber(WWPalette p);
int WWPalette_SetNumber(WWPalette p, int n); int WWPalette_SetNumber(WWPalette p, int n);
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
int WWPalette_GetTransparent(WWPalette palette); int WWPalette_GetTransparent(WWPalette palette);
int WWPalette_SetTransparent(WWPalette palette, int f); 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); WWPalette WWPalette_Create(int number, int * mapped_colors, int transparent);
#endif
WWPalette WWPalette_Destroy(WWPalette palette); WWPalette WWPalette_Destroy(WWPalette palette);
int * WWPalette_GetMappedColors(WWPalette palette, int * mapped_colors); int * WWPalette_GetMappedColors(WWPalette palette, int * mapped_colors);
int WWPalette_SetMappedColors(WWPalette palette, int * mapped_colors); int WWPalette_SetMappedColors(WWPalette palette, int * mapped_colors);
int WWPalette_GetMappedColor(WWPalette palette, int color); int WWPalette_GetMappedColor(WWPalette palette, int color);
int WWPalette_SetMappedColor(WWPalette palette, int color, int mapped_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 { typedef struct _WWPalette {
int number; int number;
/*
* WonX-2.0 WWDisplay
* WWPalette
*/
#if 0
int transparent; /* 0 は透明色になるかどうかのフラグ */ int transparent; /* 0 は透明色になるかどうかのフラグ */
#endif
/* カラーマップの8色中から4色を選択 */ /* 白黒モードの場合にはカラーマップの8色中から4色を選択 */
int mapped_color[4]; /* カラーマップの番号(07)を持つ */ int mapped_color[4]; /* 白黒モードでは,カラーマップの番号(07)を持つ */
/*
* 416rgb 使
* 403使
* 16015使
*/
int red[16];
int green[16];
int blue[16];
} _WWPalette; } _WWPalette;

View File

@ -3,7 +3,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "WWScreenP.h" #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)); screen_character = (WWScreenCharacter)malloc(sizeof(_WWScreenCharacter));
if (screen_character == NULL) if (screen_character == NULL)
Error("WWScreenCharacter", "Cannot allocate memory."); WonX_Error("WWScreenCharacter", "Cannot allocate memory.");
WWScreenCharacter_SetHorizontal(screen_character, horizontal); WWScreenCharacter_SetHorizontal(screen_character, horizontal);
WWScreenCharacter_SetVertical(screen_character, vertical); WWScreenCharacter_SetVertical(screen_character, vertical);
@ -54,7 +54,8 @@ static WWScreenCharacter WWScreenCharacter_Create(int horizontal, int vertical,
static WWScreenCharacter WWScreenCharacter_Destroy(WWScreenCharacter static WWScreenCharacter WWScreenCharacter_Destroy(WWScreenCharacter
screen_character) screen_character)
{ {
if (screen_character == NULL) return (NULL); if (screen_character == NULL)
WonX_Error("WWScreenCharacter_Destroy", "Object is not created.");
free(screen_character); free(screen_character);
return (NULL); return (NULL);
} }
@ -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); } int WWScreen_SetDrawHeight(WWScreen s, int n) { return (s->draw_height = n); }
/* カラーマップの色(07)を返す(透明色は-1を返す) */ /* カラーマップの色(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 cx, cy, px, py;
int pixel; int pixel;
@ -180,10 +182,45 @@ int WWScreen_GetPixel(WWScreen screen, int x, int y)
if (WWScreen_GetVertical( screen, cx, cy)) py = 7 - py; if (WWScreen_GetVertical( screen, cx, cy)) py = 7 - py;
character = WWScreen_GetCharacter(screen, cx, cy); character = WWScreen_GetCharacter(screen, cx, cy);
palette = WWScreen_GetPalette(screen, cx, cy);
pixel = WWCharacter_GetPixel(character, px, py); /* カーソル表示の処理 */
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); 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); return (pixel);
} }
@ -200,7 +237,8 @@ WWScreen WWScreen_Create(int number,
int x, y; int x, y;
screen = (WWScreen)malloc(sizeof(_WWScreen)); screen = (WWScreen)malloc(sizeof(_WWScreen));
if (screen == NULL) Error("WWScreen_Create", "Cannot allocate memory."); if (screen == NULL)
WonX_Error("WWScreen_Create", "Cannot allocate memory.");
WWScreen_SetNumber(screen, number); WWScreen_SetNumber(screen, number);
WWScreen_SetWidth( screen, width); WWScreen_SetWidth( screen, width);
@ -209,7 +247,7 @@ WWScreen WWScreen_Create(int number,
WWScreen_SetRollY( screen, 0); WWScreen_SetRollY( screen, 0);
WWScreen_SetEnable(screen, 1); WWScreen_SetEnable(screen, 1);
WWScreen_SetMode( screen, WWSCREEN_DRAW_ALL); WWScreen_SetMode( screen, WW_SCREEN_DRAW_ALL);
WWScreen_SetDrawX( screen, draw_x); WWScreen_SetDrawX( screen, draw_x);
WWScreen_SetDrawY( screen, draw_y); WWScreen_SetDrawY( screen, draw_y);
@ -235,7 +273,8 @@ WWScreen WWScreen_Destroy(WWScreen screen)
int x, y; int x, y;
WWScreenCharacter sc; WWScreenCharacter sc;
if (screen == NULL) return (NULL); if (screen == NULL)
WonX_Error("WWScreen_Destroy", "Object is not created.");
for (y = 0; y < screen->height; y++) { for (y = 0; y < screen->height; y++) {
for (x = 0; x < screen->width; x++) { for (x = 0; x < screen->width; x++) {

View File

@ -5,24 +5,30 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdlib.h>
#include "WWPalette.h"
#include "WWCharacter.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WWScreen * WWScreen; typedef struct _WWScreen * WWScreen;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdlib.h>
#include "WWPalette.h"
#include "WWCharacter.h"
#include "WWCursor.h"
#include "WWDisplay.h"
/*****************************************************************************/ /*****************************************************************************/
/* 定数の定義 */ /* 定数の定義 */
/*****************************************************************************/ /*****************************************************************************/
#define WWSCREEN_DRAW_ALL 0 #define WW_SCREEN_DRAW_ALL 0
#define WWSCREEN_INSIDE_ONLY 1 #define WW_SCREEN_INSIDE_ONLY 1
#define WWSCREEN_OUTSIDE_ONLY 2 #define WW_SCREEN_OUTSIDE_ONLY 2
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の宣言 */ /* メンバ関数の宣言 */
@ -66,7 +72,8 @@ int WWScreen_SetDrawY( WWScreen s, int n);
int WWScreen_SetDrawWidth( WWScreen s, int n); int WWScreen_SetDrawWidth( WWScreen s, int n);
int WWScreen_SetDrawHeight(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, WWScreen WWScreen_Create(int number,
int width, int height, int width, int height,

View File

@ -33,7 +33,7 @@ typedef struct _WWScreen {
int enable; /* 表示/非表示のフラグ */ int enable; /* 表示/非表示のフラグ */
int mode; /* 表示モード */ int mode; /* 表示モード */
/* WWSCREEN_DRAW_ALL, WWSCREEN_INSIDE_ONLY, WWSCREEN_OUTSIDE_ONLY の */ /* WW_SCREEN_DRAW_ALL, WW_SCREEN_INSIDE_ONLY, WW_SCREEN_OUTSIDE_ONLY の */
/* いずれかの値を取る */ /* いずれかの値を取る */
/* 表示領域(スクリーン2のウインドウ機能用.スクリーン1では未使用) */ /* 表示領域(スクリーン2のウインドウ機能用.スクリーン1では未使用) */

86
WWSerialPort.c Normal file
View File

@ -0,0 +1,86 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WWSerialPortP.h"
#include "WonX.h"
/*****************************************************************************/
/* メンバ関数の定義 */
/*****************************************************************************/
int WWSerialPort_Open( WWSerialPort s) { return (s->opened = 1); }
int WWSerialPort_Close( WWSerialPort s) { return (s->opened = 0); }
int WWSerialPort_IsOpened(WWSerialPort s) { return (s->opened != 0); }
int WWSerialPort_IsClosed(WWSerialPort s) { return (s->opened == 0); }
int WWSerialPort_GetBaudrate(WWSerialPort s) { return (s->baudrate); }
int WWSerialPort_SetBaudrate(WWSerialPort s, int baudrate)
{ return (s->baudrate = baudrate); }
int WWSerialPort_SetBaudrate9600(WWSerialPort s)
{ return (WWSerialPort_SetBaudrate(s, WW_SERIAL_PORT_BAUDRATE_9600)); }
int WWSerialPort_SetBaudrate38400(WWSerialPort s)
{ return (WWSerialPort_SetBaudrate(s, WW_SERIAL_PORT_BAUDRATE_38400)); }
int WWSerialPort_IsBaudrate9600(WWSerialPort s)
{ return (WWSerialPort_GetBaudrate(s) == WW_SERIAL_PORT_BAUDRATE_9600); }
int WWSerialPort_IsBaudrate38400(WWSerialPort s)
{ return (WWSerialPort_GetBaudrate(s) == WW_SERIAL_PORT_BAUDRATE_38400); }
int WWSerialPort_GetSendTimeout(WWSerialPort s)
{ return (s->send_timeout); }
int WWSerialPort_SetSendTimeout(WWSerialPort s, int timeout)
{ return (s->send_timeout = timeout); }
int WWSerialPort_GetReceiveTimeout(WWSerialPort s)
{ return (s->receive_timeout); }
int WWSerialPort_SetReceiveTimeout(WWSerialPort s, int timeout)
{ return (s->receive_timeout = timeout); }
unsigned int WWSerialPort_GetCancelKey(WWSerialPort s)
{ return (s->cancel_key); }
unsigned int WWSerialPort_SetCancelKey(WWSerialPort s, int cancel_key)
{ return (s->cancel_key = cancel_key); }
/*---------------------------------------------------------------------------*/
/* オブジェクトの作成 */
/*---------------------------------------------------------------------------*/
WWSerialPort WWSerialPort_Create()
{
WWSerialPort ww_serial_port;
ww_serial_port = (WWSerialPort)malloc(sizeof(_WWSerialPort));
if (ww_serial_port == NULL)
WonX_Error("WWSerialPort_Create", "Cannot allocate memory.");
WWSerialPort_Close(ww_serial_port);
WWSerialPort_SetBaudrate38400(ww_serial_port);
WWSerialPort_SetSendTimeout(ww_serial_port, 100);
WWSerialPort_SetReceiveTimeout(ww_serial_port, 100);
return (ww_serial_port);
}
/*---------------------------------------------------------------------------*/
/* オブジェクトの削除 */
/*---------------------------------------------------------------------------*/
WWSerialPort WWSerialPort_Destroy(WWSerialPort ww_serial_port)
{
if (ww_serial_port == NULL)
WonX_Error("WWSerialPort_Destroy", "Object is not created.");
WWSerialPort_Close(ww_serial_port);
free(ww_serial_port);
return (NULL);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

75
WWSerialPort.h Normal file
View File

@ -0,0 +1,75 @@
#ifndef _WWSerialPort_h_INCLUDED_
#define _WWSerialPort_h_INCLUDED_
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WWSerialPort * WWSerialPort;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "wonx/comm.h"
/*****************************************************************************/
/* 定数の定義 */
/*****************************************************************************/
#define WW_SERIAL_PORT_BAUDRATE_9600 0
#define WW_SERIAL_PORT_BAUDRATE_38400 1
/*****************************************************************************/
/* メンバ関数の宣言 */
/*****************************************************************************/
int WWSerialPort_Open( WWSerialPort s);
int WWSerialPort_Close( WWSerialPort s);
int WWSerialPort_IsOpened(WWSerialPort s);
int WWSerialPort_IsClosed(WWSerialPort s);
int WWSerialPort_GetBaudrate(WWSerialPort s);
int WWSerialPort_SetBaudrate(WWSerialPort s, int baudrate);
int WWSerialPort_SetBaudrate9600(WWSerialPort s);
int WWSerialPort_SetBaudrate38400(WWSerialPort s);
int WWSerialPort_IsBaudrate9600(WWSerialPort s);
int WWSerialPort_IsBaudrate38400(WWSerialPort s);
int WWSerialPort_GetSendTimeout(WWSerialPort s);
int WWSerialPort_SetSendTimeout(WWSerialPort s, int timeout);
int WWSerialPort_GetReceiveTimeout(WWSerialPort s);
int WWSerialPort_SetReceiveTimeout(WWSerialPort s, int timeout);
unsigned int WWSerialPort_GetCancelKey(WWSerialPort s);
unsigned int WWSerialPort_SetCancelKey(WWSerialPort s, int cancel_key);
/*---------------------------------------------------------------------------*/
/* オブジェクトの作成 */
/*---------------------------------------------------------------------------*/
WWSerialPort WWSerialPort_Create();
/*---------------------------------------------------------------------------*/
/* オブジェクトの削除 */
/*---------------------------------------------------------------------------*/
WWSerialPort WWSerialPort_Destroy(WWSerialPort ww_serial_port);
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
#endif
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

View File

@ -1,25 +1,32 @@
#ifndef _WonxText_h_INCLUDED_ #ifndef _WWSerialPortP_h_INCLUDED_
#define _WonxText_h_INCLUDED_ #define _WWSerialPortP_h_INCLUDED_
/*****************************************************************************/ /*****************************************************************************/
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "WWText.h" #include "WWSerialPort.h"
#include "WWScreen.h"
#include "WWPalette.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WonxText * WonxText; typedef struct _WWSerialPort {
WWText WonxText_GetWWText(WonxText wonx_text); int opened; /* ポートの状態(open/close) */
WWText WonxText_SetWWText(WonxText wonx_text, WWText ww_text); int baudrate; /* ボーレート */
WonxText WonxText_Create(WWScreen screen, int x, int y, int width, int height,
WWPalette palette); /*
WonxText WonxText_Destroy(WonxText wonx_text); *
* VBLANK wonx
* WONX_SERIAL_PORT_TIMETICKS
*/
int send_timeout;
int receive_timeout;
unsigned int cancel_key;
} _WWSerialPort;
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */

View File

@ -3,6 +3,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "WWSpriteP.h" #include "WWSpriteP.h"
#include "WonX.h"
#include "etc.h" #include "etc.h"
/*****************************************************************************/ /*****************************************************************************/
@ -37,20 +38,45 @@ int WWSprite_SetPosition(WWSprite sprite, int x, int y)
return (0); 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; WWPalette palette;
WWCharacter c; WWCharacter character;
int pixel; int pixel;
p = WWSprite_GetPalette(sprite); palette = WWSprite_GetPalette(sprite);
c = WWSprite_GetCharacter(sprite); character = WWSprite_GetCharacter(sprite);
if (WWSprite_GetHorizontal(sprite)) x = 7 - x; if (WWSprite_GetHorizontal(sprite)) x = 7 - x;
if (WWSprite_GetVertical( sprite)) y = 7 - y; if (WWSprite_GetVertical( sprite)) y = 7 - y;
pixel = WWCharacter_GetPixel(c, x, y); pixel = WWCharacter_GetPixel(character, x, y, display);
pixel = WWPalette_GetMappedColor(p, pixel);
/* カラー対応 */
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); return (pixel);
} }
@ -63,7 +89,8 @@ WWSprite WWSprite_Create(int number, int x, int y,
WWSprite sprite; WWSprite sprite;
sprite = (WWSprite)malloc(sizeof(_WWSprite)); sprite = (WWSprite)malloc(sizeof(_WWSprite));
if (sprite == NULL) Error("WWSprite_Create", "Cannot allocate memory."); if (sprite == NULL)
WonX_Error("WWSprite_Create", "Cannot allocate memory.");
WWSprite_SetNumber(sprite, number); WWSprite_SetNumber(sprite, number);
WWSprite_SetHorizontal(sprite, horizontal); WWSprite_SetHorizontal(sprite, horizontal);
@ -80,7 +107,8 @@ WWSprite WWSprite_Create(int number, int x, int y,
WWSprite WWSprite_Destroy(WWSprite sprite) WWSprite WWSprite_Destroy(WWSprite sprite)
{ {
if (sprite == NULL) return (NULL); if (sprite == NULL)
WonX_Error("WWSprite_Destroy", "Object is not created.");
free(sprite); free(sprite);
return (NULL); return (NULL);
} }
@ -93,21 +121,21 @@ int WWSprite_PrintData(WWSprite s, FILE * f)
fprintf(f, "\n"); fprintf(f, "\n");
fprintf(f, "sprite[%d] :\tnumber = %d\n", n, WWSprite_GetNumber(s)); fprintf(f, "sprite[%03d] :\tnumber = %d\n", n, WWSprite_GetNumber(s));
fprintf(f, "sprite[%d] :\thorizontal = %s\n", fprintf(f, "sprite[%03d] :\thorizontal = %s\n",
n, true_false(WWSprite_GetHorizontal(s))); n, wonx_true_false(WWSprite_GetHorizontal(s)));
fprintf(f, "sprite[%d] :\tvertical = %s\n", fprintf(f, "sprite[%03d] :\tvertical = %s\n",
n, true_false(WWSprite_GetVertical( s))); n, wonx_true_false(WWSprite_GetVertical( s)));
fprintf(f, "sprite[%d] :\tpriority = %s\n", fprintf(f, "sprite[%03d] :\tpriority = %s\n",
n, true_false(WWSprite_GetPriority( s))); n, wonx_true_false(WWSprite_GetPriority( s)));
fprintf(f, "sprite[%d] :\tclipping = %s\n", fprintf(f, "sprite[%03d] :\tclipping = %s\n",
n, true_false(WWSprite_GetClipping( s))); n, wonx_true_false(WWSprite_GetClipping( s)));
fprintf(f, "sprite[%d] :\tpalette number = %d\n", fprintf(f, "sprite[%03d] :\tpalette number = %d\n",
n, WWPalette_GetNumber(WWSprite_GetPalette(s))); 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))); n, WWCharacter_GetNumber(WWSprite_GetCharacter(s)));
fprintf(f, "sprite[%d] :\tx = %d\n", n, WWSprite_GetX(s)); fprintf(f, "sprite[%03d] :\tx = %d\n", n, WWSprite_GetX(s));
fprintf(f, "sprite[%d] :\ty = %d\n", n, WWSprite_GetY(s)); fprintf(f, "sprite[%03d] :\ty = %d\n", n, WWSprite_GetY(s));
fflush(f); fflush(f);

View File

@ -5,17 +5,22 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdlib.h>
#include "WWPalette.h"
#include "WWCharacter.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WWSprite * WWSprite; 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_GetX(WWSprite sprite);
int WWSprite_GetY(WWSprite sprite); int WWSprite_GetY(WWSprite sprite);
int WWSprite_SetPosition(WWSprite sprite, int x, int y); 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, WWSprite WWSprite_Create(int number, int x, int y,
int horizontal, int vertical, int horizontal, int vertical,

View File

@ -3,7 +3,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "WWTextP.h" #include "WWTextP.h"
#include "etc.h" #include "WonX.h"
/* フォントのビットマップデータ */ /* フォントのビットマップデータ */
#include "WWTextFonts.c" #include "WWTextFonts.c"
@ -55,9 +55,9 @@ int WWText_SetTextWindow(WWText ww_text, int x, int y,
c = WWText_GetBase(ww_text); c = WWText_GetBase(ww_text);
for (ty = 0; ty < WWText_GetHeight(ww_text); ty++) { for (ty = 0; ty < WWText_GetHeight(ww_text); ty++) {
for (tx = 0; tx < WWText_GetWidth(ww_text); tx++) { for (tx = 0; tx < WWText_GetWidth(ww_text); tx++) {
if (c >= 512) Error("WWText_SetTextWindow", "Over character."); if (c >= 512) WonX_Error("WWText_SetTextWindow", "Over character.");
ww_character = WWDisplay_GetCharacter(ww_display, c); ww_character = WWDisplay_GetCharacter(ww_display, c);
WWCharacter_SetBitmap(ww_character, NULL); WWCharacter_ClearAllPixels(ww_character);
WWScreen_SetCharacter(WWText_GetScreen(ww_text), WWScreen_SetCharacter(WWText_GetScreen(ww_text),
WWText_GetX(ww_text) + tx, WWText_GetX(ww_text) + tx,
WWText_GetY(ww_text) + ty, WWText_GetY(ww_text) + ty,
@ -72,9 +72,15 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
WWDisplay ww_display) WWDisplay ww_display)
{ {
WWCharacter ww_character; WWCharacter ww_character;
int j, k, n;
int f, b;
unsigned short int pixel;
unsigned short int bitmap;
if ((character < 0) || (character > 127)) if ((character < 0) || (character > 127)) {
Error("WWText_PutCharacter", "Character number is out of range."); WonX_Warning("WWText_PutCharacter", "Character number is out of range.");
return (-1);
}
/* /*
* text_window_init() * text_window_init()
@ -82,8 +88,10 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
*/ */
if ( (x < 0) || (x > WWText_GetWidth( ww_text) - 1) || if ( (x < 0) || (x > WWText_GetWidth( ww_text) - 1) ||
(y < 0) || (y > WWText_GetHeight(ww_text) - 1) ) (y < 0) || (y > WWText_GetHeight(ww_text) - 1) ) {
Error("WWText_PutCharacter", "Position is out of range."); WonX_Warning("WWText_PutCharacter", "Position is out of range.");
return (-1);
}
#if 0 #if 0
n = WWText_GetBase(ww_text) + n = WWText_GetBase(ww_text) +
@ -96,7 +104,34 @@ int WWText_PutCharacter(WWText ww_text, int x, int y, int character,
WWText_GetY(ww_text) + y); WWText_GetY(ww_text) + y);
#endif #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), WWScreen_SetPalette(WWText_GetScreen(ww_text),
@ -116,20 +151,44 @@ WWText WWText_Create(WWScreen screen,
WWPalette palette) WWPalette palette)
{ {
WWText ww_text; 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)); ww_text = (WWText)malloc(sizeof(_WWText));
if (ww_text == NULL) Error("WWText_Create", "Cannot allocate memory."); if (ww_text == NULL) WonX_Error("WWText_Create", "Cannot allocate memory.");
WWText_SetScreen(ww_text, screen); WWText_SetScreen(ww_text, screen);
WWText_SetX(ww_text, 0); WWText_SetX(ww_text, x);
WWText_SetY(ww_text, 0); WWText_SetY(ww_text, y);
WWText_SetWidth( ww_text, width ); WWText_SetWidth( ww_text, width );
WWText_SetHeight(ww_text, height); WWText_SetHeight(ww_text, height);
WWText_SetPalette(ww_text, palette); 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++) { 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); return (ww_text);
@ -139,7 +198,8 @@ WWText WWText_Destroy(WWText ww_text)
{ {
int i; int i;
if (ww_text == NULL) Error("WWText_Destroy", "Object is not created."); if (ww_text == NULL)
WonX_Error("WWText_Destroy", "Object is not created.");
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
if (WWText_GetFont(ww_text, i)) if (WWText_GetFont(ww_text, i))

View File

@ -5,16 +5,20 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "WWDisplay.h"
#include "WWScreen.h"
#include "WWPalette.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WWText * WWText; 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); WWPalette palette);
WWText WWText_Destroy(WWText text); WWText WWText_Destroy(WWText text);
/*****************************************************************************/
/* ¤³¤³¤Þ¤Ç */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */
/*****************************************************************************/ /*****************************************************************************/

View File

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

View File

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

View File

@ -3,7 +3,7 @@
/*****************************************************************************/ /*****************************************************************************/
#include "WWTimerP.h" #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)); ww_timer = (WWTimer)malloc(sizeof(_WWTimer));
if (ww_timer == NULL) if (ww_timer == NULL)
Error("WWTimer_Create", "Cannot allocate memory."); WonX_Error("WWTimer_Create", "Cannot allocate memory.");
WWTimer_OFF(ww_timer); WWTimer_OFF(ww_timer);
WWTimer_SetAutoPreset(ww_timer, auto_preset); WWTimer_SetAutoPreset(ww_timer, auto_preset);
@ -98,7 +98,9 @@ WWTimer WWTimer_Create(int auto_preset, int preset)
WWTimer WWTimer_Destroy(WWTimer ww_timer) WWTimer WWTimer_Destroy(WWTimer ww_timer)
{ {
if (ww_timer == NULL) if (ww_timer == NULL)
Error("WWTimer_Destroy", "Object is not created."); WonX_Error("WWTimer_Destroy", "Object is not created.");
WWTimer_OFF(ww_timer);
free(ww_timer); free(ww_timer);

View File

@ -5,17 +5,21 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "sys/timer.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WWTimer * WWTimer; 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 "WonXDisplayP.h"
#include "etc.h" #include "WonX.h"
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の定義 */ /* メンバ関数の定義 */
/*****************************************************************************/ /*****************************************************************************/
XDisplay WonxDisplay_GetXDisplay(WonxDisplay wonx_display) XDisplay WonXDisplay_GetXDisplay(WonXDisplay wonx_display)
{ return (wonx_display->x_display); } { return (wonx_display->x_display); }
WWDisplay WonxDisplay_GetWWDisplay(WonxDisplay wonx_display) WWDisplay WonXDisplay_GetWWDisplay(WonXDisplay wonx_display)
{ return (wonx_display->ww_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); } { 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); } { 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_lcd_panel_width, int ww_lcd_panel_height,
int ww_screen_width, int ww_screen_height) int ww_screen_width, int ww_screen_height)
{ {
WonxDisplay wonx_display; WonXDisplay wonx_display;
WWDisplay ww_display; WWDisplay ww_display;
XDisplay x_display; XDisplay x_display;
wonx_display = (WonxDisplay)malloc(sizeof(_WonxDisplay)); wonx_display = (WonXDisplay)malloc(sizeof(_WonXDisplay));
if (wonx_display == NULL) if (wonx_display == NULL)
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_display = WWDisplay_Create(ww_lcd_panel_width, ww_lcd_panel_height,
ww_screen_width, ww_screen_height); ww_screen_width, ww_screen_height);
if (ww_display == NULL) if (ww_display == NULL)
Error("WonxDisplay_Create", "Cannot create WonderWitch display."); WonX_Error("WonXDisplay_Create", "Cannot create WonderWitch display.");
WonxDisplay_SetWWDisplay(wonx_display, ww_display); WonXDisplay_SetWWDisplay(wonx_display, ww_display);
x_display = XDisplay_Create(x_width, x_height); x_display = XDisplay_Create(x_width, x_height);
if (x_display == NULL) if (x_display == NULL)
Error("WonxDisplay_Create", "Cannot create X display."); WonX_Error("WonXDisplay_Create", "Cannot create X display.");
WonxDisplay_SetXDisplay(wonx_display, x_display); WonXDisplay_SetXDisplay(wonx_display, x_display);
return (wonx_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; int i;
XDisplay x_display; XDisplay x_display;
WWDisplay ww_display; WWDisplay ww_display;
x_display = WonxDisplay_GetXDisplay(wonx_display); x_display = WonXDisplay_GetXDisplay(wonx_display);
ww_display = WonxDisplay_GetWWDisplay(wonx_display); ww_display = WonXDisplay_GetWWDisplay(wonx_display);
if (XDisplay_GetColorMapPrint(x_display)) { if (XDisplay_GetColorMapPrint(x_display)) {
WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout); WWColorMap_PrintData(WWDisplay_GetColorMap(ww_display), stdout);
fflush(stdout);
XDisplay_SetColorMapPrint(x_display, 0); XDisplay_SetColorMapPrint(x_display, 0);
} }
if (XDisplay_GetPalettePrint(x_display)) { if (XDisplay_GetPalettePrint(x_display)) {
for (i = 0; i < 16; i++) { 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); XDisplay_SetPalettePrint(x_display, 0);
} }
if (XDisplay_GetCharacterPrint(x_display)) { if (XDisplay_GetCharacterPrint(x_display)) {
for (i = 0; i < 512; i++) { 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); XDisplay_SetCharacterPrint(x_display, 0);
} }
@ -76,31 +102,48 @@ int WonxDisplay_Sync(WonxDisplay wonx_display)
if (XDisplay_GetSpritePrint(x_display)) { if (XDisplay_GetSpritePrint(x_display)) {
for (i = 0; i < 128; i++) { for (i = 0; i < 128; i++) {
WWSprite_PrintData(WWDisplay_GetSprite(ww_display, i), stdout); WWSprite_PrintData(WWDisplay_GetSprite(ww_display, i), stdout);
fflush(stdout);
} }
XDisplay_SetSpritePrint(x_display, 0); XDisplay_SetSpritePrint(x_display, 0);
} }
XDisplay_Sync(x_display);
return (0); return (0);
} }
int WonxDisplay_Flush(WonxDisplay wonx_display) int WonXDisplay_DrawLCDWindow(WonXDisplay wonx_display)
{ {
XDisplay x_display; XDisplay x_display;
WWDisplay ww_display; WWDisplay ww_display;
WWLCDPanel ww_lcd_panel; WWLCDPanel ww_lcd_panel;
x_display = WonxDisplay_GetXDisplay(wonx_display); x_display = WonXDisplay_GetXDisplay(wonx_display);
ww_display = WonxDisplay_GetWWDisplay(wonx_display); ww_display = WonXDisplay_GetWWDisplay(wonx_display);
if (XDisplay_GetLCDDraw(x_display)) { /* 表示レベルが1以上のときだけ描画する */
if (XDisplay_GetLCDDrawLevel(x_display) > 0) {
WWDisplay_DrawLCDPanel(ww_display); WWDisplay_DrawLCDPanel(ww_display);
ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display); ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
XDisplay_DrawLCDWindow(x_display, ww_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); return (0);
} }

View File

@ -1,26 +1,37 @@
#ifndef _WonxDisplay_h_INCLUDED_ #ifndef _WonXDisplay_h_INCLUDED_
#define _WonxDisplay_h_INCLUDED_ #define _WonXDisplay_h_INCLUDED_
/*****************************************************************************/ /*****************************************************************************/
/* ¤³¤³¤«¤é */ /* ¤³¤³¤«¤é */
/*****************************************************************************/ /*****************************************************************************/
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonXDisplay * WonXDisplay;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include "XDisplay.h" #include "XDisplay.h"
#include "WWDisplay.h" #include "WWDisplay.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの年盗 */ /* メンバ関数の宣言 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WonxDisplay * WonxDisplay; XDisplay WonXDisplay_GetXDisplay(WonXDisplay wonx_display);
WWDisplay WonXDisplay_GetWWDisplay(WonXDisplay wonx_display);
XDisplay WonxDisplay_GetXDisplay(WonxDisplay wonx_display); WonXDisplay WonXDisplay_Create(int x_width, int x_height,
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_lcd_panel_width, int ww_lcd_panel_height,
int ww_screen_width, int ww_screen_height); int ww_screen_width, int ww_screen_height);
int WonxDisplay_Sync(WonxDisplay wonx_display); WonXDisplay WonXDisplay_Destroy(WonXDisplay wonx_display);
int WonxDisplay_Flush(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_ #ifndef _WonXDisplayP_h_INCLUDED_
#define _WonxDisplayP_h_INCLUDED_ #define _WonXDisplayP_h_INCLUDED_
/*****************************************************************************/ /*****************************************************************************/
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "WonxDisplay.h" #include "WonXDisplay.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WonxDisplay { typedef struct _WonXDisplay {
XDisplay x_display; XDisplay x_display;
WWDisplay ww_display; WWDisplay ww_display;
} _WonxDisplay; } _WonXDisplay;
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */

30
WonXP.h Normal file
View File

@ -0,0 +1,30 @@
#ifndef _WonXP_h_INCLUDED_
#define _WonXP_h_INCLUDED_
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WonX.h"
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonX {
WonXDisplay wonx_display;
WonXSystem wonx_system;
WonXSerialPort wonx_serial_port;
} _WonX;
typedef struct _WonX * WonX;
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
#endif
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

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. */
/*****************************************************************************/

44
WonXSerialPort.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef _WonXSerialPort_h_INCLUDED_
#define _WonXSerialPort_h_INCLUDED_
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonXSerialPort * WonXSerialPort;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include "WWSerialPort.h"
#include "UNIXSerialPort.h"
/*****************************************************************************/
/* メンバ関数の定義 */
/*****************************************************************************/
WWSerialPort WonXSerialPort_GetWWSerialPort(WonXSerialPort wonx_sp);
WWSerialPort WonXSerialPort_SetWWSerialPort(WonXSerialPort wonx_sp,
WWSerialPort ww_sp);
UNIXSerialPort WonXSerialPort_GetUNIXSerialPort(WonXSerialPort wonx_sp);
UNIXSerialPort WonXSerialPort_SetUNIXSerialPort(WonXSerialPort wonx_sp,
UNIXSerialPort unix_sp);
WonXSerialPort WonXSerialPort_Create();
WonXSerialPort WonXSerialPort_Destroy(WonXSerialPort wonx_serial_port);
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
#endif
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

View File

@ -1,23 +1,20 @@
#ifndef _WonxP_h_INCLUDED_ #ifndef _WonXSerialPortP_h_INCLUDED_
#define _WonxP_h_INCLUDED_ #define _WonXSerialPortP_h_INCLUDED_
/*****************************************************************************/ /*****************************************************************************/
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "Wonx.h" #include "WonXSerialPort.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _Wonx { typedef struct _WonXSerialPort {
WonxDisplay wonx_display; WWSerialPort ww_serial_port;
WonxText wonx_text; UNIXSerialPort unix_serial_port;
WonxSystem wonx_system; } _WonXSerialPort;
} _Wonx;
typedef struct _Wonx * Wonx;
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */

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_ #ifndef _WonXSystem_h_INCLUDED_
#define _WonxSystem_h_INCLUDED_ #define _WonXSystem_h_INCLUDED_
/*****************************************************************************/ /*****************************************************************************/
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
/*****************************************************************************/
/* クラスの定義 */
/*****************************************************************************/
typedef struct _WonXSystem * WonXSystem;
/*****************************************************************************/
/* ヘッダファイルのインクルード */
/*****************************************************************************/
#include "WWInterrupt.h" #include "WWInterrupt.h"
#include "WWTimer.h" #include "WWTimer.h"
#include "UNIXTimer.h" #include "UNIXTimer.h"
/*****************************************************************************/
/* ¥¯¥é¥¹¤ÎÄêµÁ */
/*****************************************************************************/
typedef struct _WonxSystem * WonxSystem;
/*****************************************************************************/ /*****************************************************************************/
/* メンバ関数の定義 */ /* メンバ関数の定義 */
/*****************************************************************************/ /*****************************************************************************/
WWInterrupt WonxSystem_GetWWInterrupt(WonxSystem wonx_system); WWInterrupt WonXSystem_GetWWInterrupt(WonXSystem wonx_system);
WWInterrupt WonxSystem_SetWWInterrupt(WonxSystem wonx_system, WWInterrupt WonXSystem_SetWWInterrupt(WonXSystem wonx_system,
WWInterrupt ww_interrupt); WWInterrupt ww_interrupt);
WWTimer WonxSystem_GetWWTimer(WonxSystem wonx_system, int type); WWTimer WonXSystem_GetWWTimer(WonXSystem wonx_system, int type);
WWTimer WonxSystem_SetWWTimer(WonxSystem wonx_system, int type, WWTimer t); WWTimer WonXSystem_SetWWTimer(WonXSystem wonx_system, int type, WWTimer t);
WWTimer WonxSystem_GetWWVBlankTimer(WonxSystem wonx_system); WWTimer WonXSystem_GetWWVBlankTimer(WonXSystem wonx_system);
WWTimer WonxSystem_SetWWVBlankTimer(WonxSystem wonx_system, WWTimer t); WWTimer WonXSystem_SetWWVBlankTimer(WonXSystem wonx_system, WWTimer t);
WWTimer WonxSystem_GetWWVBlankCountUpTimer(WonxSystem wonx_system); WWTimer WonXSystem_GetWWVBlankCountUpTimer(WonXSystem wonx_system);
WWTimer WonxSystem_SetWWVBlankCountUpTimer(WonxSystem wonx_system, WWTimer t); WWTimer WonXSystem_SetWWVBlankCountUpTimer(WonXSystem wonx_system, WWTimer t);
WWTimer WonxSystem_GetWWHBlankCountUpTimer(WonxSystem wonx_system); WWTimer WonXSystem_GetWWHBlankCountUpTimer(WonXSystem wonx_system);
WWTimer WonxSystem_SetWWHBlankCountUpTimer(WonxSystem wonx_system, WWTimer t); WWTimer WonXSystem_SetWWHBlankCountUpTimer(WonXSystem wonx_system, WWTimer t);
UNIXTimer WonxSystem_GetUNIXTimer(WonxSystem wonx_system); UNIXTimer WonXSystem_GetUNIXTimer(WonXSystem wonx_system);
UNIXTimer WonxSystem_SetUNIXTimer(WonxSystem wonx_system, UNIXTimer WonXSystem_SetUNIXTimer(WonXSystem wonx_system,
UNIXTimer unix_timer); UNIXTimer unix_timer);
WonxSystem WonxSystem_Create(); WonXSystem WonXSystem_Create();
WonxSystem WonxSystem_Destroy(WonxSystem wonx_system); WonXSystem WonXSystem_Destroy(WonXSystem wonx_system);
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */

View File

@ -1,17 +1,17 @@
#ifndef _WonxSystemP_h_INCLUDED_ #ifndef _WonXSystemP_h_INCLUDED_
#define _WonxSystemP_h_INCLUDED_ #define _WonXSystemP_h_INCLUDED_
/*****************************************************************************/ /*****************************************************************************/
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "WonxSystem.h" #include "WonXSystem.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
typedef struct _WonxSystem { typedef struct _WonXSystem {
WWInterrupt ww_interrupt; WWInterrupt ww_interrupt;
@ -24,7 +24,7 @@ typedef struct _WonxSystem {
UNIXTimer unix_timer; UNIXTimer unix_timer;
} _WonxSystem; } _WonXSystem;
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */

60
Wonx.c
View File

@ -1,60 +0,0 @@
#include "WonxP.h"
#include "etc.h"
#include "sys/disp.h"
#include "sys/text.h"
#include "sys/system.h"
/*****************************************************************************/
/* ディスプレイの確保 */
/*****************************************************************************/
static Wonx wonx = NULL;
int Wonx_IsCreated(void)
{
return (wonx != NULL);
}
void Wonx_Create(void)
{
WWScreen screen;
WWPalette palette;
wonx = (Wonx)malloc(sizeof(_Wonx));
if (wonx == NULL) Error("Wonx_Create", "Cannot allocate memory.");
wonx->wonx_display =
WonxDisplay_Create(LCD_PIXEL_WIDTH * 2, LCD_PIXEL_HEIGHT * 2,
LCD_PIXEL_WIDTH, LCD_PIXEL_HEIGHT,
SCREEN_CHAR_WIDTH, SCREEN_CHAR_HEIGHT);
screen =
WWDisplay_GetScreen(WonxDisplay_GetWWDisplay(wonx->wonx_display), SCREEN2);
/* デフォルトのテキスト表示用パレットは0 */
palette =
WWDisplay_GetPalette(WonxDisplay_GetWWDisplay(wonx->wonx_display), 0);
wonx->wonx_text =
WonxText_Create(screen, 0, 0, TEXT_SCREEN_WIDTH, TEXT_SCREEN_HEIGHT,
palette);
wonx->wonx_system = WonxSystem_Create();
return;
}
WonxDisplay Wonx_GetWonxDisplay(void)
{
return (wonx->wonx_display);
}
WonxText Wonx_GetWonxText(void)
{
return (wonx->wonx_text);
}
WonxSystem Wonx_GetWonxSystem(void)
{
return (wonx->wonx_system);
}

18
Wonx.h
View File

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

View File

@ -1,172 +0,0 @@
/*****************************************************************************/
/* ここから */
/*****************************************************************************/
#include "WonxSystemP.h"
#include "configure.h"
#include "etc.h"
/*****************************************************************************/
/* メンバ関数の定義 */
/*****************************************************************************/
WWInterrupt WonxSystem_GetWWInterrupt(WonxSystem wonx_system)
{ return (wonx_system->ww_interrupt); }
WWInterrupt WonxSystem_SetWWInterrupt(WonxSystem wonx_system,
WWInterrupt ww_interrupt)
{ return (wonx_system->ww_interrupt = ww_interrupt); }
WWTimer WonxSystem_GetWWTimer(WonxSystem wonx_system, int type)
{ return (wonx_system->ww_timer[type]); }
WWTimer WonxSystem_SetWWTimer(WonxSystem wonx_system, int type, WWTimer t)
{ return (wonx_system->ww_timer[type] = t); }
WWTimer WonxSystem_GetWWVBlankTimer(WonxSystem wonx_system)
{ return (WonxSystem_GetWWTimer(wonx_system, 0)); }
WWTimer WonxSystem_SetWWVBlankTimer(WonxSystem wonx_system, WWTimer t)
{ return (WonxSystem_SetWWTimer(wonx_system, 0, t)); }
WWTimer WonxSystem_GetWWVBlankCountUpTimer(WonxSystem wonx_system)
{ return (WonxSystem_GetWWTimer(wonx_system, 1)); }
WWTimer WonxSystem_SetWWVBlankCountUpTimer(WonxSystem wonx_system, WWTimer t)
{ return (WonxSystem_SetWWTimer(wonx_system, 1, t)); }
WWTimer WonxSystem_GetWWHBlankCountUpTimer(WonxSystem wonx_system)
{ return (WonxSystem_GetWWTimer(wonx_system, 2)); }
WWTimer WonxSystem_SetWWHBlankCountUpTimer(WonxSystem wonx_system, WWTimer t)
{ return (WonxSystem_SetWWTimer(wonx_system, 2, t)); }
UNIXTimer WonxSystem_GetUNIXTimer(WonxSystem wonx_system)
{ return (wonx_system->unix_timer); }
UNIXTimer WonxSystem_SetUNIXTimer(WonxSystem wonx_system,
UNIXTimer unix_timer)
{ return (wonx_system->unix_timer = unix_timer); }
static int WonxTimer_Callback(WonxSystem wonx_system)
{
WWTimer ww_timer;
WWInterrupt ww_interrupt;
ww_interrupt = WonxSystem_GetWWInterrupt(wonx_system);
ww_timer = WonxSystem_GetWWVBlankTimer(wonx_system);
if (WWTimer_IsON(ww_timer)) {
if (WWTimer_Count(ww_timer))
WWInterrupt_ExecuteVBlankCallback(ww_interrupt);
}
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(wonx_system);
if (WWTimer_IsON(ww_timer)) {
if (WWTimer_Count(ww_timer))
WWInterrupt_ExecuteTimerCountUpCallback(ww_interrupt);
}
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(wonx_system);
if (WWTimer_IsON(ww_timer)) {
if (WWTimer_Count(ww_timer))
WWInterrupt_ExecuteHBlankCountUpCallback(ww_interrupt);
}
return (0);
}
WonxSystem WonxSystem_Create()
{
WonxSystem wonx_system;
WWInterrupt ww_interrupt;
WWTimer ww_timer;
UNIXTimer unix_timer;
wonx_system = (WonxSystem)malloc(sizeof(_WonxSystem));
if (wonx_system == NULL)
Error("WonxSystem_Create", "Cannot allocate memory.");
ww_interrupt = WWInterrupt_Create();
if (ww_interrupt == NULL)
Error("WonxSystem_Create", "Cannot create WonderWitch interrupt.");
WonxSystem_SetWWInterrupt(wonx_system, ww_interrupt);
/* VBlank は WONX_VBLANK_INTERVAL * 0.1 秒毎とする */
ww_timer = WWTimer_Create(1, WONX_VBLANK_INTERVAL);
if (ww_timer == NULL)
Error("WonxSystem_Create", "Cannot create WonderWitch VBlank timer.");
WonxSystem_SetWWVBlankTimer(wonx_system, ww_timer);
ww_timer = WWTimer_Create(0, WONX_VBLANK_INTERVAL);
if (ww_timer == NULL)
Error("WonxSystem_Create",
"Cannot create WonderWitch VBlank count up timer.");
WonxSystem_SetWWVBlankCountUpTimer(wonx_system, ww_timer);
ww_timer = WWTimer_Create(0, WONX_HBLANK_INTERVAL);
if (ww_timer == NULL)
Error("WonxSystem_Create",
"Cannot create WonderWitch HBlank count up timer.");
WonxSystem_SetWWHBlankCountUpTimer(wonx_system, ww_timer);
WWTimer_Reset(WonxSystem_GetWWVBlankTimer( wonx_system));
WWTimer_Reset(WonxSystem_GetWWVBlankCountUpTimer(wonx_system));
WWTimer_Reset(WonxSystem_GetWWHBlankCountUpTimer(wonx_system));
WWTimer_ON( WonxSystem_GetWWVBlankTimer( wonx_system));
WWTimer_OFF(WonxSystem_GetWWVBlankCountUpTimer(wonx_system));
WWTimer_OFF(WonxSystem_GetWWHBlankCountUpTimer(wonx_system));
/* タイマのインターバルは0.1 秒単位とする */
unix_timer = UNIXTimer_Create(1, WONX_TIMER_INTERVAL, wonx_system,
(UNIXTimerCallBack)WonxTimer_Callback);
if (unix_timer == NULL)
Error("WonxSystem_Create", "Cannot create UNIX timer.");
WonxSystem_SetUNIXTimer(wonx_system, unix_timer);
UNIXTimer_ON(unix_timer);
return (wonx_system);
}
WonxSystem WonxSystem_Destroy(WonxSystem wonx_system)
{
WWInterrupt wi;
WWTimer wt;
UNIXTimer unix_timer;
if (wonx_system == NULL)
Error("WonxSystem_Destroy", "Object is not created.");
unix_timer = WonxSystem_GetUNIXTimer(wonx_system);
if (unix_timer)
UNIXTimer_OFF(unix_timer);
wt = WonxSystem_GetWWVBlankTimer(wonx_system);
if (wt) WWTimer_OFF(wt);
wt = WonxSystem_GetWWVBlankCountUpTimer(wonx_system);
if (wt) WWTimer_OFF(wt);
wt = WonxSystem_GetWWHBlankCountUpTimer(wonx_system);
if (wt) WWTimer_OFF(wt);
if (unix_timer)
WonxSystem_SetUNIXTimer(wonx_system, UNIXTimer_Destroy(unix_timer));
wt = WonxSystem_GetWWVBlankTimer(wonx_system);
if (wt) WonxSystem_SetWWVBlankTimer(wonx_system, WWTimer_Destroy(wt));
wt = WonxSystem_GetWWVBlankCountUpTimer(wonx_system);
if (wt) WonxSystem_SetWWVBlankCountUpTimer(wonx_system, WWTimer_Destroy(wt));
wt = WonxSystem_GetWWHBlankCountUpTimer(wonx_system);
if (wt) WonxSystem_SetWWHBlankCountUpTimer(wonx_system, WWTimer_Destroy(wt));
wi = WonxSystem_GetWWInterrupt(wonx_system);
if (wi) WonxSystem_SetWWInterrupt(wonx_system, WWInterrupt_Destroy(wi));
free(wonx_system);
return (NULL);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

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)
Error("WonxText_Create", "Cannot allocate memory.");
ww_text = WWText_Create(screen, x, y, width, height, palette);
if (ww_text == NULL)
Error("WonxText_Create", "Cannot create WonderWitch text.");
WonxText_SetWWText(wonx_text, ww_text);
return (wonx_text);
}
WonxText WonxText_Destroy(WonxText wonx_text)
{
if (wonx_text == NULL)
Error("WonxText_Destroy", "Object is not created.");
if (WonxText_GetWWText(wonx_text))
WonxText_SetWWText(wonx_text,
WWText_Destroy(WonxText_GetWWText(wonx_text)));
free(wonx_text);
return (NULL);
}
/*****************************************************************************/
/* ここまで */
/*****************************************************************************/
/*****************************************************************************/
/* End of File. */
/*****************************************************************************/

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

@ -2,21 +2,39 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "XDisplayP.h"
#include "Wonx.h"
#include "etc.h"
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
#include <sys/types.h>
#include "XDisplayP.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); } unsigned int XDisplay_GetKeyPress(XDisplay d) { return (d->key_press); }
int XDisplay_GetLCDDraw(XDisplay d) { return (d->lcd_draw); }
int XDisplay_GetLCDDrawLevel(XDisplay d) { return (d->lcd_draw_level); }
int XDisplay_SetLCDDrawLevel(XDisplay d, int level)
{
d->lcd_draw_level = level;
WonXDisplay_Flush(WonX_GetWonXDisplay());
return (d->lcd_draw_level);
}
int XDisplay_LCDDrawLevelDown(XDisplay d)
{ return (XDisplay_SetLCDDrawLevel(d, d->lcd_draw_level - 1)); }
int XDisplay_LCDDrawLevelUp( XDisplay d)
{ return (XDisplay_SetLCDDrawLevel(d, d->lcd_draw_level + 1)); }
int XDisplay_GetColorMapPrint(XDisplay d) {return (d->color_map_print); } int XDisplay_GetColorMapPrint(XDisplay d) {return (d->color_map_print); }
int XDisplay_GetPalettePrint(XDisplay d) {return (d->palette_print); } int XDisplay_GetPalettePrint(XDisplay d) {return (d->palette_print); }
@ -68,16 +86,16 @@ static void iconify(Widget w, XEvent * event, String * params, Cardinal * num)
XIconifyWindow(XtDisplay(w), XtWindow(w), DefaultScreen(XtDisplay(w))); 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 old_t;
time_t t; time_t t;
int i; int i;
/* UNIXTimer.c 内部で SIGALRM を使用しているのでsleep() は使用できない */ /* UNIXTimer.c 内部で SIGALRM を使用しているのでsleep() は使用できない */
#if 0 #if 0
sleep(3); sleep(10);
#else #else
for (i = 0; i < 3; i++) { for (i = 0; i < 10; i++) {
time(&t); time(&t);
old_t = t; old_t = t;
while (t == old_t) while (t == old_t)
@ -90,20 +108,22 @@ static XtActionsRec actions[] = {
{"quit", quit}, {"quit", quit},
{"wm_protocols_proc", wm_protocols_proc}, {"wm_protocols_proc", wm_protocols_proc},
{"iconify", iconify}, {"iconify", iconify},
{"pause", sleep_3} {"pause", sleep_10}
}; };
static char * translations = static char * translations =
"<Message>WM_PROTOCOLS: wm_protocols_proc()\n" "<Message>WM_PROTOCOLS: wm_protocols_proc()\n"
"None<Key>p: pause()\n" "None<Key>F11: pause()\n"
"Ctrl<Key>i: iconify()\n" "Ctrl<Key>i: iconify()\n"
"Ctrl<Key>c: quit()\n" "Ctrl<Key>c: quit()\n"
"None<Key>F12: quit()\n"
"None<Key>q: quit()"; "None<Key>q: quit()";
/*===========================================================================*/ /*===========================================================================*/
/* 色名からピクセル値を取得する */ /* 色名からピクセル値を取得する */
/*===========================================================================*/ /*===========================================================================*/
#ifdef USE_X_FONT
static unsigned long XDisplay_GetPixelFromColorName(XDisplay x_display, static unsigned long XDisplay_GetPixelFromColorName(XDisplay x_display,
char * color_name) char * color_name)
{ {
@ -112,11 +132,27 @@ static unsigned long XDisplay_GetPixelFromColorName(XDisplay x_display,
&c0, &c1); &c0, &c1);
return (c0.pixel); 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,61 +171,104 @@ static void KeyHandler(Widget w, XtPointer p, XEvent * event,
switch (key_sym) { switch (key_sym) {
/* WonderSwan用 */ /* WonderSwan用 */
case XK_Up : press = KEY_UP1; break; case XK_Up : press = KEY_UP1; printf("key : Up1 " ); break;
case XK_Right : press = KEY_RIGHT1; break; case XK_Right : press = KEY_RIGHT1; printf("key : Right1 "); break;
case XK_Down : press = KEY_DOWN1; break; case XK_Down : press = KEY_DOWN1; printf("key : Down1 " ); break;
case XK_Left : press = KEY_LEFT1; break; case XK_Left : press = KEY_LEFT1; printf("key : Left1 " ); break;
case XK_i : press = KEY_UP2; break; case XK_i : press = KEY_UP2; printf("key : Up2 " ); break;
case XK_l : press = KEY_RIGHT2; break; case XK_l : press = KEY_RIGHT2; printf("key : Right2 "); break;
case XK_k : press = KEY_DOWN2; break; case XK_k : press = KEY_DOWN2; printf("key : Down2 " ); break;
case XK_j : press = KEY_LEFT2; break; case XK_j : press = KEY_LEFT2; printf("key : Left2 " ); break;
case XK_s : press = KEY_START; break; case XK_s : press = KEY_START; printf("key : Start " ); break;
case XK_space : press = KEY_A; break; case XK_space : press = KEY_A; printf("key : A " ); break;
case XK_Shift_L : press = KEY_B; break; case XK_Shift_L : press = KEY_B; printf("key : B " ); break;
default : press = 0; break; default : press = 0; break;
} }
/* 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) { if (event->type == KeyPress) {
switch (key_sym) { switch (key_sym) {
/* 表示モード変更 */ /* 表示モード変更 */
case XK_p : case XK_F9 :
x_display->lcd_draw = !(x_display->lcd_draw); case XK_F10 :
if (x_display->lcd_draw)
WonxDisplay_Flush(Wonx_GetWonxDisplay()); 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; break;
/* データのダンプ操作 */ /* データのダンプ操作 */
case XK_F1 : x_display->color_map_print = 1; break; case XK_F1 :
case XK_F2 : x_display->palette_print = 1; break; printf("key : F1 Pressed\n");
case XK_F3 : x_display->character_print = 1; break; x_display->color_map_print = 1;
case XK_F4 : x_display->sprite_print = 1; break; printf("dump : color_map\n");
break;
case XK_F2 :
printf("key : F2 Pressed\n");
x_display->palette_print = 1;
printf("dump : palette\n");
break;
case XK_F3 :
printf("key : F3 Pressed\n");
x_display->character_print = 1;
printf("dump : character\n");
break;
case XK_F4 :
printf("key : F4 Pressed\n");
x_display->sprite_print = 1;
printf("dump : sprite\n");
break;
}
} }
} }
if (press) {
if (event->type == KeyPress) x_display->key_press |= press;
else x_display->key_press &= ~press;
}
}
return;
}
/*---------------------------------------------------------------------------*/
/* イクスポーズ */
/*---------------------------------------------------------------------------*/
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; return;
} }
@ -226,17 +305,18 @@ XDisplay XDisplay_Create(int width, int height)
int i; int i;
x_display = (XDisplay)malloc(sizeof(_XDisplay)); x_display = (XDisplay)malloc(sizeof(_XDisplay));
if (x_display == NULL) Error("XDisplay_Create", "Cannot allocate memory."); if (x_display == NULL)
WonX_Error("XDisplay_Create", "Cannot allocate memory.");
x_display->width = width; x_display->width = width;
x_display->height = height; x_display->height = height;
x_display->toplevel = XtAppInitialize(&(x_display->app_context), x_display->toplevel = XtAppInitialize(&(x_display->app_context),
"Wonx", "WonX",
NULL, 0, &argc, argv, NULL, NULL, 0); NULL, 0, &argc, argv, NULL, NULL, 0);
XtVaSetValues(x_display->toplevel, XtNinput, True, NULL); 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, XtNwidth , x_display->width , NULL);
XtVaSetValues(x_display->toplevel, XtNminWidth , x_display->width , NULL); XtVaSetValues(x_display->toplevel, XtNminWidth , x_display->width , NULL);
XtVaSetValues(x_display->toplevel, XtNmaxWidth , x_display->width , NULL); XtVaSetValues(x_display->toplevel, XtNmaxWidth , x_display->width , NULL);
@ -245,7 +325,7 @@ XDisplay XDisplay_Create(int width, int height)
XtVaSetValues(x_display->toplevel, XtNmaxHeight, x_display->height, NULL); XtVaSetValues(x_display->toplevel, XtNmaxHeight, x_display->height, NULL);
x_display->key_press = 0; x_display->key_press = 0;
x_display->lcd_draw = 1; x_display->lcd_draw_level = 1;
XtRealizeWidget(x_display->toplevel); XtRealizeWidget(x_display->toplevel);
while (!XtIsRealized(x_display->toplevel)) { /* None */ } while (!XtIsRealized(x_display->toplevel)) { /* None */ }
@ -279,6 +359,7 @@ XDisplay XDisplay_Create(int width, int height)
XSetFunction(x_display->display, x_display->color_gc[i], GXcopy); XSetFunction(x_display->display, x_display->color_gc[i], GXcopy);
} }
#ifdef USE_X_FONT
/* フォントの確保 */ /* フォントの確保 */
x_display->font = XLoadFont(x_display->display, "8x16"); x_display->font = XLoadFont(x_display->display, "8x16");
x_display->font_gc = XCreateGC(x_display->display, x_display->font_gc = XCreateGC(x_display->display,
@ -289,6 +370,24 @@ XDisplay XDisplay_Create(int width, int height)
XDisplay_GetPixelFromColorName(x_display, "white")); XDisplay_GetPixelFromColorName(x_display, "white"));
XSetBackground(x_display->display, x_display->font_gc, XSetBackground(x_display->display, x_display->font_gc,
XDisplay_GetPixelFromColorName(x_display, "black")); XDisplay_GetPixelFromColorName(x_display, "black"));
#endif
/* GCのデータベース初期化 */
/*
* XColorGCDatabase_Create() XCreateGC() GC
* XFreeGC() Segmentation Fault
* (FreeBSD OS (Xライブラリ)
* )XColorGCDatabase_Create() GC
*
*/
x_display->color_gc_database =
XColorGCDatabase_Create(x_display,
0, /* studying_flag */
1, /* cache_flag */
3, /* cache_size */
256, /* hash_number */
"black", /* background_color */
16 /* gradation */);
XFillRectangle(x_display->display, x_display->lcd_window, XFillRectangle(x_display->display, x_display->lcd_window,
x_display->color_gc[0], x_display->color_gc[0],
@ -338,17 +437,87 @@ XDisplay XDisplay_Destroy(XDisplay x_display)
{ {
int i; int i;
if (x_display == NULL) return (NULL); if (x_display == NULL)
WonX_Error("XDisplay_Destroy", "Object is not created.");
/* Xサーバと同期をとる */
/* True だと,イベントキュー内のイベントを廃棄する */
XSync(x_display->display, True);
/* トランスレーションのアンインストール */
XtUninstallTranslations(x_display->toplevel);
/* アクションの削除 */
#if 0
/*
*
* ()
*/
#endif
/* アイコンの削除 */
#if 0
/* アイコンの削除処理が必要な場合にはここに書く.現状では必要無し */
#endif
/* イベントハンドラの削除 */
XtRemoveEventHandler(x_display->toplevel, KeyPressMask | KeyReleaseMask,
False, KeyHandler, x_display);
XtRemoveEventHandler(x_display->toplevel, ExposureMask,
False, ExposeHandler, x_display);
XtRemoveEventHandler(x_display->toplevel, LeaveWindowMask | FocusChangeMask,
False, LeaveWindowHandler, x_display);
/* GCのデータベース終了処理 */
if (x_display->color_gc_database) {
x_display->color_gc_database =
XColorGCDatabase_Destroy(x_display->color_gc_database);
}
#ifdef USE_X_FONT
/* フォントの解放 */
if (x_display->font_gc) {
XFreeGC(x_display->display, x_display->font_gc);
x_display->font_gc = 0;
}
if (x_display->font) {
XUnloadFont(x_display->display, x_display->font);
x_display->font = 0;
}
#endif
/* あとでリソースの解放を追加すること */
if (x_display->color_gc != NULL) {
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
if (x_display->color_gc[i]) if (x_display->color_gc[i]) {
XFreeGC(x_display->display, x_display->color_gc[i]); XFreeGC(x_display->display, x_display->color_gc[i]);
x_display->color_gc[i] = 0; x_display->color_gc[i] = 0;
} }
} }
if (x_display->copy_gc) {
XFreeGC(x_display->display, x_display->copy_gc);
x_display->copy_gc = 0;
}
if (x_display->lcd_pixmap) {
XFreePixmap(x_display->display, x_display->lcd_pixmap);
x_display->lcd_pixmap = 0;
}
x_display->key_press = 0;
x_display->lcd_draw_level = 0;
#if 0
if (x_display->app_context) {
XtDestroyApplicationContext(x_display->app_context);
x_display->app_context = 0;
}
#endif
if (x_display->toplevel) {
XtDestroyWidget(x_display->toplevel);
x_display->toplevel = 0;
}
free(x_display); free(x_display);
return (NULL); return (NULL);
@ -360,14 +529,21 @@ XDisplay XDisplay_Destroy(XDisplay x_display)
int XDisplay_Sync(XDisplay x_display) int XDisplay_Sync(XDisplay x_display)
{ {
XEvent event;
XFlush(x_display->display); XFlush(x_display->display);
/* Xサーバと同期をとる */ /* Xサーバと同期をとる */
/* False だと,イベントキュー内のイベントを廃棄しない */ /* False だと,イベントキュー内のイベントを廃棄しない */
XSync(x_display->display, False); XSync(x_display->display, False);
return (0);
}
int XDisplay_Flush(XDisplay x_display)
{
XEvent event;
XDisplay_Sync(x_display);
/* イベントの処理 */ /* イベントの処理 */
while (XtAppPending(x_display->app_context)) { while (XtAppPending(x_display->app_context)) {
XtAppNextEvent(x_display->app_context, &event); XtAppNextEvent(x_display->app_context, &event);
@ -381,20 +557,34 @@ 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 x, y;
int px, py, ph; int px, py, ph;
int num; int num;
int n[16]; int n[16];
XRectangle rectangle;
XRectangle * rectangles[16]; XRectangle * rectangles[16];
int pixel; unsigned short int pixel;
int ww_lcd_width, ww_lcd_height; int ww_lcd_width, ww_lcd_height;
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)) {
case COLOR_MODE_GRAYSCALE:
/* 隣接しているピクセルはまとめて描画するので,ピクセル数の最大値は */ /* 隣接しているピクセルはまとめて描画するので,ピクセル数の最大値は */
/* 最悪の場合(縞々模様のとき)でwidth * height / 2 になる. */ /* 最悪の場合(縞々模様のとき)でwidth * height / 2 になる. */
num = num =
WWLCDPanel_GetHeight(ww_lcd_panel) * WWLCDPanel_GetWidth(ww_lcd_panel) / 2; WWLCDPanel_GetHeight(ww_lcd_panel) *
WWLCDPanel_GetWidth(ww_lcd_panel) / 2;
/* /*
* malloc() 使 * malloc() 使
@ -405,10 +595,7 @@ int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel)
rectangles[pixel] = (XRectangle *)malloc(sizeof(XRectangle) * num); rectangles[pixel] = (XRectangle *)malloc(sizeof(XRectangle) * num);
} }
if (rectangles == NULL) if (rectangles == NULL)
Error("XDisplay_DrawLCDWindow", "Cannot allocate memory."); WonX_Error("XDisplay_DrawLCDWindow", "Cannot allocate memory.");
ww_lcd_width = WWLCDPanel_GetWidth( ww_lcd_panel);
ww_lcd_height = WWLCDPanel_GetHeight(ww_lcd_panel);
/* ここの処理はホットスポットになるので,のちのちにチューニングすること */ /* ここの処理はホットスポットになるので,のちのちにチューニングすること */
@ -451,6 +638,71 @@ int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel)
} }
} }
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, XCopyArea(x_display->display, x_display->lcd_pixmap,
x_display->lcd_window, x_display->copy_gc, 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);
@ -460,10 +712,27 @@ int XDisplay_DrawLCDWindow(XDisplay x_display, WWLCDPanel ww_lcd_panel)
XDisplay_Sync(x_display); XDisplay_Sync(x_display);
for (pixel = 0; pixel < 16; pixel++) { return (0);
free(rectangles[pixel]);
} }
/*---------------------------------------------------------------------------*/
/* GC の作成 */
/*---------------------------------------------------------------------------*/
GC XDisplay_CreateGC(XDisplay x_display)
{
GC gc;
gc = XCreateGC(x_display->display, x_display->lcd_window, 0, 0);
return (gc);
}
/*---------------------------------------------------------------------------*/
/* GC の解放 */
/*---------------------------------------------------------------------------*/
int XDisplay_DestroyGC(XDisplay x_display, GC gc)
{
XFreeGC(x_display->display, gc);
return (0); return (0);
} }

View File

@ -5,10 +5,6 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include "sys/key.h"
#include "WWLCDPanel.h"
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
@ -16,11 +12,32 @@
typedef struct _XDisplay * XDisplay; 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); unsigned int XDisplay_GetKeyPress(XDisplay x_display);
int XDisplay_GetLCDDraw(XDisplay x_display);
int XDisplay_GetLCDDrawLevel(XDisplay d);
int XDisplay_SetLCDDrawLevel(XDisplay d, int level);
int XDisplay_LCDDrawLevelDown(XDisplay d);
int XDisplay_LCDDrawLevelUp( XDisplay d);
int XDisplay_GetColorMapPrint(XDisplay d); int XDisplay_GetColorMapPrint(XDisplay d);
int XDisplay_GetPalettePrint(XDisplay d); int XDisplay_GetPalettePrint(XDisplay d);
@ -53,12 +70,26 @@ XDisplay XDisplay_Destroy(XDisplay x_display);
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int XDisplay_Sync(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 <signal.h>
#include <X11/Xlib.h>
#include <X11/Intrinsic.h> #include <X11/Intrinsic.h>
#include <X11/StringDefs.h> #include <X11/StringDefs.h>
#include <X11/Shell.h> #include <X11/Shell.h>
#include <X11/Xatom.h> #include <X11/Xatom.h>
#include <X11/keysym.h> #include <X11/keysym.h>
/*
* X
*/
#define USE_X_FONT
/*****************************************************************************/ /*****************************************************************************/
/* クラスの定義 */ /* クラスの定義 */
/*****************************************************************************/ /*****************************************************************************/
@ -37,17 +41,22 @@ typedef struct _XDisplay {
Pixmap lcd_pixmap; Pixmap lcd_pixmap;
GC copy_gc; 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; Font font;
GC font_gc; GC font_gc;
#endif
/* キーの状態 */ /* キーの状態 */
unsigned int key_press; unsigned int key_press;
/* LCD描画のフラグ */ /* LCD描画のレベル */
int lcd_draw; int lcd_draw_level;
/* ダンプ出力のフラグ */ /* ダンプ出力のフラグ */
int color_map_print; int color_map_print;

18
bank.c
View File

@ -5,9 +5,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "sys/bank.h" #include "wonx/bank.h"
#include "Wonx.h" #include "WonX.h"
/*****************************************************************************/ /*****************************************************************************/
/* 高垂簇眶の年盗 */ /* 高垂簇眶の年盗 */
@ -39,39 +39,39 @@ int bank_get_map(int bank)
return (0); return (0);
} }
unsigned char bank_read_byte(int bank, unsigned int offset) unsigned char bank_read_byte(int bank, unsigned int off)
{ {
return (0); return (0);
} }
void bank_write_byte(int bank, unsigned int offset, unsigned int data) void bank_write_byte(int bank, unsigned int off, unsigned int data)
{ {
return; return;
} }
unsigned int bank_read_word(int bank, unsigned int offset) unsigned int bank_read_word(int bank, unsigned int off)
{ {
return (0); return (0);
} }
void bank_write_word(int bank, unsigned int offset, unsigned int data) void bank_write_word(int bank, unsigned int off, unsigned int data)
{ {
return; return;
} }
void bank_read_block(int bank, unsigned int offset, void bank_read_block(int bank, unsigned int off,
void * buffer, unsigned int size) void * buffer, unsigned int size)
{ {
return; return;
} }
void bank_write_block(int bank, unsigned int offset, void bank_write_block(int bank, unsigned int off,
void * buffer, unsigned int size) void * buffer, unsigned int size)
{ {
return; return;
} }
void bank_fill_block(int bank, unsigned int offset, void bank_fill_block(int bank, unsigned int off,
unsigned int size, unsigned int data) unsigned int size, unsigned int data)
{ {
return; return;

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

527
comm.c
View File

@ -4,10 +4,20 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/time.h>
#include "sys/comm.h" #include "wonx/comm.h"
#include "Wonx.h" #include "wonx_configure.h"
#include "WonX.h"
#include "WonXSerialPort.h"
#include "WWSerialPort.h"
#include "UNIXSerialPort.h"
#include "etc.h"
/*****************************************************************************/ /*****************************************************************************/
/* 高垂簇眶の年盗 */ /* 高垂簇眶の年盗 */
@ -30,69 +40,546 @@
*/ */
void comm_open(void) void comm_open(void)
{} {
WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_open() : \n");
fflush(stdout);
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (WWSerialPort_IsOpened(ww_serial_port))
WonX_Warning("comm_open", "WW serial port has already opened.");
WWSerialPort_Open(ww_serial_port);
if (UNIXSerialPort_IsOpened(unix_serial_port))
WonX_Warning("comm_open", "UNIX serial port has already opened.");
UNIXSerialPort_Open(unix_serial_port);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_open() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
void comm_close(void) void comm_close(void)
{}
int comm_send_char(unsigned char byte)
{ {
return (0); WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_close() : \n");
fflush(stdout);
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsClosed(ww_serial_port))
WonX_Warning("comm_close", "WW serial port is not opened.");
WWSerialPort_Close(ww_serial_port);
if (!UNIXSerialPort_IsClosed(unix_serial_port))
WonX_Warning("comm_close", "UNIX serial port is not opened.");
UNIXSerialPort_Close(unix_serial_port);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_close() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
static void comm_output(unsigned char c)
{
WonXSerialPort wonx_serial_port;
UNIXSerialPort unix_serial_port;
wonx_serial_port = WonX_GetWonXSerialPort();
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
UNIXSerialPort_SendCharacter(unix_serial_port, c);
return;
}
static int comm_input(int timeout)
{
WonXSerialPort wonx_serial_port;
UNIXSerialPort unix_serial_port;
int c;
wonx_serial_port = WonX_GetWonXSerialPort();
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
c = UNIXSerialPort_ReceiveCharacter(unix_serial_port,
WONX_SERIAL_PORT_TIMETICKS * timeout);
return (c);
}
int comm_send_char(unsigned char c)
{
WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_send_char() : character = \'");
wonx_print_character(stdout, c);
printf("\'\n");
fflush(stdout);
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsOpened(ww_serial_port))
WonX_Error("comm_send_char", "WW serial port is not opened.");
if (!UNIXSerialPort_IsOpened(unix_serial_port))
WonX_Error("comm_send_char", "UNIX serial port is not opened.");
printf("output to serial port : \"");
comm_output(c);
printf("\"\n");
fflush(stdout);
ret = 0;
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_send_char() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
int comm_receive_char(void) int comm_receive_char(void)
{ {
return (0); WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
int c;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_receive_char() : \n");
fflush(stdout);
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsOpened(ww_serial_port))
WonX_Error("comm_receive_char", "WW serial port is not opened.");
if (!UNIXSerialPort_IsOpened(unix_serial_port))
WonX_Error("comm_receive_char", "UNIX serial port is not opened.");
c = comm_input(WWSerialPort_GetReceiveTimeout(ww_serial_port));
if (c == -1) ret = ERR_SIO_TIMEOUT;
else ret = c;
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_receive_char() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
int comm_receive_with_timeout(int timeout) int comm_receive_with_timeout(int timeout)
{ {
return (0); WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
int c;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_receive_with_timeout() : timeout = %d\n", timeout);
fflush(stdout);
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsOpened(ww_serial_port))
WonX_Error("comm_receive_with_timeout", "WW serial port is not opened.");
if (!UNIXSerialPort_IsOpened(unix_serial_port))
WonX_Error("comm_receive_with_timeout", "UNIX serial port is not opened.");
c = comm_input(timeout);
if (c == -1) ret = ERR_SIO_TIMEOUT;
else ret = c;
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_receive_with_timeout() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
int comm_send_string(char * string) int comm_send_string(char * string)
{ {
return (0); WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
int ret;
char * p;
int i;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_send_string() : string = \"");
for (p = string; *p != '\0'; p++) wonx_print_character(stdout, *p);
printf("\"\n");
fflush(stdout);
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsOpened(ww_serial_port))
WonX_Error("comm_send_string", "WW serial port is not opened.");
if (!UNIXSerialPort_IsOpened(unix_serial_port))
WonX_Error("comm_send_string", "UNIX serial port is not opened.");
printf("output to serial port : \"");
for (i = 0; string[i]; i++) {
comm_output(string[i]);
}
printf("\"\n");
fflush(stdout);
ret = 0;
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_send_string() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
int comm_send_block(void * buffer, int size) int comm_send_block(void * buffer, int size)
{ {
return (0); WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
int ret;
int i;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_send_block() : buffer = %p, size = %d\n", buffer, size);
fflush(stdout);
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsOpened(ww_serial_port))
WonX_Error("comm_send_block", "WW serial port is not opened.");
if (!UNIXSerialPort_IsOpened(unix_serial_port))
WonX_Error("comm_send_block", "UNIX serial port is not opened.");
printf("output to serial port : \"");
for (i = 0; i < size; i++) {
comm_output(((char *)buffer)[i]);
}
printf("\"\n");
fflush(stdout);
ret = 0;
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_send_block() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
int comm_receive_block(void * buffer, int size) int comm_receive_block(void * buffer, int size)
{ {
return (0); WonXSerialPort wonx_serial_port;
WWSerialPort ww_serial_port;
UNIXSerialPort unix_serial_port;
int ret;
int c;
int i;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_receive_block() : buffer = %p, size = %d\n",
buffer, size);
fflush(stdout);
wonx_serial_port = WonX_GetWonXSerialPort();
ww_serial_port = WonXSerialPort_GetWWSerialPort(wonx_serial_port);
unix_serial_port = WonXSerialPort_GetUNIXSerialPort(wonx_serial_port);
if (!WWSerialPort_IsOpened(ww_serial_port))
WonX_Error("comm_receive_block", "WW serial port is not opened.");
if (!UNIXSerialPort_IsOpened(unix_serial_port))
WonX_Error("comm_receive_block", "UNIX serial port is not opened.");
ret = 0;
for (i = 0; i < size; i++) {
c = comm_input(WWSerialPort_GetReceiveTimeout(ww_serial_port));
if (c == -1) {
ret = ERR_SIO_TIMEOUT;
break;
}
((char *)buffer)[i] = c;
} }
void comm_set_timeout(int receive_timeout, int send_timeout) WonXDisplay_Sync(WonX_GetWonXDisplay());
{
printf("call : comm_receive_block() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
void comm_set_baudrate(int speed) void comm_set_timeout(int recv_timeout, int send_timeout)
{ {
WWSerialPort ww_serial_port;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_set_timeout() : receive_timeout = %d, send_timeout = %d\n", recv_timeout, send_timeout);
fflush(stdout);
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
WWSerialPort_SetReceiveTimeout(ww_serial_port, recv_timeout);
WWSerialPort_SetSendTimeout( ww_serial_port, send_timeout);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_set_timeout() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
}
void comm_set_baudrate(int baudrate)
{
WWSerialPort ww_serial_port;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_set_baudrate() : baudrate = %d\n", baudrate);
fflush(stdout);
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
switch (baudrate) {
case COMM_SPEED_9600: WWSerialPort_SetBaudrate9600( ww_serial_port); break;
case COMM_SPEED_38400: WWSerialPort_SetBaudrate38400(ww_serial_port); break;
default: WonX_Error("comm_set_baudrate", "Invalid baudrate");
}
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_set_baudrate() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
} }
int comm_get_baudrate(void) int comm_get_baudrate(void)
{ {
return (0); WWSerialPort ww_serial_port;
int ret = 0;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_get_baudrate() : \n");
fflush(stdout);
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
if (WWSerialPort_IsBaudrate9600(ww_serial_port))
ret = COMM_SPEED_9600;
else if (WWSerialPort_IsBaudrate38400(ww_serial_port))
ret = COMM_SPEED_38400;
else WonX_Error("comm_get_baudrate", "Invalid baudrate");
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_get_baudrate() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
void comm_set_cancel_key(unsigned int pattern) void comm_set_cancel_key(unsigned int pattern)
{ {
WWSerialPort ww_serial_port;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_set_cancel_key() : pattern = %u\n", (int)pattern);
fflush(stdout);
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
WWSerialPort_SetCancelKey(ww_serial_port, pattern);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_set_cancel_key() : return value = none\n");
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return;
} }
unsigned int comm_get_cancel_key(void) unsigned int comm_get_cancel_key(void)
{ {
return (0); WWSerialPort ww_serial_port;
unsigned int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_get_cancel_key() : \n");
fflush(stdout);
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
/* ここに処理を書く */
ret = WWSerialPort_GetCancelKey(ww_serial_port);
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_get_cancel_key() : return value = %u\n", (int)ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
#if 0
int comm_xmodem(void * xmodem) int comm_xmodem(void * xmodem)
{ {
return (0); WWSerialPort ww_serial_port;
int ret;
if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : comm_xmodem() : xmodem = %p\n", xmodem);
fflush(stdout);
ww_serial_port = WonXSerialPort_GetWWSerialPort(WonX_GetWonXSerialPort());
/* 未サポート */
printf("call : comm_xmodem() : not supported.\n");
fflush(stdout);
ret = 0;
WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("call : comm_xmodem() : return value = %d\n", ret);
fflush(stdout);
/* タイマをもとに戻す */
UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret);
} }
#endif
/*****************************************************************************/ /*****************************************************************************/
/* ここまで */ /* ここまで */

View File

@ -1,15 +0,0 @@
/* configure.h for configuration of xfireworks */
#ifndef _WONX_CONFIGURE_H_INCLUDED_
#define _WONX_CONFIGURE_H_INCLUDED_
/* Wonx でのタイマ割り込みの周期(単位はマイクロ秒) */
#define WONX_TIMER_INTERVAL 100000 /* 0.1 秒*/
/* HBLANK, VBLANK 割り込みのデフォルトのインターバル(0.1秒単位) */
#define WONX_HBLANK_INTERVAL ( 3 * 10) /* 3 秒毎 */
#define WONX_VBLANK_INTERVAL (20 * 10) /* 20 秒毎 */
#endif /* _WONX_CONFIGURE_H_INCLUDED_ */
/* End of configure.h */

569
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 "etc.h"
#include <stdio.h> #include <ctype.h>
#include <stdlib.h>
/*===========================================================================*/
/* ¥¨¥é¡¼½èÍý */
/*===========================================================================*/
int Error(char * funcname, char * message)
{
fprintf(stderr, "%s(): %s\n", funcname, message);
exit (1);
}
/*===========================================================================*/ /*===========================================================================*/
/* "true", "false" の矢机误を手す */ /* "true", "false" の矢机误を手す */
/*===========================================================================*/ /*===========================================================================*/
char * true_false(int b) char * wonx_true_false(int b)
{ {
char * s[] = {"false", "true"}; char * s[] = {"false", "true"};
b = b ? 1 : 0; b = b ? 1 : 0;
return (s[b]); 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_ #ifndef _etc_h_INCLUDED_
#define _etc_h_INCLUDED_ #define _etc_h_INCLUDED_
/*===========================================================================*/ #include <stdio.h>
/* エラー処理 */ #include <stdlib.h>
/*===========================================================================*/
int Error(char * funcname, char * message);
/*===========================================================================*/ /*===========================================================================*/
/* "true", "false" の矢机误を手す */ /* "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 #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);

114
key.c
View File

@ -5,9 +5,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "sys/key.h" #include "wonx/key.h"
#include "Wonx.h" #include "WonX.h"
/*****************************************************************************/ /*****************************************************************************/
/* 互換関数の定義 */ /* 互換関数の定義 */
@ -34,24 +34,25 @@ int key_press_check(void)
XDisplay x_display; XDisplay x_display;
int ret; int ret;
if (!Wonx_IsCreated()) Wonx_Create(); if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */ /* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : key_press_check() : "); fflush(stdout); printf("call : key_press_check() : \n"); fflush(stdout);
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay()); x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Sync(x_display); XDisplay_Flush(x_display);
ret = XDisplay_GetKeyPress(x_display); ret = XDisplay_GetKeyPress(x_display);
WonxDisplay_Sync(Wonx_GetWonxDisplay()); WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("return value = 0x%04x\n", (int)ret); fflush(stdout); 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); return (ret);
} }
@ -61,24 +62,25 @@ int key_hit_check(void)
XDisplay x_display; XDisplay x_display;
int ret; int ret;
if (!Wonx_IsCreated()) Wonx_Create(); if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */ /* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : key_hit_check() : "); fflush(stdout); printf("call : key_hit_check() : \n"); fflush(stdout);
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay()); x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Sync(x_display); XDisplay_Flush(x_display);
ret = XDisplay_GetKeyPress(x_display); ret = XDisplay_GetKeyPress(x_display);
WonxDisplay_Sync(Wonx_GetWonxDisplay()); WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("return value = 0x%04x\n", (int)ret); fflush(stdout); 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); return (ret);
} }
@ -86,53 +88,66 @@ int key_hit_check(void)
int key_wait(void) int key_wait(void)
{ {
XDisplay x_display; XDisplay x_display;
int ret; volatile int ret;
if (!Wonx_IsCreated()) Wonx_Create(); if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */ /* タイマを一時停止する */
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; ret = 0;
do { do {
XDisplay_Sync(x_display); #if 0 /* タイマを Unpause しない場合には必要 */
XDisplay_Flush(x_display);
#endif
ret = XDisplay_GetKeyPress(x_display); ret = XDisplay_GetKeyPress(x_display);
} while (ret == 0); } while (ret == 0);
UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
WonxDisplay_Sync(Wonx_GetWonxDisplay()); WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("return value = 0x%04x\n", (int)ret); fflush(stdout); 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); return (ret);
} }
void key_set_repeat(int rate, int delay) 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); fflush(stdout);
WonxDisplay_Sync(Wonx_GetWonxDisplay()); WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("return value = none\n"); fflush(stdout); printf("call : key_set_repeat() : return value = none\n"); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
@ -141,21 +156,22 @@ int key_get_repeat(void)
{ {
int ret; int ret;
if (!Wonx_IsCreated()) Wonx_Create(); if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */ /* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : key_get_repeat() : "); fflush(stdout); printf("call : key_get_repeat() : \n"); fflush(stdout);
ret = 0; ret = 0;
WonxDisplay_Sync(Wonx_GetWonxDisplay()); WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("return value = 0x%04x\n", (int)ret); fflush(stdout); 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); return (ret);
} }
@ -165,24 +181,26 @@ int key_hit_check_with_repeat(void)
XDisplay x_display; XDisplay x_display;
int ret; int ret;
if (!Wonx_IsCreated()) Wonx_Create(); if (!WonX_IsCreated()) WonX_Create();
/* タイマを一時停止する */ /* タイマを一時停止する */
UNIXTimer_Pause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Pause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
printf("call : key_hit_check_with_repeat() : "); fflush(stdout); printf("call : key_hit_check_with_repeat() : \n"); fflush(stdout);
x_display = WonxDisplay_GetXDisplay(Wonx_GetWonxDisplay()); x_display = WonXDisplay_GetXDisplay(WonX_GetWonXDisplay());
XDisplay_Sync(x_display); XDisplay_Flush(x_display);
ret = XDisplay_GetKeyPress(x_display); ret = XDisplay_GetKeyPress(x_display);
WonxDisplay_Sync(Wonx_GetWonxDisplay()); WonXDisplay_Sync(WonX_GetWonXDisplay());
printf("return value = 0x%04x\n", (int)ret); fflush(stdout); 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); 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. */
/*****************************************************************************/

38
makefile_for_smac Normal file
View File

@ -0,0 +1,38 @@
SOURCES = chara.c game.c man.c mansub.c mansub2.c map.c mapsub.c menu.c monster.c picture.c player.c smac.c stage.c dsp.c etc.c
# コマンドラインの長さには制限があるので,長さに注意すること
OBJS = chara.o game.o man.o mansub.o mansub2.o map.o mapsub.o menu.o monster.o picture.o player.o smac.o stage.o dsp.o etc.o main.o
.SUFFIXES: .c .o
all : smac
smac : $(OBJS)
gcc -g -o smac $(OBJS) -lwonx -lX11 -lXt -L. -L/usr/X11R6/lib
# xsmac
#smac : smac.fx
#smac.fx : smac.bin
# doscmd mkfent16 smac.cf
#smac.bin : $(OBJS)
# echo $(OBJS) > objs
# doscmd lcc86 -o smac.bin -O @objs
.c.o : $*.c
gcc -c $*.c -g -I.
clean :
rm -f smac.fx smac.bin smac $(OBJS)
package : smac.fx
rm -fR smac-b02
mkdir -p smac-b02
cp -R copying copyrigh readme history makefile doscmdrc *.c *.h \
smac.bin smac.cf smac.fx pic8 \
smac-b02
zip -r smac-b02 smac-b02
xsmac :

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)

23
sample1.c Normal file
View File

@ -0,0 +1,23 @@
#include "wonx/text.h"
#include "wonx/key.h"
main()
{
text_screen_init();
text_put_string(0, 1, " WonX - WonderWitch on X. ");
text_put_string(0, 3, " This is test program ");
text_put_string(0, 4, " for WonX. ");
text_put_string(0, 6, " WonX is an emulator for ");
text_put_string(0, 7, " WonderWitch on X. It is ");
text_put_string(0, 8, " linked to program for ");
text_put_string(0, 9, " WonderWitch and behave as ");
text_put_string(0, 10, " WonderWitch. ");
text_put_string(0, 12, "WonX Copyright (c) 2000-2002");
text_put_string(0, 13, " Sakai Hiroaki. ");
text_put_string(0, 14, " All Rights Reserved. ");
text_put_string(0, 16, " Hit space key to exit. ");
key_wait();
bios_exit();
}

47
sample2.c Normal file
View File

@ -0,0 +1,47 @@
#include "wonx/disp.h"
#include "wonx/key.h"
static unsigned char clear[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char block[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
main()
{
int x, y, f, k;
display_control(DCM_SCR2 | DCM_SPR);
lcd_set_color(0, 0xffff);
palette_set_color(0, 0);
palette_set_color(8, (0xf << 12));
font_set_color(0x03);
font_set_monodata(0, 1, clear);
font_set_monodata(1, 1, block);
sprite_set_char(0,
CFM_SPR_UPPER |
((0 << 9) & CFM_SPR_PALETTE) |
(1 & CFM_FONT)
);
sprite_set_range(0, 1);
x = 14;
y = 9;
f = 0;
while (!f) {
sprite_set_location(0, x * 8, y * 8);
k = key_hit_check();
if (k & KEY_START) f = 1;
if (k & KEY_A) f = 1;
if ((k & KEY_LEFT1) && (x > 0)) x--;
if ((k & KEY_RIGHT1) && (x < LCD_PIXEL_WIDTH/8 - 1)) x++;
if ((k & KEY_UP1) && (y > 0)) y--;
if ((k & KEY_DOWN1) && (y < LCD_PIXEL_HEIGHT/8 - 1)) y++;
}
bios_exit();
}

35
sample3.c 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. */
/*****************************************************************************/

BIN
smac-b02.zip Normal file

Binary file not shown.

View File

@ -5,9 +5,9 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "sys/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

@ -2,11 +2,12 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "sys/system.h" #include "wonx/system.h"
#include "Wonx.h" #include "WonX.h"
/*****************************************************************************/ /*****************************************************************************/
/* 互換関数の定義 */ /* 互換関数の定義 */
@ -28,66 +29,66 @@
* *
*/ */
void sys_interrupt_set_hook(int type, intvector_t * intvector, void sys_interrupt_set_hook(int type, intvector_t * vector,
intvector_t * last_intvector) intvector_t * old_vector)
{ {
WWInterrupt ww_interrupt; 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, intvector = %p, last_intvector = %p\n", type, intvector, last_intvector); printf("call : sys_interrupt_set_hook() : type = %d, vector = %p, old_vector = %p\n", type, vector, old_vector);
fflush(stdout); fflush(stdout);
ww_interrupt = WonxSystem_GetWWInterrupt(Wonx_GetWonxSystem()); ww_interrupt = WonXSystem_GetWWInterrupt(WonX_GetWonXSystem());
last_intvector->callback = WWInterrupt_GetCallback(ww_interrupt, type); old_vector->callback = WWInterrupt_GetCallback(ww_interrupt, type);
last_intvector->cs = WWInterrupt_GetCS(ww_interrupt, type); old_vector->cs = WWInterrupt_GetCS(ww_interrupt, type);
last_intvector->ds = WWInterrupt_GetDS(ww_interrupt, type); old_vector->ds = WWInterrupt_GetDS(ww_interrupt, type);
WWInterrupt_SetCallback(ww_interrupt, type, intvector->callback); WWInterrupt_SetCallback(ww_interrupt, type, vector->callback);
WWInterrupt_SetCS(ww_interrupt, type, intvector->cs); WWInterrupt_SetCS(ww_interrupt, type, vector->cs);
WWInterrupt_SetDS(ww_interrupt, type, intvector->ds); WWInterrupt_SetDS(ww_interrupt, type, vector->ds);
printf("call : sys_interrupt_set_hook() : return value = none\n"); printf("call : sys_interrupt_set_hook() : return value = none\n");
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
void sys_interrupt_reset_hook(int type, intvector_t * last_intvector) void sys_interrupt_reset_hook(int type, intvector_t * old_vector)
{ {
WWInterrupt ww_interrupt; 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, last_intvector = %p\n", type, last_intvector); printf("call : sys_interrupt_reset_hook() : type = %d, old_vector = %p\n", type, old_vector);
fflush(stdout); fflush(stdout);
ww_interrupt = WonxSystem_GetWWInterrupt(Wonx_GetWonxSystem()); ww_interrupt = WonXSystem_GetWWInterrupt(WonX_GetWonXSystem());
WWInterrupt_SetCallback(ww_interrupt, type, last_intvector->callback); WWInterrupt_SetCallback(ww_interrupt, type, old_vector->callback);
WWInterrupt_SetCS(ww_interrupt, type, last_intvector->cs); WWInterrupt_SetCS(ww_interrupt, type, old_vector->cs);
WWInterrupt_SetDS(ww_interrupt, type, last_intvector->ds); WWInterrupt_SetDS(ww_interrupt, type, old_vector->ds);
printf("call : sys_interrupt_reset_hook() : return value = none\n"); printf("call : sys_interrupt_reset_hook() : return value = none\n");
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
void sys_wait(unsigned int time) void sys_wait(unsigned int wait_time)
{ {
} }
@ -109,7 +110,7 @@ int sys_get_sleep_time(void)
return (0); return (0);
} }
void sys_set_awake_key(int awake_key_pattern) void sys_set_awake_key(int pattern)
{ {
} }
@ -118,7 +119,7 @@ int sys_get_awake_key(void)
return (0); return (0);
} }
void sys_set_keepalive_int(int keepalive_pattern) void sys_set_keepalive_int(int pattern)
{ {
} }
@ -135,7 +136,7 @@ void sys_resume(int core)
{ {
} }
void sys_set_remote(int remote_enable) void sys_set_remote(int remote)
{ {
} }
@ -144,7 +145,7 @@ unsigned int sys_get_remote(void)
return (0); return (0);
} }
void * sys_alloc_iram(void *pointer, unsigned size) void * sys_alloc_iram(void * p, unsigned int size)
{ {
return (NULL); return (NULL);
} }

412
text.c
View File

@ -2,13 +2,17 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "sys/text.h" #include "wonx/text.h"
#include "Wonx.h" #include "WonX.h"
#include "WWText.h" #include "WWText.h"
#include "WWDisplay.h"
#include "WWCursor.h"
#include "etc.h"
/*****************************************************************************/ /*****************************************************************************/
/* 互換関数の定義 */ /* 互換関数の定義 */
@ -30,15 +34,15 @@
* *
*/ */
static void _text_window_init(int x, int y, int w, int h, unsigned font_base) static void _text_window_init(int x, int y, int w, int h, unsigned int base)
{ {
WWText ww_text;
WWDisplay ww_display; 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, font_base, ww_display); WWText_SetTextWindow(ww_text, x, y, w, h, base, ww_display);
WWScreen_SetRollX(WWText_GetScreen(ww_text), 0); WWScreen_SetRollX(WWText_GetScreen(ww_text), 0);
WWScreen_SetRollY(WWText_GetScreen(ww_text), 0); WWScreen_SetRollY(WWText_GetScreen(ww_text), 0);
@ -51,51 +55,51 @@ void text_screen_init(void)
WWDisplay ww_display; WWDisplay ww_display;
WWLCDPanel ww_lcd_panel; 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"); printf("call : text_screen_init() : \n");
fflush(stdout); fflush(stdout);
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display); ww_lcd_panel = WWDisplay_GetLCDPanel(ww_display);
_text_window_init(0, 0, TEXT_SCREEN_WIDTH, TEXT_SCREEN_HEIGHT, 8); _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); printf("call : text_screen_init() : return value = none\n"); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
void text_window_init(int x, int y, int w, int h, unsigned int font_base) void text_window_init(int x, int y, int w, int h, unsigned int base)
{ {
WWDisplay ww_display; 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)font_base); printf("call : text_window_init() : x = %d, y = %d, width = %d, height = %d, base = %u\n", x, y, w, h, (int)base);
fflush(stdout); fflush(stdout);
ww_display = WonxDisplay_GetWWDisplay(Wonx_GetWonxDisplay()); ww_display = WonXDisplay_GetWWDisplay(WonX_GetWonXDisplay());
_text_window_init(x, y, w, h, font_base); _text_window_init(x, y, w, h, base);
WonxDisplay_Flush(Wonx_GetWonxDisplay()); WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : text_screen_init() : return value = none\n"); fflush(stdout); printf("call : text_window_init() : return value = none\n"); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
@ -109,13 +113,13 @@ int text_get_mode(void)
return (0); return (0);
} }
void _text_put_char(int x, int y, unsigned int c) static void _text_put_char(int x, int y, unsigned int c)
{ {
WWText ww_text;
WWDisplay ww_display; 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); WWText_PutCharacter(ww_text, x, y, c, ww_display);
@ -124,121 +128,128 @@ void _text_put_char(int x, int y, unsigned int c)
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); fflush(stdout);
_text_put_char(x, y, c); _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); printf("call : text_put_char() : return value = none\n"); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
static int _text_put_string(int x, int y, char * s) static int _text_put_string(int x, int y, char * string)
{ {
int i, len, ret; int i, len, ret;
WWText ww_text;
WWDisplay ww_display; 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(s); len = strlen(string);
ret = 0; ret = 0;
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0) if (WWText_PutCharacter(ww_text, x + i, y, string[i], ww_display) >= 0)
ret++; ret++;
} }
return (ret); return (ret);
} }
int text_put_string(int x, int y, char * s) int text_put_string(int x, int y, char * string)
{ {
int ret; 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, s); 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); fflush(stdout);
ret = _text_put_string(x, y, s); 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); printf("call : text_put_string() : return value = %d\n", ret);
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret); return (ret);
} }
int text_put_substring(int x, int y, char * s, int len) int text_put_substring(int x, int y, char * s, int length)
{ {
int i, ret; int i, ret;
WWText ww_text;
WWDisplay ww_display; 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, len); 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); 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; ret = 0;
for (i = 0; i < len; i++) { for (i = 0; i < length; i++) {
if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0) if (WWText_PutCharacter(ww_text, x + i, y, s[i], ww_display) >= 0)
ret++; ret++;
} }
WonxDisplay_Flush(Wonx_GetWonxDisplay()); WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : text_put_substring() : return value = %d\n", ret); printf("call : text_put_substring() : return value = %d\n", ret);
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret); return (ret);
} }
void text_put_numeric(int x, int y, int len, int format, int number) void text_put_numeric(int x, int y, int length, int format, int number)
{ {
char buf[20]; char buf[20];
char f[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, len = %d, format = %04x, number = %d\n", x, y, len, format, number); printf("call : text_put_numeric() : x = %d, y = %d, length = %d, format = %04x, number = %d\n", x, y, length, format, number);
fflush(stdout); fflush(stdout);
strcpy(f, "%"); strcpy(f, "%");
if (format & NUM_PADZERO) strcat(f, "0"); if (format & NUM_PADZERO) strcat(f, "0");
sprintf(f + strlen(f), "%d", len); sprintf(f + strlen(f), "%d", length);
if (format & NUM_HEXA) strcat(f, "x"); if (format & NUM_HEXA) strcat(f, "x");
else if (format & NUM_SIGNED) strcat(f, "d"); else if (format & NUM_SIGNED) strcat(f, "d");
else strcat(f, "u"); else strcat(f, "u");
@ -247,200 +258,393 @@ void text_put_numeric(int x, int y, int len, int format, int number)
sprintf(buf, f, number); sprintf(buf, f, number);
_text_put_string(x, y, buf); _text_put_string(x, y, buf);
WonxDisplay_Flush(Wonx_GetWonxDisplay()); WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : text_put_numeric() : return value = none\n"); printf("call : text_put_numeric() : return value = none\n");
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
void text_store_numeric(char * buffer, int len, int format, int number) void text_store_numeric(char * buffer, int length, int format, int number)
{ {
} }
void text_fill_char(int x, int y, int len, int code) void text_fill_char(int x, int y, int length, int c)
{ {
int i; 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, code = %d\n", x, y, len, code); printf("call : text_fill_char() : x = %d, y = %d, length = %d, character = %d\n", x, y, length, c);
fflush(stdout); fflush(stdout);
for (i = 0; i < len; i++) { for (i = 0; i < length; i++) {
_text_put_char(x + i, y, code); _text_put_char(x + i, y, c);
} }
WonxDisplay_Flush(Wonx_GetWonxDisplay()); WonXDisplay_Flush(WonX_GetWonXDisplay());
printf("call : text_fill_char() : return value = none\n"); printf("call : text_fill_char() : return value = none\n");
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
void text_set_palette(int palette_num) void text_set_palette(int palette_num)
{ {
WWText ww_text;
WWDisplay ww_display; 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); printf("call : text_set_palette() : palette = %d\n", palette_num);
fflush(stdout); 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)); 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"); printf("call : text_set_palette() : return value = none\n");
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
int text_get_palette(void) int text_get_palette(void)
{ {
WWDisplay ww_display;
WWText ww_text; WWText ww_text;
int num; 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"); printf("call : text_get_palette() : \n");
fflush(stdout); 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)); 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); printf("call : text_get_palette() : return value = %d\n", num);
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (num); return (num);
} }
void text_set_ank_font(int font_base_num, int is_color, int font_count, void text_set_ank_font(int base, int color, int count, void * font)
void * font)
{ {
} }
void text_set_sjis_font(void * font_address) void text_set_sjis_font(void * p)
{ {
} }
void text_get_fontdata(int char_code, void * fontdata_buffer) void text_get_fontdata(int c, void * buffer)
{ {
} }
void text_set_screen(int screen) void text_set_screen(int screen)
{ {
WWText ww_text;
WWDisplay ww_display; 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); printf("call : text_set_screen() : screen = %d\n", screen);
fflush(stdout); 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)); 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"); printf("call : text_set_screen() : return value = none\n");
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
int text_get_screen(void) int text_get_screen(void)
{ {
WWDisplay ww_display;
WWText ww_text; WWText ww_text;
int n; 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"); printf("call : text_get_screen() : \n");
fflush(stdout); 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)); 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); printf("call : text_set_screen() : return value = %d\n", n);
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (n); return (n);
} }
void cursor_display(int cursor_enable) 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) 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) 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 cursor_get_location(void) 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 blink_interval) 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 cursor_get_type(void) 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, ...) int text_printf(int x, int y, const char *format, ...)

104
timer.c
View File

@ -2,24 +2,15 @@
/* ここから */ /* ここから */
/*****************************************************************************/ /*****************************************************************************/
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include "sys/timer.h" #include "wonx/timer.h"
#include "Wonx.h" #include "wonx_configure.h"
#include "WonX.h"
#include "etc.h" #include "etc.h"
#include "configure.h"
typedef struct {
unsigned char year;
unsigned char month;
unsigned char date;
unsigned char day_of_week;
unsigned char hour;
unsigned char minute;
unsigned char second;
} datetime_t;
/* int tm_year; year - 1900 */ /* int tm_year; year - 1900 */
static int get_year(struct tm * tblock) { return (tblock->tm_year - 100); } static int get_year(struct tm * tblock) { return (tblock->tm_year - 100); }
@ -56,10 +47,10 @@ static int get_second(struct tm * tblock) { return (tblock->tm_sec); }
* *
*/ */
void rtc_set_datetime(int field, unsigned int value) void rtc_set_datetime(int type, unsigned int value)
{ {
printf("call : rtc_set_datetime() : field = %d, value = %d\n", printf("call : rtc_set_datetime() : type = %d, value = %d\n",
field, (int)value); type, (int)value);
fflush(stdout); fflush(stdout);
/* 未サポート */ /* 未サポート */
@ -71,19 +62,19 @@ void rtc_set_datetime(int field, unsigned int value)
return; return;
} }
unsigned int rtc_get_datetime(int field) unsigned int rtc_get_datetime(int type)
{ {
unsigned int ret = 0; unsigned int ret = 0;
time_t timer; time_t timer;
struct tm * tblock; struct tm * tblock;
printf("call : rtc_get_datetime() : field = %d\n", field); printf("call : rtc_get_datetime() : type = %d\n", type);
fflush(stdout); fflush(stdout);
time(&timer); time(&timer);
tblock = localtime(&timer); tblock = localtime(&timer);
switch (field) { switch (type) {
case RTC_YEAR : ret = get_year( tblock); break; case RTC_YEAR : ret = get_year( tblock); break;
case RTC_MONTH : ret = get_month( tblock); break; case RTC_MONTH : ret = get_month( tblock); break;
case RTC_DATE : ret = get_day( tblock); break; case RTC_DATE : ret = get_day( tblock); break;
@ -91,7 +82,7 @@ unsigned int rtc_get_datetime(int field)
case RTC_HOUR : ret = get_hour( tblock); break; case RTC_HOUR : ret = get_hour( tblock); break;
case RTC_MIN : ret = get_minute(tblock); break; case RTC_MIN : ret = get_minute(tblock); break;
case RTC_SEC : ret = get_second(tblock); break; case RTC_SEC : ret = get_second(tblock); break;
default : 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); printf("call : rtc_get_datetime() : return value = %d\n", (int)ret);
@ -100,9 +91,9 @@ unsigned int rtc_get_datetime(int field)
return (ret); return (ret);
} }
void rtc_set_datetime_struct(void * buffer) void rtc_set_datetime_struct(datetime_t * d)
{ {
printf("call : rtc_set_datetime_struct() : buffer = %p\n", buffer); printf("call : rtc_set_datetime_struct() : buffer = %p\n", (void *)d);
fflush(stdout); fflush(stdout);
/* 未サポート */ /* 未サポート */
@ -114,27 +105,24 @@ void rtc_set_datetime_struct(void * buffer)
return; return;
} }
void rtc_get_datetime_struct(void * buffer) void rtc_get_datetime_struct(datetime_t * d)
{ {
time_t timer; time_t timer;
struct tm * tblock; struct tm * tblock;
datetime_t * p;
printf("call : rtc_get_datetime_struct() : buffer = %p\n", buffer); printf("call : rtc_get_datetime_struct() : buffer = %p\n", (void *)d);
fflush(stdout); fflush(stdout);
time(&timer); time(&timer);
tblock = localtime(&timer); tblock = localtime(&timer);
p = (datetime_t *)buffer; d->year = get_year(tblock);
d->month = get_month(tblock);
p->year = get_year(tblock); d->date = get_day(tblock);
p->month = get_month(tblock); d->day_of_week = get_week(tblock);
p->date = get_day(tblock); d->hour = get_hour(tblock);
p->day_of_week = get_week(tblock); d->minute = get_minute(tblock);
p->hour = get_hour(tblock); d->second = get_second(tblock);
p->minute = get_minute(tblock);
p->second = get_second(tblock);
printf("call : rtc_get_datetime_struct() : return value = none\n"); printf("call : rtc_get_datetime_struct() : return value = none\n");
fflush(stdout); fflush(stdout);
@ -170,17 +158,17 @@ void rtc_disable_alarm(void)
return; return;
} }
void timer_enable(int type, unsigned int auto_preset, unsigned int preset) void timer_enable(int type, unsigned int auto_preset, unsigned int count)
{ {
WWTimer ww_timer; 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, preset = %u\n", printf("call : timer_enable() : type = %d, auto_preset = %u, count = %u\n",
type, (int)auto_preset, (int)preset); type, (int)auto_preset, (int)count);
fflush(stdout); fflush(stdout);
/* /*
@ -192,12 +180,12 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int preset)
switch (type) { switch (type) {
case TIMER_VBLANK: case TIMER_VBLANK:
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(Wonx_GetWonxSystem()); ww_timer = WonXSystem_GetWWVBlankCountUpTimer(WonX_GetWonXSystem());
WWTimer_SetPresetCounter(ww_timer, preset * WONX_VBLANK_INTERVAL); WWTimer_SetPresetCounter(ww_timer, count * WONX_VBLANK_INTERVAL);
break; break;
case TIMER_HBLANK: case TIMER_HBLANK:
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(Wonx_GetWonxSystem()); ww_timer = WonXSystem_GetWWHBlankCountUpTimer(WonX_GetWonXSystem());
WWTimer_SetPresetCounter(ww_timer, preset * WONX_HBLANK_INTERVAL); WWTimer_SetPresetCounter(ww_timer, count * WONX_HBLANK_INTERVAL);
break; break;
default: default:
/* /*
@ -205,13 +193,13 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int preset)
* NULL * NULL
*/ */
ww_timer = NULL; ww_timer = NULL;
Error("timer_enable", "Invalid timer type."); WonX_Error("timer_enable", "Invalid timer type.");
} }
switch (auto_preset) { switch (auto_preset) {
case TIMER_ONESHOT: WWTimer_SetAutoPresetOFF(ww_timer); break; case TIMER_ONESHOT: WWTimer_SetAutoPresetOFF(ww_timer); break;
case TIMER_AUTOPRESET: WWTimer_SetAutoPresetON( ww_timer); break; case TIMER_AUTOPRESET: WWTimer_SetAutoPresetON( ww_timer); break;
default: Error("timer_enable", "Invalid auto preset type."); default: WonX_Error("timer_enable", "Invalid auto preset type.");
} }
WWTimer_Reset(ww_timer); WWTimer_Reset(ww_timer);
@ -221,7 +209,7 @@ void timer_enable(int type, unsigned int auto_preset, unsigned int preset)
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
@ -230,20 +218,20 @@ void timer_disable(int type)
{ {
WWTimer ww_timer; 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); printf("call : timer_disable() : type = %d\n", type);
fflush(stdout); fflush(stdout);
switch (type) { switch (type) {
case TIMER_VBLANK: case TIMER_VBLANK:
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(Wonx_GetWonxSystem()); ww_timer = WonXSystem_GetWWVBlankCountUpTimer(WonX_GetWonXSystem());
break; break;
case TIMER_HBLANK: case TIMER_HBLANK:
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(Wonx_GetWonxSystem()); ww_timer = WonXSystem_GetWWHBlankCountUpTimer(WonX_GetWonXSystem());
break; break;
default: default:
/* /*
@ -251,7 +239,7 @@ void timer_disable(int type)
* NULL * NULL
*/ */
ww_timer = NULL; ww_timer = NULL;
Error("timer_disable", "Invalid timer type."); WonX_Error("timer_disable", "Invalid timer type.");
} }
WWTimer_OFF(ww_timer); WWTimer_OFF(ww_timer);
@ -260,7 +248,7 @@ void timer_disable(int type)
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return; return;
} }
@ -270,20 +258,20 @@ unsigned int timer_get_count(int type)
WWTimer ww_timer; WWTimer ww_timer;
unsigned int ret = 0; 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); printf("call : timer_get_count() : type = %d\n", type);
fflush(stdout); fflush(stdout);
switch (type) { switch (type) {
case TIMER_VBLANK: case TIMER_VBLANK:
ww_timer = WonxSystem_GetWWVBlankCountUpTimer(Wonx_GetWonxSystem()); ww_timer = WonXSystem_GetWWVBlankCountUpTimer(WonX_GetWonXSystem());
break; break;
case TIMER_HBLANK: case TIMER_HBLANK:
ww_timer = WonxSystem_GetWWHBlankCountUpTimer(Wonx_GetWonxSystem()); ww_timer = WonXSystem_GetWWHBlankCountUpTimer(WonX_GetWonXSystem());
break; break;
default: default:
/* /*
@ -291,7 +279,7 @@ unsigned int timer_get_count(int type)
* NULL * NULL
*/ */
ww_timer = NULL; ww_timer = NULL;
Error("timer_get_count", "Invalid timer type."); WonX_Error("timer_get_count", "Invalid timer type.");
} }
ret = WWTimer_GetCounter(ww_timer); ret = WWTimer_GetCounter(ww_timer);
@ -300,7 +288,7 @@ unsigned int timer_get_count(int type)
fflush(stdout); fflush(stdout);
/* タイマをもとに戻す */ /* タイマをもとに戻す */
UNIXTimer_Unpause(WonxSystem_GetUNIXTimer(Wonx_GetWonxSystem())); UNIXTimer_Unpause(WonXSystem_GetUNIXTimer(WonX_GetWonXSystem()));
return (ret); 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. */
/*****************************************************************************/

39
wonx/bank.h Normal file
View File

@ -0,0 +1,39 @@
#ifndef _WONX_SYS_BANK_H_
#define _WONX_SYS_BANK_H_
#include "service.h"
/*****************************************************************************/
/* 年眶の年盗 */
/*****************************************************************************/
#define BANK_SRAM 0
#define BANK_ROM0 1
#define BANK_ROM1 2
#define sram_get_map() bank_get_map(BANK_SRAM)
#define rom0_get_map() bank_get_map(BANK_ROM0)
#define rom1_get_map() bank_get_map(BANK_ROM1)
#define sram_set_map(bank) bank_set_map(BANK_SRAM, bank)
#define rom0_set_map(bank) bank_set_map(BANK_ROM0, bank)
#define rom1_set_map(bank) bank_set_map(BANK_ROM1, bank)
/*****************************************************************************/
/* 高垂簇眶の离咐 */
/*****************************************************************************/
void bank_set_map(int bank, int bank_num);
int bank_get_map(int bank);
unsigned char bank_read_byte(int bank, unsigned int off);
void bank_write_byte(int bank, unsigned int off, unsigned int data);
unsigned int bank_read_word(int bank, unsigned int off);
void bank_write_word(int bank, unsigned int off, unsigned int data);
void bank_read_block(int bank, unsigned int off,
void * buffer, unsigned int size);
void bank_write_block(int bank, unsigned int off,
void * buffer, unsigned int size);
void bank_fill_block(int bank, unsigned int off,
unsigned int size, unsigned int data);
void bank_erase_flash(int bank);
#endif

13
wonx/bios.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef _WONX_SYS_BIOS_H_
#define _WONX_SYS_BIOS_H_
#include "bank.h"
#include "comm.h"
#include "disp.h"
#include "key.h"
#include "sound.h"
#include "system.h"
#include "text.h"
#include "timer.h"
#endif

71
wonx/comm.h Normal file
View File

@ -0,0 +1,71 @@
#ifndef _WONX_SYS_COMM_H_
#define _WONX_SYS_COMM_H_
#include "service.h"
/*****************************************************************************/
/* 年眶の年盗 */
/*****************************************************************************/
#define COMM_SPEED_9600 0
#define COMM_SPEED_38400 1
#define XMODE_SEND 0
#define XMODE_RECEIVE 1
#define XMODE_SEND_ENCRYPTED 2
#define XMODE_RECEIVE_ENCRYPTED 3
#define XMODE_AUTO_ERASE 4
#define ERR_SIO_OK 0x0000
#define ERR_SIO_BUSY 0x8100
#define ERR_SIO_TIMEOUT 0x8101
#define ERR_SIO_OVERRUN 0x8102
#define ERR_SIO_CANCEL 0x8103
#define ERR_XM_STATECODE 0x8104
#define ERR_XM_CANCELED 0x8105
#define ERR_XM_BLOCK_LOST 0x8106
#define ERR_XM_TOO_LARGE 0x8107
enum {
XM_START = 1,
XM_NEGO,
XM_BLOCK,
XM_BLOCK_RETRY,
XM_CLOSE,
XM_ABORT,
XM_DONE,
XM_ERASE_BANK
};
typedef struct {
int state;
char mode;
char retry_c;
int block_c;
int block_max;
int block_size;
int bank;
int offset;
int timeout_c;
} xmodeminfo;
/*****************************************************************************/
/* 高垂簇眶の离咐 */
/*****************************************************************************/
void comm_open(void);
void comm_close(void);
int comm_send_char(unsigned char c);
int comm_receive_char(void);
int comm_receive_with_timeout(int timeout);
int comm_send_string(char * string);
int comm_send_block(void * buffer, int size);
int comm_receive_block(void * buffer, int size);
void comm_set_timeout(int recv_timeout, int send_timeout);
void comm_set_baudrate(int baudrate);
int comm_get_baudrate(void);
void comm_set_cancel_key(unsigned int pattern);
unsigned int comm_get_cancel_key(void);
int comm_xmodem(void * xmodem);
#endif

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