Exemple #1
0
/*
     * Set up the terminal attributes.
     */
void setup_terminal(void)
{
    char *termtype;
    struct termios newtty;
    if (!Batch)
    	termtype = getenv("TERM");
    else 
	termtype = "dumb";
    if (!termtype) {
	/* In theory, $TERM should never not be set, but in practice,
	   some gettys don't.  Fortunately, vt100 is nearly always
	   correct (or pretty close). */
	termtype = "VT100";
	/* fprintf(stderr, PROGNAME ": $TERM not set\n"); */
	/* exit(1); */
    }

    /*
     * Get termcap entries and window size.
     */
    if(tgetent(NULL, termtype) != 1) {
       fprintf(stderr, PROGNAME ": Unknown terminal \"%s\" in $TERM\n",
               termtype);
       exit(1);
    }

    cm = tgetstr("cm", 0);
    top_clrtobot = tgetstr("cd", 0);
    cl = tgetstr("cl", 0);
    top_clrtoeol = tgetstr("ce", 0);
    ho = tgetstr("ho", 0);
    md = tgetstr("md", 0);
    mr = tgetstr("mr", 0);
    me = tgetstr("me", 0);


    if (Batch) return; /* the rest doesn't apply to batch mode */
    if (tcgetattr(0, &Savetty) == -1) {
        perror(PROGNAME ": tcgetattr() failed");
	error_end(errno);
    }
    newtty = Savetty;
    newtty.c_lflag &= ~ICANON;
    newtty.c_lflag &= ~ECHO;
    newtty.c_cc[VMIN] = 1;
    newtty.c_cc[VTIME] = 0;
    if (tcsetattr(0, TCSAFLUSH, &newtty) == -1) {
	printf("cannot put tty into raw mode\n");
	error_end(1);
    }
    tcgetattr(0, &Rawtty);
}
Exemple #2
0
/*
 * Reads the memory info and displays it.  Returns the total memory
 * available, for use in percent memory usage calculations.
 */
unsigned show_meminfo(void)
{
    unsigned long long **mem = get_meminfo();	/* read+parse /proc/meminfo */
    
    if (!mem ||	mem[meminfo_main][meminfo_total] == 0) {	/* cannot normalize mem usage */
	fprintf(stderr, "Cannot get size of memory from /proc/meminfo\n");
	error_end(1);
    }
    if (show_memory) {
	printf("Mem:  %7LdK av, %7LdK used, %7LdK free, %7LdK shrd, %7LdK buff",
	       mem[meminfo_main][meminfo_total] >> 10,
	       mem[meminfo_main][meminfo_used] >> 10,
	       mem[meminfo_main][meminfo_free] >> 10,
	       mem[meminfo_main][meminfo_shared] >> 10,
	       mem[meminfo_main][meminfo_buffers] >> 10);
	PUTP(top_clrtoeol);
	putchar('\n');
	printf("Swap: %7LdK av, %7LdK used, %7LdK free                 %7LdK cached",
	       mem[meminfo_swap][meminfo_total] >> 10,
	       mem[meminfo_swap][meminfo_used] >> 10,
	       mem[meminfo_swap][meminfo_free] >> 10,
	       mem[meminfo_total][meminfo_cached] >> 10);
	PUTP(top_clrtoeol);
	putchar('\n');
    }
    PUTP(me);
    PUTP(top_clrtoeol);
    putchar('\n');
    return mem[meminfo_main][meminfo_total] >> 10;
}
Exemple #3
0
/*
     * Set up the terminal attributes.
     */
void setup_terminal(void)
{
    char *termtype;
    struct termio newtty;

    termtype = getenv("TERM");
    if (!termtype) {
	/* In theory, $TERM should never not be set, but in practice,
	   some gettys don't.  Fortunately, vt100 is nearly always
	   correct (or pretty close). */
	termtype = "VT100";
	/* fprintf(stderr, PROGNAME ": $TERM not set\n"); */
	/* exit(1); */
    }
    if (ioctl(0, TCGETA, &Savetty) == -1) {
	perror(PROGNAME ": ioctl() failed");
	error_end(errno);
    }
    newtty = Savetty;
    newtty.c_lflag &= ~ICANON;
    newtty.c_lflag &= ~ECHO;
    newtty.c_cc[VMIN] = 1;
    newtty.c_cc[VTIME] = 0;
    if (ioctl(0, TCSETAF, &newtty) == -1) {
	printf("cannot put tty into raw mode\n");
	error_end(1);
    }
    ioctl(0, TCGETA, &Rawtty);

    /*
     * Get termcap entries and window size.
     */
    tgetent(NULL, termtype);
    cm = tgetstr("cm", 0);
    top_clrtobot = tgetstr("cd", 0);
    cl = tgetstr("cl", 0);
    top_clrtoeol = tgetstr("ce", 0);
    ho = tgetstr("ho", 0);
    md = tgetstr("md", 0);
    mr = tgetstr("mr", 0);
    me = tgetstr("me", 0);
}
Exemple #4
0
int mdx_load( char *filename, MDX_DATA **mdx, PDX_DATA **pdx, int slowDevice, int infloop ) {
if (!self_construct()) {
    /* failed to create class instances */
    return -1;
  }

	pdx_pathname        = (char *)NULL;
	no_pdx              = FLAG_FALSE;
	no_fm               = FLAG_FALSE;
	no_opl3             = FLAG_TRUE;
	no_ym2151           = FLAG_FALSE;
	no_fm_voice         = FLAG_FALSE;
	fm_waveform         = 0;
	pcm_volume          = 127;
	fm_volume           = 127;
	volume              = 127;
	is_output_to_stdout = FLAG_FALSE;
	max_infinite_loops  = (infloop==1?10:1); 
	fade_out_speed      = 5;
	dump_voice          = FLAG_FALSE;
	output_titles       = FLAG_FALSE;
	is_use_reverb       = (slowDevice?FLAG_FALSE:FLAG_TRUE);
	reverb_predelay     = 0.05f;
	reverb_roomsize     = 0.5f;
	reverb_damp         = 0.1f;
	reverb_width        = 0.8f;
	reverb_wet          = 0.2f;
	reverb_dry          = 0.5f;
	
	dsp_device          = (char *)NULL;
	is_use_fragment     = FLAG_TRUE;
	
	is_output_to_stdout_in_wav = FLAG_TRUE;
	

    /* load mdx file */

    *mdx = mdx_open_mdx( filename );
    if ( (*mdx) == NULL ) error_end(_("file not found"));
	
	(*mdx)->slowDevice = slowDevice;

    (*mdx)->is_use_pcm8         = no_pdx      == FLAG_TRUE ? FLAG_FALSE:FLAG_TRUE;
    (*mdx)->is_use_fm           = no_fm       == FLAG_TRUE ? FLAG_FALSE:FLAG_TRUE;
    (*mdx)->is_use_opl3         = no_opl3     == FLAG_TRUE ? FLAG_FALSE:FLAG_TRUE;
    (*mdx)->is_use_ym2151       = no_ym2151   == FLAG_TRUE ? FLAG_FALSE:FLAG_TRUE;
    (*mdx)->is_use_fm_voice     = no_fm_voice == FLAG_TRUE ? FLAG_FALSE:FLAG_TRUE;
    (*mdx)->fm_wave_form        = fm_waveform;
    (*mdx)->master_volume       = volume;
    (*mdx)->fm_volume           = fm_volume  * volume/127;
    (*mdx)->pcm_volume          = pcm_volume * volume/127;
    (*mdx)->max_infinite_loops  = max_infinite_loops;
    (*mdx)->fade_out_speed      = fade_out_speed;

    (*mdx)->is_output_to_stdout = is_output_to_stdout; 
    (*mdx)->is_use_fragment     = is_use_fragment;
    (*mdx)->dsp_device          = dsp_device;
    (*mdx)->dump_voice          = dump_voice;
    (*mdx)->is_output_titles    = output_titles;

    (*mdx)->is_use_reverb       = is_use_reverb;
    (*mdx)->reverb_predelay     = reverb_predelay;
    (*mdx)->reverb_roomsize     = reverb_roomsize;
    (*mdx)->reverb_damp         = reverb_damp;
    (*mdx)->reverb_width        = reverb_width;
    (*mdx)->reverb_dry          = reverb_dry;
    (*mdx)->reverb_wet          = reverb_wet;

    (*mdx)->is_output_to_stdout_in_wav = is_output_to_stdout_in_wav; 

    /* voice data load */

    if ( mdx_get_voice_parameter( *mdx ) == 0 ) {
		/* load pdx data */
		*pdx = _get_pdx(*mdx, filename);
    } else {
		self_destroy();
		return -1;
	}
	
	return 0;
}