diff options
author | Simon Howard | 2011-03-06 21:08:32 +0000 |
---|---|---|
committer | Simon Howard | 2011-03-06 21:08:32 +0000 |
commit | 68f51552ff65668deaeef923fc8c496d64ea9a60 (patch) | |
tree | a23137a2b6124e33a31948690f751c15094d2174 | |
parent | 52db6da5814c867fc6dd6bb0ec5d51d76b1fcc4e (diff) | |
parent | b0519667da8edcea1592a0ba7b0dfa4b4709e034 (diff) | |
download | chocolate-doom-68f51552ff65668deaeef923fc8c496d64ea9a60.tar.gz chocolate-doom-68f51552ff65668deaeef923fc8c496d64ea9a60.tar.bz2 chocolate-doom-68f51552ff65668deaeef923fc8c496d64ea9a60.zip |
Merge from trunk.
Subversion-branch: /branches/raven-branch
Subversion-revision: 2292
-rw-r--r-- | NEWS | 6 | ||||
-rw-r--r-- | opl/dbopl.c | 208 | ||||
-rw-r--r-- | opl/dbopl.h | 5 | ||||
-rw-r--r-- | opl/ioperm_sys.c | 16 | ||||
-rw-r--r-- | src/i_sdlsound.c | 14 | ||||
-rw-r--r-- | src/setup/display.c | 10 |
6 files changed, 162 insertions, 97 deletions
@@ -1,5 +1,10 @@ 1.6.0 (2011-??-??): + Compatibility: + * Very short sound effects are not played, to better emulate the + behavior of DMX in Vanilla Doom (thanks to Quasar for help in + investigating this). + Bugs fixed: * Menu navigation when using joystick/joypad (thanks Alexandre Xavier). @@ -7,6 +12,7 @@ right shift, not left shift (thanks AlexXav). * Default joystick buttons for the setup tool now match Vanilla (thanks twipley). + * Visual Studio project files work again (thanks GhostlyDeath). libtextscreen: * It is now possible to type a '+' in input boxes (thanks diff --git a/opl/dbopl.c b/opl/dbopl.c index 159cae45..0c21e0b6 100644 --- a/opl/dbopl.c +++ b/opl/dbopl.c @@ -412,8 +412,9 @@ static void Operator__UpdateRates(Operator *self, const Chip* chip ) { } static inline Bit32s Operator__RateForward(Operator *self, Bit32u add ) { + Bit32s ret; // haleyjd: GNUisms out! self->rateIndex += add; - Bit32s ret = self->rateIndex >> RATE_SH; + ret = self->rateIndex >> RATE_SH; self->rateIndex = self->rateIndex & RATE_MASK; return ret; } @@ -543,10 +544,11 @@ static void Operator__Write60(Operator *self, const Chip* chip, Bit8u val ) { static void Operator__Write80(Operator *self, const Chip* chip, Bit8u val ) { Bit8u change = (self->reg80 ^ val ); + Bit8u sustain; // haleyjd 09/09/10: GNUisms out! if ( !change ) return; self->reg80 = val; - Bit8u sustain = val >> 4; + sustain = val >> 4; //Turn 0xf into 0x1f sustain |= ( sustain + 1) & 0x10; self->sustainLevel = sustain << ( ENV_BITS - 5 ); @@ -556,10 +558,11 @@ static void Operator__Write80(Operator *self, const Chip* chip, Bit8u val ) { } static void Operator__WriteE0(Operator *self, const Chip* chip, Bit8u val ) { + Bit8u waveForm; // haleyjd 09/09/10: GNUisms out! if ( !(self->regE0 ^ val) ) return; //in opl3 mode you can always selet 7 waveforms regardless of waveformselect - Bit8u waveForm = val & ( ( 0x3 & chip->waveFormMask ) | (0x7 & chip->opl3Active ) ); + waveForm = val & ( ( 0x3 & chip->waveFormMask ) | (0x7 & chip->opl3Active ) ); self->regE0 = val; #if( DBOPL_WAVE == WAVE_HANDLER ) self->waveHandler = WaveHandlerTable[ waveForm ]; @@ -731,10 +734,11 @@ static void Channel__UpdateFrequency(Channel *self, const Chip* chip, Bit8u four static void Channel__WriteA0(Channel *self, const Chip* chip, Bit8u val ) { Bit8u fourOp = chip->reg104 & chip->opl3Active & self->fourMask; + Bit32u change; // haleyjd 09/09/10: GNUisms out! //Don't handle writes to silent fourop channels if ( fourOp > 0x80 ) return; - Bit32u change = (self->chanData ^ val ) & 0xff; + change = (self->chanData ^ val ) & 0xff; if ( change ) { self->chanData ^= change; Channel__UpdateFrequency( self, chip, fourOp ); @@ -743,10 +747,11 @@ static void Channel__WriteA0(Channel *self, const Chip* chip, Bit8u val ) { static void Channel__WriteB0(Channel *self, const Chip* chip, Bit8u val ) { Bit8u fourOp = chip->reg104 & chip->opl3Active & self->fourMask; + Bitu change; // haleyjd 09/09/10: GNUisms out! //Don't handle writes to silent fourop channels if ( fourOp > 0x80 ) return; - Bitu change = (self->chanData ^ ( val << 8 ) ) & 0x1f00; + change = (self->chanData ^ ( val << 8 ) ) & 0x1f00; if ( change ) { self->chanData ^= change; Channel__UpdateFrequency( self, chip, fourOp ); @@ -789,6 +794,7 @@ static void Channel__WriteC0(Channel *self, const Chip* chip, Bit8u val ) { //4-op mode enabled for this channel if ( (chip->reg104 & self->fourMask) & 0x3f ) { Channel* chan0, *chan1; + Bit8u synth; // haleyjd 09/09/10: GNUisms out! //Check if it's the 2nd channel in a 4-op if ( !(self->fourMask & 0x80 ) ) { chan0 = self; @@ -798,7 +804,7 @@ static void Channel__WriteC0(Channel *self, const Chip* chip, Bit8u val ) { chan1 = self; } - Bit8u synth = ( (chan0->regC0 & 1) << 0 )| (( chan1->regC0 & 1) << 1 ); + synth = ( (chan0->regC0 & 1) << 0 )| (( chan1->regC0 & 1) << 1 ); switch ( synth ) { case 0: chan0->synthHandler = Channel__BlockTemplate_sm3FMFM; @@ -850,6 +856,15 @@ static inline void Channel__GeneratePercussion(Channel *self, Chip* chip, //BassDrum Bit32s mod = (Bit32u)((self->old[0] + self->old[1])) >> self->feedback; + Bit32s sample; // haleyjd 09/09/10 + Bit32u noiseBit; + Bit32u c2; + Bit32u c5; + Bit32u phaseBit; + Bit32u hhVol; + Bit32u sdVol; + Bit32u tcVol; + self->old[0] = self->old[1]; self->old[1] = Operator__GetSample( Channel__Op(self, 0), mod ); @@ -859,22 +874,22 @@ static inline void Channel__GeneratePercussion(Channel *self, Chip* chip, } else { mod = self->old[0]; } - Bit32s sample = Operator__GetSample( Channel__Op(self, 1), mod ); + sample = Operator__GetSample( Channel__Op(self, 1), mod ); //Precalculate stuff used by other outputs - Bit32u noiseBit = Chip__ForwardNoise(chip) & 0x1; - Bit32u c2 = Operator__ForwardWave(Channel__Op(self, 2)); - Bit32u c5 = Operator__ForwardWave(Channel__Op(self, 5)); - Bit32u phaseBit = (((c2 & 0x88) ^ ((c2<<5) & 0x80)) | ((c5 ^ (c5<<2)) & 0x20)) ? 0x02 : 0x00; + noiseBit = Chip__ForwardNoise(chip) & 0x1; + c2 = Operator__ForwardWave(Channel__Op(self, 2)); + c5 = Operator__ForwardWave(Channel__Op(self, 5)); + phaseBit = (((c2 & 0x88) ^ ((c2<<5) & 0x80)) | ((c5 ^ (c5<<2)) & 0x20)) ? 0x02 : 0x00; //Hi-Hat - Bit32u hhVol = Operator__ForwardVolume(Channel__Op(self, 2)); + hhVol = Operator__ForwardVolume(Channel__Op(self, 2)); if ( !ENV_SILENT( hhVol ) ) { Bit32u hhIndex = (phaseBit<<8) | (0x34 << ( phaseBit ^ (noiseBit << 1 ))); sample += Operator__GetWave( Channel__Op(self, 2), hhIndex, hhVol ); } //Snare Drum - Bit32u sdVol = Operator__ForwardVolume( Channel__Op(self, 3) ); + sdVol = Operator__ForwardVolume( Channel__Op(self, 3) ); if ( !ENV_SILENT( sdVol ) ) { Bit32u sdIndex = ( 0x100 + (c2 & 0x100) ) ^ ( noiseBit << 8 ); sample += Operator__GetWave( Channel__Op(self, 3), sdIndex, sdVol ); @@ -883,7 +898,7 @@ static inline void Channel__GeneratePercussion(Channel *self, Chip* chip, sample += Operator__GetSample( Channel__Op(self, 4), 0 ); //Top-Cymbal - Bit32u tcVol = Operator__ForwardVolume(Channel__Op(self, 5)); + tcVol = Operator__ForwardVolume(Channel__Op(self, 5)); if ( !ENV_SILENT( tcVol ) ) { Bit32u tcIndex = (1 + phaseBit) << 8; sample += Operator__GetWave( Channel__Op(self, 5), tcIndex, tcVol ); @@ -962,6 +977,10 @@ Channel* Channel__BlockTemplate(Channel *self, Chip* chip, Operator__Prepare( Channel__Op( self, 5 ), chip ); } for ( i = 0; i < samples; i++ ) { + Bit32s mod; // haleyjd 09/09/10: GNUisms out! + Bit32s sample; + Bit32s out0; + //Early out for percussion handlers if ( mode == sm2Percussion ) { Channel__GeneratePercussion( self, chip, output + i, FALSE ); @@ -972,11 +991,11 @@ Channel* Channel__BlockTemplate(Channel *self, Chip* chip, } //Do unsigned shift so we can shift out all bits but still stay in 10 bit range otherwise - Bit32s mod = (Bit32u)((self->old[0] + self->old[1])) >> self->feedback; + mod = (Bit32u)((self->old[0] + self->old[1])) >> self->feedback; self->old[0] = self->old[1]; self->old[1] = Operator__GetSample( Channel__Op(self, 0), mod ); - Bit32s sample = 0; - Bit32s out0 = self->old[0]; + sample = 0; + out0 = self->old[0]; if ( mode == sm2AM || mode == sm3AM ) { sample = out0 + Operator__GetSample( Channel__Op(self, 1), 0 ); } else if ( mode == sm2FM || mode == sm3FM ) { @@ -986,17 +1005,20 @@ Channel* Channel__BlockTemplate(Channel *self, Chip* chip, next = Operator__GetSample( Channel__Op(self, 2), next ); sample = Operator__GetSample( Channel__Op(self, 3), next ); } else if ( mode == sm3AMFM ) { + Bits next; // haleyjd 09/09/10: GNUisms out! sample = out0; - Bits next = Operator__GetSample( Channel__Op(self, 1), 0 ); + next = Operator__GetSample( Channel__Op(self, 1), 0 ); next = Operator__GetSample( Channel__Op(self, 2), next ); sample += Operator__GetSample( Channel__Op(self, 3), next ); } else if ( mode == sm3FMAM ) { + Bits next; // haleyjd 09/09/10: GNUisms out! sample = Operator__GetSample( Channel__Op(self, 1), out0 ); - Bits next = Operator__GetSample( Channel__Op(self, 2), 0 ); + next = Operator__GetSample( Channel__Op(self, 2), 0 ); sample += Operator__GetSample( Channel__Op(self, 3), next ); } else if ( mode == sm3AMAM ) { + Bits next; // haleyjd 09/09/10: GNUisms out! sample = out0; - Bits next = Operator__GetSample( Channel__Op(self, 1), 0 ); + next = Operator__GetSample( Channel__Op(self, 1), 0 ); sample += Operator__GetSample( Channel__Op(self, 2), next ); sample += Operator__GetSample( Channel__Op(self, 3), 0 ); } @@ -1057,8 +1079,9 @@ void Chip__Chip(Chip *self) { } static inline Bit32u Chip__ForwardNoise(Chip *self) { + Bitu count; self->noiseCounter += self->noiseAdd; - Bitu count = self->noiseCounter >> LFO_SH; + count = self->noiseCounter >> LFO_SH; self->noiseCounter &= WAVE_MASK; for ( ; count > 0; --count ) { //Noise calculation from mame @@ -1069,14 +1092,17 @@ static inline Bit32u Chip__ForwardNoise(Chip *self) { } static inline Bit32u Chip__ForwardLFO(Chip *self, Bit32u samples ) { + Bit32u todo; // haleyjd 09/09/10: GNUisms out!!!!!! + Bit32u count; + //Current vibrato value, runs 4x slower than tremolo self->vibratoSign = ( VibratoTable[ self->vibratoIndex >> 2] ) >> 7; self->vibratoShift = ( VibratoTable[ self->vibratoIndex >> 2] & 7) + self->vibratoStrength; self->tremoloValue = TremoloTable[ self->tremoloIndex ] >> self->tremoloStrength; //Check hom many samples there can be done before the value changes - Bit32u todo = LFO_MAX - self->lfoCounter; - Bit32u count = (todo + self->lfoAdd - 1) / self->lfoAdd; + todo = LFO_MAX - self->lfoCounter; + count = (todo + self->lfoAdd - 1) / self->lfoAdd; if ( count > samples ) { count = samples; self->lfoCounter += count * self->lfoAdd; @@ -1288,7 +1314,8 @@ void Chip__GenerateBlock3(Chip *self, Bitu total, Bit32s* output ) { void Chip__Setup(Chip *self, Bit32u rate ) { double original = OPLRATE; - Bit32u i; + Bit32u i; + Bit32u freqScale; // haleyjd 09/09/10: GNUisms out! // double original = rate; double scale = original / (double)rate; @@ -1311,7 +1338,7 @@ void Chip__Setup(Chip *self, Bit32u rate ) { self->freqMul[i] = (Bit32u)( 0.5 + freqScale * FreqCreateTable[ i ] ); } #else - Bit32u freqScale = (Bit32u)( 0.5 + scale * ( 1 << ( WAVE_SH - 1 - 10))); + freqScale = (Bit32u)( 0.5 + scale * ( 1 << ( WAVE_SH - 1 - 10))); for ( i = 0; i < 16; i++ ) { self->freqMul[i] = freqScale * FreqCreateTable[ i ]; } @@ -1326,22 +1353,29 @@ void Chip__Setup(Chip *self, Bit32u rate ) { //Generate the best matching attack rate for ( i = 0; i < 62; i++ ) { Bit8u index, shift; + Bit32s original; // haleyjd 09/09/10: GNUisms out! + Bit32s guessAdd; + Bit32s bestAdd; + Bit32u bestDiff; + Bit32u passes; EnvelopeSelect( i, &index, &shift ); //Original amount of samples the attack would take - Bit32s original = (Bit32u)( (AttackSamplesTable[ index ] << shift) / scale); + original = (Bit32u)( (AttackSamplesTable[ index ] << shift) / scale); - Bit32s guessAdd = (Bit32u)( scale * (EnvelopeIncreaseTable[ index ] << ( RATE_SH - shift - 3 ))); - Bit32s bestAdd = guessAdd; - Bit32u bestDiff = 1 << 30; - Bit32u passes; + guessAdd = (Bit32u)( scale * (EnvelopeIncreaseTable[ index ] << ( RATE_SH - shift - 3 ))); + bestAdd = guessAdd; + bestDiff = 1 << 30; for ( passes = 0; passes < 16; passes ++ ) { Bit32s volume = ENV_MAX; Bit32s samples = 0; Bit32u count = 0; + Bit32s diff; + Bit32u lDiff; while ( volume > 0 && samples < original * 2 ) { + Bit32s change; // haleyjd 09/09/10 count += guessAdd; - Bit32s change = count >> RATE_SH; + change = count >> RATE_SH; count &= RATE_MASK; if ( GCC_UNLIKELY(change) ) { // less than 1 % volume += ( ~volume * change ) >> 3; @@ -1349,8 +1383,8 @@ void Chip__Setup(Chip *self, Bit32u rate ) { samples++; } - Bit32s diff = original - samples; - Bit32u lDiff = labs( diff ); + diff = original - samples; + lDiff = labs( diff ); //Init last on first pass if ( lDiff < bestDiff ) { bestDiff = lDiff; @@ -1510,65 +1544,71 @@ void DBOPL_InitTables( void ) { TremoloTable[TREMOLO_TABLE - 1 - i] = val; } //Create a table with offsets of the channels from the start of the chip - Chip *chip = NULL; - for ( i = 0; i < 32; i++ ) { - Bitu index = i & 0xf; - if ( index >= 9 ) { - ChanOffsetTable[i] = 0; - continue; - } - //Make sure the four op channels follow eachother - if ( index < 6 ) { - index = (index % 3) * 2 + ( index / 3 ); + { // haleyjd 09/09/10: Driving me #$%^@ insane + Chip *chip = NULL; + for ( i = 0; i < 32; i++ ) { + Bitu index = i & 0xf; + Bitu blah; // haleyjd 09/09/10 + if ( index >= 9 ) { + ChanOffsetTable[i] = 0; + continue; + } + //Make sure the four op channels follow eachother + if ( index < 6 ) { + index = (index % 3) * 2 + ( index / 3 ); + } + //Add back the bits for highest ones + if ( i >= 16 ) + index += 9; + blah = (Bitu) ( &(chip->chan[ index ]) ); + ChanOffsetTable[i] = blah; } - //Add back the bits for highest ones - if ( i >= 16 ) - index += 9; - Bitu blah = (Bitu) ( &(chip->chan[ index ]) ); - ChanOffsetTable[i] = blah; - } - //Same for operators - for ( i = 0; i < 64; i++ ) { - if ( i % 8 >= 6 || ( (i / 8) % 4 == 3 ) ) { - OpOffsetTable[i] = 0; - continue; + //Same for operators + for ( i = 0; i < 64; i++ ) { + Bitu chNum; // haleyjd 09/09/10 + Bitu opNum; + Bitu blah; + Channel* chan = NULL; + if ( i % 8 >= 6 || ( (i / 8) % 4 == 3 ) ) { + OpOffsetTable[i] = 0; + continue; + } + chNum = (i / 8) * 3 + (i % 8) % 3; + //Make sure we use 16 and up for the 2nd range to match the chanoffset gap + if ( chNum >= 12 ) + chNum += 16 - 12; + opNum = ( i % 8 ) / 3; + blah = (Bitu) ( &(chan->op[opNum]) ); + OpOffsetTable[i] = ChanOffsetTable[ chNum ] + blah; } - Bitu chNum = (i / 8) * 3 + (i % 8) % 3; - //Make sure we use 16 and up for the 2nd range to match the chanoffset gap - if ( chNum >= 12 ) - chNum += 16 - 12; - Bitu opNum = ( i % 8 ) / 3; - Channel* chan = NULL; - Bitu blah = (Bitu) ( &(chan->op[opNum]) ); - OpOffsetTable[i] = ChanOffsetTable[ chNum ] + blah; - } #if 0 - //Stupid checks if table's are correct - for ( Bitu i = 0; i < 18; i++ ) { - Bit32u find = (Bit16u)( &(chip->chan[ i ]) ); - for ( Bitu c = 0; c < 32; c++ ) { - if ( ChanOffsetTable[c] == find ) { - find = 0; - break; + //Stupid checks if table's are correct + for ( Bitu i = 0; i < 18; i++ ) { + Bit32u find = (Bit16u)( &(chip->chan[ i ]) ); + for ( Bitu c = 0; c < 32; c++ ) { + if ( ChanOffsetTable[c] == find ) { + find = 0; + break; + } } - } - if ( find ) { - find = find; - } - } - for ( Bitu i = 0; i < 36; i++ ) { - Bit32u find = (Bit16u)( &(chip->chan[ i / 2 ].op[i % 2]) ); - for ( Bitu c = 0; c < 64; c++ ) { - if ( OpOffsetTable[c] == find ) { - find = 0; - break; + if ( find ) { + find = find; } } - if ( find ) { - find = find; + for ( Bitu i = 0; i < 36; i++ ) { + Bit32u find = (Bit16u)( &(chip->chan[ i / 2 ].op[i % 2]) ); + for ( Bitu c = 0; c < 64; c++ ) { + if ( OpOffsetTable[c] == find ) { + find = 0; + break; + } + } + if ( find ) { + find = find; + } } - } #endif + } } /* diff --git a/opl/dbopl.h b/opl/dbopl.h index a5c10bfd..63aa1330 100644 --- a/opl/dbopl.h +++ b/opl/dbopl.h @@ -200,4 +200,7 @@ void Chip__Chip(Chip *self); void Chip__WriteReg(Chip *self, Bit32u reg, Bit8u val ); void Chip__GenerateBlock2(Chip *self, Bitu total, Bit32s* output ); - +// haleyjd 09/09/10: Not standard C. +#ifdef _MSC_VER +#define inline __inline +#endif diff --git a/opl/ioperm_sys.c b/opl/ioperm_sys.c index 8f50bcd3..531b4136 100644 --- a/opl/ioperm_sys.c +++ b/opl/ioperm_sys.c @@ -52,10 +52,12 @@ struct ioperm_data // Function pointers for advapi32.dll. This DLL does not exist on // Windows 9x, so they are dynamically loaded from the DLL at runtime. -static SC_HANDLE WINAPI (*MyOpenSCManagerW)(wchar_t *lpMachineName, +// haleyjd 09/09/10: Moved calling conventions into ()'s + +static SC_HANDLE (WINAPI *MyOpenSCManagerW)(wchar_t *lpMachineName, wchar_t *lpDatabaseName, DWORD dwDesiredAccess) = NULL; -static SC_HANDLE WINAPI (*MyCreateServiceW)(SC_HANDLE hSCManager, +static SC_HANDLE (WINAPI *MyCreateServiceW)(SC_HANDLE hSCManager, wchar_t *lpServiceName, wchar_t *lpDisplayName, DWORD dwDesiredAccess, @@ -68,17 +70,17 @@ static SC_HANDLE WINAPI (*MyCreateServiceW)(SC_HANDLE hSCManager, wchar_t *lpDependencies, wchar_t *lpServiceStartName, wchar_t *lpPassword); -static SC_HANDLE WINAPI (*MyOpenServiceW)(SC_HANDLE hSCManager, +static SC_HANDLE (WINAPI *MyOpenServiceW)(SC_HANDLE hSCManager, wchar_t *lpServiceName, DWORD dwDesiredAccess); -static BOOL WINAPI (*MyStartServiceW)(SC_HANDLE hService, +static BOOL (WINAPI *MyStartServiceW)(SC_HANDLE hService, DWORD dwNumServiceArgs, wchar_t **lpServiceArgVectors); -static BOOL WINAPI (*MyControlService)(SC_HANDLE hService, +static BOOL (WINAPI *MyControlService)(SC_HANDLE hService, DWORD dwControl, LPSERVICE_STATUS lpServiceStatus); -static BOOL WINAPI (*MyCloseServiceHandle)(SC_HANDLE hSCObject); -static BOOL WINAPI (*MyDeleteService)(SC_HANDLE hService); +static BOOL (WINAPI *MyCloseServiceHandle)(SC_HANDLE hSCObject); +static BOOL (WINAPI *MyDeleteService)(SC_HANDLE hService); static struct { diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index 1cfafa6f..2bce2fb1 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -479,11 +479,23 @@ static boolean CacheSFX(sfxinfo_t *sfxinfo) // If the header specifies that the length of the sound is greater than // the length of the lump itself, this is an invalid sound lump - if (length > lumplen - 8) + // We also discard sound lumps that are less than 49 samples long, + // as this is how DMX behaves - although the actual cut-off length + // seems to vary slightly depending on the sample rate. This needs + // further investigation to better understand the correct + // behavior. + + if (length > lumplen - 8 || length <= 48) { return false; } + // The DMX sound library seems to skip the first 16 and last 16 + // bytes of the lump - reason unknown. + + data += 16; + length -= 32; + // Sample rate conversion ExpandSoundData(sfxinfo, data + 8, samplerate, length); diff --git a/src/setup/display.c b/src/setup/display.c index 1e5e9e31..9ed0ae5f 100644 --- a/src/setup/display.c +++ b/src/setup/display.c @@ -257,9 +257,7 @@ static int GetSupportedBPPIndex(char *description) } } - // Shouldn't happen; fall back to the first in the list. - - return 0; + return -1; } // Set selected_bpp to match screen_bpp. @@ -277,7 +275,11 @@ static int TrySetSelectedBPP(void) if (pixel_depths[i].bpp == screen_bpp) { selected_bpp = GetSupportedBPPIndex(pixel_depths[i].description); - return 1; + + if (selected_bpp >= 0) + { + return 1; + } } } |