void play_song( unsigned int song_num )
{
	if (song_num != song_playing)
	{
		load_song(song_num);
		song_playing = song_num;
	}
	
	music_stopped = false;
}
Example #2
0
int main() {
	while(1) {
		while (*key2 == 0) {
			printf("Key2 press awknowledged.\n");
			av_config_setup();
			load_song();
			while (*key2 == 0) {}
		}
	}
	return 0;
}
Example #3
0
/** process any queued events */
void
Lash::process ( void )
{
    lash_event_t *e;

    char *name;

    while ( ( e = lash_get_event( _client ) ) )
    {
        asprintf( &name, "%s/%s", lash_event_get_string( e ), "song.non" );

        const int t = lash_event_get_type ( e );

        switch ( t )
        {
            case LASH_Save_File:
            {
                MESSAGE( "LASH wants us to save \"%s\"", name );

                save_song( name );

                lash_send_event( _client, lash_event_new_with_type( LASH_Save_File ) );

                break;

            }
            case LASH_Restore_File:
            {
                MESSAGE( "LASH wants us to load \"%s\"", name );

                if ( ! load_song( name ) )
                    /* FIXME: should we tell lash that we couldn't load the song? */;

                lash_send_event( _client, lash_event_new_with_type( LASH_Restore_File ) );

                break;
            }
            case LASH_Quit:
                MESSAGE( "LASH wants us to quit" );
                quit();
                break;
            default:
                WARNING( "unhandled LASH event (%d)", t );
        }

        lash_event_destroy( e );
    }
}
Example #4
0
/**
* Runs the main part of the program.  Note it is an infinite loop.
* @author Group B1
* @date 12/4/2012
*/
void run_robot(oi_t *oi) 
{
	int x = STARTING_X_POS;
	int y = STARTING_Y_POS;
	int o = STARTING_ORENTATION;
	int msg = 0;
	while(1){

			char c = read_one_char(); 
			oi_update(oi);
			printf("11 %d\n", oi->virtual_wall);
			lprintf("\n      Group B1\n\n\n\n");
			lprintf("%d %d %d %d\n%d", oi->cliff_left_signal  , oi->cliff_frontleft_signal  , oi->cliff_frontright_signal  , oi->cliff_right_signal, oi->virtual_wall );
			if(	oi->cliff_left_signal > 1000 && oi->cliff_frontleft_signal > 1000 && oi->cliff_frontright_signal > 1000 && oi->cliff_right_signal > 1000 ){
				printf("10\n");
			}
			if(c == FORWARD)
			{	
				if(move_forward(oi, DEFAULT_DISTANCE) >= DEFAULT_DISTANCE){
					if(o == NORTH){
						y = y + 1 * STEP;
					}
					else if(o == EAST){
						x = x + 1 * STEP;
					}
					else if(o == SOUTH){
						y = y - 1 * STEP;
					}
					else if(o == WEST){
						x = x - 1 * STEP;
					}
					printf("2 %d %d %d %d\n", x,y,o,msg);
				}				
			}
			else if(c == RIGHT_TURN)
			{
				turn_clockwise();
				if(o == NORTH){
					o = WEST;
				}
				else if(o == EAST){
					o = NORTH;
				}
				else if(o == SOUTH){
					o = EAST;
				}
				else if(o == WEST){
					o = SOUTH;
				}
				printf("2 %d %d %d %d\n", x,y,o,msg);
			}
			else if(c == LEFT_TURN)
			{
				
				turn_counter_clockwise();
				if(o == NORTH){
					o = EAST;
				}
				else if(o == EAST){
					o = SOUTH;
				}
				else if(o == SOUTH){
					o = WEST;
				}
				else if(o == WEST){
					o = NORTH;
				}
				printf("2 %d %d %d %d\n", x,y,o,msg);

									
			}
			else if(c == RESET)
			{
				move_servo(0);
				x = STARTING_X_POS;
				y = STARTING_Y_POS;
				o = STARTING_ORENTATION;
				msg = 0;
				printf("2 %d %d %d %d\n", x,y,o,msg);
			}
			else if(c == MUSIC)
			{
				load_song();
				oi_play_song(JAWS);
			}
			else if(c == SCAN)
			{
				oi_update(oi);
				printf("1 %d %d %d %d %d ", oi->virtual_wall ,x,y,o,msg);
				for(int i = 0 ; i <= 1800 ;i = i + 1)
				{
					move_servo(i * 1);
					int x = ir_distance();
					printf("%d ", x);
				}
				printf("\n");
				move_servo(0);
			}				
	}
}
Example #5
0
File: bb.c Project: stroucki/bb
int bb(void)
{
    aa_gotoxy(context, 0, 0);
    introscreen();
    params = aa_getrenderparams();
    aa_render(context, params, 0, 0, 1, 1);
    font = uncompressfont( /*context->params.font */ &aa_font16);
    scenetimer = tl_create_timer();
    srand(time(NULL));
    if (stage != 1)
	finish_stuff = 1;
    do
	switch (stage) {
	default:
	case 1:
	    load_song("bb.s3m");
	    bbupdate();
	    starttime = endtime = TIME;

	    scene1();
	    scene3();
	    if (quitnow)
		goto quit;
	    vezen(&fk1, &fk2, &fk3, &fk4);
	    messager("FILIP KUPSA known as FK, Tingle Notions, Dawn Music\n"
		"birth: June 22 1979, Tabor, Czech Republic, sex: male\n"
		     "\n"
	     "1992 - Changed his piano for 386/mp.com/pc-speaker music\n"
		     "1993 - Got his first Sound Blaster\n"
		     "1995 - Changed his SB for a new GUS technology\n"
		     "1996 - Composed his first great hits\n"
		     "1996 - FAT recomposition made by Windows 95\n"
		     "1997 - Released his musac in BB\n"
		     "\n"
		     "1998 - Got retired\n"
		     "\n"
		     "Contact address: via KT");
	    devezen2();
	    scene4();
	    scene2();
	    if (quitnow)
		goto quit;
	    vezen(&ms1, &ms2, &ms3, &ms4);
	    messager("MOJMIR SVOBODA known as MS, TiTania, MSS, Bill\n"
		     "birth: ??, Tabor, Czech Republic, sex: ? male ?\n"
		     "\n"
		     "1993 - Installed Linux on his 386sx/25 + 40MB HDD\n"
		     "1994 - Removed Linux to make space for Doom\n"
		   "1995 - Reinstalled Linux on his 486Dx4/120 + 850MB\n"
		     "1996 - Removed Linux to make space for Windows 95\n"
		     "\n"
		     "1997 - Removed Windows 95 to make space for aalib\n"
		     "\n"
		     "Contact address: [email protected]");
	    devezen3();
	    scene8();
	    scene6();
	case 2:
	    if (quitnow)
		goto quit;
	    vezen(&kt1, &kt2, &kt3, &kt4);
	    messager("KAMIL TOMAN known as KT, Kato, Whale, Bart\n"
		 "birth: May 19 1979, Tabor, Czech Republic, sex: male\n"
		     "\n"
		     "1993 - Became a linux extremist\n"
		     "1993 - Successful attempt to establish a secret organization\n"
		     "       Commandline Brotherhood\n"
		     "1995 - Action 'koules' - a secret project to train brotherhood\n"
		     "       members - covered under a game design\n"
		     "\n"
		 "1998 - Heading a new wave of command line revolution\n"
		     "\n"
		     "Contact address: [email protected]");
	    bbupdate();
	    starttime = endtime = TIME;
	    devezen1();
	    if (quitnow)
		goto quit;
	    scene7();
	    if (quitnow)
		goto quit;
	    scene5();
	    if (quitnow)
		goto quit;
	    scene10();
	    vezen(&hh1, &hh2, &hh3, &hh4);
	    messager("JAN HUBICKA known as HH, Jahusoft, HuJaSoft, JHS, UNIX, Honza\n"
		  "birth: Apr 1 1978, Tabor, Czech Republic, sex: male\n"
		     "\n"
		     "1991 - Installed underground hackers OS Linux\n"
		     "1995 - Headed Action 'koules'\n"
		     "1996 - Famous troan XaoS to convert all windows instalations\n"
		     "       into Linux\n"
		     "\n"
		     "1998 - Secret plan to make `Text Windows` system to confuse users\n"
		 "2001 - Planning an assassination of dictator Bill G.\n"
		     "\n"
		     "Contact address: [email protected]");
	    devezen4();
	    if (quitnow)
		goto quit;
	    credits();
	    if (quitnow)
		goto quit;
	case 3:
	    if (loopmode)
		break;
	    credits2();
	}
    while (loopmode);
  quit:;
    aa_close(context);
    return (0);
}
Example #6
0
int
main ( int argc, char **argv )
{

    printf( "%s %s %s -- %s\n", APP_TITLE, VERSION, "", COPYRIGHT );

    if ( ! Fl::visual( FL_DOUBLE | FL_RGB ) )
    {
        WARNING( "Xdbe not supported, FLTK will fake double buffering." );
    }

    ::signal( SIGTERM, sigterm_handler );
    ::signal( SIGHUP, sigterm_handler );
    ::signal( SIGINT, sigterm_handler );

    config.follow_playhead = true;
    config.record_mode = MERGE;
    song.play_mode = PATTERN;
    song.random.feel = 8;
    song.random.probability = 0.33;

    asprintf( &config.user_config_dir, "%s/%s", getenv( "HOME" ), USER_CONFIG_DIR );
    mkdir( config.user_config_dir, 0777 );

    playlist = new sequence;

    pattern_c = new Canvas;
    phrase_c = new Canvas;
    trigger_c = new Canvas;

    nsm = new NSM_Client;

    song.filename = NULL;
    clear_song();

    pattern::signal_create_destroy.connect( mem_fun( phrase_c,  &Canvas::v_zoom_fit ) );
    pattern::signal_create_destroy.connect( mem_fun( song, &song_settings::set_dirty ) );
    phrase::signal_create_destroy.connect( mem_fun( song, &song_settings::set_dirty ) );

    //
    song.dirty( false );

    init_colors();

    ui = new UI;

    ui->main_window->show( 0, 0 );

    instance_name = strdup( APP_NAME );

    const char *nsm_url = getenv( "NSM_URL" );
    
    if ( nsm_url )
    {
        if ( ! nsm->init( nsm_url ) )
        {
            nsm->announce( APP_NAME, ":switch:dirty:", argv[0] );

            song.signal_dirty.connect( sigc::mem_fun( nsm, &NSM_Client::is_dirty ) );
            song.signal_clean.connect( sigc::mem_fun( nsm, &NSM_Client::is_clean ) );

            // poll so we can keep OSC handlers running in the GUI thread and avoid extra sync
            Fl::add_timeout( NSM_CHECK_INTERVAL, check_nsm, NULL );
        }       
        else
            WARNING( "Error initializing NSM" );
    }
    else
    {
        setup_jack();
        if ( argc > 1 )
        {
            /* maybe a filename on the commandline */
            if ( ! load_song( argv[ 1 ] ) )
                ASSERTION( "Could not load song \"%s\" specified on command line", argv[ 1 ] );
        }
    }

    MESSAGE( "Initializing GUI" );

    Fl::add_check( check_sigterm );

    ui->load_settings();
    ui->run();

    return 0;
}
Example #7
0
void credits2(void)
{
    int i, ch;
    int p;
    int plast = -1;
    clrscr();

    centerprint(aa_imgwidth(context) / 2, aa_imgheight(context) / 3, 3, 128, "The", 0);
    centerprint(aa_imgwidth(context) / 2, 2 * aa_imgheight(context) / 3, 3, 128, "END", 0);
    drawptr = decrand;
    params->randomval = 50;
    timestuff(0, NULL, draw, 5000000);
    drawptr = NULL;
    params->randomval = 0;
    drawptr = pryc;
    timestuff(0, NULL, draw, MAXTIME);
    drawptr = NULL;
    clrscr();
    draw();
    load_song("bb3.s3m");
    bbupdate();
    starttime = endtime = TIME;
    play();
    bbwait(1);
    for (i = 0; i < LOGOHEIGHT; i++) {
	aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i, AA_BOLD, "8  8");
	if (i)
	    aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i - 1, AA_NORMAL, "8  8");
	bbflushwait(100000);
    }
    aa_puts(context, aa_scrwidth(context) / 2 - 2, LOGOY + i - 1, AA_NORMAL, "8  8");

#define LWIDTH

    for (i = aa_scrwidth(context) / 2; i; i--) {
	display8();
	displaya(i);
	bbflushwait(10000);
    }
    for (; i < 100; i++) {
	textclrscr();
	displaya(10 * sin(i * M_PI / 100));
	display8();
	bbflushwait(10000);
    }
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_DIM, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_NORMAL, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_BOLD, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    aa_puts(context, aa_scrwidth(context) / 2 - 9, LOGOY + 3, AA_NORMAL, "<PROJECT><PROJECT>");
    bbflushwait(100000);
    bbwait(1000000);
    for (i = LOGOY; i > 1; i--) {
	textclrscr();
	displogo(i);
	bbflushwait(30000);
    }

    source = malloc(aa_imgwidth(context) * (aa_imgheight(context)));
    target = malloc(aa_imgwidth(context) * (aa_imgheight(context)));
    params->dither = AA_NONE;
    format(dual ? aa_scrwidth(context) / 2 : aa_scrwidth(context));
    p = 0;
    while (1) {
	if (p != plast) {
	    getsource();
	    displaytext(p);
	    gettarget();
	    morph();
	    displaytext(p);
	    aa_flush(context);
        emscripten_sleep(1);
	    plast = p;
	}
      again:
    emscripten_sleep(100);
#ifndef __DJGPP__
	//ch = aa_getkey(context, 100);
    ch = AA_NONE;
#else
	while ((ch = bbupdate()) == AA_NONE) ;
#endif

	switch (ch) {
	case '1':
	    load_song("bb.s3m");
	    bbupdate();
	    play();
	    break;
	case '2':
	    load_song("bb2.s3m");
	    bbupdate();
	    play();
	    break;
	case '3':
	    load_song("bb3.s3m");
	    bbupdate();
	    play();
	    break;

	case 'b':
	case 'k':
	case 'B':
	case 'K':
	case AA_BACKSPACE:
	case AA_UP:
	    p -= (aa_scrheight(context) - YSTART) / 2 * (dual + 1);
	    if (p < 0)
		p = 0;
	    break;
	case AA_DOWN:
	case AA_LEFT:
	case 'f':
	case 'F':
	case ' ':
	case 'j':
	case 'J':
	    p += (aa_scrheight(context) - YSTART) / 2 * (dual + 1);
	    if (p > textsize)
		p = textsize;
	    break;
	case 'q':
	case 'Q':
	case AA_ESC:
	    finish_stuff = 0;
	    backconvert(0, 0, aa_scrwidth(context), aa_scrheight(context));
	    bbupdate();
	    starttime = endtime = TIME;
	    drawptr = decbright;
	    timestuff(0, NULL, draw, 1000000);
	    textclrscr();
	    drawptr = NULL;
	    aa_flush(context);
        emscripten_sleep(1);
	    free(source);
	    free(target);
	    return;
	default:
	    goto again;
	}
	bbupdate();
	starttime = endtime = TIME;
    }
}