Continue engine

This commit is contained in:
drummyfish 2024-12-24 01:41:45 +01:00
parent e6c5283bf4
commit 3eeb4d7fc2
2 changed files with 21 additions and 7 deletions

24
audio.h
View file

@ -23,7 +23,7 @@ struct
int engineIntensity;
int engineOsc;
int engineInc;
@ -38,8 +38,12 @@ void LCR_audioInit(void)
LCR_audio.noise = 0;
LCR_audio.engineOsc = 0;
LCR_audio.engineInc = 1;
LCR_audio.engineIntensity = 0;
}
void LCR_audioSetEngineIntensity(uint8_t value)
@ -59,17 +63,27 @@ uint8_t _LCR_audioNoise(void)
return LCR_audio.noise >> 16;
}
uint8_t LCR_audioGetNextSample(void)
{
unsigned char result = 128;
if (LCR_audio.engineIntensity > 5)
//if (LCR_audio.engineIntensity)
{
LCR_audio.engineOsc +=
((_LCR_audioNoise() % 256) <
(30 + LCR_audio.engineIntensity));
LCR_audio.engineInc ?
(((_LCR_audioNoise() % 256) <
(10 + LCR_audio.engineIntensity))) : -31;
result += LCR_audio.engineOsc;
if (LCR_audio.engineInc && LCR_audio.engineOsc >
(90 + (LCR_audio.engineIntensity / 8)))
LCR_audio.engineInc = 0;
else if ((!LCR_audio.engineInc) && LCR_audio.engineOsc < 10)
LCR_audio.engineInc = 1;
result +=
LCR_audio.engineIntensity < 20 ?
LCR_audio.engineOsc / 2 : LCR_audio.engineOsc;
}
LCR_audio.frame++;

2
game.h
View file

@ -396,7 +396,7 @@ LCR_GameUnit physicsInterpolationParam = LCR_GAME_UNIT -
int val = LCR_carSpeedKMH();
LCR_audioSetEngineIntensity(val < 256 ? val : 255);
LCR_audioSetEngineIntensity((2 * val) < 256 ? (2 * val) : 255);
if (val < 5) // don't show tiny oscillations when still
val = 0;