summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Haley2010-09-10 01:53:57 +0000
committerJames Haley2010-09-10 01:53:57 +0000
commit9f4c5a6ed4e490fb51aa207c2def75fcb2622584 (patch)
tree3f12bb085abcd77e071091bcd431e6c376288397
parent120d90c67b2a4aa0a8883c4897241dee2222acd2 (diff)
downloadchocolate-doom-9f4c5a6ed4e490fb51aa207c2def75fcb2622584.tar.gz
chocolate-doom-9f4c5a6ed4e490fb51aa207c2def75fcb2622584.tar.bz2
chocolate-doom-9f4c5a6ed4e490fb51aa207c2def75fcb2622584.zip
Post-merge fixes: Created project for OPL library. Fixed OPL library to
not use GNU C-isms such as inline keyword, declaration/statement mixing, and strange calling convention syntax for import function pointers. Fixed critical buffer overflow in M_BindChatControls - should be back-merged immediately. Added autogenerated directories *back* to ignore list. Subversion-branch: /branches/strife-branch Subversion-revision: 2052
-rw-r--r--.gitignore19
-rw-r--r--msvc/chocolate.sln6
-rw-r--r--msvc/libopl.vcproj232
-rw-r--r--msvc/strife.vcproj24
-rw-r--r--opl/dbopl.c208
-rw-r--r--opl/dbopl.h5
-rw-r--r--opl/ioperm_sys.c16
-rw-r--r--src/m_controls.c2
-rw-r--r--src/midifile.c10
9 files changed, 419 insertions, 103 deletions
diff --git a/.gitignore b/.gitignore
index 34652d0c..57ab998c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,21 +1,24 @@
-Makefile.in
-Makefile
-INSTALL
CMDLINE
-autotools
+INSTALL
+Makefile
+Makefile.in
+TAGS
aclocal.m4
-configure
+autom4te.cache
+autotools
+bin
+config.h
config.hin
config.log
config.status
-config.h
-autom4te.cache
+configure
+lib
+obj
rpm.spec
stamp-h
stamp-h.in
stamp-h1
tags
-TAGS
# These are the default patterns globally ignored by Subversion:
*.o
diff --git a/msvc/chocolate.sln b/msvc/chocolate.sln
index 5758df1c..2c9cca8b 100644
--- a/msvc/chocolate.sln
+++ b/msvc/chocolate.sln
@@ -32,6 +32,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtextscreen", "libtextscr
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Strife", "strife.vcproj", "{FC4DACBA-2A3E-4AF0-804A-AF5FFFD13B08}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libopl", "libopl.vcproj", "{FC8D0610-1507-4F36-99BC-6F5A422B6AD3}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -70,6 +72,10 @@ Global
{FC4DACBA-2A3E-4AF0-804A-AF5FFFD13B08}.Debug|Win32.Build.0 = Debug|Win32
{FC4DACBA-2A3E-4AF0-804A-AF5FFFD13B08}.Release|Win32.ActiveCfg = Release|Win32
{FC4DACBA-2A3E-4AF0-804A-AF5FFFD13B08}.Release|Win32.Build.0 = Release|Win32
+ {FC8D0610-1507-4F36-99BC-6F5A422B6AD3}.Debug|Win32.ActiveCfg = Debug|Win32
+ {FC8D0610-1507-4F36-99BC-6F5A422B6AD3}.Debug|Win32.Build.0 = Debug|Win32
+ {FC8D0610-1507-4F36-99BC-6F5A422B6AD3}.Release|Win32.ActiveCfg = Release|Win32
+ {FC8D0610-1507-4F36-99BC-6F5A422B6AD3}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/msvc/libopl.vcproj b/msvc/libopl.vcproj
new file mode 100644
index 00000000..f7fbb59b
--- /dev/null
+++ b/msvc/libopl.vcproj
@@ -0,0 +1,232 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libopl"
+ ProjectGUID="{FC8D0610-1507-4F36-99BC-6F5A422B6AD3}"
+ RootNamespace="libopl"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="..\lib"
+ IntermediateDirectory="..\obj\libopl\$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".;..\src"
+ PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="..\lib"
+ IntermediateDirectory="..\obj\libopl\$(ConfigurationName)"
+ ConfigurationType="4"
+ CharacterSet="2"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ FavorSizeOrSpeed="0"
+ AdditionalIncludeDirectories=".;..\src"
+ PreprocessorDefinitions="WIN32;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE"
+ StringPooling="true"
+ MinimalRebuild="false"
+ ExceptionHandling="0"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ WarningLevel="3"
+ DebugInformationFormat="0"
+ CompileAs="1"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath="..\opl\dbopl.c"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\ioperm_sys.c"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl.c"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_linux.c"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_obsd.c"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_queue.c"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_sdl.c"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_timer.c"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_win32.c"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath="..\opl\dbopl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\ioperm_sys.h"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl.h"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_internal.h"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_queue.h"
+ >
+ </File>
+ <File
+ RelativePath="..\opl\opl_timer.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/msvc/strife.vcproj b/msvc/strife.vcproj
index a78a52e6..63778125 100644
--- a/msvc/strife.vcproj
+++ b/msvc/strife.vcproj
@@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
- AdditionalIncludeDirectories=".;..\src;..\src\strife;..\src\doom;..\textscreen;..\pcsound"
+ AdditionalIncludeDirectories=".;..\src;..\src\strife;..\src\doom;..\textscreen;..\pcsound;..\opl"
PreprocessorDefinitions="WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;PROGRAM_PREFIX=&quot;\&quot;chocolate-\&quot;&quot;"
MinimalRebuild="true"
ExceptionHandling="0"
@@ -66,7 +66,7 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="SDL.lib SDL_mixer.lib SDL_net.lib SDLmain.lib ..\lib\libpcsound.lib ..\lib\libtextscreen.lib"
+ AdditionalDependencies="SDL.lib SDL_mixer.lib SDL_net.lib SDLmain.lib ..\lib\libpcsound.lib ..\lib\libtextscreen.lib ..\lib\libopl.lib"
OutputFile="$(OutDir)\chocolate-strife-dbg.exe"
LinkIncremental="2"
IgnoreDefaultLibraryNames="msvcrtd.lib"
@@ -302,6 +302,10 @@
>
</File>
<File
+ RelativePath="..\src\midifile.h"
+ >
+ </File>
+ <File
RelativePath="..\src\mus2mid.h"
>
</File>
@@ -374,6 +378,10 @@
>
</File>
<File
+ RelativePath="..\src\w_main.h"
+ >
+ </File>
+ <File
RelativePath="..\src\w_merge.h"
>
</File>
@@ -642,6 +650,10 @@
>
</File>
<File
+ RelativePath="..\src\i_oplmusic.c"
+ >
+ </File>
+ <File
RelativePath="..\src\i_pcsound.c"
>
</File>
@@ -714,6 +726,10 @@
>
</File>
<File
+ RelativePath="..\src\midifile.c"
+ >
+ </File>
+ <File
RelativePath="..\src\mus2mid.c"
>
</File>
@@ -774,6 +790,10 @@
>
</File>
<File
+ RelativePath="..\src\w_main.c"
+ >
+ </File>
+ <File
RelativePath="..\src\w_merge.c"
>
</File>
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/m_controls.c b/src/m_controls.c
index 8b8af160..a9beed46 100644
--- a/src/m_controls.c
+++ b/src/m_controls.c
@@ -355,7 +355,7 @@ void M_BindMenuControls(void)
void M_BindChatControls(unsigned int num_players)
{
- char name[20];
+ char name[32]; // haleyjd: 20 not large enough - Thank you, come again!
int i;
M_BindVariable("key_multi_msg", &key_multi_msg);
diff --git a/src/midifile.c b/src/midifile.c
index 1990dcdc..e9af051c 100644
--- a/src/midifile.c
+++ b/src/midifile.c
@@ -36,6 +36,11 @@
#define TRACK_CHUNK_ID "MTrk"
#define MAX_BUFFER_SIZE 0x10000
+// haleyjd 09/09/10: packing required
+#ifdef _MSC_VER
+#pragma pack(push, 1)
+#endif
+
typedef struct
{
byte chunk_id[4];
@@ -50,6 +55,11 @@ typedef struct
unsigned short time_division;
} PACKEDATTR midi_header_t;
+// haleyjd 09/09/10: packing off.
+#ifdef _MSC_VER
+#pragma pack(pop)
+#endif
+
typedef struct
{
// Length in bytes: