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

📄 wrdt_wcon.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 Windows console control terminal * 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#ifndef __CYGWIN32__#include <conio.h>#endif#include "timidity.h"#include "common.h"#include "instrum.h"#include "playmidi.h"#include "readmidi.h"#include "controls.h"#include "wrd.h"// #define DEBUG1#ifndef __OLD_BORLANDC__#define USE_ESC#define NULL_STMT do ; while(0)#define gotoxy(x, y) NULL_STMT#define wherex() 1#define wherey() 1#define putch putchar#define cputs puts#define delline() NULL_STMT#define clrscr() NULL_STMT#define clreol() NULL_STMT#endif /* __OLD_BORLANDC__ */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 wcon_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;#ifdef __OLD_BORLANDC__static struct text_info text_info;static struct conattr {	int attr;	int bc;	int fc;} iniattr, curattr, saveattr;static void borlandc_con_set_attr(struct conattr *attr){	if(attr->attr & REVERSE)		textattr((attr->attr & ~REVERSE) + (attr->bc >> 4) + (attr->fc << 4));	else		textattr((attr->attr & ~REVERSE) + attr->bc + attr->fc);}static void borlandc_con_save_attr(void){	saveattr.attr = curattr.attr;	saveattr.bc = curattr.bc;	saveattr.fc = curattr.fc;}static void borlandc_con_restore_attr(void){	curattr.attr = saveattr.attr;	curattr.bc = saveattr.bc;	curattr.fc = saveattr.fc;	borlandc_con_set_attr(&curattr);}static void borlandc_con_reset_attr(void){	borlandc_con_set_attr(&iniattr);}static void borlandc_con_init(void){	gettextinfo(&text_info);	iniattr.attr = text_info.attribute & 0xff00;	iniattr.bc = text_info.attribute & 0xf0;	iniattr.fc = text_info.attribute & 0x0f;	curattr.attr = text_info.attribute & 0xff00;	curattr.bc = text_info.attribute & 0xf0;	curattr.fc = text_info.attribute & 0x0f;	borlandc_con_save_attr();}static void borlandc_con_reset(void){	borlandc_con_reset_attr();}#elsestruct {    int winleft, winright;    int wintop, winbottom;} text_info = {  1,25,  1,80,};#endif#define CANNOC_X(x) \{\	if(x < text_info.winleft) x = text_info.winleft;\	else if(x > text_info.winright) x = text_info.winright;\}#define CANNOC_Y(y) \{\	if(y < text_info.wintop) y = text_info.wintop;\	else if(y > text_info.winbottom) y = text_info.winbottom;\}static void putstring(char *str){	cputs(str);}static void putstringn(char *str, int n){	while(n--)		putch(*(str++));}#ifdef __OLD_BORLANDC__static void borlandc_con_color(int color){	switch(color){		case 0:			borlandc_con_reset_attr();			break;		case 2:			curattr.attr |= VERTICALLINE;			borlandc_con_set_attr(&curattr);			break;		case 4:			curattr.attr |= UNDERLINE;			borlandc_con_set_attr(&curattr);			break;		case 5:			curattr.attr |= BLINK;			borlandc_con_set_attr(&curattr);			break;		case 8: case 16: case 30:			curattr.attr &= ~REVERSE;			curattr.fc = BLACK;			borlandc_con_set_attr(&curattr);			break;		case 17: case 31:			curattr.attr &= ~REVERSE;			curattr.fc = LIGHTRED;			borlandc_con_set_attr(&curattr);			break;		case 18: case 34:			curattr.attr &= ~REVERSE;			curattr.fc = LIGHTBLUE;			borlandc_con_set_attr(&curattr);			break;		case 19: case 35:			curattr.attr &= ~REVERSE;			curattr.fc = LIGHTMAGENTA;			borlandc_con_set_attr(&curattr);			break;		case 20: case 32:			curattr.attr &= ~REVERSE;			curattr.fc = LIGHTGREEN;			borlandc_con_set_attr(&curattr);			break;		case 21: case 33:			curattr.attr &= ~REVERSE;			curattr.fc = YELLOW;			borlandc_con_set_attr(&curattr);			break;		case 22: case 36:			curattr.attr &= ~REVERSE;			curattr.fc = LIGHTCYAN;			borlandc_con_set_attr(&curattr);			break;		case 23: case 37:			curattr.attr &= ~REVERSE;			curattr.fc = WHITE;			borlandc_con_set_attr(&curattr);			break;/*		case 40:			attr = REVERSE + (bc << 4) + BLACK;			textattr(attr);			break;		case 41:			attr = REVERSE + (bc << 4) + LIGHTRED;			textattr(attr);			break;		case 42:			attr = REVERSE + (bc << 4) + LIGHTGREEN;			textattr(attr);			break;		case 43:			attr = REVERSE + (bc << 4) + YELLOW;			textattr(attr);			break;		case 44:			attr = REVERSE + (bc << 4) + LIGHTBLUE;			textattr(attr);			break;		case 45:			attr = REVERSE + (bc << 4) + LIGHTMAGENTA;			textattr(attr);			break;		case 46:			attr = REVERSE + (bc << 4) + LIGHTCYAN;			textattr(attr);			break;		case 47:			attr = REVERSE + (bc << 4) + WHITE;			textattr(attr);			break;*/		case 40:			curattr.attr |= REVERSE;			curattr.fc = BLACK;			borlandc_con_set_attr(&curattr);			break;		case 41:			curattr.attr |= REVERSE;			curattr.fc = LIGHTRED;			borlandc_con_set_attr(&curattr);			break;		case 42:			curattr.attr |= REVERSE;			curattr.fc = LIGHTGREEN;			borlandc_con_set_attr(&curattr);			break;		case 43:			curattr.attr |= REVERSE;			curattr.fc = YELLOW;			borlandc_con_set_attr(&curattr);			break;		case 44:			curattr.attr |= REVERSE;			curattr.fc = LIGHTBLUE;			borlandc_con_set_attr(&curattr);			break;		case 45:			curattr.attr |= REVERSE;			curattr.fc = LIGHTMAGENTA;			borlandc_con_set_attr(&curattr);			break;		case 46:			curattr.attr |= REVERSE;			curattr.fc = LIGHTCYAN;			borlandc_con_set_attr(&curattr);			break;		case 47:			curattr.attr |= REVERSE;			curattr.fc = WHITE;			borlandc_con_set_attr(&curattr);			break;		default:			break;	}	return;}#endif/* Escape sequence */static void esc_index(void){	int x = wherex(), y = wherey();	if(y<text_info.winbottom)		gotoxy(x,y+1);	else {		putstring("\n");		gotoxy(x,y);	}}void esc_nextline(void){	int y = wherey();	if(y<text_info.winbottom)		gotoxy(text_info.winleft,y+1);	else {		putstring("\n");	}}void esc_reverseindex(void){	int x = wherex(), y = wherey();	if(y <= text_info.wintop)		delline();	else		y--;	gotoxy(x,y);}void esc_clearscreen(void){	clrscr();}void esc_directcursoraddressing(int x, int y){	CANNOC_X(x);	CANNOC_Y(y);	gotoxy(x,y);}void esc_cursorup(int n){	int y;	if(n < 1) n = 1;	y = wherey() - n;	CANNOC_Y(y);	gotoxy(wherex(),y);}void esc_cursordown(int n){	int y;	if(n < 1) n = 1;	y = wherey() + n;	CANNOC_Y(y);	gotoxy(wherex(),y);}void esc_cursorforward(int n){	int x;	if(n < 1) n = 1;	x = wherex() - n;	CANNOC_X(x);	gotoxy(x,wherey());}void esc_cursorbackward(int n){	int x;	if(n < 1) n = 1;	x = wherex() + n;	CANNOC_X(x);	gotoxy(x,wherey());}void esc_clearfromcursortoendofscreen(void){	int oldx = wherex(), oldy = wherey();	int y;	clreol();	for(y=oldy+1;y<=text_info.winbottom;y++){		gotoxy(text_info.winleft,y);		clreol();	}	gotoxy(oldx,oldy);}void esc_clearfrombeginningofscreentocursor(void){	int oldx = wherex(), oldy = wherey();	int y;	for(y=oldy;y<=text_info.winbottom;y++){		gotoxy(text_info.winleft,y);		clreol();	}	gotoxy(oldx,oldy);}void esc_clearfromcursortoendofline(void){	int oldx = wherex(), oldy = wherey();	int x;	for(x=oldx;x<=text_info.winright;x++)		putstringn(" ",1);	gotoxy(oldx,oldy);}void esc_clearfrombeginningoflinetocursor(void){	int oldx = wherex(), oldy = wherey();	int x;	for(x=oldx;x>=text_info.winright;x--)		putstringn(" ",1);	gotoxy(oldx,oldy);}void esc_clearentirelinecontainingcursor(void){	int oldx = wherex(), oldy = wherey();	int x;	for(x=text_info.winleft;x<=text_info.winright;x++)		putstringn(" ",1);	gotoxy(oldx,oldy);}void esc_deleteline(int n){	int i, n_max;	if(n < 1) n = 1;	n_max = text_info.winbottom - wherey() + 1;	if(n > n_max) n = n_max;	for(i=1;i<=n;i++)		delline();	gotoxy(text_info.winleft,wherey());}void esc_insertline(int n){	int i;	if(n < 1) n = 1;	for(i=1;i<=n;i++)		delline();	gotoxy(text_info.winleft,wherey());}void esc_savecursorposition(void){	return;}void esc_setcursorposition(void){	return;}void esc_enablecursordisplay(void){#ifdef __OLD_BORLANDC__	_setcursortype(_NORMALCURSOR);#endif /* __OLD_BORLANDC__ */}void esc_disablecursordisplay(void){#ifdef __OLD_BORLANDC__	_setcursortype(_NOCURSOR);#endif /* __OLD_BORLANDC__ */}void esc_characterattribute(int n){#ifdef __OLD_BORLANDC__	borlandc_con_color(n);#endif}/* 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;}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){		putstringn(str,p-str);		str = p;		break;	  }	  if(*p == '\0')		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 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){

⌨️ 快捷键说明

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