static s16 sfxShotClock; static u16 sfxShotFreq; void sfxPlayerShot(){ sfxShotClock = 4; sfxShotFreq = 150; PSG_setEnvelope(2, 2); PSG_setFrequency(2, sfxShotFreq); } static s16 sfxEnemyShotClock; static u16 sfxEnemyShotFreq; static u8 sfxEnemyShotType; // high sharp zap - quick descending chirp void sfxEnemyShotA(){ sfxEnemyShotClock = 3; sfxEnemyShotFreq = 1200; sfxEnemyShotType = 0; PSG_setEnvelope(1, 3); PSG_setFrequency(1, sfxEnemyShotFreq); } // mid buzzy pulse - sits in the midrange void sfxEnemyShotB(){ sfxEnemyShotClock = 5; sfxEnemyShotFreq = 400; sfxEnemyShotType = 1; PSG_setEnvelope(1, 3); PSG_setFrequency(1, sfxEnemyShotFreq); } // quick rising ping - sweeps upward void sfxEnemyShotC(){ sfxEnemyShotClock = 4; sfxEnemyShotFreq = 300; sfxEnemyShotType = 2; PSG_setEnvelope(1, 3); PSG_setFrequency(1, sfxEnemyShotFreq); } static s16 sfxExpClock; void sfxExplosion(){ sfxExpClock = 18; PSG_setNoise(PSG_NOISE_TYPE_WHITE, PSG_NOISE_FREQ_CLOCK2); PSG_setEnvelope(3, 0); } void updateSfx(){ if(sfxExpClock > 0){ sfxExpClock--; PSG_setEnvelope(3, (18 - sfxExpClock) * 15 / 18); if(sfxExpClock == 0){ PSG_setEnvelope(3, 15); } } if(sfxEnemyShotClock > 0){ sfxEnemyShotClock--; if(sfxEnemyShotType == 0) sfxEnemyShotFreq -= 300; else if(sfxEnemyShotType == 1) sfxEnemyShotFreq -= 50; else sfxEnemyShotFreq += 150; PSG_setFrequency(1, sfxEnemyShotFreq); PSG_setEnvelope(1, 3 + (sfxEnemyShotType == 0 ? (3 - sfxEnemyShotClock) * 4 : sfxEnemyShotType == 1 ? (5 - sfxEnemyShotClock) * 2 : (4 - sfxEnemyShotClock) * 3)); if(sfxEnemyShotClock == 0){ PSG_setEnvelope(1, 15); } } if(sfxShotClock > 0){ sfxShotClock--; sfxShotFreq -= 30; PSG_setFrequency(2, sfxShotFreq); PSG_setEnvelope(2, 2 + (4 - sfxShotClock) * 3); if(sfxShotClock == 0){ PSG_setEnvelope(2, 15); } } }