⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 w32g_subwin2.c

📁 MIDI解码程序(用VC编写)
💻 C
📖 第 1 页 / 共 5 页
字号:
	SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );	w32g_wrd_wnd.modified_graphic[index] = TRUE;	wrd_wnd_unlock();	wrd_graphic_apply ( &rc, index, TRUE );}static void wrd_graphic_reset_all ( void ){	int i;	wrd_wnd_lock();	w32g_wrd_wnd.default_gpal[0] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0x00 ));	w32g_wrd_wnd.default_gpal[1] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0x7F ) );	w32g_wrd_wnd.default_gpal[2] = RGBtoRGBQUAD (RGB ( 0x7F, 0x00, 0x00 ));	w32g_wrd_wnd.default_gpal[3] = RGBtoRGBQUAD (RGB ( 0x7F, 0x00, 0x7F ));	w32g_wrd_wnd.default_gpal[4] = RGBtoRGBQUAD (RGB ( 0x00, 0x7F, 0x00 ));	w32g_wrd_wnd.default_gpal[5] = RGBtoRGBQUAD (RGB ( 0x00, 0x7F, 0x7F ));	w32g_wrd_wnd.default_gpal[6] = RGBtoRGBQUAD (RGB ( 0x7F, 0x7F, 0x00 ));	w32g_wrd_wnd.default_gpal[7] = RGBtoRGBQUAD (RGB ( 0x7F, 0x7F, 0x7F ));	w32g_wrd_wnd.default_gpal[8] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0x00 ));	w32g_wrd_wnd.default_gpal[9] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0xFF ));	w32g_wrd_wnd.default_gpal[10] = RGBtoRGBQUAD (RGB ( 0xFF, 0x00, 0x00 ));	w32g_wrd_wnd.default_gpal[11] = RGBtoRGBQUAD (RGB ( 0xFF, 0x00, 0xFF ));	w32g_wrd_wnd.default_gpal[12] = RGBtoRGBQUAD (RGB ( 0x00, 0xFF, 0x00 ));	w32g_wrd_wnd.default_gpal[13] = RGBtoRGBQUAD (RGB ( 0x00, 0xFF, 0xFF ));	w32g_wrd_wnd.default_gpal[14] = RGBtoRGBQUAD (RGB ( 0xFF, 0xFF, 0x00 ));	w32g_wrd_wnd.default_gpal[15] = RGBtoRGBQUAD (RGB ( 0xFF, 0xFF, 0xFF ));	for ( i = 16; i < W32G_WRDWND_GRAPHIC_PALLETE_MAX; i++ )		w32g_wrd_wnd.default_gpal[i] = RGBtoRGBQUAD (RGB ( 0x00, 0x00, 0x00 ));	wrd_wnd_unlock();	for ( i = 0; i < W32G_WRDWND_GRAPHIC_PLANE_MAX; i ++ ) {		wrd_graphic_reset ( i );	}	wrd_wnd_lock();	w32g_wrd_wnd.gmode = 0xFFFF;	w32g_wrd_wnd.fade_from = -1;	w32g_wrd_wnd.fade_to = -1;	wrd_wnd_unlock();}// 僾儗乕儞 index 偺僌儔僼傿僢僋偺 lprc 椞堟傪 hmdc_graphic 傊峏怴static void wrd_graphic_apply ( RECT *lprc, int index, int lockflag ){#if 0	if ( WrdWndInfo.GraphicStop ) return;//	if ( !w32g_wrd_wnd.modified_graphic[index] ) return;	if ( lockflag ) wrd_wnd_lock();	w32g_wrd_wnd.modified_graphic[index] = FALSE;	if ( lockflag ) wrd_wnd_unlock();#endif}// lprc 椞堟偺僌儔僼傿僢僋傪峏怴static void wrd_graphic_update ( RECT *lprc, int lockflag ){	if ( WrdWndInfo.GraphicStop ) return;	if ( w32g_wrd_wnd.draw_skip ) return;	wrd_wnd_lock();	if ( lockflag ) GDI_LOCK();	// 夋憸張棟偟偨娭悢偱峴偆丅	if ( w32g_wrd_wnd.flag & WRD_FLAG_GRAPHIC ) {		if ( w32g_wrd_wnd.flag & WRD_FLAG_TEXT ) {			HDC hmdc_work, hmdc_tmask, hmdc_graphic;			GdiFlush ();			hmdc_work = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );			hmdc_tmask = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );			hmdc_graphic = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );			SelectObject ( hmdc_work, w32g_wrd_wnd.hbmp_work );			SelectObject ( hmdc_tmask, w32g_wrd_wnd.hbmp_tmask );			SelectObject ( hmdc_graphic, w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display]->hbmp );			BitBlt ( w32g_wrd_wnd.hmdc, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,				hmdc_tmask,  lprc->left, lprc->top, SRCAND );			BitBlt ( hmdc_work, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,				hmdc_tmask,  lprc->left, lprc->top, NOTSRCCOPY );			BitBlt ( hmdc_work, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,				hmdc_graphic, lprc->left, lprc->top, SRCAND );			BitBlt ( w32g_wrd_wnd.hmdc, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,				hmdc_work,  lprc->left, lprc->top, SRCPAINT );			DeleteDC ( hmdc_work );			DeleteDC ( hmdc_tmask );			DeleteDC ( hmdc_graphic );		} else {			HDC hmdc_graphic;			hmdc_graphic = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );			SelectObject ( hmdc_graphic, w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_display]->hbmp );			BitBlt ( w32g_wrd_wnd.hmdc, lprc->left, lprc->top, lprc->right - lprc->left, lprc->bottom - lprc->top,				hmdc_graphic,  lprc->left, lprc->top, SRCCOPY );			DeleteDC ( hmdc_graphic );		}	}	if ( lockflag ) GDI_UNLOCK();	wrd_wnd_unlock();}// 椞堟偺僥僉僗僩傪峏怴static void wrd_text_update ( int x_from, int y_from, int x_to, int y_to, int lockflag ){	RECT rc;	if ( w32g_wrd_wnd.draw_skip ) return;	if ( x_from < 0 ) x_from = 0;	if ( x_from >= w32g_wrd_wnd.row ) x_from = w32g_wrd_wnd.row - 1;	if ( x_to < 0 ) x_to = 0;	if ( x_to >= w32g_wrd_wnd.row ) x_to = w32g_wrd_wnd.row - 1;	if ( y_from < 0 ) y_from = 0;	if ( y_from >= w32g_wrd_wnd.row ) y_from = w32g_wrd_wnd.col - 1;	if ( y_to < 0 ) y_to = 0;	if ( y_to >= w32g_wrd_wnd.row ) y_to = w32g_wrd_wnd.col - 1;	SetRect ( &rc, x_from * w32g_wrd_wnd.font_width, y_from * w32g_wrd_wnd.font_height,		(x_to+1) * w32g_wrd_wnd.font_width, (y_to+1) * w32g_wrd_wnd.font_height);	wrd_wnd_lock();	if ( lockflag ) GDI_LOCK();	if ( w32g_wrd_wnd.flag & WRD_FLAG_TEXT ) {		HDC hmdc_tmask;		COLORREF forecolor, backcolor, prevforecolor, prevbackcolor;		char attr;		HGDIOBJ hgdiobj;		int x, y;		forecolor = w32g_wrd_wnd.pals[w32g_wrd_wnd.curforecolor];		backcolor = w32g_wrd_wnd.pals[w32g_wrd_wnd.curbackcolor];		prevforecolor = SetTextColor( w32g_wrd_wnd.hmdc, forecolor );		prevbackcolor = SetBkColor( w32g_wrd_wnd.hmdc, backcolor );		hgdiobj = SelectObject( w32g_wrd_wnd.hmdc, w32g_wrd_wnd.hFont );		hmdc_tmask = CreateCompatibleDC ( w32g_wrd_wnd.hmdc );		SelectObject( hmdc_tmask, w32g_wrd_wnd.hbmp_tmask );		SelectObject( hmdc_tmask, w32g_wrd_wnd.hFont );		SelectObject( hmdc_tmask, w32g_wrd_wnd.hNullBrush );		SelectObject( hmdc_tmask, w32g_wrd_wnd.hNullPen );		attr = 0;		SetTextColor( hmdc_tmask, COLOR_MASK_WHITE );		SetBkColor( hmdc_tmask, COLOR_MASK_BLACK );		for( y = y_from; y <= y_to; y++ ) {			for( x = x_from; x <= x_to; x++ ) {				char mbt = _MBC_SINGLE;				RECT rc_part;				if ( forecolor != w32g_wrd_wnd.pals[w32g_wrd_wnd.forecolorbuf[y][x]] ) {					forecolor = w32g_wrd_wnd.pals[w32g_wrd_wnd.forecolorbuf[y][x]];					SetTextColor( w32g_wrd_wnd.hmdc, forecolor );				}				if ( backcolor != w32g_wrd_wnd.pals[w32g_wrd_wnd.backcolorbuf[y][x]] ) {					backcolor = w32g_wrd_wnd.pals[w32g_wrd_wnd.backcolorbuf[y][x]];					SetBkColor( w32g_wrd_wnd.hmdc, backcolor );				}				if ( attr != w32g_wrd_wnd.attrbuf[y][x] ) {					if ( ( attr & W32G_WRDWND_ATTR_REVERSE ) != ( w32g_wrd_wnd.attrbuf[y][x] & W32G_WRDWND_ATTR_REVERSE ) ) {						if ( w32g_wrd_wnd.attrbuf[y][x] & W32G_WRDWND_ATTR_REVERSE ) {							SetTextColor( hmdc_tmask, COLOR_MASK_BLACK );							SetBkColor( hmdc_tmask, COLOR_MASK_WHITE );						} else {							SetTextColor( hmdc_tmask, COLOR_MASK_WHITE );							SetBkColor( hmdc_tmask, COLOR_MASK_BLACK );						}					}					attr = w32g_wrd_wnd.attrbuf[y][x];				}				if ( PlayerLanguage == LANGUAGE_JAPANESE && _mbbtype( w32g_wrd_wnd.textbuf[y][x], _MBC_SINGLE ) == _MBC_LEAD ) {					SetRect ( &rc_part, x * w32g_wrd_wnd.font_width, y * w32g_wrd_wnd.font_height,						(x + 2) * w32g_wrd_wnd.font_width, (y + 1) * w32g_wrd_wnd.font_height );					if ( w32g_wrd_wnd.flag & WRD_FLAG_TEXT )						ExtTextOut( w32g_wrd_wnd.hmdc, rc_part.left, rc_part.top, ETO_OPAQUE | ETO_CLIPPED, &rc_part, w32g_wrd_wnd.textbuf[y] + x, 2, NULL);					ExtTextOut( hmdc_tmask, rc_part.left, rc_part.top, ETO_OPAQUE | ETO_CLIPPED, &rc_part, w32g_wrd_wnd.textbuf[y] + x, 2, NULL);					x++;				} else {					SetRect ( &rc_part, x * w32g_wrd_wnd.font_width, y * w32g_wrd_wnd.font_height,						(x + 1) * w32g_wrd_wnd.font_width, (y + 1) * w32g_wrd_wnd.font_height );					if ( w32g_wrd_wnd.flag & WRD_FLAG_TEXT )						ExtTextOut( w32g_wrd_wnd.hmdc, rc_part.left, rc_part.top, ETO_OPAQUE | ETO_CLIPPED, &rc_part, w32g_wrd_wnd.textbuf[y] + x, 1, NULL);					ExtTextOut( hmdc_tmask, rc_part.left, rc_part.top, ETO_OPAQUE | ETO_CLIPPED, &rc_part, w32g_wrd_wnd.textbuf[y] + x, 1, NULL);				}			}		}		SetTextColor( w32g_wrd_wnd.hmdc, prevforecolor);		SetBkColor( w32g_wrd_wnd.hmdc, prevbackcolor);		SelectObject( w32g_wrd_wnd.hmdc, hgdiobj );		DeleteDC ( hmdc_tmask );	}	if ( lockflag ) GDI_UNLOCK();	wrd_wnd_unlock();	if ( ! WrdWndInfo.GraphicStop ) {		wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );		wrd_graphic_update ( &rc, 0 );	}	InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE);}extern void wrd_graphic_ginit ( void );extern void wrd_graphic_gcls ( int sw );extern void wrd_graphic_gscreen ( int active, int display );extern void wrd_graphic_gon ( int sw );extern void wrd_graphic_gline ( int x1, int y1, int x2, int y2, int p1, int sw, int p2 );extern void wrd_graphic_gcircle ( int x, int y, int r, int p1, int sw, int p2 );extern void wrd_graphic_pload ( char *path );extern void wrd_graphic_pal_g4r4b4 ( int p, int *g4r4b4, int max );extern void wrd_graphic_palrev ( int p );extern void wrd_graphic_apply_pal ( int p );extern void wrd_graphic_fade ( int p1, int p2, int speed );extern void wrd_graphic_fadestep ( int v );extern void wrd_graphic_gmode ( int sw );extern void wrd_graphic_gmove ( int x1, int y1, int x2, int y2, int xd, int yd, int vs, int vd, int sw );extern void wrd_graphic_mag ( char *path, int x, int y, int s, int p );extern void wrd_text_scroll ( int x1, int y1, int x2, int y2, int mode, int color, int c );extern void wrd_start_skip ( void );extern void wrd_end_skip ( void );extern void wrd_graphic_xcopy ( int sx1, int sy1, int sx2, int sy2, int tx, int ty, int ss, int ts, int method,	 int opt1, int opt2, int opt3, int opt4, int opt5 );void wrd_graphic_ginit ( void ){	RECT rc;	int index_display_old = w32g_wrd_wnd.index_display;	if ( WrdWndInfo.GraphicStop ) return;	if ( !w32g_wrd_wnd.active ) return;	wrd_graphic_plane_change ( 0, 0 );	wrd_graphic_reset_all ();	wrd_wnd_lock();	mag_deletetab();	wrd_wnd_unlock();	SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );	InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );}void wrd_graphic_gcls ( int sw ){	RECT rc;	int i, size;	if ( WrdWndInfo.GraphicStop ) return;	if ( !w32g_wrd_wnd.active ) return;	wrd_wnd_lock();	GdiFlush ();	size = w32g_wrd_wnd.width * w32g_wrd_wnd.height;	if ( sw == 0 )		sw = 0xFF;	for ( i = 0; i < size; i ++ ) {		w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_active]->bits[i] &= ~sw;	}	w32g_wrd_wnd.modified_graphic[w32g_wrd_wnd.index_active] = TRUE;	SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );	wrd_wnd_unlock();	if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {		wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );		wrd_graphic_update ( &rc, TRUE );		InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );	}}void wrd_graphic_gscreen ( int active, int display ){	int display_old = w32g_wrd_wnd.index_display;	if ( WrdWndInfo.GraphicStop ) return;	if ( !w32g_wrd_wnd.active ) return;	if ( active < 0 || active >= 2 || display < 0 || display >= 2 )		return;	wrd_wnd_lock();	wrd_graphic_plane_change ( active, display );	wrd_wnd_unlock();	if ( display_old != w32g_wrd_wnd.index_display ) {		RECT rc;		SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );		wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );		wrd_graphic_update ( &rc, TRUE );		InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );	}}void wrd_graphic_gon ( int sw ){	int sw_old = w32g_wrd_wnd.flag & WRD_FLAG_GRAPHIC;	if ( WrdWndInfo.GraphicStop ) return;	if ( !w32g_wrd_wnd.active ) return;	if ( sw && !sw_old ) {		w32g_wrd_wnd.flag |= WRD_FLAG_GRAPHIC;		// 愭偵愝掕		if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {			RECT rc;			SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );			wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );			wrd_graphic_update ( &rc, TRUE );			InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );		}	} else if ( !sw && sw_old ) {		if ( w32g_wrd_wnd.index_active == w32g_wrd_wnd.index_display ) {			RECT rc;			SetRect ( &rc, 0, 0, w32g_wrd_wnd.width, w32g_wrd_wnd.height );			wrd_graphic_apply ( &rc, w32g_wrd_wnd.index_display, TRUE );			wrd_graphic_update ( &rc, TRUE );			InvalidateRect ( w32g_wrd_wnd.hwnd, &rc, FALSE );		}	}	if ( sw )		w32g_wrd_wnd.flag |= WRD_FLAG_GRAPHIC;	else		w32g_wrd_wnd.flag &= ~WRD_FLAG_GRAPHIC;}void wrd_graphic_gline ( int x1, int y1, int x2, int y2, int p1, int sw, int p2 ){	int x, y, i;	RECT rc[10];	int rc_max = 0;	char *bits = w32g_wrd_wnd.graphic_dib[w32g_wrd_wnd.index_active]->bits;	if ( WrdWndInfo.GraphicStop ) return;	if ( !w32g_wrd_wnd.active ) return;	if ( x1 > x2 || y1 > y2 || x1 < 0 || y1 < 0 || x2 >= w32g_wrd_wnd.width || y2 >=  w32g_wrd_wnd.height )		return;	wrd_wnd_lock();	GdiFlush ();	// w32g_wrd_wnd.gmode	if ( sw >= 1 ) {		for ( x = x1; x <= x2; x ++ ) 			bits[ y1 * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;		SetRect ( &rc[rc_max++], x1, y1, x2+1, y1+1 );		for ( y = y1 + 1; y <= y2 - 1; y ++ ) {			bits[ y * w32g_wrd_wnd.width + x1] = w32g_wrd_wnd.gmode & p1;			bits[ y * w32g_wrd_wnd.width + x2] = w32g_wrd_wnd.gmode & p1;		}		SetRect ( &rc[rc_max++], x1, y1, x1+1, y2+1 );		SetRect ( &rc[rc_max++], x2, y1, x2+1, y2+1 );		for ( x = x1; x <= x2; x ++ ) 			bits[ y2 * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;		SetRect ( &rc[rc_max++], x1, y2, x2+1, y2+1 );		if ( sw == 2 ) {			for ( y = y1 + 1; y <= y2 - 1; y ++ ) 				for ( x = x1 + 1; x <= x2 - 1; x ++ ) 					bits[ y * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p2;			rc_max = 0;			SetRect ( &rc[rc_max++], x1, y1, x2+1, y2+1 );		}	} else if ( sw == 0 ) {		if ( x1 == x2 ) {			for ( y = y1 ; y <= y2 ; y ++ ) 				bits[ y * w32g_wrd_wnd.width + x1] = w32g_wrd_wnd.gmode & p1;			SetRect ( &rc[rc_max++], x1, y1, x1+1, y2+1 );		} else if ( y1 == y2 ) {			for ( x = x1; x <= x2; x ++ ) 				bits[ y1 * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p2;			SetRect ( &rc[rc_max++], x1, y1, x2+1, y1+1 );		} else if ( x2 - x1 == y2 - y1 ) {			for ( y = y1; y <= y2; y ++ ) 				bits[ y1 * w32g_wrd_wnd.width + (y - y1) + x1] = w32g_wrd_wnd.gmode & p2;			SetRect ( &rc[rc_max++], x1, y1, x2+1, y2+1 );		} else if ( x2 - x1 > y2 - y1 ) {			double r = (y2 - y1) / (x2 -x1), r2;			int x_min = x1;			for ( y = y1; y <= y2 - 1; y ++ ) {				for ( x = x_min; x <= x2; x ++ ) {					r2 = r * (x - x1) - (y - y1);					if ( r2 < 0.0 || r2 >= 1.0 ) {						break;					} else if ( r2 <= 0.5 ) {						bits[ y * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;						x_min = x + 1;					} else {						bits[ (y + 1) * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;						x_min = x + 1;					}				}			}			SetRect ( &rc[rc_max++], x1, y1, x2+1, y2+1 );		} else if ( x2 - x1 < y2 - y1 ) {			double r = (x2 - x1) / (y2 -y1), r2;			int y_min = y1;			for ( x = x1; x <= x2 - 1; x ++ ) {				for ( y = y_min; y <= y2; y ++ ) {					r2 = r * (y - y1) - (x - x1);					if ( r2 < 0.0 || r2 >= 1.0 ) {						break;					} else if ( r2 <= 0.5 ) {						bits[ y * w32g_wrd_wnd.width + x] = w32g_wrd_wnd.gmode & p1;						y_min = y + 1;					} else {						bits[ y * w32g_wrd_wnd.width + x + 1] = w32g_wrd_wnd.gmode & p1;						y_min = y + 1;					}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -