Esempio n. 1
0
void setup()
{
#ifdef DEBUG_FS
    Serial.begin(115200);
#endif
    if (init_fs()) {
#ifdef DEBUG_FS
        Serial.println("Error initialising filesystem");
#endif
        return;
    }

    random_init();
    sound_setup();

    /* set the pins and pull them up */
    pinMode(INPUT0_PIN, INPUT);
    digitalWrite(INPUT0_PIN, HIGH);
    pinMode(INPUT1_PIN, INPUT);
    digitalWrite(INPUT1_PIN, HIGH);
    pinMode(INPUT2_PIN, INPUT);
    digitalWrite(INPUT2_PIN, HIGH);
    pinMode(INPUT3_PIN, INPUT);
    digitalWrite(INPUT3_PIN, HIGH);
    /* input4 is analog because we ran out of pins */

    pinMode(LED0_PIN, OUTPUT);
    pinMode(LED1_PIN, OUTPUT);
    pinMode(LED2_PIN, OUTPUT);
#ifndef DEBUG_FS
    /* pins 0 and 1 are used for serial debugging */
    pinMode(LED3_PIN, OUTPUT);
    pinMode(LED4_PIN, OUTPUT);
#endif
}
Esempio n. 2
0
static int general_setup(void)
{
	int i;

	maths_setup();
	config_setup();

	screen_w = cfgnum("screen.width", 800);
	screen_h = cfgnum("screen.height", 600);
	if (cfgnum("fullscreen", 0) == 1)
		displayflags |= SDL_FULLSCREEN;

	sprite_global.opt_alpha = cfgnum("alpha", 0);

	i = SDL_Init(SDL_INITFLAGS);
	assert(i == 0);

	atexit(atexit_cleanup);

	SDL_WM_SetCaption(VERSIONSTRING, 0);

	sprite_global.display = SDL_SetVideoMode(screen_w, screen_h, 0, displayflags);
	assert(sprite_global.display);
	SDL_ShowCursor(SDL_DISABLE);

	if (cfgnum("sound", 0) == 1)
	{
		sound_setup();
		/* place the ear on the ground, in the center */
		sound_move_ear(screen_w / 2, screen_h);
	}
	sprite_setup();
	text_setup();
	console_setup();
	console_set_pos(9, 254);
	console_load_bg(path_to_data("console-bg.png"));
	sprite_types_setup();

	char bg1[255];
	char bg2[255];
	sprintf(bg1,"data/bg%d.png",screen_w);
	sprintf(bg2,"data/bgmask%d.png",screen_w);

	sprite_background_load(bg1, bg2);

	level_setup();
	winds_setup();

	return 0;
}
Esempio n. 3
0
/* Initilaise sound subsystem */
static int do_init(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
{
	struct udevice *dev;
	int ret;

	ret = uclass_first_device_err(UCLASS_SOUND, &dev);
	if (!ret)
		ret = sound_setup(dev);
	if (ret) {
		printf("Initialise Audio driver failed (ret=%d)\n", ret);
		return CMD_RET_FAILURE;
	}

	return 0;
}
Esempio n. 4
0
int main(int argc, char **argv) {
  pthread_t thread_psmove, thread_game, thread_usb;
  sound_setup();
  psmove = psmove_setup(NULL);

  memset(&game, 0, sizeof(game));
  game.state = IDLE;
  game.jostle_reference = 300;
  
  if (pthread_create(&thread_psmove, NULL, psmove_updater, NULL) < 0)
    fatal("psmove thread");
  if (pthread_create(&thread_game, NULL, game_runner, NULL) < 0)
    fatal("game thread");
  if (pthread_create(&thread_usb, NULL, usb_scanner , NULL) < 0)
    fatal("usb thread");
  pthread_join(thread_psmove, NULL);
  pthread_join(thread_game, NULL);
}
Esempio n. 5
0
int
init_module (void)
{
  int             err;
  int             ints[21];
  int             i;

  if (connect_wrapper (WRAPPER_VERSION) < 0)
    {
      printk ("Sound: Incompatible kernel (wrapper) version\n");
      return -EINVAL;
    }

  /*
     * "sound=" command line handling by Harald Milz.
   */
  i = 0;
  while (i < 20 && sound[i])
    ints[i + 1] = sound[i++];
  ints[0] = i;

  if (i)
    sound_setup ("sound=", ints);

  err = module_register_chrdev (sound_major, "sound", &sound_fops);
  if (err)
    {
      printk ("sound: driver already loaded/included in kernel\n");
      return err;
    }

  chrdev_registered = 1;
  soundcard_init ();

  if (sound_nblocks >= 1024)
    printk ("Sound warning: Deallocation table was too small.\n");

  return 0;
}
Esempio n. 6
0
File: main.c Progetto: filur/dracsgh
int main(int argc, char** argv)
{
	SDL_Event ev;
	
	int quit = 0;
	int sleepCycle[] = {16, 17, 17};
	int sleepNth = 0;
	int sleepTotal = 0;
	int frameStart = 0;
	int frameEnd = 0;
	int frameDelta = 0;
	// int fps = 0, fpsreport = 0;
	
	nthlevel = 0;
	newlevelpause = 1;
	
	SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
	TTF_Init();
	
	sound_setup();
	sound_set_song(2);
	
	sfx_player_jump = sound_synth_get(0);
	sfx_player_jump->waveform = SYNTH_SQUARE;
	sfx_player_jump->length = 100;
	sfx_player_jump->amp_start = 0.3;
	sfx_player_jump->amp_end = 0.2;
	sfx_player_jump->freq_start = 300;
	sfx_player_jump->freq_end = 500;
	
	sfx_player_scare = sound_synth_get(1);
	sfx_player_scare->waveform = SYNTH_NOISE;
	sfx_player_scare->length = 320;
	sfx_player_scare->amp_start = 0.1;
	sfx_player_scare->amp_end = 0.1;
	sfx_player_scare->freq_start = 3200;
	sfx_player_scare->freq_end = 4800;
	
	sfx_player_scare2 = sound_synth_get(2);
	sfx_player_scare2->waveform = SYNTH_SQUARE;
	sfx_player_scare2->length = 320;
	sfx_player_scare2->amp_start = 0.15;
	sfx_player_scare2->amp_end = 0.0;
	sfx_player_scare2->freq_start = 1200;
	sfx_player_scare2->freq_end = 1550;
	
	sfx_clear_goat1 = sound_synth_get(3);
	sfx_clear_goat1->waveform = SYNTH_SQUARE;
	sfx_clear_goat1->length = 50;
	sfx_clear_goat1->amp_start = 0.3;
	sfx_clear_goat1->amp_end = 0.3;
	sfx_clear_goat1->freq_start = 450;
	sfx_clear_goat1->freq_end = 450;
	
	sfx_clear_goat2 = sound_synth_get(4);
	sfx_clear_goat2->waveform = SYNTH_SQUARE;
	sfx_clear_goat2->length = 50;
	sfx_clear_goat2->delay = 50;
	sfx_clear_goat2->amp_start = 0.3;
	sfx_clear_goat2->amp_end = 0.3;
	sfx_clear_goat2->freq_start = 1250;
	sfx_clear_goat2->freq_end = 1250;
	
	sfx_hurting = sound_synth_get(5);
	sfx_hurting->waveform = SYNTH_SQUARE;
	sfx_hurting->length = 180;
	sfx_hurting->delay = 0;
	sfx_hurting->amp_start = 0.3;
	sfx_hurting->amp_end = 0;
	sfx_hurting->freq_start = 1000;
	sfx_hurting->freq_end = 2;
	
	sfx_c4 = sound_synth_get(6);
	sfx_c4->waveform = SYNTH_SQUARE;
	sfx_c4->length = 180;
	sfx_c4->delay = 0;
	sfx_c4->amp_start = 0.3;
	sfx_c4->amp_end = 0.1;
	sfx_c4->freq_start = 261.626;
	sfx_c4->freq_end = 261.626;
	
	sfx_f4 = sound_synth_get(7);
	sfx_f4->waveform = SYNTH_SQUARE;
	sfx_f4->length = 180;
	sfx_f4->delay = 0;
	sfx_f4->amp_start = 0.3;
	sfx_f4->amp_end = 0.1;
	sfx_f4->freq_start = 349.228;
	sfx_f4->freq_end = 349.228;
	
	level = 0;
	gravity = 0.8;
	
	framefn = &_introfn;
	memset(&controls, 0, sizeof(Controls));
	memset(&player, 0, sizeof(Player));
	
	player.hearts = 10;
	
	player.rect.w = 48;
	player.rect.h = 64;
	
	// level_place_player();
	
	player.spriterect.x = 192;
	player.spriterect.y = 0;
	player.spriterect.w = 48;
	player.spriterect.h = 64;
	
	font = TTF_OpenFont("Vera.ttf", 16);
	screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE);
	
	load_sprites();
	
	mygoats = (Goat**) malloc(sizeof(Goat*) * 16);
	memset(mygoats, 0, sizeof(Goat*) * 16);
	
	// mygoats[0] = goat_create(100, 10);
	// mygoats[1] = goat_create(300, 10);
	// mygoats[2] = goat_create(500, 10);
	
	myslimes = (Slime**) malloc(sizeof(Slime*) * 16);
	memset(myslimes, 0, sizeof(Slime*) * 16);
	
	// myslimes[0] = slime_create(400, 10, 1);
	// myslimes[0]->controls.left = 1;
	
	// fpsreport = SDL_GetTicks() + 1000;
	
	while (!quit)
	{
		frameDelta = SDL_GetTicks() - frameStart;
		frameStart = SDL_GetTicks();
		
		framefn(frameDelta);
		
		while (SDL_PollEvent(&ev))
		{
			switch (ev.type)
			{
				case SDL_KEYDOWN:
					switch (ev.key.keysym.sym)
					{
						case SDLK_LEFT:
							controls.left = 1;
							break;
						
						case SDLK_RIGHT:
							controls.right = 1;
							break;
						
						case SDLK_UP:
							// controls.up = 1;
							controls.button1 = 1;
							break;
						
						case SDLK_DOWN:
							controls.down = 1;
							break;
						
						case SDLK_z:
						case SDLK_SPACE:
							controls.button1 = 1;
							break;
						
						case SDLK_x:
						case SDLK_LCTRL:
							controls.button2 = 1;
							break;
						
						default:
							break;
					}
					
					break;
				
				case SDL_KEYUP:
					switch (ev.key.keysym.sym)
					{
						case SDLK_LEFT:
							controls.left = 0;
							break;
						
						case SDLK_RIGHT:
							controls.right = 0;
							break;
						
						case SDLK_UP:
							// controls.up = 0;
							controls.button1 = 0;
							break;
						
						case SDLK_DOWN:
							controls.down = 0;
							break;
						
						case SDLK_z:
						case SDLK_SPACE:
							controls.button1 = 0;
							break;
						
						case SDLK_x:
						case SDLK_LCTRL:
							controls.button2 = 0;
							break;
						
						default:
							break;
					}
					
					break;
				
				case SDL_QUIT:
					quit = 1;
					break;
				
				default:
					break;
			}
		}
		
		// ++fps;
		
		frameEnd = SDL_GetTicks();
		
		// if (fpsreport <= frameEnd)
		// {
			// printf("%d fps\n", fps);
			// fps = 0;
			// fpsreport += 1000;
		// }
		
		if (sleepCycle[sleepNth] - (frameEnd - frameStart) > 0)
		{
			SDL_Delay(sleepCycle[sleepNth] - (frameEnd - frameStart));
		}
		
		if (++sleepNth > 2)
		{
			sleepNth = 0;
		}
	}
	
	sound_quit();
	TTF_CloseFont(font);
	TTF_Quit();
	SDL_Quit();
	
	return EXIT_SUCCESS;
}
Esempio n. 7
0
int main(int argc, char *argv[])
{
    int     wpm  = WPM;
    int     freq = FREQ;
    int     rate = RATE;
    int     ampl = AMPL;
    int     atta = ATTA;
    int     deca = DECA;

    /* Get any optional command line args (start with -) */
    while (argc > 1 && *argv[1] == '-') {
        if (!strcmp(argv[1], "-w")) { 
            wpm = atoi(argv[2]); 
        }
        if (!strcmp(argv[1], "-o")) {
            if (!strcmp(argv[2], "alsa"))
                outp = ALSA;
            else if (!strcmp(argv[2], "dsp"))
                outp = DSP;
            else if (!strcmp(argv[2], "alsa"))
                outp = STDOUT;
            else
                outp = 0;
        }
        if (!strcmp(argv[1], "-f")) { 
            freq = atoi(argv[2]); 
        }
        if (!strcmp(argv[1], "-r")) { 
            rate = atoi(argv[2]); 
        }
        if (!strcmp(argv[1], "-a")) { 
            ampl = atoi(argv[2]); 
        }
        if (!strcmp(argv[1], "-da")) { 
            atta = atoi(argv[2]); 
        }
        if (!strcmp(argv[1], "-dd")) { 
            deca = atoi(argv[2]); 
        }
        if (!strcmp(argv[1], "-h")) { 
            fprintf(stderr, usage, MAXTONES);
            return -1;
        }
        if (!strcmp(argv[1], "-v")) { 
            verbose = 1; 
            ++argc;     /* Offset for lack of value */
            --argv;     /* Needs to be last test!   */
        }
        argc -= 2;
        argv += 2;
    }

    /* Make sure we have more following */
    if (!(argc > 1)) {
        fprintf(stderr, "No text given\n");
        return -1;
    }

    /* Sanity check of values */
    if (wpm < MINWPM || wpm > MAXWPM) {
        fprintf(stderr, "Support %d to %d word per minute range\n",
                MINWPM, MAXWPM);
        return -1;
    }
    if (outp < 1) {
        fprintf(stderr, "Output format needs to be alsa, dsp, or stdout\n");
        return -1;
    }
    if (rate < 2 * freq) {
        fprintf(stderr, "Sample rate must be more then twice the frequency\n");
        return -1;
    }
    if (freq < MINFREQ || freq > MAXFREQ) {
        fprintf(stderr, "Support %d to %d Hz frequency range\n",
                MINFREQ, MAXFREQ);
        return -1;
    }
    if (rate < MINRATE || rate > MAXRATE) {
        fprintf(stderr, "Support %d to %d samples per second\n",
                MINRATE, MAXRATE);
        return -1;
    }
    if (ampl < MINAMPL || ampl > MAXAMPL) {
        fprintf(stderr, "Support %d to %d amplitude\n", MINAMPL, MAXAMPL);
        return -1;
    }

    /* Generate waveforms */
    if (mktones(wpm, freq, rate, ampl, atta, deca)) {
        return -1;
    }

    /* Setup DSP device */
    sound_open(outp);
    sound_setup(rate, outp);

    if (verbose) fprintf(stderr, "Morse code: "); 

    /* Disect remaining argv into letters */
    while (argc > 1) {
        text2code(argv[1]);
        argc--;
        argv++;
    }

    if (verbose) fprintf(stderr, "\n"); 

    /* Exit clean */
    free(ditbf);
    free(dahbf);
    free(sgapbf);
    free(lgapbf);
    sound_close(outp);
    return 0;
}