Esempio n. 1
0
File: final.c Progetto: kd8bny/HCS12
int readPattern(){
    //Reads user input of SW's Then determines grade P/F
    int grade;
    unsigned char tempPattern[4];
    int i;
    int button;
    for(i=0;i<4;i++){
        //[SW3][SW2][SW1][SW0]
        while(PTH == 0xFF);
        switch(PTH){
            case 0xFE:
                //SW0
                makeSound(20);
                PTB = 0x01;
                tempPattern[i] = 0x01;
                makeSound(sound[i]);
                break;
            case 0xFD:
                //SW1
                makeSound(30);
                PTB = 0x02;
                tempPattern[i] = 0x02;
                makeSound(sound[i]);
                break;
            case 0xFB:
                //SW2
                makeSound(40);
                PTB = 0x04;
                tempPattern[i] = 0x04;
                makeSound(sound[i]);
                break;
            case 0xF7:
                //SW3
                makeSound(50);
                PTB = 0x08;
                tempPattern[i] = 0x08;
                makeSound(sound[i]);
                break;
        }
        superTimer(200);    //Delay to read next input
        PTB = 0x00;
        PWME = 0x00;    //kill sound
    }
    // Missing Equals() in embedded C :( Resort to for loop
    for(i=0;i<4;i++){
        if(tempPattern[i] != pattern[i]){
            grade = 0;
            break;
        }
        else{
            grade = 1;
        }
    }
    return grade;
}
Esempio n. 2
0
File: final.c Progetto: kd8bny/HCS12
int sendPattern(int delayDiff){
    //Displays Pattern on LEDS
    int i;
    for(i=0;i<4;i++){
        PTB = pattern[i];
        makeSound(sound[i]);
        superTimer(delayDiff);
        PTB = 0x00;     //write zero to note subsequent blinks
        PWME = 0x00;    //kill sound
        superTimer(200);
    }
	return ;
}
Esempio n. 3
0
File: final.c Progetto: kd8bny/HCS12
int main(){
    int pass;
    int score = 0;
    int delayDiff = 5000; //5s   
    setup();
    while(1){
        sendPattern(delayDiff);
        pass = readPattern();
        if(pass == 1){
            makeSound(95);      //passTune
            delayDiff -= 500;   //Increase difficulty -0.5s
            score += 10;
            makePattern();      //new pattern
        }
        else{
            makeSound(10);        //failTune();
            print(1,score);
            PWME = 0x00;    //kill sound
            break;
        }
    }
}
 Direction::Direction()
 :myAttributes( std::make_shared<DirectionAttributes>() )
 ,myDirectionTypeSet()
 ,myOffset( makeOffset() )
 ,myHasOffset( false )
 ,myEditorialVoiceDirectionGroup( makeEditorialVoiceDirectionGroup() )
 ,myStaff( makeStaff() )
 ,myHasStaff( false )
 ,mySound( makeSound() )
 ,myHasSound( false )
 {
     myDirectionTypeSet.push_back( makeDirectionType() );
 }
Esempio n. 5
0
void Sound::loadSfxFile(const GameSpecificSettings *gss) {
	if (_hasEffectsFile)
		return;

	_effects = makeSound(_mixer, gss->effects_filename);
	_hasEffectsFile = (_effects != 0);

	if (_hasEffectsFile)
		return;

	const bool dataIsUnsigned = true;

	if (Common::File::exists(gss->effects_filename)) {
		_hasEffectsFile = true;
		_effects = new VocSound(_mixer, gss->effects_filename, dataIsUnsigned);
	}
}
Esempio n. 6
0
void Sound::switchVoiceFile(const GameSpecificSettings *gss, uint disc) {
	if (_lastVoiceFile == disc)
		return;

	_mixer->stopHandle(_voiceHandle);
	delete _voice;

	_hasVoiceFile = false;
	_lastVoiceFile = disc;

	char filename[16];

	sprintf(filename, "%s%u", gss->speech_filename, disc);
	_voice = makeSound(_mixer, filename);
	_hasVoiceFile = (_voice != 0);

	if (!_hasVoiceFile)
		error("switchVoiceFile: Can't load voice file %s", filename);
}
Esempio n. 7
0
void Sound::loadVoiceFile(const GameSpecificSettings *gss) {
	// Game versions which use separate voice files
	if (_hasVoiceFile || _vm->getGameType() == GType_FF || _vm->getGameId() == GID_SIMON1CD32)
		return;

	_voice = makeSound(_mixer, gss->speech_filename);
	_hasVoiceFile = (_voice != 0);

	if (_hasVoiceFile)
		return;

	if (_vm->getGameType() == GType_SIMON2) {
		// for simon2 mac/amiga, only read index file
		Common::File file;
		if (file.open("voices.idx")) {
			int end = file.size();
			_filenums = (uint16 *)malloc((end / 6 + 1) * 2);
			_offsets = (uint32 *)malloc((end / 6 + 1 + 1) * 4);

			for (int i = 1; i <= end / 6; i++) {
				_filenums[i] = file.readUint16BE();
				_offsets[i] = file.readUint32BE();
			}
			// We need to add a terminator entry otherwise we get an out of
			// bounds read when the offset table is accessed in
			// BaseSound::getSoundStream.
			_offsets[end / 6 + 1] = 0;

			_hasVoiceFile = true;
			return;
		}
	}

	const bool dataIsUnsigned = true;

	if (Common::File::exists(gss->speech_filename)) {
		_hasVoiceFile = true;
		if (_vm->getGameType() == GType_PP)
			_voice = new WavSound(_mixer, gss->speech_filename);
		else
			_voice = new VocSound(_mixer, gss->speech_filename, dataIsUnsigned);
	}
}
bool SimExplosionCloud::onSimRenderQueryImage(SimRenderQueryImage * q)
{
   if (removeFromRenderSet)
      return true;

	TSRenderContext & rc = *q->renderContext;
	// get camera pos
	Point3F camPos;
	TMat3F wCamMat = rc.getCamera()->getTCW();
   camPos = wCamMat.p;

	SimExplosionTable::ShortList sl;
	SimExplosionTable::getShortList(megatons,typeMask,sl,manager);

	// we can put delay in detonationTime after less than
	// following limit "megatons" are left to ignite
	float nowLimit = megatons * (1.0f-proportionNow);

	int numLeft = sl.size();
	while (numLeft)
	{
		int choose = g_expRand.getInt(0,numLeft);
		SimExplosion * explosion = new SimExplosion(-1,sl[choose].index);
		// add explosion to container...
		database.update(explosion);
		addObject(explosion);
		// set off the explosion
		lightFuse(explosion,camPos,megatons>nowLimit);
		megatons -= sl[choose].megatons;
		while (numLeft && sl[numLeft-1].megatons>megatons)
			numLeft--;
	}

	makeSound();

	// no longer need to be in render set
	removeFromRenderSet = true;

   if (database.explosionList.empty())
      SimMessageEvent::post(this,-1);

	return true;
}