static void driveclick_close(void) { driveclick_fdrawcmd_close (0); driveclick_fdrawcmd_close (1); for (int i = 0; i < 4; i++) { for (int j = 0; j < DS_END; j++) freesample (&drvs[i][j]); } memset (drvs, 0, sizeof (drvs)); click_initialized = 0; wave_initialized = 0; driveclick_reset (); }
void driveclick_init (void) { int v, vv, i, j; char tmp[1000]; driveclick_free (); vv = 0; for (i = 0; i < 4; i++) { if (currprefs.dfxclick[i]) { /* TODO: Implement location of sample data */ #if 0 if (currprefs.dfxclick[i] > 0) { v = 0; if (driveclick_loadresource (drvs[i], currprefs.dfxclick[i])) v = 3; } else if (currprefs.dfxclick[i] == -1) { sprintf (tmp, "%suae_data%cdrive_click_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); v = loadsample (tmp, &drvs[i][DS_CLICK]); sprintf (tmp, "%suae_data%cdrive_spin_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); v += loadsample (tmp, &drvs[i][DS_SPIN]); sprintf (tmp, "%suae_data%cdrive_spinnd_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); v += loadsample (tmp, &drvs[i][DS_SPINND]); sprintf (tmp, "%suae_data%cdrive_startup_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); v += loadsample (tmp, &drvs[i][DS_START]); sprintf (tmp, "%suae_data%cdrive_snatch_%s", start_path, FSDB_DIR_SEPARATOR, currprefs.dfxclickexternal[i]); v += loadsample (tmp, &drvs[i][DS_SNATCH]); } if (v == 0) { int j; for (j = 0; j < DS_END; j++) freesample (&drvs[i][j]); currprefs.dfxclick[i] = changed_prefs.dfxclick[i] = 0; } for (j = 0; j < DS_END; j++) drvs[i][j].len <<= DS_SHIFT; drvs[i][DS_CLICK].pos = drvs[i][DS_CLICK].len; drvs[i][DS_SNATCH].pos = drvs[i][DS_SNATCH].len; vv += currprefs.dfxclick[i]; #endif } } if (vv > 0) { driveclick_reset (); click_initialized = 1; } }
void driveclick_free (void) { int i, j; driveclick_fdrawcmd_close (0); driveclick_fdrawcmd_close (1); for (i = 0; i < 4; i++) { for (j = 0; j < DS_END; j++) freesample (&drvs[i][j]); drv_starting[i] = 0; drv_spinning[i] = 0; drv_has_spun[i] = 0; drv_has_disk[i] = 0; } memset (drvs, 0, sizeof (drvs)); click_initialized = 0; wave_initialized = 0; driveclick_reset (); }
int init_sound (void) { write_log("init_sound\n"); gui_data.sndbuf_status = 3; gui_data.sndbuf = 0; if (!sound_available) return 0; if (currprefs.produce_sound <= 1) return 0; if (have_sound) return 1; if (!open_sound ()) return 0; //sdp->paused = 1; #ifdef DRIVESOUND driveclick_reset (); #endif //reset_sound (); //resume_sound (); return 1; }
int init_sound(void) { write_log("init_sound\n"); gui_data.sndbuf_status = 3; gui_data.sndbuf = 0; if (!sound_available) return 0; if (currprefs.produce_sound <= 1) return 0; if (have_sound) return 1; in_callback = 0; closing_sound = 0; init_sound_thread (); write_comm_pipe_int (&to_sound_pipe, 0, 1); uae_sem_wait (&sound_init_sem); // SDL_PauseAudio (0); #ifdef DRIVESOUND driveclick_reset (); #endif return have_sound; }
void driveclick_init (void) { int v, vv; TCHAR tmp[MAX_DPATH]; #ifdef FSUAE write_log("driveclick_init\n"); #endif driveclick_fdrawcmd_detect (); driveclick_close(); vv = 0; for (int i = 0; i < 4; i++) { struct floppyslot *fs = &currprefs.floppyslots[i]; for (int j = 0; j < CLICK_TRACKS; j++) { drvs[i][DS_CLICK].indexes[j] = 0; drvs[i][DS_CLICK].lengths[j] = 0; } if (fs->dfxclick) { v = 0; if (fs->dfxclick > 0) { switch(fs->dfxclick) { case 1: if (driveclick_loadresource (drvs[i], fs->dfxclick)) v = 3; for (int j = 0; j < CLICK_TRACKS; j++) drvs[i][DS_CLICK].lengths[j] = drvs[i][DS_CLICK].len; wave_initialized = 1; break; default: if (driveclick_fdrawcmd_open (fs->dfxclick - 2)) v = 1; break; } } else if (fs->dfxclick == -1) { TCHAR path2[MAX_DPATH]; wave_initialized = 1; for (int j = 0; j < CLICK_TRACKS; j++) drvs[i][DS_CLICK].lengths[j] = drvs[i][DS_CLICK].len; get_plugin_path (path2, sizeof path2 / sizeof (TCHAR), _T("floppysounds")); _stprintf (tmp, _T("%sdrive_click_%s"), path2, fs->dfxclickexternal); v = loadsample (tmp, &drvs[i][DS_CLICK]); if (v) processclicks (&drvs[i][DS_CLICK]); _stprintf (tmp, _T("%sdrive_spin_%s"), path2, fs->dfxclickexternal); v += loadsample (tmp, &drvs[i][DS_SPIN]); _stprintf (tmp, _T("%sdrive_spinnd_%s"), path2, fs->dfxclickexternal); v += loadsample (tmp, &drvs[i][DS_SPINND]); _stprintf (tmp, _T("%sdrive_startup_%s"), path2, fs->dfxclickexternal); v += loadsample (tmp, &drvs[i][DS_START]); _stprintf (tmp, _T("%sdrive_snatch_%s"), path2, fs->dfxclickexternal); v += loadsample (tmp, &drvs[i][DS_SNATCH]); } if (v == 0) { for (int j = 0; j < DS_END; j++) freesample (&drvs[i][j]); fs->dfxclick = changed_prefs.floppyslots[i].dfxclick = 0; } else { vv++; } for (int j = 0; j < DS_END; j++) drvs[i][j].len <<= DS_SHIFT; drvs[i][DS_CLICK].pos = drvs[i][DS_CLICK].len; drvs[i][DS_SNATCH].pos = drvs[i][DS_SNATCH].len; } } if (vv > 0) { click_initialized = 1; } driveclick_reset(); }
void driveclick_init (void) { int v, vv, i, j; TCHAR tmp[MAX_DPATH]; driveclick_fdrawcmd_detect (); driveclick_free (); vv = 0; for (i = 0; i < 4; i++) { for (j = 0; j < CLICK_TRACKS; j++) { drvs[i][DS_CLICK].indexes[j] = 0; drvs[i][DS_CLICK].lengths[j] = 0; } if (currprefs.dfxclick[i]) { if (currprefs.dfxclick[i] > 0) { v = 0; switch(currprefs.dfxclick[i]) { case 1: if (driveclick_loadresource (drvs[i], currprefs.dfxclick[i])) v = 3; for (j = 0; j < CLICK_TRACKS; j++) drvs[i][DS_CLICK].lengths[j] = drvs[i][DS_CLICK].len; wave_initialized = 1; break; default: if (driveclick_fdrawcmd_open (currprefs.dfxclick[i] - 2)) v = 1; break; } } else if (currprefs.dfxclick[i] == -1) { TCHAR path2[MAX_DPATH]; wave_initialized = 1; for (j = 0; j < CLICK_TRACKS; j++) drvs[i][DS_CLICK].lengths[j] = drvs[i][DS_CLICK].len; // _stprintf (tmp, "%splugins%cfloppysounds%c", "./", FSDB_DIR_SEPARATOR, FSDB_DIR_SEPARATOR, FSDB_DIR_SEPARATOR); // if (my_existsdir (tmp)) // _tcscpy (path2, tmp); // else _stprintf (path2, "%suae_data%c", "./", FSDB_DIR_SEPARATOR); _stprintf (tmp, "%sdrive_click_LOUD%s", path2, currprefs.dfxclickexternal[i]); v = loadsample (tmp, &drvs[i][DS_CLICK]); if (v) processclicks (&drvs[i][DS_CLICK]); _stprintf (tmp, "%sdrive_spin_LOUD%s", path2, currprefs.dfxclickexternal[i]); v += loadsample (tmp, &drvs[i][DS_SPIN]); _stprintf (tmp, "%sdrive_spinnd_LOUD%s", path2, currprefs.dfxclickexternal[i]); v += loadsample (tmp, &drvs[i][DS_SPINND]); _stprintf (tmp, "%sdrive_startup_LOUD%s", path2, currprefs.dfxclickexternal[i]); v += loadsample (tmp, &drvs[i][DS_START]); _stprintf (tmp, "%sdrive_snatch_LOUD%s", path2, currprefs.dfxclickexternal[i]); v += loadsample (tmp, &drvs[i][DS_SNATCH]); } if (v == 0) { int j; for (j = 0; j < DS_END; j++) freesample (&drvs[i][j]); currprefs.dfxclick[i] = changed_prefs.dfxclick[i] = 0; } else { vv++; } for (j = 0; j < DS_END; j++) drvs[i][j].len <<= DS_SHIFT; drvs[i][DS_CLICK].pos = drvs[i][DS_CLICK].len; drvs[i][DS_SNATCH].pos = drvs[i][DS_SNATCH].len; } } if (vv > 0) { driveclick_reset (); click_initialized = 1; } }
int32_t init_sound (void) { int32_t tmp; int32_t rate; int32_t dspbits; int32_t bufsize; sound_fd = open ("/dev/dsp", O_WRONLY); have_sound = !(sound_fd < 0); if (! have_sound) { perror ("Can't open /dev/dsp"); if (errno != EBUSY) sound_available = 0; return 0; } if (ioctl (sound_fd, SNDCTL_DSP_GETFMTS, &formats) == -1) { perror ("ioctl failed - can't use sound"); close (sound_fd); have_sound = 0; return 0; } dspbits = 16; ioctl (sound_fd, SNDCTL_DSP_SAMPLESIZE, &dspbits); ioctl (sound_fd, SOUND_PCM_READ_BITS, &dspbits); if (dspbits != 16) { fprintf (stderr, "Can't use sound with %d bits\n", dspbits); return 0; } tmp = currprefs.sound_stereo; ioctl (sound_fd, SNDCTL_DSP_STEREO, &tmp); rate = currprefs.sound_freq; ioctl (sound_fd, SNDCTL_DSP_SPEED, &rate); ioctl (sound_fd, SOUND_PCM_READ_RATE, &rate); /* Some soundcards have a bit of tolerance here. */ if (rate < currprefs.sound_freq * 90 / 100 || rate > currprefs.sound_freq * 110 / 100) { fprintf (stderr, "Can't use sound with desired frequency %d\n", currprefs.sound_freq); return 0; } bufsize = rate * (dspbits / 8) * (currprefs.sound_stereo ? 2 : 1) / 1000; tmp = 0x00040000 + exact_log2 (bufsize); ioctl (sound_fd, SNDCTL_DSP_SETFRAGMENT, &tmp); ioctl (sound_fd, SNDCTL_DSP_GETBLKSIZE, &paula_sndbufsize); obtainedfreq = currprefs.sound_freq; if (!(formats & AFMT_S16_NE)) return 0; sample_handler = currprefs.sound_stereo ? sample16s_handler : sample16_handler; sound_available = 1; printf ("Sound driver found and configured for %d bits at %d Hz, buffer is %d bytes (%d ms).\n", dspbits, rate, paula_sndbufsize, paula_sndbufsize * 1000 / (rate * dspbits / 8 * (currprefs.sound_stereo ? 2 : 1))); paula_sndbufpt = paula_sndbuffer; #ifdef DRIVESOUND driveclick_reset (); #endif return 1; }
int init_sound (void) { /* If setup_sound wasn't called or didn't complete successfully. */ if (!ppb_audio_interface) { write_log("init_sound called, but audio not set up yet.\n"); return 0; } /* If sound is set to none (0) or interrupts (1). */ if (currprefs.produce_sound <= 1) { write_log("init_sound called, but UAE is configured not to produce" " sound.\n"); return 0; } PP_AudioSampleRate sample_rate = ppb_audio_config_interface-> RecommendSampleRate(pp_instance); uint32_t frame_count = ppb_audio_config_interface-> RecommendSampleFrameCount(pp_instance, sample_rate, sample_rate * currprefs.sound_latency / 1000); audio_config = ppb_audio_config_interface-> CreateStereo16Bit(pp_instance, sample_rate, frame_count); if (!audio_config) { write_log("Could not create Pepper audio config.\n"); return 0; } /* Adjust preferences to reflect what the underlying system gave us. */ if (!audio_config_is_ok(audio_config)) { write_log("Pepper AudioConfig failed.\n"); return 0; } adjust_prefs(audio_config); audio_resource = ppb_audio_interface->Create( pp_instance, audio_config, sound_callback, 0 /* user_data */); if (!audio_resource) { write_log("Could not create a Pepper audio resource.\n"); return 0; } paula_sndbufsize = frame_count * 2 /* stereo */ * 2 /* 16-bit */; paula_sndbufpt = paula_sndbuffer = malloc(paula_sndbufsize); paula_sndbuffer_front_buffer = malloc(paula_sndbufsize); memset(paula_sndbuffer_front_buffer, 0, paula_sndbufsize); clear_sound_buffers(); #ifdef DRIVESOUND driveclick_reset(); #endif if (!ppb_audio_interface->StartPlayback(audio_resource)) { write_log("Could not start Pepper audio playback.\n"); return 0; } return 1; }