From 645e33ef2522d402cc11f7f5252abc27819c4d66 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 14 Feb 2011 20:40:23 +0000 Subject: Increase buffer size to 32 to fix overflow (thanks Quasar). Subversion-branch: /branches/raven-branch Subversion-revision: 2267 --- src/m_controls.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/m_controls.c b/src/m_controls.c index 60a96ac2..685a0f13 100644 --- a/src/m_controls.c +++ b/src/m_controls.c @@ -303,7 +303,7 @@ void M_BindMenuControls(void) void M_BindChatControls(unsigned int num_players) { - char name[20]; + char name[32]; int i; M_BindVariable("key_multi_msg", &key_multi_msg); -- cgit v1.2.3 From 8bf9496eeb4b9b32f1863cd10765b31f80bb971c Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 20 Feb 2011 22:29:52 +0000 Subject: Looks like a merge error - oops. Subversion-branch: /branches/raven-branch Subversion-revision: 2270 --- src/setup/keyboard.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/setup/keyboard.c b/src/setup/keyboard.c index 3d9f9977..a128b3ab 100644 --- a/src/setup/keyboard.c +++ b/src/setup/keyboard.c @@ -294,12 +294,6 @@ static void OtherKeysDialog(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) AddKeyControl(table, "- to brown", &key_multi_msgplayer[2]); AddKeyControl(table, "- to red", &key_multi_msgplayer[3]); - TXT_AddWidgets(table, TXT_NewStrut(0, 1), - TXT_NewStrut(0, 1), - TXT_NewLabel(" - Map - "), - TXT_NewStrut(0, 0), - NULL); - scrollpane = TXT_NewScrollPane(0, 13, table); TXT_AddWidget(window, scrollpane); -- cgit v1.2.3 From b24a72cfd68ccf06ab86a70356f5c6df87bd9eb6 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 24 Feb 2011 20:55:54 +0000 Subject: Load response files from main() before calling D_DoomMain, so that all executables load response files, including the setup tool. Subversion-branch: /branches/raven-branch Subversion-revision: 2276 --- src/doom/d_main.c | 2 -- src/heretic/d_main.c | 1 - src/hexen/h2_main.c | 1 - src/i_main.c | 2 ++ 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/doom/d_main.c b/src/doom/d_main.c index 2f116f1e..991907fa 100644 --- a/src/doom/d_main.c +++ b/src/doom/d_main.c @@ -1100,8 +1100,6 @@ void D_DoomMain (void) I_AtExit(D_Endoom, false); - M_FindResponseFile (); - // print banner I_PrintBanner(PACKAGE_STRING); diff --git a/src/heretic/d_main.c b/src/heretic/d_main.c index 169a86ea..5c2d5cf2 100644 --- a/src/heretic/d_main.c +++ b/src/heretic/d_main.c @@ -805,7 +805,6 @@ void D_DoomMain(void) I_AtExit(D_Endoom, false); - M_FindResponseFile(); nomonsters = M_CheckParm("-nomonsters"); respawnparm = M_CheckParm("-respawn"); ravpic = M_CheckParm("-ravpic"); diff --git a/src/hexen/h2_main.c b/src/hexen/h2_main.c index abc58f15..4f9fe312 100644 --- a/src/hexen/h2_main.c +++ b/src/hexen/h2_main.c @@ -232,7 +232,6 @@ void D_DoomMain(void) int p; I_AtExit(D_HexenQuitMessage, false); - M_FindResponseFile(); startepisode = 1; autostart = false; startskill = sk_medium; diff --git a/src/i_main.c b/src/i_main.c index 1ccc52c0..fdfa3cbc 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -154,6 +154,8 @@ int main(int argc, char **argv) LockCPUAffinity(); + M_FindResponseFile(); + // start doom D_DoomMain (); -- cgit v1.2.3 From 72c1191348ab26e7d3171791c48353cd708a74fa Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 24 Feb 2011 20:57:30 +0000 Subject: Make code changes to add Heretic/Hexen support to OS X launcher. Subversion-branch: /branches/raven-branch Subversion-revision: 2277 --- pkg/osx/IWADController.h | 4 ++++ pkg/osx/IWADController.m | 35 ++++++++++++++++++++++++++++++++++- pkg/osx/LauncherManager.m | 24 +++++++++++++++++++++--- 3 files changed, 59 insertions(+), 4 deletions(-) diff --git a/pkg/osx/IWADController.h b/pkg/osx/IWADController.h index 90f44667..fef28918 100644 --- a/pkg/osx/IWADController.h +++ b/pkg/osx/IWADController.h @@ -36,6 +36,9 @@ id doom2; id plutonia; id tnt; + + id heretic; + id hexen; } - (void) closeConfigWindow: (id)sender; @@ -47,6 +50,7 @@ - (void) saveConfig; - (char *) doomWadPath; - (void) setEnvironment; +- (const char *) getGameName; @end diff --git a/pkg/osx/IWADController.m b/pkg/osx/IWADController.m index 3c596850..6cab7ff2 100644 --- a/pkg/osx/IWADController.m +++ b/pkg/osx/IWADController.m @@ -33,6 +33,8 @@ typedef enum IWAD_TNT, IWAD_PLUTONIA, IWAD_CHEX, + IWAD_HERETIC, + IWAD_HEXEN, NUM_IWAD_TYPES } IWAD; @@ -42,7 +44,9 @@ static NSString *IWADLabels[NUM_IWAD_TYPES] = @"Doom II: Hell on Earth", @"Final Doom: TNT: Evilution", @"Final Doom: Plutonia Experiment", - @"Chex Quest" + @"Chex Quest", + @"Heretic", + @"Hexen" }; static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] = @@ -52,6 +56,8 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] = @"tnt.wad", @"plutonia.wad", @"chex.wad", + @"heretic.wad", + @"hexen.wad", @"undefined" }; @@ -64,6 +70,8 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] = iwadList[IWAD_TNT] = self->tnt; iwadList[IWAD_PLUTONIA] = self->plutonia; iwadList[IWAD_CHEX] = self->chex; + iwadList[IWAD_HERETIC] = self->heretic; + iwadList[IWAD_HEXEN] = self->hexen; } - (IWAD) getSelectedIWAD @@ -102,6 +110,27 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] = } } +// Get the name used for the executable for the selected IWAD. + +- (const char *) getGameName +{ + IWAD selectedIWAD; + + selectedIWAD = [self getSelectedIWAD]; + + switch (selectedIWAD) + { + case IWAD_HERETIC: + return "heretic"; + + case IWAD_HEXEN: + return "hexen"; + + default: + return "doom"; + } +} + - (void) setIWADConfig { IWADLocation *iwadList[NUM_IWAD_TYPES]; @@ -250,6 +279,10 @@ static NSString *IWADFilenames[NUM_IWAD_TYPES + 1] = - (void) awakeFromNib { + // TODO: This is temporary: + self->heretic = self->doom1; + self->hexen = self->doom2; + [self->configWindow center]; // Set configuration for all IWADs from configuration file. diff --git a/pkg/osx/LauncherManager.m b/pkg/osx/LauncherManager.m index 8c523ab4..36723db5 100644 --- a/pkg/osx/LauncherManager.m +++ b/pkg/osx/LauncherManager.m @@ -278,6 +278,8 @@ static NSString *AppendQuotedFilename(NSString *str, NSString *fileName) { NSString *iwad; NSString *args; + char *executable_name; + const char *game_name; [self saveConfig]; @@ -294,7 +296,11 @@ static NSString *AppendQuotedFilename(NSString *str, NSString *fileName) return; } - ExecuteProgram(PACKAGE_TARNAME, [iwad UTF8String], + game_name = [self->iwadController getGameName]; + executable_name = malloc(strlen(PROGRAM_PREFIX) + strlen(game_name) + 1); + sprintf(executable_name, "%s%s", PROGRAM_PREFIX, game_name); + + ExecuteProgram(executable_name, [iwad UTF8String], [args UTF8String]); [NSApp terminate:sender]; } @@ -303,10 +309,22 @@ static NSString *AppendQuotedFilename(NSString *str, NSString *fileName) - (void) runSetup: (id)sender { - [self saveConfig]; + const char *game_name; + char *arg; + [self saveConfig]; [self->iwadController setEnvironment]; - ExecuteProgram("chocolate-setup", NULL, NULL); + + // Provide the -game command line parameter to select the game + // to configure, based on the game selected in the dropdown. + + game_name = [self->iwadController getGameName]; + arg = malloc(strlen(game_name) + 8); + sprintf(arg, "-game %s", game_name); + + ExecuteProgram(PROGRAM_PREFIX "setup", NULL, arg); + + free(arg); } // Invoked when the "Terminal" option is selected from the menu, to open -- cgit v1.2.3 From 909d93ce182c215fddcd48acec9dd291dd8aba34 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 28 Feb 2011 20:48:27 +0000 Subject: Fix autoadjust of pixel depth in setup tool. Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2283 --- setup/display.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/setup/display.c b/setup/display.c index f4a82520..b4e95688 100644 --- a/setup/display.c +++ b/setup/display.c @@ -247,9 +247,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. @@ -267,7 +265,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; + } } } -- cgit v1.2.3 From 52db6da5814c867fc6dd6bb0ec5d51d76b1fcc4e Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 28 Feb 2011 21:19:09 +0000 Subject: Bind screen_bpp variable in setup tool. Subversion-branch: /branches/raven-branch Subversion-revision: 2284 --- src/setup/display.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/setup/display.c b/src/setup/display.c index f5f190f2..1e5e9e31 100644 --- a/src/setup/display.c +++ b/src/setup/display.c @@ -715,6 +715,7 @@ void BindDisplayVariables(void) M_BindVariable("fullscreen", &fullscreen); M_BindVariable("screen_width", &screen_width); M_BindVariable("screen_height", &screen_height); + M_BindVariable("screen_bpp", &screen_bpp); M_BindVariable("startup_delay", &startup_delay); M_BindVariable("video_driver", &video_driver); M_BindVariable("usegamma", &usegamma); -- cgit v1.2.3 From 6a5d123fc662bcdbc08d973e3b8b79a95f24fa51 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 3 Mar 2011 21:41:51 +0000 Subject: Fix Visual Studio build (thanks GhostlyDeath). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2287 --- NEWS | 1 + msvc/ChocolateDoom.vcproj | 622 +++++++++++++++++++++++++++++++++++++++++++++- opl/dbopl.c | 208 +++++++++------- opl/dbopl.h | 5 +- opl/ioperm_sys.c | 16 +- 5 files changed, 754 insertions(+), 98 deletions(-) diff --git a/NEWS b/NEWS index 7e89584c..ad358aed 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,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/msvc/ChocolateDoom.vcproj b/msvc/ChocolateDoom.vcproj index 5e01a47d..c87da01b 100644 --- a/msvc/ChocolateDoom.vcproj +++ b/msvc/ChocolateDoom.vcproj @@ -41,11 +41,12 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3030,6 +3108,42 @@ /> + + + + + + + + + + + + + + @@ -4463,9 +4577,22 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 { -- cgit v1.2.3 From b0519667da8edcea1592a0ba7b0dfa4b4709e034 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Sun, 6 Mar 2011 20:59:51 +0000 Subject: Discard very short sound effects and strip lead-in / lead-out samples that apparently aren't played by Vanilla Doom (thanks Quasar). Subversion-branch: /trunk/chocolate-doom Subversion-revision: 2291 --- NEWS | 5 +++++ src/i_sdlsound.c | 14 +++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index ad358aed..3983ac76 100644 --- a/NEWS +++ b/NEWS @@ -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). diff --git a/src/i_sdlsound.c b/src/i_sdlsound.c index a26a81dd..14a5147f 100644 --- a/src/i_sdlsound.c +++ b/src/i_sdlsound.c @@ -359,7 +359,13 @@ static boolean LoadSoundLump(int sound, // 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) { W_ReleaseLumpNum(*lumpnum); return false; @@ -368,6 +374,12 @@ static boolean LoadSoundLump(int sound, // Prune header *data_ref += 8; + // The DMX sound library seems to skip the first 16 and last 16 + // bytes of the lump - reason unknown. + + *data_ref += 16; + *length -= 32; + return true; } -- cgit v1.2.3