Пример #1
0
void lynx_common_outp(UWORD port, UBYTE value)
{
  switch(port&0xFF)
  {
    //COMMON OUTPUT PORTS
    case 0x80:                              //common Vid latch property - speaker enable
      speaker_enable=value&0x01;
      if(SoundEnable)update_sound();
        break;
    case 0x84:
      sound_port=value;
      if(SoundEnable)update_sound();
      if((raw_motor==1) && (tape_operation==TAPE_STOPPED))start_tape_record();
      if(tape_operation==TAPE_RECORD)update_tape();
        break;
    case 0x54:
    case 0x55:
    case 0x56:
    case 0x57:
    case 0x58:
      disk_outp(port,value);//Disk ports
      break;
    case 0x86:
      crtc_reg=value;
      break;
    case 0x87:
      CRTC_reg[crtc_reg]=value;
      break;
    case 0x93:
      save_lynx_tap();                //TRAP for SAVE
      break;
  }
//      disk_outp(port,value);//Disk options
}
Пример #2
0
// ---------------------------------------------
// update the active sounds queue
// point is the current central point around
// which the sounds are checked
// ---------------------------------------------
void update_active_sounds( t_level_map_point_2d point, t_adventure_map const& map )
{
 	// look for near by adventure objects to play sounds for
	play_sounds_for_nearby_adventure_objects( point, map );

	t_active_sounds::iterator iter;

	// traverse the list of active sounds and process each
	for( iter = active_sounds.begin(); iter != active_sounds.end(); )
	{
		t_managed_sound * playing_sound = (*iter).get();

		if( playing_sound )
		{ 
			int dist_sq = update_sound( point, playing_sound );

			t_level_map_point_2d const & sound_point = playing_sound->get_position();

			// check for removal
			if( !playing_sound->get_sound_ptr()->is_playing() || 
				point.level != sound_point.level ||
				dist_sq > k_max_sound_dist_sq )
			{
				playing_sound->get_sound_ptr()->stop();
				iter = active_sounds.erase(iter);
				continue;
			} else 
				++iter;
		}
	}
}
Пример #3
0
static int open_sound (void) {
	if (!currprefs.produce_sound)
		return 0;
	config_changed = 1;

	clearbuffer();

    currprefs.sound_stereo = 1;
    //currprefs.sound_freq = fs_emu_get_audio_frequency();
    //changed_prefs.sound_freq = g_audio_frequency;

	//init_sound_table16 ();
	sample_handler = currprefs.sound_stereo ? sample16s_handler : sample16_handler;

	//obtainedfreq = currprefs.sound_freq;
	obtainedfreq = g_audio_frequency;

	have_sound = 1;
	sound_available = 1;
	update_sound (fake_vblank_hz, 1, currprefs.ntscmode);
	//paula_sndbufsize = spec.samples * 2 * spec.channels;
	//paula_sndbufsize = fs_emu_get_audio_buffer_size();
	paula_sndbufsize = g_audio_buffer_size;
	paula_sndbufpt = paula_sndbuffer;
#ifdef DRIVESOUND
	write_log("initialize drivesound\n");
	driveclick_init();
#endif
	write_log("open_sound returning 1\n");
	return 1;
}
Пример #4
0
static void coleco_finish_frame(void) {
    int16 buf[882 << 1];
    int samples = 0, total_lines, line;

    if(sms_region & SMS_VIDEO_NTSC)
        total_lines = NTSC_LINES_PER_FRAME;
    else
        total_lines = PAL_LINES_PER_FRAME;

    for(line = scanline; line < total_lines; ++line) {
        cycles_to_run += SMS_CYCLES_PER_LINE;

        cycles_run += tms9918a_vdp_execute(scanline, &sms_z80_nmi, 0);
        cycles_run += sms_z80_run(cycles_to_run - cycles_run);

        samples = update_sound(buf, samples, line);
    }

    sound_update_buffer(buf, samples << 1);

    /* Reset the state for the next frame. */
    cycles_run -= cycles_to_run;
    cycles_to_run = 0;
    scanline = 0;
}
Пример #5
0
static void coleco_finish_scanline(void) {
    int16 buf[882 << 1];
    int total_lines, samples = 0;

    /* Make sure we have something to do. */
    if(cycles_run >= cycles_to_run)
        return;

    /* Run the Z80 for the rest of the line. The VDP should've already been
       run. */
    cycles_run += sms_z80_run(cycles_to_run - cycles_run);

    samples = update_sound(buf, 0, scanline);
    sound_update_buffer(buf, samples << 1);

    /* See if we hit the end of a frame by finishing this line. */
    if(sms_region & SMS_VIDEO_NTSC)
        total_lines = NTSC_LINES_PER_FRAME;
    else
        total_lines = PAL_LINES_PER_FRAME;

    if(++scanline == total_lines) {
        /* Reset the state for the next frame. */
        cycles_run -= cycles_to_run;
        cycles_to_run = 0;
        scanline = 0;
    }
}
Пример #6
0
static void coleco_scanline(void) {
    int16 buf[882 << 1];
    int total_lines, samples = 0;

    cycles_to_run += SMS_CYCLES_PER_LINE;

    /* Run the VDP and Z80 for the whole line. */
    cycles_run += sms_vdp_execute(scanline, 0);
    cycles_run += tms9918a_vdp_execute(scanline, &sms_z80_nmi, 0);

    samples = update_sound(buf, 0, scanline);
    sound_update_buffer(buf, samples << 1);

    /* See if we hit the end of a frame by running this scanline. */
    if(sms_region & SMS_VIDEO_NTSC)
        total_lines = NTSC_LINES_PER_FRAME;
    else
        total_lines = PAL_LINES_PER_FRAME;

    if(++scanline == total_lines) {
        /* Reset the state for the next frame. */
        cycles_run -= cycles_to_run;
        cycles_to_run = 0;
        scanline = 0;
    }
}
Пример #7
0
// ---------------------------------------------
// Play and adventure map sound and add it to
// the active playing sounds queue for update management
// NOTE: If the sound is not going to loop, you really
//       don't need it to be managed, just play it normally
//       and do not call this function for non-looping sounds
// ---------------------------------------------
t_managed_sound_ptr play_adventure_sound(	t_adventure_object const & owner,
											t_sound_ptr sound, 
											t_level_map_point_2d const & point, 
											int volume, bool fade_in )
{
	// go through the current managed sound list and make sure a sound
	// with this owner is NOT already playing
	t_active_sounds::iterator iter;

	// traverse the list of active sounds and process each
	for( iter = active_sounds.begin(); iter != active_sounds.end(); ++iter )
	{
		t_managed_sound * playing_sound = (*iter).get();

		if( &playing_sound->get_owner() == &owner )
		{
			return 0;
		}
	}

	t_playing_sound_ptr playing_sound = sound->play( volume, true, fade_in );

  	if( playing_sound && playing_sound->is_playing() )
	{
		t_managed_sound_ptr managed_sound = new t_managed_sound( owner, point, playing_sound );
		update_sound( point, managed_sound, false );
		active_sounds.push_back( managed_sound );
		return managed_sound;
	}

	return 0;
}
Пример #8
0
/*following functions are architecture dependent */
void tl_update_time(void)
{
#ifdef POOL_SOUND
    update_sound();
#endif
#ifdef HAVE_UCLOCK
    currenttime=uclock();
#else
#ifdef USE_CLOCK 
    currenttime=clock();
#else
#ifdef HAVE_GETTIMEOFDAY
    do {
	gettimeofday(&currenttime, &tzp);
    } while (currenttime.tv_usec > 999999);
#else
#ifdef HAVE_FTIME
    ftime(&currenttime);
#endif
#endif
#endif
#endif
#ifdef _plan9_
    currenttime = plan9_msec();
#endif
}
Пример #9
0
void devices_update_sound(double clk, double syncadjust)
{
	update_sound (clk);
#ifdef WITH_TOCCATA
	update_sndboard_sound (clk / syncadjust);
#endif
	update_cda_sound(clk / syncadjust);
}
Пример #10
0
void sound_byte(ubyte iobyte) {      // if a noise program byte, return
    if ((iobyte & 0xE0) == 0xE0) return;

    if ((iobyte & 0x90) == 0x90) get_vol(iobyte);  // if a volume byte
    if ((iobyte & 0x90) == 0x80) get_freq(iobyte); // if a frequency byte
    if (!(iobyte & 0x80)) get_freq(iobyte);      // if a frequency byte
    if (soundyesno) update_sound();            // update sound

}
Пример #11
0
Файл: bb.c Проект: stroucki/bb
int bbupdate()
{
    int ch;
    tl_update_time();
    update_sound();
    TIME = tl_lookup_timer(scenetimer);
    ch = aa_getkey(context, 0);
    switch (ch) {
    case 's':
    case 'S':
    case AA_BACKSPACE:
	finish_stuff = 1;
	break;
    case AA_ESC:
    case 'q':
	finish_stuff = 1, quitnow = 1;
    }
    return (ch);
}
Пример #12
0
static void coleco_single_step(void) {
    int16 buf[882 << 1];
    int total_lines, run;

    /* If we're at the start of a frame, set things up for the first line. Also,
       if we finished a line last time (or are starting a new frame), run the
       VDP for the line. */
    if(!cycles_to_run || cycles_run >= cycles_to_run) {
        cycles_to_run += SMS_CYCLES_PER_LINE;
        if((run = tms9918a_vdp_execute(scanline, &sms_z80_nmi, 0))) {
            cycles_run += run;
            return;
        }
    }

    /* Run our one instruction. */
    cycles_run += sms_z80_run(1);

    /* Did we finish a line? */
    if(cycles_run >= cycles_to_run) {
        run = update_sound(buf, 0, scanline);
        sound_update_buffer(buf, run << 1);

        /* Was it the last line in the frame? */
        if(sms_region & SMS_VIDEO_NTSC)
            total_lines = NTSC_LINES_PER_FRAME;
        else
            total_lines = PAL_LINES_PER_FRAME;

        if(++scanline == total_lines) {
            /* Reset the state for the next frame. */
            cycles_run -= cycles_to_run;
            cycles_to_run = 0;
            scanline = 0;
        }
    }
}
Пример #13
0
int setup_sound(void)
{
    ppb_audio_interface = (PPB_Audio *) NaCl_GetInterface(PPB_AUDIO_INTERFACE);
    ppb_audio_config_interface = (PPB_AudioConfig *)
        NaCl_GetInterface(PPB_AUDIO_CONFIG_INTERFACE);
    pp_instance = NaCl_GetInstance();

    if (!ppb_audio_interface) {
        write_log("Could not acquire PPB_Audio interface.\n");
        return 0;
    }
    if (!ppb_audio_config_interface) {
        write_log("Could not acquire PPB_AudioConfig interface.\n");
        return 0;
    }
    if (!pp_instance) {
        write_log("Could not find current Pepper instance.\n");
        return 0;
    }

    if (!init_sound()) return 0;
    close_sound();

    write_log("Pepper audio successfully set up.\n");
    write_log("Frequency: %d\n", currprefs.sound_freq);
    write_log("Stereo   : %d\n", currprefs.sound_stereo);
    write_log("Latency  : %d\n", currprefs.sound_latency);

    init_sound_table16();
    sample_handler = sample16s_handler;
    obtainedfreq = currprefs.sound_freq;
    have_sound = 1;
    sound_available = 1;
    update_sound (fake_vblank_hz, 1, currprefs.ntscmode);

    return sound_available;
}
Пример #14
0
void devices_update_sound(double clk, double syncadjust)
{
	update_sound (clk);
	update_sndboard_sound (clk / syncadjust);
	update_cda_sound(clk / syncadjust);
}
Пример #15
0
dmz::Handle
dmz::AudioModuleFMOD::play_sound (
      const Handle AudioHandle,
      const SoundInit &Init,
      const SoundAttributes &Attributes) {

   Handle result (0);

   if (_system) {

      SoundStruct *data = _soundHandleTable.lookup (AudioHandle);

      if (data) {

         Handle dataHandle = data->get_handle ();

         InstanceStruct *instance = _get_new_instance (data);

         if (instance) {

            Handle instanceHandle = instance->get_handle ();

            if (instanceHandle &&
                  _instanceTable.store (instanceHandle, instance)) {

               String errorHeader ("Playing Sound '");
               errorHeader << data->FileName << "'";

               // Bind sound to channel
               FMOD_RESULT fmodResult = _system->playSound (
                  FMOD_CHANNEL_FREE,
                  data->sound,
                  true,
                  &(instance->channel));

               if (_error_check (errorHeader, fmodResult) && instance->channel) {

                  Float32 defaultFrequency (1.0);
                  // Get default frequency of sound
                  fmodResult = instance->channel->getFrequency (&(defaultFrequency));

                  instance->defaultFrequency = defaultFrequency;

                  _error_check (errorHeader, fmodResult);

                  // Set loop mode
                  if (Init.get (SoundLooped)) {

                     fmodResult = instance->channel->setMode (FMOD_LOOP_NORMAL);
                  }
                  else {

                     fmodResult = instance->channel->setMode (FMOD_LOOP_OFF);
                  }

                  _error_check (errorHeader, fmodResult);

                  if (Init.get (SoundRelative)) {

                     fmodResult = instance->channel->setMode (FMOD_3D_HEADRELATIVE);
                  }
                  else {

                     fmodResult = instance->channel->setMode (FMOD_3D_WORLDRELATIVE);
                  }

                  _error_check (errorHeader, fmodResult);

                  update_sound (instance->get_handle (), Attributes);

                  // Attach to this channel pointer to the instance struct
                  fmodResult = instance->channel->setUserData ((void *)instance);

                  if (_error_check (errorHeader, fmodResult)) {

                     fmodResult = instance->channel->setCallback (
                        FMOD_CHANNEL_CALLBACKTYPE_END,
                        _channel_callback,
                        0);

                     if (_error_check (errorHeader, fmodResult)) {

                        fmodResult = instance->channel->setPaused(false);

                        if (_error_check (errorHeader, fmodResult)) {

                           //_log.info << errorHeader << endl;
                           result = instanceHandle;
                        }
                     }
                  }
               }

               // FMOD is unsuccessful in attempting to play sound
               if (!result) { _remove_instance (instanceHandle); }
            }
            else if (instance){

               instance->reset ();

               instance->next = _instanceRecycle;
               _instanceRecycle = instance;
            }
         }
      }
   }

   return result;
}
Пример #16
0
Uint32 my_timer(Uint32 interval, void * data)
{
	int	new_time;
	SDL_Event e;
	static int normal_animation_loop_count = 2;
	
#ifdef NEW_SOUND
	update_sound(interval);
	update_item_sound(interval);
#endif	//NEW_SOUND

	// adjust the timer clock
	if(my_timer_clock == 0)
	{
		my_timer_clock=SDL_GetTicks();
	}
	else
	{
		my_timer_clock+=(TIMER_RATE-my_timer_adjust);
	}

#ifdef TIMER_CHECK
	last_my_timer=SDL_GetTicks();
#endif
	
	e.type = SDL_USEREVENT;


	if(normal_animation_timer>normal_animation_loop_count && have_a_map)
	{
		if(my_timer_adjust > 0)
		{
			my_timer_adjust--;
		}
		normal_animation_timer=0;

		if(!dungeon && 0)//we do not want clouds movement in dungeons, but we want clouds detail
		{
			clouds_movement_u+=0.0003f;
			clouds_movement_v+=0.0006f;
		}
	}
	normal_animation_timer++;

#ifdef PAWN
	check_pawn_timers ();
#endif

	// find the new interval
	new_time= TIMER_RATE-(SDL_GetTicks()-my_timer_clock);
	if(new_time<10) {
		new_time=10;	//put an absoute minimume in
	}
	
	
	/* Temporary code to test a fix for a client freeze due to too many particles:
	   http://www.eternal-lands.com/forum/index.php?showtopic=47006
	   in_main_event_loop is set true while the main loop is handling SDL events
	   normal_animation_loop_count will be increased when we check and that is the
	   case.  Increasing the count causes EVENT_UPDATE_PARTICLES to be trigger
	   less often an gives the system a chance to catch up.  When in_main_event_loop
	   is seen to be zero, normal_animation_loop_count is decrement down to standard
	   value.  This is very crude but stops the client freeze on my system.
	*/
	{
		extern volatile int in_main_event_loop;
		
		if (in_main_event_loop)
		{
			normal_animation_loop_count++;
			//printf("increase new_time=%i loop_count=%i\n", new_time, normal_animation_loop_count);
		}
		else if (normal_animation_loop_count > 2)
		{
		   	normal_animation_loop_count--;
			//printf("decrease new_time=%i loop_count=%i\n", new_time, normal_animation_loop_count);
		}
	}
	
	
	return new_time;
}
Пример #17
0
int main() {
    xenon_make_it_faster(XENON_SPEED_FULL);
    xenos_init(VIDEO_MODE_AUTO);

    console_init();
    xenon_sound_init();
    pAudioStart = pAudioBuffer = (uint16_t*) malloc(48000 * sizeof (uint16_t));
    memset(pAudioBuffer, 0, 48000 * sizeof (uint16_t));

    usb_init();
    usb_do_poll();
    SYSVideoInit();

    //    Allocates and initializes memory.  Should only be called once, before
    //    any calls to other FCEU functions.
    FCEUI_Initialize();

    //-------------------------------------------------------------------------------------
    // Set some setting
    //-------------------------------------------------------------------------------------
    //    Specifies the base FCE Ultra directory.  This should be called
    //    immediately after FCEUI_Initialize() and any time afterwards.
    std::string base = "uda:/";
    //FCEUI_SetBaseDirectory(base); // doesn't work ? newlib bug ?
    FCEUI_SetVidSystem(0);

    //Apply settings
    FCEUI_Sound(48000);
    FCEUI_SetSoundVolume(50);
    FCEUI_SetLowPass(0);


    if (FCEUI_LoadGame("uda:/Super Mario Bros. (Europe) (Rev 0A).zip", 0) != NULL) {
        FCEUI_SetInput(0, SI_GAMEPAD, (void*) &powerpadbuf, 0);
        FCEUI_SetInput(1, SI_GAMEPAD, (void*) &powerpadbuf, 0);

        //set to ntsc
        extern FCEUGI * GameInfo;
        GameInfo->vidsys = GIV_NTSC;
    }

    int32 * snd = NULL;
    int32 sndsize;

    //    Copy contents of XBuf over to video memory(or whatever needs to be 
    //    done to make the contents of XBuf visible on screen).
    //    Each line is 256 pixels(and bytes) in width, and there can be 240
    //    lines.  The pitch for each line is 272 bytes.
    //    XBuf will be 0 if the symbol FRAMESKIP is defined and this frame
    //    was skipped.

    uint8 * bitmap;
    while (1) {
        FCEUI_Emulate(&bitmap, &snd, &sndsize, 0);
        for (int i = 0; i < (256 * 240); i++) {
            //Make an ARGB bitmap
            nesBitmap[i] = ((pcpalette[bitmap[i]].r) << 16) | ((pcpalette[bitmap[i]].g) << 8) | (pcpalette[bitmap[i]].b) | (0xFF << 24);
        }
        SYSVideoUpdate();
        // Add Sound
        update_sound(snd,sndsize);
        // Add Input
        update_input();
    }

    return 0;
}