Exemplo n.º 1
0
void ay::ayReset()
{
    //init regs with defaults
    int_limit = 0;
    int_counter = 0;
    z80_per_sample_counter = 0;
    int_per_z80_counter = 0;
    memset(regs, 0, sizeof(regs));
    regs[AY_GPIO_A] = regs[AY_GPIO_B] = 0xff;
    chnl_period0 = chnl_period1 = chnl_period2 = 0;
    tone_period_init0 = tone_period_init1 = tone_period_init2 = 0;
    chnl_mute0 = chnl_mute1 = chnl_mute1 = false;
    env_type = 0;
    env_vol = 0;
    chnl_trigger0 = chnl_trigger1 = chnl_trigger2 = 0;
    noise_reg = 0x1;
    noise_trigger = 1;
    noise_period = 0;

    env_type_old = -1;
    env_step = 0;
    ay_tacts_counter = 0;

    beeper_volume = 0;
    beeper_oldval = false;

    SetParameters(0);
    setEnvelope();

}
Exemplo n.º 2
0
void YMVoice::handleCC(byte number, byte value)
{
  //Handle the Control Changes for YM2149
  switch (number) {  
    case 2:
      YM2149::setEnvelopeCONT(value);
      break;
    case 3:
      YM2149::setEnvelopeATT(value);
      break;
    case 4:
      YM2149::setEnvelopeALT(value);
      break;
    case 5:
      YM2149::setEnvelopeHOLD(value);
      break;    
    case 6:
      setNoise(value);
      break; 
    case 7:
      setTone(value);
      break;    
    case 8:
      setEnvelope(value);
      break; 
    case 71:
      setVolume(value/8);
      break;       
    case 74:
      YM2149::setNoiseFrequency(value);
      break;        
    case 75:
      YM2149::setEnvelopeFrequencyLo(value << 1);
      break;    
    case 76:
      YM2149::setEnvelopeFrequencyHi(value << 1);
      break;                 
    default:
      return;
      break;       
  }     
}
Exemplo n.º 3
0
void ay::ayWrite(unsigned char reg, unsigned char val)
{
    regs[reg & 0xf] = val;
    switch(reg)
    {
        case AY_CHNL_A_COARSE:
        case AY_CHNL_A_FINE:
            tone_period_init0 = TONE_PERIOD(0);
            break;
        case AY_CHNL_B_COARSE:
        case AY_CHNL_B_FINE:
            tone_period_init1 = TONE_PERIOD(1);
            break;
        case AY_CHNL_C_COARSE:
        case AY_CHNL_C_FINE:
            tone_period_init2 = TONE_PERIOD(2);
            break;
        case AY_NOISE_PERIOD:
            noise_period_init = NOISE_PERIOD * 2;
            break;
        case AY_MIXER:
            break;
        case AY_CHNL_A_VOL:
        case AY_CHNL_B_VOL:
        case AY_CHNL_C_VOL:
            break;
        case AY_ENV_SHAPE:
            setEnvelope();
            break;
        case AY_ENV_FINE:
        case AY_ENV_COARSE:
            env_period_init = ENVELOPE_PERIOD;
            break;
        default:
            break;
    }
}
Exemplo n.º 4
0
static void setEffect(DirectInputEffect *dinputEffect, const DIEFFECT *di_eff)
{
	uint32_t i;
	switch (dinputEffect->real_type)
	{
		case SDL_HAPTIC_CONSTANT:
		{
			DICONSTANTFORCE *di_constant = (DICONSTANTFORCE *)di_eff->typeSpecificParams;
			if (dinputEffect->effect.type == SDL_HAPTIC_SINE)
			{
				SDL_HapticPeriodic *periodic = &dinputEffect->effect.periodic;
				if (di_constant)
					periodic->magnitude = CONVERT(di_constant->magnitude);
				periodic->length = CONVERT_LENGTH(di_eff->duration);
// 				printf("Constant as Sine: %d, %d\n", periodic->length, periodic->magnitude);
			}
			else
			{
				SDL_HapticConstant *constant = &dinputEffect->effect.constant;
				if (di_constant)
					constant->level = CONVERT(di_constant->magnitude);
				constant->length = CONVERT_LENGTH(di_eff->duration);
				constant->direction.type = SDL_HAPTIC_POLAR; //di_eff->flags shows that POLAR is used (0x20)
				for (i = 0; i < di_eff->cAxes; ++i)
					constant->direction.dir[i] = di_eff->rglDirection[i];
// 				printf("Constant: %d %d %d, %X\n", constant->length, constant->level, di_eff->cAxes, di_eff->flags);
			}
		} break;
		case SDL_HAPTIC_SINE:
		{
			DIPERIODIC *di_periodic = (DIPERIODIC *)di_eff->typeSpecificParams;
			SDL_HapticPeriodic *periodic = &dinputEffect->effect.periodic;
			if (di_periodic)
			{
				periodic->magnitude = CONVERT(di_periodic->magnitude);
				periodic->offset = CONVERT(di_periodic->offset);
				periodic->period = (uint16_t)CONVERT_LENGTH(di_periodic->period);
				periodic->phase = di_periodic->phase;
			}
			periodic->length = CONVERT_LENGTH(di_eff->duration);
			if (di_eff->envelope)
				setEnvelope(&periodic->attack_length, &periodic->attack_level, &periodic->fade_length, &periodic->fade_level, di_eff->envelope);
// 			printf("Square as Sine: %d\n", periodic->magnitude);
		} break;
		case SDL_HAPTIC_SPRING:
		{
			/* Deadband always 0, Coeff and Saturation always the same */
			if (dinputEffect->effect.type == SDL_HAPTIC_SPRING)
			{
				/* Is it OK? I can't test it! */
				SDL_HapticCondition *condition = &dinputEffect->effect.condition;
				for (i = 0; i < di_eff->cAxes; ++i)
				{
					DICONDITION *di_condition = (DICONDITION *)di_eff->typeSpecificParams + i;
					condition->center[i] = CONVERT(di_condition->lOffset);
					condition->right_coeff[i] = CONVERT(di_condition->lPositiveCoefficient);
					condition->left_coeff[i] = CONVERT(di_condition->lNegativeCoefficient);
					condition->right_sat[i] = CONVERT(di_condition->dwPositiveSaturation);
					condition->left_sat[i] = CONVERT(di_condition->dwNegativeSaturation);
					condition->deadband[i] = CONVERT(di_condition->lDeadBand);
// 					printf("Spring[%d]: %d %d %d %d %d %d\n", i, condition->center[i], condition->right_coeff[i], condition->left_coeff[i], condition->right_sat[i], condition->left_sat[i], condition->deadband[i]);
				}
				condition->length = CONVERT_LENGTH(di_eff->duration);
			}
			else if (dinputEffect->effect.type == SDL_HAPTIC_CONSTANT && di_eff->cAxes)
			{
				/* Simulate Spring with Constant - this probably works bad :D */

				SDL_HapticConstant *constant = &dinputEffect->effect.constant;
				DICONDITION *di_condition = (DICONDITION *)di_eff->typeSpecificParams;

				int32_t axis = *dinputEffect->xAxis * 20000 / 65535 - 10000;
				int32_t force;
				if (*dinputEffect->xAxis > 0)
					force = di_condition->lPositiveCoefficient * (axis - di_condition->lOffset);
				else
					force = di_condition->lNegativeCoefficient * (axis - di_condition->lOffset);

				constant->direction.type = SDL_HAPTIC_CARTESIAN;
				constant->direction.dir[0] = (force == 0) ? 0 : (force < 0 ? -1 : 1);
				constant->attack_level = SDL_abs(force / 3052);
				constant->attack_length = (uint16_t)CONVERT_LENGTH(di_eff->duration);

// 				printf("Spring as Constant: coeffP: %d, coeffN: %d, offset: %d, xAxis: %d, force: %d, attack: %d\n", di_condition->lPositiveCoefficient, di_condition->lNegativeCoefficient, di_condition->lOffset, axis, force, force / 3052);
			}
		} break;
	}
}