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

📄 wrdt_w32g.c

📁 MIDI解码程序(用VC编写)
💻 C
📖 第 1 页 / 共 2 页
字号:
/*    TiMidity++ -- MIDI to WAVE converter and player    Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>    Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    GNU General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*//* * WRD Tracer for vt100 control terminal * Written by Takanori Watanabe <takawata@shidahara1.planet.kobe-u.ac.jp> *//* * WRD Tracer for Win32GUI * modified for Windows console by Daisuke Aoki <dai@y7.net> */#ifdef HAVE_CONFIG_H#include "config.h"#endif /* HAVE_CONFIG_H */#include <stdio.h>#include <stdlib.h>#ifndef NO_STRING_H#include <string.h>#else#include <strings.h>#endif#include "timidity.h"#include "common.h"#include "instrum.h"#include "playmidi.h"#include "readmidi.h"#include "controls.h"#include "wrd.h"#include <windows.h>#include "w32g_dib.h"#include "w32g_wrd.h"static int wrdt_open(char *dummy);static void wrdt_apply(int cmd, int wrd_argc, int wrd_args[]);static void wrdt_update_events(void);static void wrdt_end(void);static void wrdt_close(void);#define NO_GRAPHIC_SUPPORT#define wrdt w32g_wrdt_mode#define COLOR_REMAP(k) ((k)>16)&&((k)<30)?(k)+14:kWRDTracer wrdt ={    "Windows Console WRD tracer", 'w',    0,    wrdt_open,    wrdt_apply,    NULL,    wrdt_update_events,    NULL,    wrdt_end,    wrdt_close};static int wrd_argc;static int wrd_args[WRD_MAXPARAM];static int inkey_flag;static void putstring(char *str){	WrdWndPutString(str,TRUE);}static void putstringn(char *str, int n){	WrdWndPutStringN(str,n,TRUE);}/* Escape sequence */static void esc_index(void){	w32g_wrd_wnd.curposy++;	if ( w32g_wrd_wnd.curposy >= w32g_wrd_wnd.col ) {		WrdWndScrollUp(TRUE);		w32g_wrd_wnd.curposy = w32g_wrd_wnd.col - 1;	}}void esc_nextline(void){	w32g_wrd_wnd.curposx = 0;	w32g_wrd_wnd.curposy++;	if ( w32g_wrd_wnd.curposy >= w32g_wrd_wnd.col ) {		WrdWndScrollUp(TRUE);		w32g_wrd_wnd.curposy = w32g_wrd_wnd.col - 1;	}}void esc_reverseindex(void){	w32g_wrd_wnd.curposy--;	if ( w32g_wrd_wnd.curposy < 0 ) {		WrdWndScrollDown(TRUE);	}}void esc_clearscreen(void){	WrdWndClear(TRUE);}void esc_directcursoraddressing(int x, int y){	WrdWndGoto( x-1, y-1 );}void esc_cursorup(int n){	if(n < 1) n = 1;	WrdWndGoto( w32g_wrd_wnd.curposx, w32g_wrd_wnd.curposy - n );}void esc_cursordown(int n){	if(n < 1) n = 1;	WrdWndGoto( w32g_wrd_wnd.curposx, w32g_wrd_wnd.curposy + n );}void esc_cursorforward(int n){	if(n < 1) n = 1;	WrdWndGoto( w32g_wrd_wnd.curposx - n , w32g_wrd_wnd.curposy );}void esc_cursorbackward(int n){	if(n < 1) n = 1;	WrdWndGoto( w32g_wrd_wnd.curposx + n , w32g_wrd_wnd.curposy );}void esc_clearfromcursortoendofscreen(void){	WrdWndLineClearFrom(FALSE, TRUE);	WrdWndClearLineFromTo(w32g_wrd_wnd.curposy + 1, w32g_wrd_wnd.col - 1, TRUE);}void esc_clearfrombeginningofscreentocursor(void){	WrdWndClearLineFromTo(0,w32g_wrd_wnd.curposy - 1, TRUE);	WrdWndLineClearFrom(TRUE, TRUE);}void esc_clearfromcursortoendofline(void){	WrdWndLineClearFrom(FALSE, TRUE);}void esc_clearfrombeginningoflinetocursor(void){	WrdWndLineClearFrom(TRUE, TRUE);}void esc_clearentirelinecontainingcursor(void){	WrdWndClearLineFromTo( w32g_wrd_wnd.curposy, w32g_wrd_wnd.curposy, TRUE );}void esc_deleteline(int n){	int i;	if(n < 1) n = 1;	if( w32g_wrd_wnd.curposy + n >= w32g_wrd_wnd.col )		n = w32g_wrd_wnd.col - 1 - w32g_wrd_wnd.curposy;	for( i = w32g_wrd_wnd.curposy; i < w32g_wrd_wnd.curposy + n; i++ ) {		WrdWndMoveLine(i+n,i,TRUE);	}	WrdWndClearLineFromTo(w32g_wrd_wnd.col - n, w32g_wrd_wnd.col - 1, TRUE);	w32g_wrd_wnd.curposx = 0;}void esc_insertline(int n){	int i;	if(n < 1) n = 1;	if( w32g_wrd_wnd.curposy + n >= w32g_wrd_wnd.col )		n = w32g_wrd_wnd.col - 1 - w32g_wrd_wnd.curposy;	for( i = w32g_wrd_wnd.col - n - 1; i >= w32g_wrd_wnd.curposy; i-- ) {		WrdWndMoveLine(i,i+n,TRUE);	}	w32g_wrd_wnd.curposx = 0;}static volatile int saved_x;static volatile int saved_y;static volatile int saved_attr;void esc_savecursorposition(void){	WrdWndCurStateSaveAndRestore(1);	return;}void esc_setcursorposition(void){	WrdWndCurStateSaveAndRestore(0);	return;}void esc_enablecursordisplay(void){	return;}void esc_disablecursordisplay(void){	return;}void esc_characterattribute(int n){	WrdWndSetAttr98(n);}/* return figures */static int getdigit(char *str,int *num){	int i;	char local[20];	for(i=0;i<=10;i++)		if(str[i] < '0' || str[i] > '9'){			if(i<1)				return 0;			else				break;		}	strncpy(local,str,i);	local[i] = '\0';	*num = atoi(local);	return i;}extern int gdi_lock(void);extern int gdi_unlock(void);static void putstring_with_esc(char *str){  char *p;  while(*str)  {    p = str;	for(;;)	{	  if((unsigned char)*p >= 0x20){	    p++;		continue;	  }	  if(p-str > 0){		WrdWndPutStringN(str,p-str,TRUE);		str = p;		break;	  }	  if(*p == '\0')		break;		if(*p == '\n') {			esc_nextline();			str = p + 1;			break;		}		if(*p == '\r' && *(p+1) == '\n') {			esc_nextline();			str = p + 2;			break;		}		if(*p == '\t') {			WrdWndPutStringN ( "        ", 8, TRUE );			str = p + 1;			break;		}	  if(*p != 0x1b){			str = p + 1;			break;		}	  if(*p == 0x1b){		int res, n[1024], n_max = 0;		char *oldp = p;		p++;		if(*p == '['){			p++;			for(;;){				res = getdigit(p,&(n[n_max+1]));				if(res>0){					n_max++;					p += res;				}				if(*p != ';')					break;				else					p++;			}		} else if(*p == 'D'){			esc_index();			p++;			str = p;			break;		} else if(*p == 'E'){			esc_nextline();			p++;			str = p;			break;		} else if(*p == 'M'){			esc_reverseindex();			p++;			str = p;			break;		} else if(*p == '*'){			esc_clearscreen();			p++;			str = p;			break;		} else {			p = oldp;		    if(p-str > 0){				WrdWndPutStringN(str,p-str,TRUE);					str = p;				break;			}		}		if(n_max == 2 && (*p == 'H' || *p == 'f')){			esc_directcursoraddressing(n[2],n[1]);			p++;			str = p;			break;		}		if((n_max == 1 && *p == 'A') || (n_max == 0 && *p == 'A')){			if(n_max == 0)				n[1] = 1;			esc_cursorup(n[1]);			p++;			str = p;			break;		}		if((n_max == 1 && *p == 'B') || (n_max == 0 && *p == 'B')){			if(n_max == 0)				n[1] = 1;			esc_cursordown(n[1]);			p++;			str = p;			break;		}		if((n_max == 1 && *p == 'C') || (n_max == 0 && *p == 'C')){			if(n_max == 0)				n[1] = 1;			esc_cursorforward(n[1]);			p++;			str = p;			break;		}		if((n_max == 1 && *p == 'D') || (n_max == 0 && *p == 'D')){			if(n_max == 0)				n[1] = 1;			esc_cursorbackward(n[1]);			p++;			str = p;			break;		}		if((n_max == 1 && *p == 'J') || (n_max == 0 && *p == 'J')){			if(n_max == 0 || n[1] == 0)				esc_clearfromcursortoendofscreen();			else if(n[1] == 1)				esc_clearfrombeginningofscreentocursor();			else if(n[1] == 2)				esc_clearscreen();			p++;			str = p;			break;		}		if((n_max == 1 && *p == 'K') || (n_max == 0 && *p == 'K')){			if(n_max == 0 || n[1] == 0)				esc_clearfromcursortoendofline();			else if(n[1] == 1)				esc_clearfrombeginningoflinetocursor();			else if(n[1] == 2)				esc_clearentirelinecontainingcursor();			p++;			str = p;			break;		}		if((n_max == 1 && *p == 'M') || (n_max == 0 && *p == 'M')){			if(n_max == 0)				n[1] = 1;			esc_deleteline(n[1]);			p++;			str = p;			break;		}		if((n_max == 1 && *p == 'L') || (n_max == 0 && *p == 'L')){			if(n_max == 0)				n[1] = 1;			esc_insertline(n[1]);			p++;			str = p;			break;		}		if(n_max == 0 && *p == 's'){			esc_savecursorposition();			p++;			str = p;			break;		}		if(n_max == 0 && *p == 'u'){			esc_setcursorposition();			p++;			str = p;			break;		}		if(!strncmp(p,">5l",3)){			esc_enablecursordisplay();			p += 3;			str = p;			break;		}		if(!strncmp(p,">5h",3)){			esc_disablecursordisplay();			p += 3;			str = p;			break;		}		if(!strncmp(p,">1h",3)){		/* Enabel bottom line */			p += 3;			str = p;			break;		}		if(!strncmp(p,">1l",3)){		/* Disabel bottom line */			p += 3;			str = p;			break;

⌨️ 快捷键说明

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