DSCREEN.H
[目次 | 型・クラス・構造体 | マクロ]
1|/***************************************************************************
2|* 1. <<< ダブルバッファ・ワーク画面 [DScreen] >>>
3|****************************************************************************/
4|
5|#ifndef __DSCREEN_H
6|#define __DSCREEN_H
7|
8|/*----------------------------------------------------------------------
9|[Module Property]
10|name = DScreen
11|title = マスク付き画面
12|category = グラフィック
13|src = dscreen.c
14|depend =
15|priority =
16|accord =
17|----------------------------------------------------------------------*/
18|
19|#ifndef USES_PRIORITY_HEADER
20|/*[START_OF_PRIORITY_HEADER]*/
21|
22|#define USES_DSCREEN
23|typedef struct _DScreen DScreen;
24|typedef struct _DScreen_Sc DScreen_Sc;
25|
26|/*[END_OF_PRIORITY_HEADER]*/
27|#endif /* USES_PRIORITY_HEADER */
28|
29|
30|/*** コンポーネント・プロパティ ***/
31|#define DScreen_ClearColor -1 /* デバッグ用透明色 -1 = 透明(リリース用)、0以上 = その色(デバッグ用) */
32|
33|/*** 集約コンポーネント ***/
34|#ifdef _STDLIB
35|#include <stdio.h>
36|#endif
37|
38|/*-------------------------------------------------------------------*/
39|/*--- Interface Area ------------------------------------------------*/
40|/*-------------------------------------------------------------------*/
41|
42|#ifdef __cplusplus
43|extern "C" {
44|#endif
45|
46|/**************************************************************************
47|* 2. <<< マスク付きワーク画面 [DScreen] >>>
48|*【補足】
49|*・マスクによって透明色を扱える画面です。
50|*・座標は (0,0)-(width-1+_pixelParByte, height) です。
51|***************************************************************************/
52|struct _DScreen {
53| char* adr;
54| int width; int height; /* 幅と高さ */
55| int offsetX; int offsetY; /* オフセット */
56| int clipX; int clipY; /* クリッピング領域の左上座標 */
57| int clipWidth; int clipHeight; /* クリッピング領域の幅と高さ */
58|};
59|
60|/* 操作 */
61|void DScreen_init( DScreen*, char* adr, int width, int height );
62|void DScreen_clear( DScreen*, int color );
63|void DScreen_trueClear( DScreen* );
64|void DScreen_setClip( DScreen*, int x, int y, int w, int h );
65|void DScreen_clearClip( DScreen* );
66|void DScreen_rectFillClear2( DScreen*, int x1, int y1,
67| int x2, int y2 );
68|void DScreen_pset( DScreen*, int x, int y, int color );
69|void DScreen_psetXor( DScreen*, int x, int y, int color );
70|#ifdef USES_MASK
71|void DScreen_psets( DScreen*, int x, int y, unsigned char* pattern,
72| int nPixel, int color );
73|#endif /* USES_MASK */
74|void DScreen_xorPaint( DScreen* );
75|#ifdef USES_DRAWSCR
76|void DScreen_flushTo( DScreen*, DrawScr target );
77|void DScreen_flushTo2( DScreen*, DrawScr target,
78| Mask_A* mask, int baseX, int baseY );
79|#endif /* USES_DRAWSCR */
80|#ifdef _STDLIB
81|void DScreen_print( DScreen*, FILE* file );
82|#endif
83|#ifdef USES_DRAWSCR
84|DrawScr DScreen_inf_DrawScr( DScreen* );
85|DScreen* DScreen_by_DrawScr( DrawScr inf );
86|#endif
87|
88|/* 属性 */
89|int DScreen_getAdr( DScreen* ); /* 描画の先頭アドレス=地図画面(1) */
90|int DScreen_pgetAdr( DScreen*, int x, int y ); /* ある点のアドレス */
91|int DScreen_psetSubAdr( DScreen*, int x, int y ); /* ある点のマスク画面のアドレス */
92|int DScreen_getWidth( DScreen* ); /* 横ピクセル数 */
93|int DScreen_getHeight( DScreen* ); /* 縦ピクセル数 */
94|int DScreen_getSingleSize( DScreen* ); /* 1画面分のバッファ・サイズ(byte) */
95|int DScreen_getPixelPerByte( DScreen* ); /* 1バイトあたりのピクセル数 */
96|int DScreen_getBitPerPixel( DScreen* ); /* 1ピクセルあたりのビット数 */
97|void DScreen_setOffset( DScreen*, int x, int y );
98|int DScreen_getOffsetX( DScreen* ); /* オフセット X */
99|int DScreen_getOffsetY( DScreen* ); /* オフセット Y */
100|int DScreen_getClipMinX( DScreen* ); /* クリッピング幅 */
101|int DScreen_getClipMaxX( DScreen* ); /* クリッピング高さ */
102|int DScreen_getClipMinY( DScreen* ); /* クリッピング幅 */
103|int DScreen_getClipMaxY( DScreen* ); /* クリッピング高さ */
104|
105|#ifdef __cplusplus
106|}
107|#endif
108|
109|/*---------------------------------------------------------------------*/
110|/*--- Mapping Area ----------------------------------------------------*/
111|/*---------------------------------------------------------------------*/
112|
113|/* DScreen インターフェイス・マッピング */
114|#define DScreen_flushTo( this, target ) \
115| DScreen_flushTo2( this, target, NULL, 0, 0 )
116|#define DScreen_getAdr(this) ((DScreen*)(this))->adr
117|#define DScreen_pgetAdr( this,x, y ) \
118| ( DScreen_getAdr(this) + ( DScreen_getWidth(this) * (y) + (x) ) \
119| / DScreen_getPixelPerByte(this) )
120|#define DScreen_pgetSubAdr( this, x, y ) \
121| ( (char*)DScreen_pgetAdr( this,x, y ) + DScreen_getSingleSize( this ) )
122|#define DScreen_getWidth(this) ((DScreen*)(this))->width
123|#define DScreen_getHeight(this) ((DScreen*)(this))->height
124|#define DScreen_getSingleSize(this) \
125| ( DScreen_getWidth(this) * DScreen_getHeight(this) / 2)
126|#define DScreen_getPixelPerByte(this) 2
127|#define DScreen_getBitPerPixel(this) ( 8 / DScreen_getPixelPerByte(this) )
128|#define DScreen_getOffsetX(this) ((DScreen*)(this))->offsetX
129|#define DScreen_getOffsetY(this) ((DScreen*)(this))->offsetY
130|#define DScreen_setOffset(this, x, y ) \
131| { DScreen_getOffsetX(this) = (x); DScreen_getOffsetY(this) = (y); }
132|#define DScreen_getClipMinX(this) ((this)->clipX)
133|#define DScreen_getClipMaxX(this) ((this)->clipX + (this)->clipWidth -1)
134|#define DScreen_getClipMinY(this) ((this)->clipY)
135|#define DScreen_getClipMaxY(this) ((this)->clipY + (this)->clipHeight-1)
136|
137|
138|/* 関数プロトタイプ宣言 */
139|DrawScr DScreen_inf_DrawScr( DScreen* );
140|DScreen* DScreen_by_DrawScr( DrawScr );
141|
142|/* 具象クラスのマクロ定義(プロトタイプ宣言より後で定義) */
143|#ifdef NDEBUG
144|#define DScreen_by_DrawScr(inf) INF_SUB_MACRO( DScreen, DrawScr, DScreen_by_DrawScr )
145|#endif
146|
147|#endif
148|
149|