1
0
mirror of https://github.com/jummy0/sb2-decomp synced 2025-03-15 04:24:48 +01:00
This commit is contained in:
jummy 2024-09-23 20:41:01 -05:00
commit ee08f63a37
77 changed files with 16005 additions and 10656 deletions

12
.gitignore vendored

@ -3,11 +3,13 @@
################################################################################
/.vs
/Release
/Debug
/x64
/Release
/Speedy E.e424a3cb
/DATA
/IMAGE*
/MOVIE
/x64
/IMAGE08
/IMAGE16
/SOUND
/MOVIE
/DATA
Speedy Eggbert 2 Source.vcxproj.user

2
.gitmodules vendored

@ -1,3 +1,3 @@
[submodule "dxsdk3"]
path = dxsdk3
url = https://github.com/masonmc/dxsdk3.git
url = https://github.com/jummy0/dxsdk3.git

@ -5,18 +5,18 @@
| CPP File | Progress |
| -------- | -------- |
| blupi.cpp | 95% complete |
| button.cpp | 98% complete |
| decblupi.cpp | 1% complete |
| decor.cpp | 8% complete |
| event.cpp | 30% complete |
| blupi.cpp | 99% complete |
| button.cpp | 100% complete |
| decor.cpp | 80% complete |
| event.cpp | 70% complete |
| menu.cpp | 100% complete |
| misc.cpp | 100% complete |
| movie.cpp | 100% complete |
| network.cpp | 2% complete |
| pixmap.cpp | 80% complete |
| sound.cpp | 90% complete |
| text.cpp | 85% complete |
| network.cpp | 100% complete |
| pixmap.cpp | 99% complete |
| sound.cpp | 100% complete |
| text.cpp | 100% complete |
| wave.cpp | 100% complete |
Credit to jummy over at the Blupi Games Fan Server for doing the decompilation work on the game.

@ -23,34 +23,35 @@
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{e424a3cb-c8b8-447c-be63-41a57e65b449}</ProjectGuid>
<RootNamespace>SpeedyEggbert2Source</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<CharacterSet>NotSet</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
@ -70,19 +71,38 @@
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<TargetName>$(ProjectName)_</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<TargetName>$(ProjectName)_</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<TargetName>$(ProjectName)_</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<TargetName>$(ProjectName)_</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WINVER=0x400;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
<AdditionalIncludeDirectories>dxsdk3\sdk\inc</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE;_WIN32_WINNT;NTDDI_VERSION</UndefinePreprocessorDefinitions>
<PrecompiledHeaderFile />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalOptions>/FORCE:MULTIPLE /DYNAMICBASE "legacy_stdio_definitions.lib" %(AdditionalOptions) </AdditionalOptions>
<AdditionalLibraryDirectories>./dxsdk3/sdk/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>/DYNAMICBASE "legacy_stdio_definitions.lib" %(AdditionalOptions) /VERBOSE</AdditionalOptions>
<AdditionalLibraryDirectories>dxsdk3\sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<TreatLinkerWarningAsErrors>false</TreatLinkerWarningAsErrors>
<AdditionalDependencies>dxsdk3/sdk/lib/*.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<OptimizeReferences>true</OptimizeReferences>
<ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -91,28 +111,41 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WINVER=0x400;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>dxsdk3\sdk\inc</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE;_WIN32_WINNT;NTDDI_VERSION</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>./dxsdk3/sdk/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>dxsdk3\sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput>
<AdditionalOptions>/DYNAMICBASE "legacy_stdio_definitions.lib" %(AdditionalOptions) /VERBOSE</AdditionalOptions>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<AdditionalDependencies>dxsdk3/sdk/lib/*.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WINVER=0x400;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>dxsdk3\sdk\inc</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE;_WIN32_WINNT;NTDDI_VERSION</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>./dxsdk3/sdk/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>dxsdk3\sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<OptimizeReferences>true</OptimizeReferences>
<ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput>
<AdditionalOptions>/DYNAMICBASE "legacy_stdio_definitions.lib" %(AdditionalOptions) /VERBOSE</AdditionalOptions>
<AdditionalDependencies>dxsdk3/sdk/lib/*.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -121,81 +154,89 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WINVER=0x400;WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>dxsdk3\sdk\inc</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE;_WIN32_WINNT;NTDDI_VERSION</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>./dxsdk3/sdk/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>dxsdk3\sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ForceFileOutput>MultiplyDefinedSymbolOnly</ForceFileOutput>
<AdditionalOptions>/DYNAMICBASE "legacy_stdio_definitions.lib" %(AdditionalOptions) /VERBOSE</AdditionalOptions>
<LinkTimeCodeGeneration>Default</LinkTimeCodeGeneration>
<AdditionalDependencies>dxsdk3/sdk/lib/*.lib;winmm.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="action.h" />
<ClInclude Include="button.h" />
<ClInclude Include="ddraw.h" />
<ClInclude Include="ddutil.h" />
<ClInclude Include="decor.h" />
<ClInclude Include="dectables.h" />
<ClInclude Include="def.h" />
<ClInclude Include="dplay.h" />
<ClInclude Include="dsound.h" />
<ClInclude Include="event.h" />
<ClInclude Include="fifo.h" />
<ClInclude Include="decmove.h" />
<ClInclude Include="jauge.h" />
<ClInclude Include="menu.h" />
<ClInclude Include="misc.h" />
<ClInclude Include="movie.h" />
<ClInclude Include="network.h" />
<ClInclude Include="pixmap.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="resource1.h" />
<ClInclude Include="sound.h" />
<ClInclude Include="text.h" />
<ClInclude Include="texttables.h" />
<ClInclude Include="wave.h" />
<None Include="Debug\DATA\config.def" />
<None Include="resource\IDC_ARROW.cur" />
<None Include="resource\IDC_ARROWD.cur" />
<None Include="resource\IDC_ARROWDL.cur" />
<None Include="resource\IDC_ARROWDR.cur" />
<None Include="resource\IDC_ARROWL.cur" />
<None Include="resource\IDC_ARROWR.cur" />
<None Include="resource\IDC_ARROWU.cur" />
<None Include="resource\IDC_ARROWUL.cur" />
<None Include="resource\IDC_ARROWUR.cur" />
<None Include="resource\IDC_EMPTY.cur" />
<None Include="resource\IDC_FILL.cur" />
<None Include="resource\IDC_MAP.cur" />
<None Include="resource\IDC_POINTER.cur" />
<None Include="resource\IDC_WAIT.cur" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="blupi.cpp" />
<ClCompile Include="button.cpp" />
<ClCompile Include="ddutil.cpp" />
<ClCompile Include="decor.cpp" />
<ClCompile Include="event.cpp" />
<ClCompile Include="jauge.cpp" />
<ClCompile Include="menu.cpp" />
<ClCompile Include="misc.cpp" />
<ClCompile Include="movie.cpp" />
<ClCompile Include="network.cpp" />
<ClCompile Include="pixmap.cpp" />
<ClCompile Include="sound.cpp" />
<ClCompile Include="text.cpp" />
<ClCompile Include="wave.cpp" />
<ClCompile Include="src\blupi.cpp" />
<ClCompile Include="src\button.cpp" />
<ClCompile Include="src\ddutil.cpp" />
<ClCompile Include="src\decblock.cpp" />
<ClCompile Include="src\decblupi.cpp" />
<ClCompile Include="src\decdesign.cpp" />
<ClCompile Include="src\decio.cpp" />
<ClCompile Include="src\decmove.cpp" />
<ClCompile Include="src\decnet.cpp" />
<ClCompile Include="src\decor.cpp" />
<ClCompile Include="src\event.cpp" />
<ClCompile Include="src\jauge.cpp" />
<ClCompile Include="src\menu.cpp" />
<ClCompile Include="src\misc.cpp" />
<ClCompile Include="src\movie.cpp" />
<ClCompile Include="src\network.cpp" />
<ClCompile Include="src\pixmap.cpp" />
<ClCompile Include="src\sound.cpp" />
<ClCompile Include="src\text.cpp" />
<ClCompile Include="src\wave.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Eggbert2.rc" />
<ClInclude Include="src\button.h" />
<ClInclude Include="src\ddutil.h" />
<ClInclude Include="src\decor.h" />
<ClInclude Include="src\dectables.h" />
<ClInclude Include="src\def.h" />
<ClInclude Include="src\event.h" />
<ClInclude Include="src\jauge.h" />
<ClInclude Include="src\menu.h" />
<ClInclude Include="src\misc.h" />
<ClInclude Include="src\movie.h" />
<ClInclude Include="src\network.h" />
<ClInclude Include="src\obstacle.h" />
<ClInclude Include="src\pixmap.h" />
<ClInclude Include="src\pixtables.h" />
<ClInclude Include="src\resource.h" />
<ClInclude Include="src\resource1.h" />
<ClInclude Include="src\sound.h" />
<ClInclude Include="src\text.h" />
<ClInclude Include="src\texttables.h" />
<ClInclude Include="src\wave.h" />
</ItemGroup>
<ItemGroup>
<None Include="cursor1.cur" />
<None Include="IDC_ARROW.cur" />
<None Include="IDC_ARROWD.cur" />
<None Include="IDC_ARROWDL.cur" />
<None Include="IDC_ARROWDR.cur" />
<None Include="IDC_ARROWL.cur" />
<None Include="IDC_ARROWR.cur" />
<None Include="IDC_ARROWU.cur" />
<None Include="IDC_ARROWUL.cur" />
<None Include="IDC_ARROWUR.cur" />
<None Include="IDC_EMPTY.cur" />
<None Include="IDC_FILL.cur" />
<None Include="IDC_MAP.cur" />
<None Include="IDC_POINTER.cur" />
<None Include="IDC_WAIT.cur" />
<Image Include="resource\IDR_MAINFRAME.ico" />
</ItemGroup>
<ItemGroup>
<Image Include="IDR_MAINFRAME.ico" />
<ResourceCompile Include="resource\Eggbert2.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

@ -13,174 +13,189 @@
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Data">
<UniqueIdentifier>{0ff9ef1b-78f1-41d7-9a2b-813cedd6907d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="button.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ddraw.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ddutil.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="decor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="def.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dplay.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dsound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="event.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="jauge.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="menu.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="misc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="movie.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="network.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="pixmap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="sound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="text.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="wave.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="decmove.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="dectables.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="texttables.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="resource1.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="blupi.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="button.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ddutil.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="decor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="event.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="jauge.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="menu.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="misc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="movie.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="network.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pixmap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="sound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="text.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="wave.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Eggbert2.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<None Include="cursor1.cur">
<None Include="Debug\DATA\config.def">
<Filter>Data</Filter>
</None>
<None Include="resource\IDC_FILL.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROW.cur">
<None Include="resource\IDC_MAP.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROWD.cur">
<None Include="resource\IDC_POINTER.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROWDL.cur">
<None Include="resource\IDC_WAIT.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROWDR.cur">
<None Include="resource\IDC_ARROW.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROWL.cur">
<None Include="resource\IDC_ARROWD.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROWR.cur">
<None Include="resource\IDC_ARROWDL.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROWU.cur">
<None Include="resource\IDC_ARROWDR.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROWUL.cur">
<None Include="resource\IDC_ARROWL.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_ARROWUR.cur">
<None Include="resource\IDC_ARROWR.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_EMPTY.cur">
<None Include="resource\IDC_ARROWU.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_FILL.cur">
<None Include="resource\IDC_ARROWUL.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_MAP.cur">
<None Include="resource\IDC_ARROWUR.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_POINTER.cur">
<Filter>Resource Files</Filter>
</None>
<None Include="IDC_WAIT.cur">
<None Include="resource\IDC_EMPTY.cur">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Image Include="IDR_MAINFRAME.ico">
<ClCompile Include="src\blupi.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\button.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\ddutil.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\decblupi.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\decor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\event.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\jauge.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\menu.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\misc.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\movie.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\network.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\pixmap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\sound.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\text.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\wave.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\decblock.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\decnet.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\decdesign.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\decio.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\decmove.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\resource.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\dectables.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\decor.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\def.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\event.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\jauge.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\menu.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\misc.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\movie.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\network.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\obstacle.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\pixmap.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\resource1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\sound.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\texttables.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\text.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\wave.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\button.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\ddutil.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="src\pixtables.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="resource\IDR_MAINFRAME.ico">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="resource\Eggbert2.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
</Project>

@ -1,14 +0,0 @@
#define OPTERM 0
#define OPLIST 1
#define OPREPEAT 2
#define OPSOUND 3
typedef enum
{
obj_squaretech0,
obj_squaretech1,
obj_squaretech2,
obj_triangulartech_left0,
}
Object;

@ -1,449 +0,0 @@
// Button.cpp
//
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
//#include <minwindef.h>
#include <windef.h>
#include "def.h"
#include "pixmap.h"
#include "sound.h"
#include "decor.h"
#include "button.h"
#include "misc.h"
using namespace std;
//////////////////////////////////////////////////////////
// Constructor
CButton::CButton()
{
m_type = 0;
m_bEnable = TRUE;
m_bHide = FALSE;
m_bSomething = FALSE;
m_state = 0;
m_mouseState = 0;
m_nbMenu = 0;
m_nbToolTips = 0;
m_selMenu = 0;
m_bMouseDown = FALSE;
m_bMinimizeRedraw = FALSE;
m_bRedraw = FALSE;
}
// Destructor
CButton::~CButton()
{
}
// Create a new Button
BOOL CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
POINT pos, int type, BOOL bMinimizeRedraw, int region, UINT message)
{
POINT iconDim;
//int i, icon;
static int ttypes[] =
{
DIMBUTTONX,DIMBUTTONY,
};
if ( type < 0 || type > 0 ) return FALSE;
iconDim.x = ttypes[type*2+0];
iconDim.y = ttypes[type*2+1];
m_hWnd = hWnd;
m_pPixmap = pPixmap;
m_pSound = pSound;
m_type = type;
m_bMinimizeRedraw = bMinimizeRedraw;
m_bEnable = TRUE;
m_bHide = FALSE;
m_bSomething = FALSE;
m_message = message;
m_pos.x = pos.x;
m_pos.y = pos.y;
m_dim.x = iconDim.x;
m_dim.y = iconDim.y;
m_nbMenu = 0;
m_nbToolTips = 0;
m_selMenu = 0;
m_state = 0;
m_mouseState = 0;
m_bMouseDown = FALSE;
m_bRedraw = TRUE;
/* Do we need this yet?
// No. 👍
///////////////////////////////////////////////////
for ( i=0 ; i<nbMenu ; i++ )
{
icon = pMenu[i];
if ( region == 1 ) // palmiers ?
{
if ( icon == 0 ) icon = 90; // sol normal
if ( icon == 1 ) icon = 91; // sol inflammable
if ( icon == 2 ) icon = 92; // sol inculte
if ( icon == 7 ) icon = 9; // plante
if ( icon == 8 ) icon = 10; // arbre
}
if ( region == 2 ) // hiver ?
{
if ( icon == 0 ) icon = 96; // sol normal
if ( icon == 1 ) icon = 97; // sol inflammable
if ( icon == 2 ) icon = 98; // sol inculte
if ( icon == 8 ) icon = 99; // arbre
}
if ( region == 3 ) // sapin ?
{
if ( icon == 0 ) icon = 102; // sol normal
if ( icon == 1 ) icon = 103; // sol inflammable
if ( icon == 2 ) icon = 104; // sol inculte
if ( icon == 8 ) icon = 105; // arbre
}
m_iconMenu[i] = icon;
}
for ( i=0 ; i<nbToolTips ; i++ )
{
m_toolTips[i] = pToolTips[i];
}
/////////////////////////////////////////////////////
*/
return TRUE;
}
// Space for unknown menu function.
void CButton::SetSomethingMenu(int somethingMenu)
{
int i = somethingMenu;
while (0 < i)
{
//TODO
}
}
// Draw a button according to its state
void CButton::Draw()
{
int i;
POINT pos;
RECT rect;
if ( m_bMinimizeRedraw && !m_bRedraw ) return;
m_bRedraw = FALSE, m_bSomething = FALSE;
if ( m_bHide ) // is button hidden ?
{
m_pPixmap->DrawPart(-1, CHBACK, m_pos, { m_pos.x, m_pos.y, m_pos.x + m_dim.x, m_pos.y + m_dim.y }, 1); // draw the background
return;
}
if( m_bEnable ) // is button active ?
{
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, m_mouseState, m_pos);
}
else
{
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, 4, m_pos);
}
if ( m_nbMenu == 0 ) return;
pos = m_pos;
if ( m_nbMenu > 0 )
{
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type,
m_iconMenu[m_selMenu]+6, pos);
}
if ( m_nbMenu == 1 || !m_bEnable || !m_bMouseDown ) return;
pos = m_pos;
pos.x += m_dim.x+2;
for ( i=0 ; i<m_nbMenu ; i++ )
{
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, i==m_selMenu?1:0, pos);
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, m_iconMenu[i]+6, pos);
pos.x += m_dim.x-1;
}
}
/*
/Needed Yet?
//////////////////////////////////////////////
void CButton::Redraw()
{
m_bRedraw = TRUE;
}
//////////////////////////////////////////////
*/
int CButton::GetState()
{
return m_state;
}
void CButton::SetState(int state)
{
if ( m_state != state ||
m_mouseState != state )
{
m_bRedraw = TRUE;
}
m_state = state;
m_mouseState = state;
}
int CButton::GetMenu()
{
return m_selMenu;
}
void CButton::SetMenu(int menu)
{
if ( m_selMenu != menu )
{
m_bRedraw = TRUE;
}
m_selMenu = menu;
}
void CButton::SetEnable(BOOL bEnable)
{
if ( m_bEnable != bEnable )
{
m_bRedraw = TRUE;
}
m_bEnable = bEnable;
}
void CButton::SetSomething(BOOL bSomething)
{
if (m_bSomething != bSomething)
{
m_bRedraw = TRUE;
}
m_bSomething = bSomething;
}
BOOL CButton::GetHide()
{
return m_bHide;
}
void CButton::SetHide(BOOL bHide)
{
if ( m_bHide != bHide )
{
m_bRedraw = TRUE;
}
m_bHide = bHide;
}
// Event handling.
BOOL CButton::TreatEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
POINT pos;
if ( m_bHide || !m_bEnable ) return FALSE;
pos = ConvLongToPos(lParam);
switch( message )
{
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
if ( MouseDown(pos) ) return TRUE;
break;
case WM_MOUSEMOVE:
if ( MouseMove(pos) ) return TRUE;
break;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
if ( MouseUp(pos) ) return FALSE; // (*)
break;
}
return FALSE;
}
// (*) All buttons must receive the BUTTONUP event!
// Indicates whether the mouse is over this button.
BOOL CButton::MouseOnButton(POINT pos)
{
return Detect(pos);
}
// Return the tooltips for a button, depending
// on mouse position.
int CButton::GetToolTips(POINT pos)
{
int width = m_dim.x;
int rank;
if ( m_bHide || !m_bEnable ) return -1;
if ( m_nbMenu > 1 && m_bMouseDown ) // submenu is open?
{
width += 2+(m_dim.x-1)*m_nbMenu;
}
if ( pos.x < m_pos.x ||
pos.x > m_pos.x+width ||
pos.y < m_pos.y ||
pos.y > m_pos.y+m_dim.y ) return -1;
rank = (pos.x=-(m_pos.x+2+1))/(m_dim.x-1);
if ( rank < 0 ) rank = 0;
if ( rank > m_nbToolTips ) return -1;
if ( m_nbMenu > 1 )
{
if ( m_bMouseDown && rank > 0 )
{
rank --;
}
else
{
rank = m_selMenu;
}
}
return m_toolTips[rank];
}
// Detect whether the mouse is on a button.
BOOL CButton::Detect(POINT pos)
{
int width = m_dim.x;
if ( m_bHide || !m_bEnable ) return FALSE;
if ( m_nbMenu > 1 && m_bMouseDown ) // sub-menu is open?
{
width += 2+(m_dim.x-1)*m_nbMenu;
}
if ( pos.x < m_pos.x ||
pos.x > m_pos.x+width ||
pos.y < m_pos.y ||
pos.y > m_pos.y+m_dim.y ) return FALSE;
return TRUE;
}
// Mouse button pressed.
BOOL CButton::MouseDown(POINT pos)
{
if ( !Detect(pos) ) return FALSE;
m_mouseState = 1;
m_bMouseDown = TRUE;
m_bRedraw = TRUE;
PostMessage(m_hWnd, WM_UPDATE, 0, 0);
return TRUE;
}
// Mouse moved.
BOOL CButton::MouseMove(POINT pos)
{
BOOL bDetect;
int iState, iMenu;
iState = m_mouseState;
iMenu = m_selMenu;
bDetect = Detect(pos);
if ( m_bMouseDown )
{
if ( bDetect ) m_mouseState = 1; // pressed
else m_mouseState = m_state;
}
else
{
if ( bDetect ) m_mouseState = m_state+2; // hover
else m_mouseState = m_state;
}
if ( m_nbMenu > 1 &&
m_bMouseDown &&
pos.x > m_pos.x+m_dim.x+2 ) // is on sub-menu?
{
m_selMenu = (pos.x-(m_pos.x+m_dim.x+2))/(m_dim.x-1);
if ( m_selMenu >= m_nbMenu )
{
m_selMenu = m_nbMenu-1;
}
}
if ( iState != m_mouseState ||
iMenu != m_selMenu )
{
m_bRedraw = TRUE;
PostMessage(m_hWnd, WM_UPDATE, 0, 0);
}
return m_bMouseDown;
}
// Mouse button released.
BOOL CButton::MouseUp(POINT pos)
{
BOOL bDetect;
bDetect = Detect(pos);
m_mouseState = m_state;
m_bMouseDown = FALSE;
m_bRedraw = TRUE;
if ( !bDetect ) return FALSE;
if ( m_message != -1 )
{
PostMessage(m_hWnd, m_message, 0, 0);
}
return TRUE;
}

@ -1,417 +0,0 @@
/*==========================================================================
*
* Copyright (C) 1995-1996 Microsoft Corporation. All Rights Reserved.
*
* File: ddutil.cpp
* Content: Routines for loading bitmap and palettes from resources
*
***************************************************************************/
#undef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <ddraw.h>
#include <stdlib.h>
#include <stdio.h>
#include "ddutil.h"
#include "misc.h"
// Le message :
// First-chance exception in Blupi.exe (GDI32.DLL): 0xC0000005: Access Violation.
// apparaît au endroits marqués par (@) ...
BOOL g_bDebug = TRUE;
void DDSetDebug(BOOL bDebug)
{
g_bDebug = bDebug;
}
/*
* DDConnectBitmap
*
* create a DirectDrawSurface from a bitmap resource.
*
*/
extern IDirectDrawSurface * DDConnectBitmap(IDirectDraw *pdd, HBITMAP hbm)
{
BITMAP bm;
DDSURFACEDESC ddsd;
IDirectDrawSurface *pdds;
HRESULT ddrval;
//
// get size of the bitmap
//
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
//
// create a DirectDrawSurface for this bitmap
//
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
//? ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth = bm.bmWidth;
ddsd.dwHeight = bm.bmHeight;
ddrval = pdd->CreateSurface(&ddsd, &pdds, NULL);
if ( ddrval != DD_OK )
{
TraceErrorDD(ddrval, "", 0);
return NULL;
}
DDCopyBitmap(pdds, hbm, 0, 0, bm.bmWidth, bm.bmHeight);
return pdds;
}
/*
* DDLoadBitmap
*
* create a DirectDrawSurface from a bitmap resource.
*
*/
extern IDirectDrawSurface * DDLoadBitmap(IDirectDraw *pdd, LPCSTR szBitmap, int dx, int dy)
{
HBITMAP hbm;
BITMAP bm;
DDSURFACEDESC ddsd;
IDirectDrawSurface *pdds;
HRESULT ddrval;
if ( g_bDebug ) OutputDebug("DDLoadBitmap\n");
//
// try to load the bitmap as a resource, if that fails, try it as a file
//
hbm = (HBITMAP)LoadImageA(GetModuleHandle(NULL), szBitmap, IMAGE_BITMAP, dx, dy, LR_CREATEDIBSECTION);
if ( g_bDebug ) OutputDebug("DDLoadBitmap\n");
if (hbm == NULL)
{
hbm = (HBITMAP)LoadImageA(NULL, szBitmap, IMAGE_BITMAP, dx, dy, LR_LOADFROMFILE|LR_CREATEDIBSECTION); // (@)
}
if ( hbm == NULL ) return NULL;
//
// get size of the bitmap
//
if ( g_bDebug ) OutputDebug("DDLoadBitmap: GetObject\n");
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
//
// create a DirectDrawSurface for this bitmap
//
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
//? ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.ddsCaps.dwCaps = DDSCAPS_SYSTEMMEMORY;
ddsd.dwWidth = bm.bmWidth;
ddsd.dwHeight = bm.bmHeight;
if ( g_bDebug ) OutputDebug("DDLoadBitmap: CreateSurface\n");
ddrval = pdd->CreateSurface(&ddsd, &pdds, NULL);
if ( ddrval != DD_OK )
{
TraceErrorDD(ddrval, "", 0);
return NULL;
}
DDCopyBitmap(pdds, hbm, 0, 0, 0, 0);
if ( g_bDebug ) OutputDebug("DDLoadBitmap: DeleteObject\n");
DeleteObject(hbm); // (@)
if ( g_bDebug ) OutputDebug("DDLoadBitmap: return\n");
return pdds;
}
/*
* DDReLoadBitmap
*
* load a bitmap from a file or resource into a directdraw surface.
* normaly used to re-load a surface after a restore.
*
*/
HRESULT DDReLoadBitmap(IDirectDrawSurface *pdds, LPCSTR szBitmap)
{
HBITMAP hbm;
HRESULT hr;
//
// try to load the bitmap as a resource, if that fails, try it as a file
//
hbm = (HBITMAP)LoadImageA(GetModuleHandle(NULL), szBitmap, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
if (hbm == NULL)
hbm = (HBITMAP)LoadImageA(NULL, szBitmap, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if (hbm == NULL)
{
if ( g_bDebug ) OutputDebug("handle is null\n");
return E_FAIL;
}
hr = DDCopyBitmap(pdds, hbm, 0, 0, 0, 0);
if (hr != DD_OK)
{
if ( g_bDebug ) OutputDebug("ddcopybitmap failed\n");
}
DeleteObject(hbm);
return hr;
}
/*
* DDCopyBitmap
*
* draw a bitmap into a DirectDrawSurface
*
*/
extern HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int x, int y, int dx, int dy)
{
HDC hdcImage;
HDC hdc;
BITMAP bm;
DDSURFACEDESC ddsd;
HRESULT hr;
if ( g_bDebug ) OutputDebug("DDCopyBitmap\n");
if (hbm == NULL || pdds == NULL)
return E_FAIL;
//
// make sure this surface is restored.
//
if ( g_bDebug ) OutputDebug("DDCopyBitmap: Restore\n");
pdds->Restore();
//
// select bitmap into a memoryDC so we can use it.
//
if ( g_bDebug ) OutputDebug("DDCopyBitmap: CreateCompatibleDC\n");
hdcImage = CreateCompatibleDC(NULL);
if (!hdcImage)
OutputDebug("createcompatible dc failed\n");
if ( g_bDebug ) OutputDebug("DDCopyBitmap: SelectObject\n");
SelectObject(hdcImage, hbm);
//
// get size of the bitmap
//
if ( g_bDebug ) OutputDebug("DDCopyBitmap: GetObject\n");
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
dx = dx == 0 ? bm.bmWidth : dx; // use the passed size, unless zero
dy = dy == 0 ? bm.bmHeight : dy;
//
// get size of surface.
//
if ( g_bDebug ) OutputDebug("DDCopyBitmap: GetSurfaceDesc\n");
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
pdds->GetSurfaceDesc(&ddsd);
if ( g_bDebug ) OutputDebug("DDCopyBitmap: StretchBlt\n");
if ((hr = pdds->GetDC(&hdc)) == DD_OK)
{
if ( g_bDebug ) OutputDebug("DDCopyBitmap: StretchBlt-go\n");
StretchBlt(hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage, x, y, dx, dy, SRCCOPY);
if ( g_bDebug ) OutputDebug("DDCopyBitmap: ReleaseDC\n");
pdds->ReleaseDC(hdc); // (@)
}
if ( g_bDebug ) OutputDebug("DDCopyBitmap: DeleteDC\n");
DeleteDC(hdcImage);
return hr;
}
//
// DDLoadPalette
//
// Create a DirectDraw palette object from a bitmap resoure
//
// if the resource does not exist or NULL is passed create a
// default 332 palette.
//
extern IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap)
{
IDirectDrawPalette* ddpal;
int i;
int n;
int fh;
HRSRC h;
LPBITMAPINFOHEADER lpbi;
PALETTEENTRY ape[256];
RGBQUAD * prgb;
//
// build a 332 palette as the default.
//
for (i=0; i<256; i++)
{
ape[i].peRed = (BYTE)(((i >> 5) & 0x07) * 255 / 7);
ape[i].peGreen = (BYTE)(((i >> 2) & 0x07) * 255 / 7);
ape[i].peBlue = (BYTE)(((i >> 0) & 0x03) * 255 / 3);
ape[i].peFlags = (BYTE)0;
}
//
// get a pointer to the bitmap resource.
//
if (szBitmap && (h = FindResourceA(NULL, szBitmap, (LPCSTR)RT_BITMAP)))
{
if ( g_bDebug ) OutputDebug("DDLoadPalette -a\n");
lpbi = (LPBITMAPINFOHEADER)LockResource(LoadResource(NULL, h));
if (!lpbi)
OutputDebug("lock resource failed\n");
prgb = (RGBQUAD*)((BYTE*)lpbi + lpbi->biSize);
if (lpbi == NULL || lpbi->biSize < sizeof(BITMAPINFOHEADER))
n = 0;
else if (lpbi->biBitCount > 8)
n = 0;
else if (lpbi->biClrUsed == 0)
n = 1 << lpbi->biBitCount;
else
n = lpbi->biClrUsed;
//
// a DIB color table has its colors stored BGR not RGB
// so flip them around.
//
for(i=0; i<n; i++ )
{
ape[i].peRed = prgb[i].rgbRed;
ape[i].peGreen = prgb[i].rgbGreen;
ape[i].peBlue = prgb[i].rgbBlue;
ape[i].peFlags = 0;
}
}
else if (szBitmap && (fh = _lopen(szBitmap, OF_READ)) != -1)
{
if ( g_bDebug ) OutputDebug("DDLoadPalette -b\n");
BITMAPFILEHEADER bf;
BITMAPINFOHEADER bi;
_lread(fh, &bf, sizeof(bf));
_lread(fh, &bi, sizeof(bi));
_lread(fh, ape, sizeof(ape));
_lclose(fh);
if (bi.biSize != sizeof(BITMAPINFOHEADER))
n = 0;
else if (bi.biBitCount > 8)
n = 0;
else if (bi.biClrUsed == 0)
n = 1 << bi.biBitCount;
else
n = bi.biClrUsed;
//
// a DIB color table has its colors stored BGR not RGB
// so flip them around.
//
//?
char s[50];
sprintf(s, "DDLoadPalette n=%d\n", n);
if ( g_bDebug ) OutputDebug(s);
//?
for(i=0; i<n; i++ )
{
BYTE r = ape[i].peRed;
ape[i].peRed = ape[i].peBlue;
ape[i].peBlue = r;
}
}
pdd->CreatePalette(DDPCAPS_8BIT, ape, &ddpal, NULL);
return ddpal;
}
/*
* DDColorMatch
*
* convert a RGB color to a pysical color.
*
* we do this by leting GDI SetPixel() do the color matching
* then we lock the memory and see what it got mapped to.
*/
extern DWORD DDColorMatch(IDirectDrawSurface *pdds, COLORREF rgb)
{
COLORREF rgbT;
HDC hdc;
DWORD dw = CLR_INVALID;
DDSURFACEDESC ddsd;
HRESULT hres;
//
// use GDI SetPixel to color match for us
//
if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK)
{
rgbT = GetPixel(hdc, 0, 0); // save current pixel value
SetPixel(hdc, 0, 0, rgb); // set our value
pdds->ReleaseDC(hdc);
}
//
// now lock the surface so we can read back the converted color
//
ddsd.dwSize = sizeof(ddsd);
while ((hres = pdds->Lock(NULL, &ddsd, 0, NULL)) == DDERR_WASSTILLDRAWING)
;
if (hres == DD_OK)
{
dw = *(DWORD *)ddsd.lpSurface; // get DWORD
dw &= (1 << ddsd.ddpfPixelFormat.dwRGBBitCount)-1; // mask it to bpp
pdds->Unlock(NULL);
}
//
// now put the color that was there back.
//
if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK)
{
SetPixel(hdc, 0, 0, rgbT);
pdds->ReleaseDC(hdc);
}
return dw;
}
/*
* DDSetColorKey
*
* set a color key for a surface, given a RGB.
* if you pass CLR_INVALID as the color key, the pixel
* in the upper-left corner will be used.
*/
extern HRESULT DDSetColorKey(IDirectDrawSurface *pdds, COLORREF rgb)
{
DDCOLORKEY ddck;
ddck.dwColorSpaceLowValue = DDColorMatch(pdds, rgb);
ddck.dwColorSpaceHighValue = ddck.dwColorSpaceLowValue;
return pdds->SetColorKey(DDCKEY_SRCBLT, &ddck);
}
extern HRESULT DDSetColorKey2(IDirectDrawSurface *pdds, COLORREF rgb1,
COLORREF rgb2)
{
DDCOLORKEY ddck;
ddck.dwColorSpaceLowValue = DDColorMatch(pdds, rgb1);
ddck.dwColorSpaceHighValue = DDColorMatch(pdds, rgb2);
return pdds->SetColorKey(DDCKEY_SRCBLT, &ddck);
}

File diff suppressed because it is too large Load Diff

3233
event.cpp

File diff suppressed because it is too large Load Diff

@ -1,323 +0,0 @@
// Network.cpp
//
#include <stdio.h>
#include <windows.h>
#include "misc.h"
#include "network.h"
// a0f94abe-11c3-d111-be62-0040f6944838
#define APP_GUID { 0xbe4af9a0, 0xc311, 0x11d1, { 0xbe, 0x62, 0x00, 0x40, 0xf6, 0x94, 0x48, 0x38 } };
CNetwork::CNetwork()
{
m_pDP = NULL;
m_dpid = 0;
m_bHost = FALSE;
m_providers.nb = 0;
* m_providers.list = NULL;
m_sessions.nb = 0;
* m_sessions.list = NULL;
m_unknown.nb = 0;
* m_unknown.list = NULL;
}
CNetwork::~CNetwork()
{
FreeProviderList();
FreeSessionList();
FreeUnknownList();
if (m_pDP) m_pDP->Release();
}
static BOOL EnumProvidersCallback(LPGUID lpguidSP, LPSTR lpSPName,
DWORD dwMajorVersion, DWORD dwMinorVersion, NamedGUIDList * lpContext)
{
if (lpContext->nb < MAXSESSION)
{
lpContext->list[lpContext->nb]->guid = * lpguidSP;
strcpy(lpContext->list[lpContext->nb]->name, lpSPName);
lpContext->nb++;
}
return TRUE;
}
BOOL CNetwork::EnumProviders()
{
FreeProviderList();
m_providers.nb = 0;
* m_providers.list = (NamedGUID *) malloc(MAXSESSION * sizeof(NamedGUID));
if (!m_providers.list) return FALSE;
if (DirectPlayEnumerate((LPDPENUMDPCALLBACKA)EnumProvidersCallback, &m_providers) != DP_OK)
{
FreeProviderList();
return FALSE;
}
return TRUE;
}
int CNetwork::GetNbProviders()
{
return m_providers.nb;
}
char * CNetwork::GetProviderName(int index)
{
if (index >= m_providers.nb) return NULL;
return m_providers.list[index]->name;
}
BOOL CNetwork::CreateProvider(int index)
{
LPDIRECTPLAY lpDP;
BOOL bOK = FALSE;
if (index >= m_providers.nb) return FALSE;
if (DirectPlayCreate(&m_providers.list[index]->guid, &lpDP, 0) == DP_OK)
{
if (lpDP->QueryInterface(IID_IDirectPlay2A, (LPVOID *) &m_pDP) == DP_OK)
{
return TRUE;
}
}
if (lpDP != NULL) lpDP->Release();
return FALSE;
}
void CNetwork::FreeProviderList()
{
if (m_providers.list) free(m_providers.list);
m_providers.nb = 0;
* m_providers.list = NULL;
}
static BOOL EnumSessionsCallback(LPDPSESSIONDESC2 lpThisSD,
LPDWORD lpdwTimeOut, DWORD dwFlags, NamedGUIDList * lpContext)
{
if (dwFlags & DPESC_TIMEDOUT) return FALSE;
if (lpContext->nb < MAXSESSION)
{
lpContext->list[lpContext->nb]->guid = lpThisSD->guidInstance;
strcpy(lpContext->list[lpContext->nb]->name, lpThisSD->lpszSessionNameA);
lpContext->nb++;
}
return TRUE;
}
BOOL CNetwork::EnumSessions()
{
DPSESSIONDESC2 desc;
FreeSessionList();
m_sessions.nb = 0;
* m_sessions.list = (NamedGUID *) malloc(MAXSESSION * sizeof(NamedGUID));
if (!m_sessions.list) return FALSE;
ZeroMemory(&desc, sizeof(desc));
desc.guidApplication = APP_GUID;
desc.dwSize = sizeof(desc);
if (m_pDP->EnumSessions(&desc, 0, (LPDPENUMSESSIONSCALLBACK2)EnumSessionsCallback, &m_sessions, DPENUMSESSIONS_AVAILABLE) != DP_OK)
{
FreeSessionList();
return FALSE;
}
return TRUE;
}
char * CNetwork::GetSessionName(int index)
{
if (index >= m_sessions.nb) return NULL;
return m_sessions.list[index]->name;
}
BOOL CNetwork::JoinSession(int index)
{
DPNAME name;
DPSESSIONDESC2 desc;
HRESULT hr;
if (index > m_sessions.nb) return FALSE;
ZeroMemory(&desc, sizeof(desc));
desc.guidInstance = m_sessions.list[index]->guid;
hr = m_pDP->Open(&desc, DPOPEN_OPENSESSION);
if (hr != DP_OK)
{
TraceErrorDP(hr);
return FALSE;
}
name.dwFlags = 0;
name.dwSize = sizeof(name);
name.lpszLongNameA = NULL;
hr = m_pDP->CreatePlayer(&m_dpid, &name, NULL, NULL, 0, 0);
if (hr != DP_OK)
{
TraceErrorDP(hr);
m_pDP->Close();
return FALSE;
}
else
{
m_bHost = FALSE;
return TRUE;
}
}
void CNetwork::FreeSessionList()
{
if (m_sessions.list) free(m_sessions.list);
m_sessions.nb = 0;
* m_sessions.list = NULL;
}
BOOL CNetwork::CreateSession(char * pName)
{
DPSESSIONDESC2 desc;
HRESULT hr;
ZeroMemory(&desc, sizeof(desc));
desc.guidApplication = APP_GUID;
desc.lpszSessionNameA = pName;
desc.dwSize = sizeof(desc);
desc.dwFlags = DPSESSION_KEEPALIVE | DPSESSION_MIGRATEHOST;
desc.dwMaxPlayers = MAXNETPLAYER;
hr = m_pDP->Open(&desc, DPOPEN_CREATE);
if (hr != DP_OK)
{
TraceErrorDP(hr);
m_pDP->Close();
return FALSE;
}
else
{
m_bHost = TRUE;
return TRUE;
}
}
BOOL CNetwork::Send(LPVOID lpData, DWORD dwDataSize, DWORD dwFlags)
{
HRESULT hr;
if (!m_pDP) return FALSE;
if (hr = m_pDP->Send(m_dpid, 0, !!dwFlags, lpData, dwDataSize), hr != DP_OK)
{
TraceErrorDP(hr);
return FALSE;
}
return TRUE;
}
BOOL CNetwork::Receive(LPVOID pDest, DWORD dwDataSize, LPDWORD lpdwPlayer)
{
DPID from = 0, to = 0, dataSize = 500;
char dataBuffer[500];
HRESULT hr;
hr = m_pDP->Receive(&from, &to, DPRECEIVE_ALL, dataBuffer, &dataSize);
if (hr != DP_OK)
{
if (hr != DPERR_NOMESSAGES) TraceErrorDP(hr);
return FALSE;
}
ZeroMemory(pDest, dwDataSize);
*lpdwPlayer = -1;
for (int i = 0; i < MAXNETPLAYER; i++)
{
if (m_players[i].bIsPresent && from == i)
{
*lpdwPlayer = i;
break;
}
}
return TRUE;
}
BOOL CNetwork::Close()
{
return m_pDP->Close() == DP_OK;
}
void CNetwork::FreeUnknownList()
{
if (m_unknown.list) free(m_unknown.list);
m_unknown.nb = 0;
* m_unknown.list = NULL;
}
BOOL CNetwork::IsHost()
{
return m_bHost;
}
void TraceErrorDP(HRESULT hErr)
{
char dperr[256];
char err[1024];
switch (hErr)
{
case DPERR_OUTOFMEMORY : sprintf(dperr, "DPERR_OUTOFMEMORY"); break;
case DPERR_UNSUPPORTED : sprintf(dperr, "DPERR_UNSUPPORTED"); break;
case DPERR_NOINTERFACE : sprintf(dperr, "DPERR_NOINTERFACE"); break;
case DPERR_GENERIC : sprintf(dperr, "DPERR_GENERIC"); break;
case DPERR_INVALIDPARAMS : sprintf(dperr, "DPERR_INVALIDPARAMS"); break;
case DPERR_ACTIVEPLAYERS : sprintf(dperr, "DPERR_ACTIVEPLAYERS"); break;
case DPERR_ACCESSDENIED : sprintf(dperr, "DPERR_ACCESSDENIED"); break;
case DPERR_CANTADDPLAYER : sprintf(dperr, "DPERR_CANTADDPLAYER"); break;
case DPERR_CANTCREATEPLAYER : sprintf(dperr, "DPERR_CANTCREATEPLAYER"); break;
case DPERR_CANTCREATEGROUP : sprintf(dperr, "DPERR_CANTCREATEGROUP"); break;
case DPERR_CANTCREATESESSION: sprintf(dperr, "DPERR_CANTCREATESESSION"); break;
case DPERR_CAPSNOTAVAILABLEYET : sprintf(dperr, "DPERR_CAPTSNOTAVAILABLEYET"); break;
case DPERR_ALREADYINITIALIZED : sprintf(dperr, "DPERR_ALREADYINITIALIZED"); break;
case DPERR_INVALIDFLAGS: sprintf(dperr, "DPERR_INVALIDFLAGS"); break;
case DPERR_EXCEPTION: sprintf(dperr, "DPERR_EXCEPTION"); break;
case DPERR_INVALIDPLAYER: sprintf(dperr, "DPERR_INVALIDPLAYER"); break;
case DPERR_INVALIDOBJECT: sprintf(dperr, "DPERR_INVALIDOBJECT"); break;
case DPERR_NOCONNECTION: sprintf(dperr, "DPERR_NOCONNECTION"); break;
case DPERR_NONAMESERVERFOUND: sprintf(dperr, "DPERR_NONAMESERVERFOUND"); break;
case DPERR_NOMESSAGES: sprintf(dperr, "DPERR_NOMESSAGES"); break;
case DPERR_NOSESSIONS: sprintf(dperr, "DPERR_NOSESSIONS"); break;
case DPERR_NOPLAYERS: sprintf(dperr, "DPERR_NOPLAYERS"); break;
case DPERR_TIMEOUT: sprintf(dperr, "DPERR_TIMEOUT"); break;
case DPERR_SENDTOOBIG: sprintf(dperr, "DPERR_SENDTOOBIG"); break;
case DPERR_BUSY: sprintf(dperr, "DPERR_BUSY"); break;
case DPERR_UNAVAILABLE: sprintf(dperr, "DPERR_UNAVAILABLE"); break;
case DPERR_PLAYERLOST: sprintf(dperr, "DPERR_PLAYERLOST"); break;
case DPERR_USERCANCEL: sprintf(dperr, "DPERR_USERCANCEL"); break;
case DPERR_BUFFERTOOLARGE: sprintf(dperr, "DPERR_BUFFERTOOLARGE"); break;
case DPERR_SESSIONLOST: sprintf(dperr, "DPERR_SESSIONLOST"); break;
case DPERR_APPNOTSTARTED: sprintf(dperr, "DPERR_APPNOTSTARTED"); break;
case DPERR_CANTCREATEPROCESS: sprintf(dperr, "DPERR_CANTCREATEPROCESS"); break;
case DPERR_UNKNOWNAPPLICATION: sprintf(dperr, "DPERR_UNKNOWNAPPLICATION"); break;
case DPERR_INVALIDINTERFACE: sprintf(dperr, "DPERR_INVALIDINTERFACE"); break;
case DPERR_NOTLOBBIED: sprintf(dperr, "DPERR_NOTLOBBIED"); break;
case DP_OK: sprintf(dperr, "DP_OK"); break;
default : sprintf(dperr, "Unknown Error"); break;
}
sprintf(err, "DirectPlay Error %s\n", dperr);
OutputDebug(err);
}

BIN
resource/Eggbert2.aps Normal file

Binary file not shown.

Binary file not shown.

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

Before

(image error) Size: 766 B

After

(image error) Size: 766 B

Before

(image error) Size: 326 B

After

(image error) Size: 326 B

685
sound.cpp

@ -1,685 +0,0 @@
// sound.cpp
//
#include <dsound.h>
#include <stdio.h>
//#include <mciapi.h>
#include "sound.h"
#include "misc.h"
#include "def.h"
#include "resource.h"
#pragma warning (disable : 4996)
#pragma comment(lib, "dsound.lib")
using namespace std;
/////////////////////////////////////////////////////////////////////////////
// The following macro are used for proper error handling for DirectSound.
#define TRY_DS(exp) { { HRESULT rval = exp; if (rval != DS_OK) { TraceErrorDS(rval, __FILE__, __LINE__); return FALSE; } } }
struct WaveHeader
{
BYTE RIFF[4]; // "RIFF"
DWORD dwSize; // Size of data to follow
BYTE WAVE[4]; // "WAVE"
BYTE fmt_[4]; // "fmt "
DWORD dw16; // 16
WORD wOne_0; // 1
WORD wChnls; // Number of Channels
DWORD dwSRate; // Sample Rate
DWORD BytesPerSec; // Sample Rate
WORD wBlkAlign; // 1
WORD BitsPerSample; // Sample size
BYTE DATA[4]; // "DATA"
DWORD dwDSize; // Number of Samples
};
// Creates a DirectSound buffer.
BOOL CSound::CreateSoundBuffer(int dwBuf, DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample, DWORD dwBlkAlign, BOOL bStereo)
{
PCMWAVEFORMAT pcmwf;
DSBUFFERDESC dsbdesc;
// Set up wave format structure.
memset( &pcmwf, 0, sizeof(PCMWAVEFORMAT) );
pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM;
pcmwf.wf.nChannels = bStereo ? 2 : 1;
pcmwf.wf.nSamplesPerSec = dwFreq;
pcmwf.wf.nBlockAlign = (WORD)dwBlkAlign;
pcmwf.wf.nAvgBytesPerSec = pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign;
pcmwf.wBitsPerSample = (WORD)dwBitsPerSample;
// Set up DSBUFFERDESC structure.
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); // Zero it out.
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;
dsbdesc.dwBufferBytes = dwBufSize;
dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf;
TRY_DS(m_lpDS->CreateSoundBuffer(&dsbdesc, &m_lpDSB[dwBuf], NULL), 63)
return TRUE;
}
// I dunno what the fuck this does.
/*
BOOL CSound::ErrorSomething()
{
if (m_lpDS ||
m_lpDSB != 0)
{
m_lpDS, m_lpDSB->TraceErrorDS;
return FALSE;
}
return TRUE;
}
*/
// Reads in data from a wave file.
BOOL CSound::ReadData(LPDIRECTSOUNDBUFFER lpDSB, FILE* pFile, DWORD dwSize, DWORD dwPos)
{
// Seek to correct position in file (if necessary)
if ( dwPos != 0xffffffff )
{
if ( fseek(pFile, dwPos, SEEK_SET) != 0 )
{
return FALSE;
}
}
// Lock data in buffer for writing
LPVOID pData1;
DWORD dwData1Size;
LPVOID pData2;
DWORD dwData2Size;
HRESULT rval;
rval = lpDSB->Lock(0, dwSize, &pData1, &dwData1Size, &pData2, &dwData2Size, DSBLOCK_FROMWRITECURSOR);
if ( rval != DS_OK )
{
return FALSE;
}
// Read in first chunk of data
if ( dwData1Size > 0 )
{
if ( fread(pData1, dwData1Size, 1, pFile) != 1 )
{
char holder[256];
wsprintfA(holder,"Data1 : %d, dwdata: %d, pFile: %d",pData1,dwData1Size,pFile);
OutputDebug(holder);
return FALSE;
}
}
// read in second chunk if necessary
if ( dwData2Size > 0 )
{
if ( fread(pData2, dwData2Size, 1, pFile) != 1 )
{
return FALSE;
}
}
// Unlock data in buffer
rval = lpDSB->Unlock(pData1, dwData1Size, pData2, dwData2Size);
if ( rval != DS_OK )
{
return FALSE;
}
return TRUE;
}
// Creates a DirectSound buffer from a wave file.
BOOL CSound::CreateBufferFromWaveFile(int dwBuf, char *pFileName)
{
// Open the wave file
FILE* pFile = fopen(pFileName, "rb");
if ( pFile == NULL ) return FALSE;
// Read in the wave header
WaveHeader wavHdr;
if ( fread(&wavHdr, sizeof(wavHdr), 1, pFile) != 1 )
{
fclose(pFile);
return NULL;
}
// Figure out the size of the data region
DWORD dwSize = wavHdr.dwDSize;
// Is this a stereo or mono file?
BOOL bStereo = wavHdr.wChnls > 1 ? TRUE : FALSE;
// Create the sound buffer for the wave file
if ( !CreateSoundBuffer(dwBuf, dwSize, wavHdr.dwSRate,
wavHdr.BitsPerSample, wavHdr.wBlkAlign, bStereo) )
{
// Close the file
fclose(pFile);
return FALSE;
}
// Read the data for the wave file into the sound buffer
if ( !ReadData(m_lpDSB[dwBuf], pFile, dwSize, sizeof(wavHdr)) )
{
fclose(pFile);
return FALSE;
}
// Close out the wave file
fclose(pFile);
return TRUE;
}
// Stops all sounds.
BOOL CSound::StopAllSounds()
{
// Make sure we have a valid sound buffer
for (int i = 0; i < MAXSOUND; i ++)
{
if ( m_lpDSB[i] )
{
DWORD dwStatus;
TRY_DS(m_lpDSB[i]->GetStatus(&dwStatus));
if ( (dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING )
{
TRY_DS(m_lpDSB[i]->Stop())
}
}
}
return TRUE;
}
// Plays a sound using direct sound.
BOOL CSound::PlaySoundDS(DWORD dwSound, DWORD dwFlags)
{
// Make sure the sound is valid
if ( dwSound >= MAXSOUND ) return FALSE;
// Make sure we have a valid sound buffer
if ( m_lpDSB[dwSound] )
{
DWORD dwStatus;
TRY_DS(m_lpDSB[dwSound]->GetStatus(&dwStatus));
if ( (dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING )
{
// Play the sound
TRY_DS(m_lpDSB[dwSound]->Play(0, 0, dwFlags));
}
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// Modifie le volume midi.
// Le volume est compris entre 0 et 20 !
void InitMidiVolume(int volume)
{
int nb, i, n;
MMRESULT result;
HMIDIOUT hmo = 0;
static int table[21] =
{
0x00000000,
0x11111111,
0x22222222,
0x33333333,
0x44444444,
0x55555555,
0x66666666,
0x77777777,
0x88888888,
0x99999999,
0xAAAAAAAA,
0xBBBBBBBB,
0xCCCCCCCC,
0xDDDDDDDD,
0xEEEEEEEE,
0xF222F222,
0xF555F555,
0xF777F777,
0xFAAAFAAA,
0xFDDDFDDD,
0xFFFFFFFF,
};
if ( volume < 0 ) volume = 0;
if ( volume > MAXVOLUME ) volume = MAXVOLUME;
nb = midiOutGetNumDevs();
for ( i=0 ; i<nb ; i++ )
{
result = midiOutOpen((LPHMIDIOUT)&hmo, i, 0L, 0L, 0L);
if ( result != MMSYSERR_NOERROR )
{
continue;
}
result = midiOutSetVolume(hmo, table[volume]);
if ( result != MMSYSERR_NOERROR )
{
n = 1;
}
midiOutClose(hmo);
hmo = 0;
}
}
/////////////////////////////////////////////////////////////////////////////
// Constructeur.
CSound::CSound()
{
int i;
m_bEnable = FALSE;
m_bState = FALSE;
m_MidiDeviceID = 0;
m_MIDIFilename[0] = 0;
m_audioVolume = 20;
m_midiVolume = 15;
m_lastMidiVolume = 0;
m_nbSuspendSkip = 0;
m_lpDS = NULL;
for ( i=0 ; i<MAXSOUND ; i++ )
{
m_lpDSB[i] = NULL;
}
for ( i=0 ; i<MAXBLUPI ; i++ )
{
m_channelBlupi[i] = -1;
}
}
// Destructeur.
CSound::~CSound()
{
int i;
if ( m_bEnable )
{
InitMidiVolume(15); // remet un volume moyen !
}
for ( i=0 ; i<MAXSOUND ; i++ )
{
if ( m_lpDSB[i] != NULL )
{
//? m_lpDSB[i]->Release();
m_lpDSB[i]= NULL;
}
}
if ( m_lpDS != NULL )
{
m_lpDS->Release();
m_lpDS = NULL;
}
}
// Initialisation de DirectSound.
BOOL CSound::Create(HWND hWnd)
{
if ( !DirectSoundCreate(NULL, &m_lpDS, NULL) == DS_OK )
{
OutputDebug("Fatal error: DirectSoundCreate\n");
m_bEnable = FALSE;
return FALSE;
}
m_lpDS->SetCooperativeLevel(hWnd, DSSCL_NORMAL);
m_bEnable = TRUE;
m_hWnd = hWnd;
return TRUE;
}
// Retourne l'<27>tat de DirectSound.
BOOL CSound::GetEnable()
{
return m_bEnable;
}
// Enclenche ou d<>clenche le son.
void CSound::SetState(BOOL bState)
{
m_bState = bState;
}
// Gestion des volumes audio (.wav) et midi (.mid).
void CSound::SetAudioVolume(int volume)
{
m_audioVolume = volume;
}
int CSound::GetAudioVolume()
{
if ( !m_bEnable ) return 0;
return m_audioVolume;
}
void CSound::SetMidiVolume(int volume)
{
m_midiVolume = volume;
}
int CSound::GetMidiVolume()
{
if ( !m_bEnable ) return 0;
return m_midiVolume;
}
// Cache tous les ficheirs son (.wav).
void CSound::CacheAll()
{
int i;
char name[50];
if ( !m_bEnable ) return;
for ( i=0 ; i<MAXSOUND ; i++ )
{
sprintf(name, "sound\\sound%.3d.blp", i);
if ( !Cache(i, name) ) break;
}
}
// Charge un fichier son (.wav).
BOOL CSound::Cache(int channel, char *pFilename)
{
if ( !m_bEnable ) return FALSE;
if ( channel < 0 || channel >= MAXSOUND ) return FALSE;
if ( m_lpDSB[channel] != NULL )
{
Flush(channel);
}
return CreateBufferFromWaveFile(channel, pFilename);
}
// D<>charge un son.
void CSound::Flush(int channel)
{
if ( !m_bEnable ) return;
if ( channel < 0 || channel >= MAXSOUND ) return;
if ( m_lpDSB[channel] != NULL )
{
m_lpDSB[channel]->Release();
m_lpDSB[channel]= NULL;
}
}
// Fait entendre un son.
// Le volume est compris entre 0 (max) et -10000 (silence).
// Le panoramique est compris entre -10000 (gauche), 0 (centre)
// et +10000 (droite).
BOOL CSound::Play(int channel, int volume, int pan)
{
if ( !m_bEnable ) return TRUE;
if ( !m_bState || m_audioVolume == 0 ) return TRUE;
volume -= (MAXVOLUME-m_audioVolume)*((10000/4)/MAXVOLUME);
//? if ( volume == -10000 ) return TRUE;
if ( volume <= -10000/4 ) return TRUE;
if ( channel < 0 || channel >= MAXSOUND ) return FALSE;
if ( m_lpDSB[channel] == NULL ) return FALSE;
m_lpDSB[channel]->SetVolume(volume);
m_lpDSB[channel]->SetPan(pan);
m_lpDSB[channel]->Play(0, 0, 0);
return TRUE;
}
BOOL CSound::StopSound(Sound channel)
{
if (m_bEnable) return FALSE;
if (m_bState || m_audioVolume == 0) return FALSE;
if (0 < channel || channel < MAXSOUND)
{
if (m_lpDSB[channel] == NULL)
return (BOOL)m_lpDSB[channel];
m_lpDSB[channel]->Stop();
m_lpDSB[channel]->SetCurrentPosition(0);
return TRUE;
}
return FALSE;
}
// Fait entendre un son dans une image.
// Si rank != -1, il indique le rang du blupi dont il faudra
// <20>ventuellement stopper le dernier son en cours !
BOOL CSound::PlayImage(int channel, POINT pos, int rank)
{
int stopCh, volumex, volumey, volume, pan;
if ( rank >= 0 && rank < MAXBLUPI )
{
stopCh = m_channelBlupi[rank];
if ( stopCh >= 0 && m_lpDSB[stopCh] != NULL )
{
m_lpDSB[stopCh]->Stop(); // stoppe le son pr<70>c<EFBFBD>dent
m_lpDSB[stopCh]->SetCurrentPosition(0);
}
m_channelBlupi[rank] = channel;
}
//? pan = (int)(((long)pos.x*20000L)/LXIMAGE)-10000L;
//? pan = (int)(((long)pos.x*10000L)/LXIMAGE)-5000L;
pan = (int)(((long)pos.x*5000L)/LXIMAGE)-2500L;
volumex = 0; // volume maximum
if ( pos.x < 0 )
{
volumex = (pos.x*2500)/LXIMAGE;
}
if ( pos.x > LXIMAGE )
{
pos.x -= LXIMAGE;
volumex = (-pos.x*2500)/LXIMAGE;
}
if ( volumex < -10000 ) volumex = -10000;
volumey = 0; // volume maximum
if ( pos.y < 0 )
{
volumey = (pos.y*2500)/LYIMAGE;
}
if ( pos.y > LYIMAGE )
{
pos.y -= LYIMAGE;
volumey = (-pos.y*2500)/LYIMAGE;
}
if ( volumey < -10000 ) volumey = -10000;
if ( volumex < volumey ) volume = volumex;
else volume = volumey;
return Play(channel, volume, pan);
}
// Uses MCI to play a MIDI file. The window procedure
// is notified when playback is complete.
BOOL CSound::PlayMusic(HWND hWnd, LPSTR lpszMIDIFilename)
{
MCI_OPEN_PARMS mciOpenParms;
MCI_PLAY_PARMS mciPlayParms;
DWORD dwReturn;
char string[MAX_PATH];
if ( !m_bEnable ) return TRUE;
if ( m_midiVolume == 0 ) return TRUE;
InitMidiVolume(m_midiVolume);
m_lastMidiVolume = m_midiVolume;
if ( lpszMIDIFilename[1] == ':' ) // nom complet "D:\REP..." ?
{
strcpy(string, lpszMIDIFilename);
}
else
{
GetCurrentDir(string, MAX_PATH-30);
strcat(string, lpszMIDIFilename);
}
// Open the device by specifying the device and filename.
// MCI will attempt to choose the MIDI mapper as the output port.
mciOpenParms.lpstrDeviceType = (LPCWSTR)"sequencer";
mciOpenParms.lpstrElementName = (LPCWSTR)string;
dwReturn = mciSendCommand(NULL,
MCI_OPEN,
MCI_OPEN_TYPE|MCI_OPEN_ELEMENT,
(DWORD)(LPVOID)&mciOpenParms);
if ( dwReturn != 0 )
{
OutputDebug("PlayMusic-1\n");
mciGetErrorStringA(dwReturn, string, 128);
OutputDebug(string);
// Failed to open device. Don't close it; just return error.
return FALSE;
}
// The device opened successfully; get the device ID.
m_MidiDeviceID = mciOpenParms.wDeviceID;
// Begin playback.
mciPlayParms.dwCallback = (DWORD)hWnd;
dwReturn = mciSendCommand(m_MidiDeviceID,
MCI_PLAY,
MCI_NOTIFY,
(DWORD)(LPVOID)&mciPlayParms);
if ( dwReturn != 0 )
{
OutputDebug("PlayMusic-2\n");
mciGetErrorStringA(dwReturn, string, 128);
OutputDebug(string);
StopMusic();
return FALSE;
}
strcpy(m_MIDIFilename, lpszMIDIFilename);
return TRUE;
}
// Restart the MIDI player.
BOOL CSound::RestartMusic()
{
OutputDebug("RestartMusic\n");
if ( !m_bEnable ) return TRUE;
if ( m_midiVolume == 0 ) return TRUE;
if ( m_MIDIFilename[0] == 0 ) return FALSE;
return PlayMusic(m_hWnd, m_MIDIFilename);
}
// Shuts down the MIDI player.
void CSound::SuspendMusic()
{
if ( !m_bEnable ) return;
if ( m_nbSuspendSkip != 0 )
{
m_nbSuspendSkip --;
return;
}
if ( m_MidiDeviceID && m_midiVolume != 0 )
{
mciSendCommand(m_MidiDeviceID, MCI_CLOSE, 0, NULL);
}
m_MidiDeviceID = 0;
}
// Shuts down the MIDI player.
void CSound::StopMusic()
{
SuspendMusic();
m_MIDIFilename[0] = 0;
}
// Retourne TRUE si une musique est en cours.
BOOL CSound::IsPlayingMusic()
{
return (m_MIDIFilename[0] != 0);
}
// Adapte le volume de la musique en cours, si n<>cessaire.
void CSound::AdaptVolumeMusic()
{
if ( m_midiVolume != m_lastMidiVolume )
{
InitMidiVolume(m_midiVolume);
m_lastMidiVolume = m_midiVolume;
RestartMusic();
}
}
// Indique le nombre de suspend <20> sauter.
void CSound::SetSuspendSkip(int nb)
{
m_nbSuspendSkip = nb;
}

102
sound.h

@ -1,102 +0,0 @@
// sound.h
//
using namespace std;
#pragma once
#include <windef.h>
//#include <minwindef.h>
#include "dsound.h"
#include <stdio.h>
typedef enum
{
SOUND_10_BOUM,
SOUND_11_TRESOR,
SOUND_13_ENDKO,
SOUND_14_ENDOK,
SOUND_16_HELICOHIGH,
SOUND_18_HELICOLOW,
SOUND_23_PLOUF,
SOUND_24_BLUP,
SOUND_29_JEEPHIGH,
SOUND_31_JEEPLOW,
SOUND_33_DOOR,
SOUND_42_STARTSHIELD,
SOUND_50_SUCETTE,
SOUND_51_GLU,
SOUND_57_DRINK,
SOUND_58_CHARGE,
SOUND_59_ELECTRO,
SOUND_60_PERSOTAKE,
SOUND_64_TIPLOUF,
SOUND_69_BLITZ,
SOUND_74_ANGEL,
SOUND_75_SCIE,
SOUND_76_SWITCHOFF,
SOUND_92_FOLLOW
}
Sound;
///////////////////////////////////////////////////////////////////////////
#define MAXSOUND 100
#define MAXVOLUME 20
#define MAXBLUPI 100
#define WIN32_LEAN_AND_MEAN
class CSound
{
public:
CSound();
~CSound();
BOOL ErrorSomething();
BOOL Create(HWND hWnd);
void SetState(BOOL bState);
BOOL GetEnable();
void SetAudioVolume(int volume);
int GetAudioVolume();
void SetMidiVolume(int volume);
int GetMidiVolume();
void SetCDAudio(BOOL bCDAudio);
void CacheAll();
BOOL Cache(int channel, char *pFilename);
void Flush(int channel);
BOOL Play (int channel, int volume=0, int pan=0);
BOOL StopSound(int channel);
BOOL PlayImage(int channel, POINT pos, int rank=-1);
BOOL PlayMusic(HWND hWnd, LPSTR lpszMIDIFilename);
BOOL RestartMusic();
void SuspendMusic();
void StopMusic();
BOOL IsPlayingMusic();
void AdaptVolumeMusic();
void SetSuspendSkip(int nb);
protected:
BOOL CreateSoundBuffer(int dwBuf, DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample, DWORD dwBlkAlign, BOOL bStereo);
BOOL ReadData(LPDIRECTSOUNDBUFFER lpDSB, FILE* pFile, DWORD dwSize, DWORD dwPos);
BOOL CreateBufferFromWaveFile(int dwBuf, char *pFileName);
BOOL StopAllSounds();
BOOL PlaySoundDS(DWORD dwSound, DWORD dwFlags);
protected:
HWND m_hWnd;
BOOL m_bEnable;
BOOL m_bState;
BOOL m_bCDAudio;
LPDIRECTSOUND m_lpDS;
LPDIRECTSOUNDBUFFER m_lpDSB[MAXSOUND];
short m_channelBlupi[MAXBLUPI];
UINT m_MidiDeviceID;
char m_MIDIFilename[50];
int m_audioVolume;
int m_midiVolume;
int m_lastMidiVolume;
int m_nbSuspendSkip;
};

File diff suppressed because it is too large Load Diff

402
src/button.cpp Normal file

@ -0,0 +1,402 @@
// Button.cpp
//
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
#include <windef.h>
#include "def.h"
#include "pixmap.h"
#include "sound.h"
#include "decor.h"
#include "button.h"
#include "misc.h"
using namespace std;
//////////////////////////////////////////////////////////
// Constructor
CButton::CButton()
{
m_type = 0;
m_bEnable = TRUE;
m_bHide = FALSE;
m_bSomething = FALSE;
m_state = 0;
m_mouseState = 0;
m_nbMenu = 0;
m_nbToolTips = 0;
m_selMenu = 0;
m_bMouseDown = FALSE;
m_bMinimizeRedraw = FALSE;
m_bRedraw = FALSE;
}
// Destructor
CButton::~CButton()
{
}
// Create a new Button
BOOL CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
POINT pos, int type, BOOL bMinimizeRedraw, UINT message)
{
POINT iconDim;
int i, icon;
static int ttypes[] =
{
DIMBUTTONX,DIMBUTTONY,
};
if (type < 0 || type > 0) return FALSE;
iconDim.x = ttypes[type * 2 + 0];
iconDim.y = ttypes[type * 2 + 1];
m_hWnd = hWnd;
m_pPixmap = pPixmap;
m_pSound = pSound;
m_type = type;
m_bMinimizeRedraw = bMinimizeRedraw;
m_bEnable = TRUE;
m_bHide = FALSE;
m_bSomething = FALSE;
m_message = message;
m_pos.x = pos.x;
m_pos.y = pos.y;
m_dim.x = iconDim.x;
m_dim.y = iconDim.y;
m_nbMenu = 0;
m_nbToolTips = 0;
m_selMenu = 0;
m_state = 0;
m_mouseState = 0;
m_bMouseDown = FALSE;
m_bRedraw = TRUE;
return TRUE;
}
void CButton::SetIconMenu(int* pIcons, int nbMenu)
{
for (int i = 0; i < nbMenu; i++)
{
m_iconMenu[i] = pIcons[i];
}
m_nbMenu = nbMenu;
}
void CButton::SetToolTips(int* pToolTips, int nbToolTips)
{
for (int i = 0; i < nbToolTips; i++)
{
m_toolTips[i] = pToolTips[i];
}
m_nbToolTips = nbToolTips;
}
// Draw a button in its state
void CButton::Draw()
{
int i;
POINT pos;
RECT rect;
if (m_bMinimizeRedraw && !m_bRedraw) return;
m_bRedraw = FALSE;
if (m_bHide) // Hidden button
{
pos = m_pos;
return;
}
if (m_bEnable)
{
m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, m_mouseState, m_pos);
}
else
{
m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, m_bSomething ? 5 : 4, m_pos);
}
if (m_nbMenu == 0) return;
pos = m_pos;
if (m_nbMenu > 0)
{
m_pPixmap->DrawIcon(-1, CHBUTTON + m_type,
m_iconMenu[m_selMenu] + 6, pos);
}
if (m_nbMenu == 1 || !m_bEnable || !m_bMouseDown) return;
pos = m_pos;
pos.x += m_dim.x + 2;
for (i = 0; i<m_nbMenu; i++)
{
m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, i == m_selMenu ? 1 : 0, pos);
m_pPixmap->DrawIcon(-1, CHBUTTON + m_type, m_iconMenu[i] + 6, pos);
pos.x += m_dim.x - 1;
}
}
/*
/Needed Yet?
//////////////////////////////////////////////
void CButton::Redraw()
{
m_bRedraw = TRUE;
}
//////////////////////////////////////////////
*/
int CButton::GetState()
{
return m_state;
}
void CButton::SetState(int state)
{
if (m_state != state ||
m_mouseState != state)
{
m_bRedraw = TRUE;
}
m_state = state;
m_mouseState = state;
}
int CButton::GetMenu()
{
return m_selMenu;
}
void CButton::SetMenu(int menu)
{
if (m_selMenu != menu)
{
m_bRedraw = TRUE;
}
m_selMenu = menu;
}
void CButton::SetEnable(BOOL bEnable)
{
if (m_bEnable != bEnable)
{
m_bRedraw = TRUE;
}
m_bEnable = bEnable;
}
void CButton::SetSomething(BOOL bSomething)
{
if (m_bSomething != bSomething)
{
m_bRedraw = TRUE;
}
m_bSomething = bSomething;
}
/*
// Needed Yet?
/////////////////////////////////////////
BOOL CButton::GetHide()
{
return m_bHide;
}
/////////////////////////////////////////
*/
void CButton::SetHide(BOOL bHide)
{
if (m_bHide != bHide)
{
m_bRedraw = TRUE;
}
m_bHide = bHide;
}
BOOL CButton::TreatEvent(UINT message, WPARAM wParam, LPARAM lParam)
{
POINT pos;
if (m_bHide || !m_bEnable) return FALSE;
pos = ConvLongToPos(lParam);
switch (message)
{
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
if (MouseDown(pos)) return TRUE;
break;
case WM_MOUSEMOVE:
if (MouseMove(pos)) return TRUE;
break;
case WM_LBUTTONUP:
case WM_RBUTTONUP:
if (MouseUp(pos)) return FALSE;
break;
}
return FALSE;
}
// All buttons must receive the BUTTONUP event!
// Indicates whether the mouse is over this button.
BOOL CButton::MouseOnButton(POINT pos)
{
return Detect(pos);
}
// Return the tooltips for a button, depending
// on mouse position.
int CButton::GetToolTips(POINT pos)
{
int width = m_dim.x;
int rank;
if (m_bHide || !m_bEnable) return -1;
if (m_nbMenu > 1 && m_bMouseDown) // Drop-down submenu?
{
width += 2 + (m_dim.x - 1)*m_nbMenu;
}
if (pos.x < m_pos.x ||
pos.x > m_pos.x + width ||
pos.y < m_pos.y ||
pos.y > m_pos.y + m_dim.y) return -1;
rank = (pos.x = -(m_pos.x + 2 + 1)) / (m_dim.x - 1);
if (rank < 0) rank = 0;
if (rank > m_nbToolTips) return -1;
if (m_nbMenu > 1)
{
if (m_bMouseDown && rank > 0)
{
rank--;
}
else
{
rank = m_selMenu;
}
}
return m_toolTips[rank];
}
BOOL CButton::Detect(POINT pos)
{
int width = m_dim.x;
if (m_bHide || !m_bEnable) return FALSE;
if (m_nbMenu > 1 && m_bMouseDown)
{
width += 2 + (m_dim.x - 1)*m_nbMenu;
}
if (pos.x < m_pos.x ||
pos.x > m_pos.x + width ||
pos.y < m_pos.y ||
pos.y > m_pos.y + m_dim.y) return FALSE;
return TRUE;
}
BOOL CButton::MouseMove(POINT pos)
{
int selMenu = m_selMenu;
int mouseState;
BOOL BVar3;
int iVar4;
int iVar5;
BOOL BVar6;
int iVar7;
mouseState = m_mouseState;
BVar6 = Detect(pos);
BVar3 = m_bMouseDown;
if (!m_bMouseDown) {
if (!Detect(pos)) {
m_mouseState = m_state;
}
else {
m_mouseState = m_state + 2;
}
}
else if (Detect(pos)) {
m_mouseState = 1;
}
else {
m_mouseState = m_state;
}
if (m_nbMenu > 1 && m_bMouseDown) {
if ((m_pos.x + m_dim.x + 2 < pos.x))
{
m_selMenu = (pos.x - m_pos.x - m_dim.x - 2) / (m_dim.x - 1);
if (m_selMenu >= m_nbMenu) m_selMenu = m_nbMenu - 1;
}
}
if (mouseState != m_mouseState || selMenu != m_selMenu) m_bRedraw = TRUE;
return BVar3;
}
BOOL CButton::MouseDown(POINT pos)
{
if (!Detect(pos)) return FALSE;
m_mouseState = 1;
m_bMouseDown = TRUE;
m_bRedraw = TRUE;
// PostMessage(m_hWnd, WM_UPDATE, 0, 0);
m_pSound->PlayImage(SOUND_CLICK, pos);
return TRUE;
}
BOOL CButton::MouseUp(POINT pos)
{
BOOL bDetect;
bDetect = Detect(pos);
m_mouseState = m_state;
m_bMouseDown = FALSE;
m_bRedraw = TRUE;
if (!bDetect) return FALSE;
if (m_message != -1)
{
PostMessage(m_hWnd, m_message, 0, 0);
}
return TRUE;
}

@ -1,13 +1,11 @@
//#include <minwindef.h>
#pragma once
// #include <minwindef.h>
#include <windef.h>
#include "decor.h"
#include "sound.h"
#include "pixmap.h"
#pragma once
using namespace std;
class CButton
{
public:
@ -15,8 +13,9 @@ public:
~CButton();
BOOL Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
POINT pos, int type, BOOL bMinimizeRedraw, int region, UINT message);
void SetSomethingMenu(int somethingMenu);
POINT pos, int type, BOOL bMinimizeRedraw, UINT message);
void SetIconMenu(int* pIcons, int nbIcons);
void SetToolTips(int* pToolTips, int nbTooltips);
void Draw();
void Redraw();

346
src/ddutil.cpp Normal file

@ -0,0 +1,346 @@
/*==========================================================================
*
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
*
* File: ddutil.cpp
* Content: Routines for loading bitmap and palettes from resources
*
***************************************************************************/
#undef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <ddraw.h>
#include <stdio.h>
#include <stdlib.h>
#include "ddutil.h"
#include "misc.h"
using namespace std;
#define DIRECTDRAW_VERSION 0x0500
BOOL g_bDebug = TRUE;
void DDSetDebug(BOOL bDebug)
{
g_bDebug = bDebug;
}
/*
* DDLoadBitmap
*
* create a DirectDrawSurface from a bitmap resource.
*
*/
extern "C" IDirectDrawSurface * DDLoadBitmap(IDirectDraw *pdd, LPCSTR szBitmap, int dx, int dy)
{
HBITMAP hbm;
BITMAP bm;
DDSURFACEDESC ddsd;
IDirectDrawSurface *pdds;
//
// try to load the bitmap as a resource, if that fails, try it as a file
//
hbm = (HBITMAP)LoadImageA(GetModuleHandle(NULL), szBitmap, IMAGE_BITMAP, dx, dy, LR_CREATEDIBSECTION);
if (hbm == NULL)
hbm = (HBITMAP)LoadImageA(NULL, szBitmap, IMAGE_BITMAP, dx, dy, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if (hbm == NULL)
return NULL;
//
// get size of the bitmap
//
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
//
// create a DirectDrawSurface for this bitmap
//
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
ddsd.dwWidth = bm.bmWidth;
ddsd.dwHeight = bm.bmHeight;
if (pdd->CreateSurface(&ddsd, &pdds, NULL) != DD_OK)
return NULL;
DDCopyBitmap(pdds, hbm, 0, 0, 0, 0);
DeleteObject(hbm);
return pdds;
}
/*
* DDReLoadBitmap
*
* load a bitmap from a file or resource into a directdraw surface.
* normaly used to re-load a surface after a restore.
*
*/
HRESULT DDReLoadBitmap(IDirectDrawSurface *pdds, LPCSTR szBitmap)
{
HBITMAP hbm;
HRESULT hr;
//
// try to load the bitmap as a resource, if that fails, try it as a file
//
hbm = (HBITMAP)LoadImageA(GetModuleHandle(NULL), szBitmap, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
if (hbm == NULL)
hbm = (HBITMAP)LoadImageA(NULL, szBitmap, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
if (hbm == NULL)
{
OutputDebugStringA("handle is null\n");
return E_FAIL;
}
hr = DDCopyBitmap(pdds, hbm, 0, 0, 0, 0);
if (hr != DD_OK)
{
OutputDebugStringA("ddcopybitmap failed\n");
}
DeleteObject(hbm);
return hr;
}
/*
* DDCopyBitmap
*
* draw a bitmap into a DirectDrawSurface
*
*/
extern "C" HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int x, int y, int dx, int dy)
{
HDC hdcImage;
HDC hdc;
BITMAP bm;
DDSURFACEDESC ddsd;
HRESULT hr;
if (hbm == NULL || pdds == NULL)
return E_FAIL;
//
// make sure this surface is restored.
//
pdds->Restore();
//
// select bitmap into a memoryDC so we can use it.
//
hdcImage = CreateCompatibleDC(NULL);
if (!hdcImage)
OutputDebugStringA("createcompatible dc failed\n");
SelectObject(hdcImage, hbm);
//
// get size of the bitmap
//
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
dx = dx == 0 ? bm.bmWidth : dx; // use the passed size, unless zero
dy = dy == 0 ? bm.bmHeight : dy;
//
// get size of surface.
//
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
pdds->GetSurfaceDesc(&ddsd);
if ((hr = pdds->GetDC(&hdc)) == DD_OK)
{
StretchBlt(hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage, x, y, dx, dy, SRCCOPY);
pdds->ReleaseDC(hdc);
}
DeleteDC(hdcImage);
return hr;
}
//
// DDLoadPalette
//
// Create a DirectDraw palette object from a bitmap resoure
//
// if the resource does not exist or NULL is passed create a
// default 332 palette.
//
extern "C" IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap)
{
IDirectDrawPalette* ddpal;
int i;
int n;
int fh;
HRSRC h;
LPBITMAPINFOHEADER lpbi;
PALETTEENTRY ape[256];
RGBQUAD * prgb;
//
// build a 332 palette as the default.
//
for (i=0; i<256; i++)
{
ape[i].peRed = (BYTE)(((i >> 5) & 0x07) * 255 / 7);
ape[i].peGreen = (BYTE)(((i >> 2) & 0x07) * 255 / 7);
ape[i].peBlue = (BYTE)(((i >> 0) & 0x03) * 255 / 3);
ape[i].peFlags = (BYTE)0;
}
//
// get a pointer to the bitmap resource.
//
if (szBitmap && (h = FindResourceA(NULL, szBitmap, (LPCSTR)RT_BITMAP)))
{
lpbi = (LPBITMAPINFOHEADER)LockResource(LoadResource(NULL, h));
if (!lpbi)
OutputDebugStringA("lock resource failed\n");
prgb = (RGBQUAD*)((BYTE*)lpbi + lpbi->biSize);
if (lpbi == NULL || lpbi->biSize < sizeof(BITMAPINFOHEADER))
n = 0;
else if (lpbi->biBitCount > 8)
n = 0;
else if (lpbi->biClrUsed == 0)
n = 1 << lpbi->biBitCount;
else
n = lpbi->biClrUsed;
//
// a DIB color table has its colors stored BGR not RGB
// so flip them around.
//
for(i=0; i<n; i++ )
{
ape[i].peRed = prgb[i].rgbRed;
ape[i].peGreen = prgb[i].rgbGreen;
ape[i].peBlue = prgb[i].rgbBlue;
ape[i].peFlags = 0;
}
}
else if (szBitmap && (fh = _lopen(szBitmap, OF_READ)) != -1)
{
BITMAPFILEHEADER bf;
BITMAPINFOHEADER bi;
_lread(fh, &bf, sizeof(bf));
_lread(fh, &bi, sizeof(bi));
_lread(fh, ape, sizeof(ape));
_lclose(fh);
if (bi.biSize != sizeof(BITMAPINFOHEADER))
n = 0;
else if (bi.biBitCount > 8)
n = 0;
else if (bi.biClrUsed == 0)
n = 1 << bi.biBitCount;
else
n = bi.biClrUsed;
//
// a DIB color table has its colors stored BGR not RGB
// so flip them around.
//
for(i=0; i<n; i++ )
{
BYTE r = ape[i].peRed;
ape[i].peRed = ape[i].peBlue;
ape[i].peBlue = r;
}
}
pdd->CreatePalette(DDPCAPS_8BIT, ape, &ddpal, NULL);
return ddpal;
}
/*
* DDColorMatch
*
* convert a RGB color to a pysical color.
*
* we do this by leting GDI SetPixel() do the color matching
* then we lock the memory and see what it got mapped to.
*/
extern "C" DWORD DDColorMatch(IDirectDrawSurface *pdds, COLORREF rgb)
{
COLORREF rgbT;
HDC hdc;
DWORD dw = CLR_INVALID;
DDSURFACEDESC ddsd;
HRESULT hres;
//
// use GDI SetPixel to color match for us
//
if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK)
{
rgbT = GetPixel(hdc, 0, 0); // save current pixel value
SetPixel(hdc, 0, 0, rgb); // set our value
pdds->ReleaseDC(hdc);
}
//
// now lock the surface so we can read back the converted color
//
ddsd.dwSize = sizeof(ddsd);
while ((hres = pdds->Lock(NULL, &ddsd, 0, NULL)) == DDERR_WASSTILLDRAWING)
;
if (hres == DD_OK)
{
dw = *(DWORD *)ddsd.lpSurface; // get DWORD
if(ddsd.ddpfPixelFormat.dwRGBBitCount < 32)
dw &= (1 << ddsd.ddpfPixelFormat.dwRGBBitCount)-1; // mask it to bpp
pdds->Unlock(NULL);
}
//
// now put the color that was there back.
//
if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK)
{
SetPixel(hdc, 0, 0, rgbT);
pdds->ReleaseDC(hdc);
}
return dw;
}
/*
* DDSetColorKey
*
* set a color key for a surface, given a RGB.
* if you pass CLR_INVALID as the color key, the pixel
* in the upper-left corner will be used.
*/
extern "C" HRESULT DDSetColorKey(IDirectDrawSurface *pdds, COLORREF rgb)
{
DDCOLORKEY ddck;
ddck.dwColorSpaceLowValue = DDColorMatch(pdds, rgb);
ddck.dwColorSpaceHighValue = ddck.dwColorSpaceLowValue;
return pdds->SetColorKey(DDCKEY_SRCBLT, &ddck);
}
extern "C" HRESULT DDSetColorKey2(IDirectDrawSurface* pdds, COLORREF rgb1,
COLORREF rgb2)
{
DDCOLORKEY ddck;
ddck.dwColorSpaceLowValue = DDColorMatch(pdds, rgb1);
ddck.dwColorSpaceHighValue = DDColorMatch(pdds, rgb2);
return pdds->SetColorKey(DDCKEY_SRCBLT, &ddck);
}

@ -7,24 +7,26 @@
*
***************************************************************************/
#define DIRECTDRAW_VERSION 0x0500
using namespace std;
#pragma once
#include <ddraw.h>
#include "ddraw.h"
#ifdef __cplusplus
extern "C" { /* Assume C declarations for C++ */
#endif /* __cplusplus */
extern void DDSetDebug (BOOL bDebug);
extern IDirectDrawSurface * DDConnectBitmap(IDirectDraw *pdd, HBITMAP hbm);
extern void DDSetDebug(BOOL bDebug);
extern IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap);
extern IDirectDrawSurface * DDLoadBitmap(IDirectDraw *pdd, LPCSTR szBitmap, int dx, int dy);
extern HRESULT DDReLoadBitmap(IDirectDrawSurface *pdds, LPCSTR szBitmap);
extern HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int x, int y, int dx, int dy);
extern DWORD DDColorMatch(IDirectDrawSurface *pdds, COLORREF rgb);
extern HRESULT DDSetColorKey(IDirectDrawSurface *pdds, COLORREF rgb);
extern HRESULT DDSetColorKey2(IDirectDrawSurface *pdds, COLORREF rgb1, COLORREF rgb2);
extern HRESULT DDSetColorKey2(IDirectDrawSurface* pdds, COLORREF rgb1, COLORREF rgb2);
/*
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __cplusplus */

776
src/decblock.cpp Normal file

@ -0,0 +1,776 @@
// DecBlock.cpp
//
#include "def.h"
#include "decor.h"
#include "misc.h"
#include "obstacle.h"
#include "dectables.h"
BOOL CDecor::BlitzActif(POINT cel)
{
if (m_phase == WM_PHASE_BUILD) {
//TODO: rewrite this like a human
int foo = m_time >> 31;
return 1 - (((m_time ^ foo) - foo & 1 ^ foo) == foo);
}
POINT pos = { cel.x * DIMOBJX, cel.y * DIMOBJY };
int num = m_time % 100;
if (m_blupiPos.x >= pos.x - 80 && m_blupiPos.x <= pos.x + 80 &&
m_blupiPos.y >= pos.y - 500 && m_blupiPos.y <= pos.y + 500)
{
if (m_time % 100 < 70 && cel.y > 0 && m_decor[cel.x][cel.y - 1].icon == 0x130)
{
PlaySound(SOUND_BLITZ, pos, 0);
}
for (int i = 0; table_blitz[i] != -1; i++)
{
if (m_time % 100 == i) return TRUE;
}
}
return FALSE;
}
int CDecor::SoundEnviron(int sound, int obstacle)
{
if ((obstacle >= 32 && obstacle <= 34) || (obstacle >= 41 && obstacle <= 47) || (obstacle >= 139 && obstacle <= 143))
{
if (sound == SOUND_JUMPTOC)
{
return 79;
}
if (sound == SOUND_JUMPEND)
{
return 78;
}
}
if ((obstacle >= 1 && obstacle <= 28) || (obstacle >= 78 && obstacle <= 90) || (obstacle >= 250 && obstacle <= 260) || (obstacle >= 311 && obstacle <= 316) || (obstacle >= 324 && obstacle <= 329))
{
if (sound == SOUND_JUMPTOC)
{
return 81;
}
if (sound == SOUND_JUMPEND)
{
return 80;
}
}
if ((obstacle >= 284 && obstacle <= 303) || obstacle == 338)
{
if (sound == SOUND_JUMPTOC)
{
return 83;
}
if (sound == SOUND_JUMPEND)
{
return 82;
}
}
if (obstacle >= 341 && obstacle <= 363)
{
if (sound == SOUND_JUMPTOC)
{
return 85;
}
if (sound == SOUND_JUMPEND)
{
return 84;
}
}
if (obstacle >= 215 && obstacle <= 234)
{
if (sound == SOUND_JUMPTOC)
{
return 87;
}
if (sound == SOUND_JUMPEND)
{
return 86;
}
}
if (obstacle >= 246 && obstacle <= 249)
{
if (sound == SOUND_JUMPTOC)
{
return 89;
}
if (sound == SOUND_JUMPEND)
{
return 88;
}
}
if (obstacle >= 107 && obstacle <= 109)
{
if (sound == SOUND_JUMPTOC)
{
return 91;
}
if (sound == SOUND_JUMPEND)
{
return 90;
}
}
return sound;
}
int CDecor::IsWorld(POINT pos)
{
pos.x += 30;
pos.y += 30;
if (pos.x < 0 || pos.x >= 6400 || pos.y < 0 || pos.y >= 6400)
{
return -1;
}
int icon = m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon;
if (icon >= 158 && icon <= 165)
{
return icon - 158 + 1;
}
if (icon >= 166 && icon <= 173)
{
return icon - 166 + 1;
}
if (icon == 309 || icon == 310)
{
return 9;
}
if (icon >= 411 && icon <= 415)
{
return icon - 411 + 10;
}
if (icon >= 416 && icon <= 420)
{
return icon - 416 + 10;
}
if (icon >= 174 && icon <= 181)
{
return icon - 174 + 1;
}
if (icon == 184)
{
return 199;
}
return -1;
}
void CDecor::ActiveSwitch(BOOL bState, POINT cel)
{
POINT pos;
pos.x = cel.x * DIMOBJX;
pos.y = cel.y * DIMOBJY;
ModifDecor(pos, bState ? 384 : 385);
PlaySound(bState ? 77 : 76, pos);
cel.x -= 20;
for (int i = 0; i < 41; i++)
{
if (cel.x >= 0 && cel.x < 100 && m_decor[cel.x][cel.y].icon == (bState ? 379 : 378))
{
pos.x = cel.x * DIMOBJX;
pos.y = cel.y * DIMOBJY;
ModifDecor(pos, bState ? 378 : 379);
}
cel.x++;
}
}
int CDecor::GetTypeBarre(POINT pos)
{
POINT pos2 = pos;
pos.x += 30;
pos.y += 22;
if (pos.y % 64 > 44)
{
return 0;
}
if (pos.x < 0 || pos.x >= 6400 || pos.y < 0 || pos.y >= 6400)
{
return 0;
}
int icon = m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon;
if (icon != 138 && icon != 202)
{
return 0;
}
if (pos.y >= 6336)
{
return 1;
}
icon = m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY + 1].icon;
if (IsPassIcon(icon))
{
return 2;
}
RECT rect = BlupiRect(pos2);
rect.top = pos2.y + 60 - 2;
rect.bottom = pos2.y + 60 - 1;
if (DecorDetect(rect, TRUE))
{
return 2;
}
return 1;
}
BOOL CDecor::IsLave(POINT pos)
{
pos.x += 30;
return pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 68;
}
BOOL CDecor::IsPiege(POINT pos)
{
pos.x += 30;
pos.y += 60;
return pos.x % 64 >= 15 && pos.x % 64 <= 49 && pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 373;
}
BOOL CDecor::IsGoutte(POINT pos, BOOL bAlways)
{
pos.x += 30;
if (pos.x % 64 < 15 || pos.x % 64 > 49)
{
return FALSE;
}
if (pos.x < 0 || pos.x >= 6400 || pos.y < 0 || pos.y >= 6400)
{
return FALSE;
}
int icon = m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon;
if (bAlways)
{
return icon == 404 || icon == 410;
}
return icon == 404;
}
BOOL CDecor::IsScie(POINT pos)
{
pos.x += 30;
return pos.x % 64 >= 4 && pos.x % 64 <= 60 && pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 378;
}
BOOL CDecor::IsSwitch(POINT pos, POINT celSwitch)
{
pos.x += 30;
if (pos.x % 64 < 4 || pos.x % 64 > 60)
{
return FALSE;
}
if (pos.x < 0 || pos.x >= 6400 || pos.y < 0 || pos.y >= 6400)
{
return FALSE;
}
celSwitch.x = pos.x / DIMOBJX;
celSwitch.y = pos.y / DIMOBJY;
return m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 384 || m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 385;
}
BOOL CDecor::IsEcraseur(POINT pos)
{
if (m_time / 3 % 10 > 2)
{
return FALSE;
}
pos.x += 30;
return pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 317;
}
BOOL CDecor::IsBlitz(POINT pos, BOOL bAlways)
{
pos.x += 30;
if (pos.x < 0 || pos.x >= 6400 || pos.y < 0 || pos.y >= 6400)
{
return FALSE;
}
POINT tinyPoint;
tinyPoint.x = pos.x / DIMOBJX;
tinyPoint.y = pos.y / DIMOBJY;
return m_decor[tinyPoint.x][tinyPoint.y].icon == 305 && (bAlways || BlitzActif(tinyPoint));
}
BOOL CDecor::IsRessort(POINT pos)
{
pos.x += 30;
pos.y += 60;
return pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 211;
}
BOOL CDecor::IsTemp(POINT pos)
{
pos.x += 30;
pos.y += 60;
return pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 324;
}
BOOL CDecor::IsBridge(POINT pos, POINT celBridge)
{
pos.x += 30;
pos.y += 60;
if (pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 364)
{
celBridge.x = pos.x / DIMOBJX;
celBridge.y = pos.y / DIMOBJY;
return TRUE;
}
pos.y -= 60;
if (pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon == 364)
{
celBridge.x = pos.x / DIMOBJX;
celBridge.y = pos.y / DIMOBJY;
return TRUE;
}
return FALSE;
}
int CDecor::IsDoor(POINT pos, POINT celPorte)
{
int num;
if (m_blupiDir == 1)
{
num = -60;
}
else
{
num = 60;
}
pos.x += 30;
for (int i = 0; i < 2; i++)
{
if (pos.x >= 0 && pos.x < DIMOBJX * MAXCELX && pos.y >= 0 && pos.y < DIMOBJY * MAXCELY && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon >= 334 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon <= 336)
{
celPorte.x = pos.x / DIMOBJX;
celPorte.y = pos.y / DIMOBJY;
return m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon;
}
pos.x += num;
}
return -1;
}
int CDecor::IsTeleporte(POINT pos)
{
if (pos.x % DIMOBJX > 6)
{
return -1;
}
pos.x += 30;
pos.y -= 60;
if (pos.x < 0 || pos.x >= DIMOBJX * MAXCELX || pos.y < 0 || pos.y >= DIMOBJY * MAXCELY)
{
return -1;
}
if (m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon >= 330 && m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon <= 333)
{
return m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon;
}
return -1;
}
BOOL CDecor::SearchTeleporte(POINT pos, POINT newpos)
{
int num = IsTeleporte(pos);
if (num == -1)
{
return FALSE;
}
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 100; j++)
{
if (num == m_decor[i][j].icon)
{
newpos.x = i * 64;
newpos.y = j * 64 + 60;
if (newpos.x < pos.x - 40 || newpos.x > pos.x + 40 || newpos.y < pos.y - 40 || newpos.y > pos.y + 40)
{
return TRUE;
}
}
}
}
return FALSE;
}
BOOL CDecor::IsSurfWater(POINT pos)
{
if (pos.y % 64 < 64 - BLUPISURF)
{
return FALSE;
}
int icon = m_decor[(pos.x + 30) / 64][pos.y / DIMOBJY].icon;
int icon2 = m_decor[(pos.x + 30) / 64][(pos.y + BLUPISURF) / 64].icon;
return icon != 92 && icon2 == 92;
}
BOOL CDecor::IsDeepWater(POINT pos)
{
int num = (pos.x + 30) / 64;
int num2 = pos.y / DIMOBJY;
if (num < 0 || num >= 100 || num2 < 0 || num2 >= 100)
{
return FALSE;
}
int icon = m_decor[num][num2].icon;
return icon == 91 || icon == 92;
}
BOOL CDecor::IsOutWater(POINT pos)
{
int icon = m_decor[(pos.x + 30) / 64][(pos.y + 30) / 64].icon;
return icon != 91 && icon != 92 && IsPassIcon(icon);
}
BOOL CDecor::IsPassIcon(int icon)
{
if (icon == 324 && m_time / 4 % 20 >= 18)
{
return TRUE;
}
if (icon >= 0 && icon < MAXQUART)
{
for (int i = 0; i < 16; i++)
{
if (table_decor_quart[icon * 16 + i] != 0)
{
return FALSE;
}
}
}
return TRUE;
}
BOOL CDecor::IsBlocIcon(int icon)
{
if (icon < 0 || icon >= MAXQUART)
{
return FALSE;
}
if (icon == 324 && m_time / 4 % 20 < 18)
{
return FALSE;
}
for (int i = 0; i < 16; i++)
{
if (table_decor_quart[icon * 16 + i] == 0)
{
return FALSE;
}
}
return FALSE;
}
BOOL CDecor::IsVentillo(POINT pos)
{
int num = 0;
BOOL flag = FALSE;
POINT tinyPoint;
pos.x += 30;
pos.y += 30;
if (pos.x < 0 || pos.x >= 6400 || pos.y < 0 || pos.y >= 6400)
{
return FALSE;
}
int icon = m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon;
if (icon < 126 || icon > 137)
{
return FALSE;
}
if (icon == 126)
{
if (pos.x % 64 <= 16)
{
flag = TRUE;
}
tinyPoint.x = -64;
tinyPoint.y = 0;
num = 110;
}
if (icon == 129)
{
if (pos.x % 64 >= 48)
{
flag = TRUE;
}
tinyPoint.x = 64;
tinyPoint.y = 0;
num = 114;
}
if (icon == 132)
{
if (pos.y % 64 <= 32)
{
flag = TRUE;;
}
tinyPoint.x = 0;
tinyPoint.y = -64;
num = 118;
}
if (icon == 135)
{
if (pos.y % 64 >= 48)
{
flag = TRUE;
}
tinyPoint.x = 0;
tinyPoint.y = 64;
num = 122;
}
if (!flag)
{
return FALSE;
}
ModifDecor(pos, -1);
do
{
pos.x += tinyPoint.x;
pos.y += tinyPoint.y;
if (num != m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon)
{
break;
}
ModifDecor(pos, -1);
} while (pos.x >= 0 && pos.x < 6400 && pos.y >= 0 && pos.y < 6400);
return TRUE;
}
void CDecor::ModifDecor(POINT pos, int icon, BOOL bMulti)
{// TODO: this
int icon2 = m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon;
if (icon == -1 && icon >= 126 && icon2 <= 137)
{
}
m_decor[pos.x / DIMOBJX][pos.y / DIMOBJY].icon = icon;
}
BOOL CDecor::IsRightBorder(POINT pos, POINT offset)
{
return FALSE; // TODO
}
BOOL CDecor::IsFromage(POINT cel)
{
if (!IsValidCel(cel)) return FALSE;
int icon = m_decor[cel.x][cel.y].icon;
return (icon >= 246 && icon <= 249) || icon == 339;
}
BOOL CDecor::IsGrotte(POINT cel)
{
if (!IsValidCel(cel)) return FALSE;
int icon = m_decor[cel.x][cel.y].icon;
return icon = 284 || icon == 301 || icon == 337;
}
void CDecor::AdaptMidBorder(POINT cel)
{
if (!IsValidCel(cel)) return;
int num = 15;
if (!IsRightBorder({ cel.x, cel.y + 1 }, { 0, -1 }))
{
num &= -2;
}
if (!IsRightBorder({ cel.x, cel.y + 1 }, { 0, 1 }))
{
num &= -3;
}
if (!IsRightBorder({ cel.x + 1, cel.y }, { -1, 0 }))
{
num &= -5;
}
if (!IsRightBorder({ cel.x - 1, cel.y }, { 1, 0 }))
{
num &= -9;
}
int num2 = m_decor[cel.x][cel.y].icon;
if (num2 == 156)
{
num2 = 35;
}
if (num2 == 252 || num2 == 253)
{
num2 = 251;
}
if (num2 == 255)
{
num2 = 254;
}
if (num2 == 362)
{
num2 = 347;
}
if (num2 == 363)
{
num2 = 348;
}
if (num2 >= 341 && num2 <= 346)
{
num2 = 341;
}
for (int i = 0; i < 144; i++)
{
if (num2 == table_adapt_decor[i])
{
num2 = table_adapt_decor[i / 16 * 16 + num];
if (num2 == 35 && rand() % 2 == 0)
{
num2 = 156;
}
if (num2 == 251)
{
num2 = Random(251, 253);
}
if (num2 == 254 && rand() % 2 == 0)
{
num2 = 255;
}
if (num2 == 347 && rand() % 2 == 0)
{
num2 = 362;
}
if (num2 == 348 && rand() % 2 == 0)
{
num2 = 363;
}
if (num2 == 341)
{
num2 = Random(341, 346);
}
m_decor[cel.x][cel.y].icon = num2;
return;
}
}
num2 = m_decor[cel.x][cel.y].icon;
if (num2 == -1 || (num2 >= 264 && num2 <= 282))
{
num = 15;
if (!IsFromage(cel + POINT{ 0,1 }))
{
num &= -2;
}
if (!IsFromage(cel - POINT{ 0,1 }))
{
num &= -3;
}
if (!IsFromage(cel + POINT{ 1,0 }))
{
num &= -5;
}
if (!IsFromage(cel - POINT{ 1,0 }))
{
num &= -9;
}
num2 = table_adapt_fromage[num];
if (num2 == 268 && rand() % 2 == 0)
{
num2 = 279;
}
if (num2 == 269 && rand() % 2 == 0)
{
num2 = 280;
}
if (num2 == 264 && rand() % 2 == 0)
{
num2 = 281;
}
if (num2 == 265 && rand() % 2 == 0)
{
num2 = 282;
}
m_decor[cel.x][cel.y].icon = num2;
}
num2 = m_decor[cel.x][cel.y].icon;
if (num2 == -1 || (num2 >= 285 && num2 <= 303 && num2 != 301))
{
num = 15;
if (!IsGrotte(cel+POINT{0,1}))
{
num &= -2;
}
if (!IsGrotte(cel-POINT{0,1}))
{
num &= -3;
}
if (!IsGrotte(cel+POINT{1,0}))
{
num &= -5;
}
if (!IsGrotte(cel-POINT{1,0}))
{
num &= -9;
}
num2 = table_adapt_fromage[num + 16];
if (num2 == 289 && rand() % 2 == 0)
{
num2 = 300;
}
if (num2 == 285 && rand() % 2 == 0)
{
num2 = 302;
}
if (num2 == 286 && rand() % 2 == 0)
{
num2 = 303;
}
m_decor[cel.x][cel.y].icon = num2;
}
}
void CDecor::AdaptBorder(POINT cel)
{
AdaptMidBorder(cel);
AdaptMidBorder(cel + POINT{1, 0});
AdaptMidBorder(cel - POINT{1, 0});
AdaptMidBorder(cel + POINT{ 0,1 });
AdaptMidBorder(cel - POINT{ 0,1 });
int icon = m_decor[cel.x][cel.y].icon;
if (icon != -1 && !IsPassIcon(icon))
{
MoveObjectDelete(cel);
}
icon = m_decor[cel.x][cel.y].icon;
if (icon == 304)
{
for (int i = 0; i < 4; i++)
{
cel.y++;
if (cel.y >= 100)
{
break;
}
icon = m_decor[cel.x][cel.y].icon;
if (icon != -1)
{
break;
}
m_decor[cel.x][cel.y].icon = 305;
}
}
if (icon == -1)
{
for (int i = 0; i < 4; i++)
{
cel.y++;
if (cel.y >= 100)
{
return;
}
icon = m_decor[cel.x][cel.y].icon;
if (icon != 305)
{
return;
}
m_decor[cel.x][cel.y].icon = -1;
}
}
}

File diff suppressed because it is too large Load Diff

659
src/decdesign.cpp Normal file

@ -0,0 +1,659 @@
// DecDesign.cpp
//
#include "def.h"
#include "decor.h"
#include "misc.h"
#include "dectables.h"
POINT CDecor::ScreenPosToCelPos(POINT pos)
{
if (pos.x >= 0 && pos.x < LXIMAGE && pos.y >= 0 && pos.y < LYIMAGE) {
return {
(m_posDecor.x + m_dimCelHili.x * -32 + 32 + pos.x) / 64,
(m_posDecor.y + m_dimCelHili.y * -32 + 32 + pos.y) / 64
};
}
else return { -1, -1 };
}
void CDecor::SetCelPosFromScreenPos(POINT pos)
{
m_posCelHili = ScreenPosToCelPos(pos);
}
void CDecor::SetFieldCC38AndStuff(int _foo, int _bar)
{
m_dimCelHili = { 1, 1 };
if (_foo == 2 && _bar != 3 && _bar != 9 && _bar != 10) m_dimCelHili = { 2, 2 };
if (_foo == 3) m_iconLift = _bar;
if (_foo == 4) m_iconLift = _bar + 20;
if (_foo == 5) m_iconLift = _bar + 40;
m_2ndPositionCalculationSlot = -1;
}
void CDecor::DeleteCel(POINT cel)
{
m_2ndPositionCalculationSlot = -1;
if (!IsValidCel(cel)) return;
m_decor[cel.x][cel.y].icon = -1;
AdaptBorder(cel);
m_bigDecor[cel.x][cel.y].icon = -1;
MoveObjectDelete(cel);
}
void CDecor::PlaceMenuItem(short *pCel, int *pTable, int lastIndex, BYTE flags, int currentIcon, BOOL bRand)
{
if (bRand) {
*pCel = pTable[rand() % (pTable[0] + 1)];
}
else if (!(flags & 8)) {
if (flags & 1) {
lastIndex++;
if (*pCel == pTable[lastIndex] && currentIcon != 0 && pTable[0] <= lastIndex) {
lastIndex = 0;
}
*pCel = pTable[lastIndex + 1];
}
}
else {
*pCel = pTable[lastIndex + 1];
}
}
void CDecor::PlaceItemFromMenu1(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
short *pIcon = &m_decor[cel.x][cel.y].icon;
short *pIconBig = &m_bigDecor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
switch (index) {
case 0: // Tree
PlaceMenuItem(pIconBig, table_366b0, m_lastDecorIndexes[0], flags, *pIconBig, TRUE);
break;
case 1: // Palmtree
PlaceMenuItem(pIconBig, table_366c0, m_lastDecorIndexes[1], flags, *pIconBig, TRUE);
break;
case 2: // Decorative plant
PlaceMenuItem(pIconBig, table_366d8, m_lastDecorIndexes[2], flags, *pIconBig, TRUE);
break;
case 3: // Marine plant
*pIcon = Object::Marine_1;
break;
case 4: // House
PlaceMenuItem(pIconBig, table_366e8, m_lastDecorIndexes[3], flags, *pIconBig, TRUE);
break;
case 5: // Mechanical background
PlaceMenuItem(pIconBig, table_366f8, m_lastDecorIndexes[4], flags, *pIconBig, TRUE);
break;
case 6: // Kid's stuff background
PlaceMenuItem(pIconBig, table_36710, m_lastDecorIndexes[5], flags, *pIconBig, TRUE);
break;
case 7: // Green slime 2
PlaceMenuItem(pIconBig, table_36748, m_lastDecorIndexes[6], flags, *pIconBig, TRUE);
break;
case 8: // Element for Palace
PlaceMenuItem(pIconBig, table_36520, m_lastDecorIndexes[7], flags, *pIconBig, TRUE);
break;
case 9: // Support
PlaceMenuItem(pIcon, table_36670, m_lastDecorIndexes[8], flags, *pIcon, TRUE);
break;
case 10: // Spider's web
PlaceMenuItem(pIcon, table_366a0, m_lastDecorIndexes[9], flags, *pIcon, TRUE);
break;
}
}
void CDecor::PlaceItemFromMenu2(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
m_iconLift = index;
switch (index) {
case 0: // Square tech-blocks
PlaceMenuItem(pIcon, table_36418, m_lastDecorIndexes[10], flags, *pIcon, TRUE);
break;
case 1: // Special tech-blocks
PlaceMenuItem(pIcon, table_36458, m_lastDecorIndexes[11], flags, *pIcon, TRUE);
break;
case 2: // Triangular tech-blocks
PlaceMenuItem(pIcon, table_36488, m_lastDecorIndexes[12], flags, *pIcon, FALSE);
break;
case 3: // Secret tech-block
PlaceMenuItem(pIcon, table_364a0, m_lastDecorIndexes[13], flags, *pIcon, FALSE);
break;
case 4: // Mechanical square
PlaceMenuItem(pIcon, table_364b0, m_lastDecorIndexes[14], flags, *pIcon, TRUE);
break;
case 5: // Special mechanical
PlaceMenuItem(pIcon, table_364d0, m_lastDecorIndexes[15], flags, *pIcon, FALSE);
break;
case 6: // Secret mechanical
PlaceMenuItem(pIcon, table_364e8, m_lastDecorIndexes[16], flags, *pIcon, FALSE);
break;
case 7: // Pipes
*pIcon = Object::Pipes_1;
break;
}
AdaptBorder(cel);
}
void CDecor::PlaceItemFromMenu3(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
m_iconLift = index + 20;
switch (index) {
case 0: // Square rock
PlaceMenuItem(pIcon, table_36530, m_lastDecorIndexes[20], flags, *pIcon, FALSE);
break;
case 1: // Triangular rock
PlaceMenuItem(pIcon, table_36538, m_lastDecorIndexes[21], flags, *pIcon, FALSE);
break;
case 2: // Secret rock
PlaceMenuItem(pIcon, table_36548, m_lastDecorIndexes[22], flags, *pIcon, FALSE);
break;
case 3: // Cave
// todo
break;
case 4: // Secret cave
*pIcon = Object::CaveSecret;
break;
case 5: // Cheese
*pIcon = Random(Object::CheeseSquare_1, Object::CheeseSquare_4);
break;
case 6: // Secret cheese
*pIcon = Object::CheeseSecret;
break;
case 7: // Green slime 2
*pIcon = Object::Slime_1;
break;
case 8: // Grass
PlaceMenuItem(pIcon, table_365d0, m_lastDecorIndexes[23], flags, *pIcon, FALSE);
break;
case 9: // Water
PlaceMenuItem(pIcon, table_36630, m_lastDecorIndexes[24], flags, *pIcon, FALSE);
break;
}
AdaptBorder(cel);
}
void CDecor::PlaceItemFromMenu4(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
m_iconLift = index + 40;
switch (index) {
case 0: // Palace
break;
case 1: // Element for Palace
break;
case 2: // Building facade
break;
case 3: // Roof
break;
case 4: // Bricks
break;
case 5: // Furniture
break;
case 6: // Wooden wall
break;
case 7: // Kid's stuff square
break;
case 8: // Special Kid's stuff
break;
case 9: // Invisible block
break;
}
AdaptBorder(cel);
}
void CDecor::PlaceItemFromMenu5(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
int mobId;
MoveObject* pMob;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
switch (index) {
case 0: // Bomb
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_BOMBEDOWN;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 4 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0x0c;
break;
case 1: // Hanging bomb
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_BOMBEUP;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0x30;
break;
case 2: // Homing bomb
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_BOMBEFOLLOW1;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX, cel.y * DIMOBJY };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0x100;
break;
case 3: // Lava
PlaceMenuItem(pIcon, table_decor_lave, m_lastDecorIndexes[40], flags, *pIcon, FALSE);
break;
case 4: // Fan
PlaceMenuItem(pIcon, table_decor_ventillog, m_lastDecorIndexes[41], flags, *pIcon, FALSE);
break;
case 5: // Wind
PlaceMenuItem(pIcon, table_decor_ventg, m_lastDecorIndexes[42], flags, *pIcon, FALSE);
break;
case 6: // Slime trap (floor)
*pIcon = Object::SlimeTrapFloor_1;
break;
case 7: // Slime trap (ceiling)
*pIcon = Object::SlimeTrapCeiling_1;
break;
case 8: // Circular saw
PlaceMenuItem(pIcon, table_decor_scie, m_lastDecorIndexes[43], flags, *pIcon, FALSE);
break;
case 9: // Inverter
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_INVERT;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 8 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0xBB;
break;
case 10: // Lightning
*pIcon = Object::LightningMachine;
break;
case 11: // Crusher
*pIcon = Object::Crusher_1;
break;
}
AdaptBorder(cel);
}
void CDecor::PlaceItemFromMenu6(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel) || currentIcon == 0) return;
switch (m_iconLift) {
}
switch (index) {
case 0: // Slow lift
case 1: // Normal lift
case 2: // Fast lift
case 3: // Fast/Slow lift
case 4: // Lift with conveyor belt
case 5: // Bulldozer
case 6: // Fish
case 7: // Bird
case 8: // Wasp
case 9: // Slime creature
case 10: // Moving bomb
case 11: // Heliported ennemy
case 12: // Motorized ennemy
break;
}
}
void CDecor::PlaceItemFromMenu7(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
MoveObject* pMob;
int mobId;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
switch (index) {
case 0: // Chest
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_TRESOR;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 4 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0x00;
break;
case 1: // Egg
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_EGG;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 8 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0x15;
break;
case 2: // Lollipop
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_POWER;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 8 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0x88;
break;
case 3: // Shield
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_SHIELD;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 8 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0x90;
break;
case 4: // Invisibility potion
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_DRINK;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 6 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0xB2;
break;
case 5: // Glue supply
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_BULLET;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 4 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0xB1;
break;
case 6: // Recharging device
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_CHARGE;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 4 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0xEE;
break;
case 7: // Personal bomb
int type;
mobId = MoveObjectSearch(cel, -1);
if (mobId != -1 && currentIcon != 0) {
if (mobId >= TYPE_BOMBEPERSO4) {
m_lastDecorIndexes[60] = 0;
}
else {
m_lastDecorIndexes[60] = m_moveObject[mobId].type - TYPE_BOMBEPERSO1;
}
}
type = m_lastDecorIndexes[60] + TYPE_BOMBEPERSO1;
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = type;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 6 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
switch (type) {
default:
case TYPE_BOMBEPERSO1:
pMob->channel = CHBLUPI;
break;
case TYPE_BOMBEPERSO2:
pMob->channel = CHBLUPI1;
break;
case TYPE_BOMBEPERSO3:
pMob->channel = CHBLUPI2;
break;
case TYPE_BOMBEPERSO4:
pMob->channel = CHBLUPI3;
break;
}
pMob->icon = 0x101;
break;
case 8: // Dynamite
MoveObjectDelete(cel);
mobId = MoveObjectFree();
if (mobId == -1) return;
pMob = &m_moveObject[mobId];
pMob->type = TYPE_DYNAMITE;
pMob->stepAdvance = 1;
pMob->stepRecede = 1;
pMob->timeStopStart = 0;
pMob->timeStopEnd = 0;
pMob->posStart = { cel.x * DIMOBJX + 2, cel.y * DIMOBJY + 6 };
pMob->posEnd = pMob->posStart;
pMob->posCurrent = pMob->posStart;
pMob->step = STEP_STOPSTART;
pMob->time = 0;
pMob->phase = 0;
pMob->channel = CHELEMENT;
pMob->icon = 0xFC;
break;
}
AdaptBorder(cel);
}
void CDecor::PlaceItemFromMenu8(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
switch (index) {
case 0: // Key
case 1: // Door
case 2: // Closed while not all chests have been found
case 3: // Teleporter
case 4: // Bar to hang from
case 5: // Spring
case 6: // Vanishing bloc
case 7: // Fragile bridge
case 8: // Wooden case
case 9: // Secret wooden case
break;
}
}
void CDecor::PlaceItemFromMenu9(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
switch (index) {
case 0: // Hovercraft
case 1: // Helicopter
case 2: // Skateboard
case 3: // Jeep
case 4: // Glue tank
break;
}
}
void CDecor::PlaceItemFromMenu10(POINT cel, int index, BYTE flags, int currentIcon)
{
m_2ndPositionCalculationSlot = -1;
short *pIcon = &m_decor[cel.x][cel.y].icon;
if (!IsValidCel(cel)) return;
switch (index) {
case 0: // Goal
case 1: // Yellow Blupi
case 2: // Orange Blupi
case 3: // Blue Blupi
case 4: // Green Blupi
case 5: // Door
case 6: // Level start
case 7: // Key
break;
}
}
char* CDecor::GetMissionTitle()
{
return m_missionTitle;
}
void CDecor::SetMissionTitle(char *str)
{
strcpy(m_missionTitle, str);
}

49
src/decio.cpp Normal file

@ -0,0 +1,49 @@
// DecIO.cpp
//
#include "def.h"
#include "decor.h"
#include "misc.h"
void CDecor::GetMissionPath(char* str, int user, int mission, BOOL bUser)
{
if (bUser != 0)
{
sprintf(str, "data\%.3d-%.3d.blp", user, mission);
AddUserPath(str);
return;
}
sprintf(str, "data\world%.3d.blp", mission);
AddUserPath(str);
return;
}
BOOL CDecor::Write(int gamer, int mission, BOOL bUser)
{
return FALSE; //TODO
}
BOOL CDecor::Read(int gamer, int mission, BOOL bUser)
{
return FALSE; //TODO
}
BOOL CDecor::SomethingMissionPath(int gamer, int mission, BOOL bUser)
{
return FALSE; //TODO
}
BOOL CDecor::MissionStart(int gamer, int mission, BOOL bUser)
{
return FALSE; //TODO
}
BOOL CDecor::CurrentRead(int gamer, int mission, BOOL *pbMission, BOOL *pbPrivate)
{
return FALSE; //TODO
}
BOOL CDecor::CurrentWrite(int gamer, int mission, char* param3)
{
return FALSE; //TODO
}

2140
src/decmove.cpp Normal file

File diff suppressed because it is too large Load Diff

203
src/decnet.cpp Normal file

@ -0,0 +1,203 @@
// DecNet.cpp
//
#include "def.h"
#include "decor.h"
#include "misc.h"
#include "network.h"
void CDecor::NetStopCloud(int rank)
{
NetMessage msg;
msg.data1 = 0;
msg.x = 0;
msg.y = 0;
msg.type = MESS_STOPCLOUD;
msg.channel = rank;
NetMessagePush(&msg);
return;
}
void CDecor::NetPlaySound(short channel, POINT pos)
{
NetMessage msg;
msg.y = pos.y;
msg.x = pos.x;
msg.type = MESS_PLAYSOUND;
msg.data1 = 0;
msg.channel = channel;
NetMessagePush(&msg);
return;
}
void CDecor::NetStopSound(short channel)
{
NetMessage msg;
msg.data1 = 0;
msg.x = 0;
msg.y = 0;
msg.type = MESS_STOPSOUND;
msg.channel = channel;
NetMessagePush(&msg);
}
void CDecor::NetDataFlush()
{
for (int i = 0; i < MAXNETPLAYER; i++)
{
m_netPos[i].x = 0;
m_netPos[i].y = 0;
m_netIcons[i] = -1;
m_netUnk1[i] = 0;
m_netUnk2[i] = 0;
m_netTransports[i] = 0;
m_netPlayerPacketsReceived[i] = 0;
m_netPlayerPacketsReceived2[i] = 0;
m_netTimeSincePacket[i] = 0;
m_netVitesses[i].x = 0;
m_netVitesses[i].y = 0;
m_netUnk4[i].x = 0;
m_netUnk4[i].y = 0;
}
m_netPacketsSent = 0;
m_netPacketsSent2 = 0;
m_netPacketsReceived = 0;
m_netPacketsReceived2 = 0;
m_netPacketIcon = -1;
NetMessageIndexFlush();
}
void CDecor::NetFUN_155e0(BYTE _foo, short _bar)
{
char data[4]{ 4, _foo, _bar & 0xff, _bar >> 8 };
m_pNetwork->Send(&data, 4, DPSEND_GUARANTEED);
return;
}
void CDecor::TreatNetData()
{
}
void CDecor::DoNetSmooth(int player)
{
}
void CDecor::NetAdjustToLift()
{
for (int i = 0; i < MAXNETPLAYER; i++)
{
if (m_netPos[i].x != -1 && m_netTransports[i] >= 0 && m_netTransports[i] < MAXMOVEOBJECT)
{
m_netPos[i].y = m_moveObject[m_netTransports[i]].posCurrent.y - 58;
}
}
}
void CDecor::FUN_15da0(int index, short step)
{
}
void CDecor::NetPlayerCollide(POINT pos, int* out)
{
tagRECT rect1;
RECT rect2;
RECT rect3;
//TODO
}
void CDecor::NetMessageIndexFlush()
{
m_netMessageIndex1 = 0;
m_netMessageIndex2 = 0;
m_netMessageIndex3 = 0;
return;
}
BOOL CDecor::NetMessagePush(NetMessage* message)
{
NetMessage* messages;
BYTE data;
short pos;
int i;
if (m_netMessageIndex1 == MAXNETMESSAGE) return FALSE;
CopyMemory(&m_netMessages[m_netMessageIndex2], message, sizeof(NetMessage));
m_netMessageIndex1++;
m_netMessageIndex2++;
if (m_netMessageIndex2 == MAXNETMESSAGE)
{
m_netMessageIndex2 = 0;
}
return TRUE;
}
BOOL CDecor::NetMessagePop(NetMessage* message)
{
if (m_netMessageIndex1 == 0) return FALSE;
CopyMemory(message, &m_netMessages[m_netMessageIndex3], sizeof(NetMessage));
m_netMessageIndex1--;
m_netMessageIndex3++;
if (m_netMessageIndex3 == MAXNETMESSAGE)
{
m_netMessageIndex3 = 0;
}
return TRUE;
}
void CDecor::NotifFlush()
{
for (int i = 0; i < MAXNOTIF; i++)
{
m_notifText[i][0] = '\0';
}
m_notifTime = 0;
}
void CDecor::NotifPop()
{
for (int i = MAXNOTIF; i > 0; --i)
{
//strcpy()
m_notifText[MAXNOTIF - 1][0] = '\0';
m_notifTime = NOTIFDELAY; // idk
}
}
void CDecor::NotifPush(char *str)
{
int i;
for (i = 0; i < MAXNOTIF; i++)
{
if (m_notifText[i][0] != '\0') break;
}
if (i >= MAXNOTIF)
{
NotifPop();
i = MAXNOTIF - 1;
}
strcpy(m_notifText[i], str);
m_notifTime = NOTIFDELAY;
m_pSound->PlayImage(SOUND_TRESOR, { LXIMAGE / 2, LYIMAGE / 2 }, -1);
}
void CDecor::NotifStep()
{
if (m_notifTime == 0)
{
NotifPop();
}
else {
m_notifTime--;
}
}

@ -19,35 +19,8 @@
#include "network.h"
////////////////////////////////////////////////////////////////////////////////
#define MAXQUART 441
#define SCROLL_SPEED 8
#define SCROLL_MARGX 80
#define SCROLL_MARGY 40
#define BLUPIFLOOR 2
#define BLUPIOFFY 4 + BLUPIFLOOR
#define BLUPISURF 12
#define BLUPISUSPEND 12
#define OVERHEIGHT 80
#define TEXTDELAY 10 // tooltip popup delay
#define NOTIFDELAY 200
inline BOOL IsValidCel(POINT cel)
{
return cel.x >= 0 && cel.x < MAXCELX && cel.y >= 0 && cel.y < MAXCELY;
}
inline void CDecor::StopVehicleSound()
{
StopSound(SOUND_HELICOHIGH);
StopSound(SOUND_HELICOLOW);
StopSound(SOUND_JEEPHIGH);
StopSound(SOUND_JEEPLOW);
}
///////////////////////////////////////////////////////////////////////////////
// Constructor
@ -124,7 +97,7 @@ BOOL CDecor::LoadImages()
iconDim = { 0, 0 };
sprintf(filename, "decor%.3d.blp", m_region);
return m_pPixmap->BackgroundCache(CHBACK, filename, totalDim, iconDim, FALSE);
return m_pPixmap->BackgroundCache(CHDECOR, filename, totalDim, iconDim, FALSE);
}
void CDecor::InitGamer()
@ -244,7 +217,7 @@ int CDecor::GetTime()
void CDecor::PlayPrepare(BOOL bTest)
{
if (bTest) m_nbVies = 3;
if (m_bMulti)
{
m_nbVies = 10;
@ -395,7 +368,7 @@ void CDecor::MoveStep()
if (m_phase == WM_PHASE_PLAY || m_phase == WM_PHASE_PLAYTEST) {
BlupiStep();
NetFUN_15d50();
NetAdjustToLift();
NotifStep();
}
@ -472,10 +445,10 @@ void CDecor::Build(RECT rect)
tinyPoint.x += LXIMAGE - pos.x;
pos.x = 0;
}
tinyPoint.x = - posDecor.x % 64 - 64;
tinyPoint.x = -posDecor.x % 64 - 64;
for (int i = posDecor.x / 64 - 1; i < posDecor.x / 64 + LXIMAGE / 64 + 3; i++) {
tinyPoint.y = - posDecor.y % 64 + 2 - 64;
tinyPoint.y = -posDecor.y % 64 + 2 - 64;
for (int j = posDecor.y / 64 - 1; j < posDecor.y / 64 + LYIMAGE / 64 + 2; j++)
{
if (i >= 0 && i < MAXCELX && j >= 0 && j < MAXCELY)
@ -506,10 +479,10 @@ void CDecor::Build(RECT rect)
tinyPoint.x += 64;
}
tinyPoint.x = - posDecor.x % 64;
tinyPoint.x = -posDecor.x % 64;
for (int i = posDecor.x / 64; i < posDecor.x / 64 + LXIMAGE / 64 + 2; i++)
{
tinyPoint.y = - posDecor.y % 64;
tinyPoint.y = -posDecor.y % 64;
for (int j = posDecor.y / 64; j < posDecor.y / 64 + LYIMAGE / 64 + 2; j++)
{
if (i >= 0 && i < MAXCELX && j >= 0 && j < MAXCELY && m_decor[i][j].icon != -1)
@ -615,7 +588,7 @@ void CDecor::Build(RECT rect)
m_pPixmap->QuickIcon(m_moveObject[num3].channel, m_moveObject[num3].icon, tinyPoint);
if (m_moveObject[num3].type == 30)
{
for (int l = 0; l < sizeof(table_drinkoffset)/sizeof(int); l++)
for (int l = 0; l < sizeof(table_drinkoffset) / sizeof(int); l++)
{
int num4 = (m_time + table_drinkoffset[l]) % 50;
int rank = table_drinkeffect[num4 % 5];
@ -630,7 +603,7 @@ void CDecor::Build(RECT rect)
}
}
}
tinyPoint.x = - posDecor.x % 64;
tinyPoint.x = -posDecor.x % 64;
for (int i = posDecor.x / 64; i < posDecor.x / 64 + LXIMAGE / 64 + 2; i++)
{
tinyPoint.y = 0 - posDecor.y % 64;
@ -705,9 +678,9 @@ void CDecor::Build(RECT rect)
break;
}
}
tinyPoint.y += 64;
tinyPoint.y += DIMOBJY;
}
tinyPoint.x += 64;
tinyPoint.x += DIMOBJX;
}
for (int num3 = 0; num3 < MAXMOVEOBJECT; num3++)
{
@ -778,7 +751,7 @@ void CDecor::Build(RECT rect)
num2 = table_decor_eau2[(i * 11 + j * 7 + m_time / num5) % 6];
m_pPixmap->QuickIcon(1, num2, pos);
}
if (num2 == 305 && BlitzActif(i, j))
if (num2 == 305 && BlitzActif({ i, j }))
{
num2 = rand() % 4 + 305;
m_pPixmap->QuickIcon(1, num2, pos);
@ -928,14 +901,14 @@ void CDecor::DrawInfo()
POINT CDecor::DecorNextAction()
{
int num = 0;
if (m_decorAction == 0 || m_bPause)
{
return m_posDecor;
}
int num = 0;
if (m_decorAction == 0 || m_bPause)
{
return m_posDecor;
}
POINT posDecor = m_posDecor;
while (table_decor_action[num] != 0)
{
while (table_decor_action[num] != 0)
{
if (m_decorAction == table_decor_action[num])
{
if (m_decorPhase < table_decor_action[num + 1])
@ -985,24 +958,24 @@ POINT CDecor::DecorNextAction()
{
num += 2 + table_decor_action[num + 1] * 2;
}
}
}
return posDecor;
}
void CDecor::SetInput(int keys)
{
m_keyPress = keys;
if (m_blupiInvert)
{
if (keys & KEY_LEFT)
{
m_keyPress = keys & ~KEY_LEFT | KEY_RIGHT;
}
if (keys & KEY_RIGHT)
{
m_keyPress = m_keyPress & ~KEY_RIGHT | KEY_LEFT;
}
}
m_keyPress = keys;
if (m_blupiInvert)
{
if (keys & KEY_LEFT)
{
m_keyPress = keys & ~KEY_LEFT | KEY_RIGHT;
}
if (keys & KEY_RIGHT)
{
m_keyPress = m_keyPress & ~KEY_RIGHT | KEY_LEFT;
}
}
}
void CDecor::SetJoystickEnable(BOOL bJoystick)
@ -1010,7 +983,7 @@ void CDecor::SetJoystickEnable(BOOL bJoystick)
m_bJoystick = bJoystick;
}
void CDecor::SetFieldD814(BOOL param)
void CDecor::SetDemoPlay(BOOL param)
{
m_bD814 = param;
}
@ -1037,9 +1010,14 @@ void CDecor::PlaySound(int sound, POINT pos, BOOL bLocal)
}
}
void CDecor::PlaySound(int sound, POINT pos)
{
PlaySound(sound, pos, FALSE);
}
void CDecor::StopSound(int sound)
{
m_pSound->StopSound(sound);
m_pSound->StopSound(sound);
switch (sound) {
case SOUND_HELICOHIGH:
@ -1061,10 +1039,10 @@ void CDecor::AdaptMotorVehicleSound(POINT pos)
{
POINT blupiPos = pos - m_posDecor;
if (m_bHelicoMarch) m_pSound->PlayImage(SOUND_HELICOHIGH, blupiPos);
if (m_bHelicoStop) m_pSound->PlayImage(SOUND_HELICOLOW, blupiPos);
if (m_bJeepMarch) m_pSound->PlayImage(SOUND_JEEPHIGH, blupiPos);
if (m_bJeepStop) m_pSound->PlayImage(SOUND_JEEPLOW, blupiPos);
if (m_bHelicoMarch) m_pSound->PlayImage(SOUND_HELICOHIGH, blupiPos);
if (m_bHelicoStop) m_pSound->PlayImage(SOUND_HELICOLOW, blupiPos);
if (m_bJeepMarch) m_pSound->PlayImage(SOUND_JEEPHIGH, blupiPos);
if (m_bJeepStop) m_pSound->PlayImage(SOUND_JEEPLOW, blupiPos);
}
void CDecor::VehicleSoundsPhase(int phase)
@ -1139,25 +1117,25 @@ void CDecor::SetPause(BOOL bPause)
void CDecor::InitializeDoors(BYTE* doors)
{
for (int i = 0; i < MAXMOVEOBJECT; i++)
{
for (int i = 0; i < 200; i++)
{
doors[i] = m_doors[i];
}
}
}
void CDecor::MemorizeDoors(BYTE* doors)
{
for (int i = 0; i < MAXMOVEOBJECT; i++)
for (int i = 0; i < 200; i++)
{
m_doors[i] = doors[i];
}
}
}
void CDecor::SetAllMissions(BOOL bAllMissions)
{
m_bCheatDoors = bAllMissions;
AdaptDoors(m_bPrivate, m_mission);
return;
return;
}
void CDecor::CheatAction(int cheat)
@ -1397,20 +1375,20 @@ void CDecor::CheatAction(int cheat)
m_blupiCle |= CLE_RED | CLE_GREEN | CLE_BLUE;
break;
}
if (!m_blupiShield && !m_blupiHide && !m_blupiCloud && !m_blupiPower)
{
m_jauges[1].SetHide(TRUE);
}
if (!m_blupiHelico && !m_blupiOver)
{
StopSound(SOUND_HELICOHIGH);
StopSound(SOUND_HELICOLOW);
}
if (m_blupiJeep && m_blupiTank)
{
StopSound(SOUND_JEEPHIGH);
StopSound(SOUND_JEEPLOW);
}
if (!m_blupiShield && !m_blupiHide && !m_blupiCloud && !m_blupiPower)
{
m_jauges[1].SetHide(TRUE);
}
if (!m_blupiHelico && !m_blupiOver)
{
StopSound(SOUND_HELICOHIGH);
StopSound(SOUND_HELICOLOW);
}
if (m_blupiJeep && m_blupiTank)
{
StopSound(SOUND_JEEPHIGH);
StopSound(SOUND_JEEPLOW);
}
}
BOOL CDecor::GetSuperBlupi()
@ -1475,7 +1453,7 @@ void CDecor::OutputNetDebug(char* text)
if (!m_bNetDebug) return;
sprintf(textbuffer, "/ snd=%d(%d)_rcv=%d(%d)", m_netPacketsSent, m_netPacketsSent2, m_netPacketsRecieved, m_netPacketsRecieved2);
sprintf(textbuffer, "/ snd=%d(%d)_rcv=%d(%d)", m_netPacketsSent, m_netPacketsSent2, m_netPacketsReceived, m_netPacketsReceived2);
// ...?
}
@ -1576,12 +1554,12 @@ void CDecor::VoyageDraw()
BOOL CDecor::DrawMap(BOOL bPlay, int team)
{
return FALSE;
}
BOOL CDecor::SearchWorld(int world, POINT *blupi, int *dir)
{
return FALSE;
}
BOOL CDecor::SearchDoor(int n, POINT *cel, POINT *blupi)
@ -1595,34 +1573,34 @@ BOOL CDecor::SearchDoor(int n, POINT *cel, POINT *blupi)
{
if (i > 0 && m_decor[i - 1, j]->icon == 182)
{
cel.x = i - 1;
cel.y = j;
blupi.x = (i - 2) * 64 + 2;
blupi.y = j * 64 + BLUPIOFFY;
cel->x = i - 1;
cel->y = j;
blupi->x = (i - 2) * 64 + 2;
blupi->y = j * 64 + BLUPIOFFY;
return TRUE;
}
if (i > 1 && m_decor[i - 2, j]->icon == 182)
{
cel.x = i - 2;
cel.y = j;
blupi.x = (i - 3) * 64 + 2;
blupi.y = j * 64 + BLUPIOFFY;
cel->x = i - 2;
cel->y = j;
blupi->x = (i - 3) * 64 + 2;
blupi->y = j * 64 + BLUPIOFFY;
return TRUE;
}
if (i < 99 && m_decor[i + 1, j]->icon == 182)
{
cel.x = i + 1;
cel.y = j;
blupi.x = (i + 2) * 64 + 2;
blupi.y = j * 64 + BLUPIOFFY;
cel->x = i + 1;
cel->y = j;
blupi->x = (i + 2) * 64 + 2;
blupi->y = j * 64 + BLUPIOFFY;
return TRUE;
}
if (i < 98 && m_decor[i + 2, j]->icon == 182)
{
cel.x = i + 2;
cel.y = j;
blupi.x = (i + 3) * 64 + 2;
blupi.y = j * 64 + BLUPIOFFY;
cel->x = i + 2;
cel->y = j;
blupi->x = (i + 3) * 64 + 2;
blupi->y = j * 64 + BLUPIOFFY;
return TRUE;
}
}
@ -1643,7 +1621,7 @@ void CDecor::OpenDoorsTresor()
for (int y = 0; y < MAXCELY; y++)
{
int icon = m_decor[x][y].icon;
if (icon >= Object::DoorTreasure_1 && icon <= Object::DoorTreasure_1 + m_nbTresor - 1)
if (icon >= 0x1a5 && icon <= 0x1a5 + m_nbTresor - 1)
{
OpenDoor({ x, y });
}
@ -1671,7 +1649,7 @@ void CDecor::OpenDoor(POINT cel)
m_moveObject[num].phase = 0;
m_moveObject[num].channel = CHOBJECT;
m_moveObject[num].icon = icon;
PlaySound(33, m_moveObject[num].posStart);
PlaySound(33, m_moveObject[num].posStart, FALSE);
}
void CDecor::OpenDoorsWin()
@ -1690,58 +1668,60 @@ void CDecor::DoorsLost()
// more...
}
// BOOL CDecor::SearchGold(int n, POINT cel)
// Winphone functions, likely unnecessary
/*
BOOL CDecor::SearchGold(int n, POINT cel)
{
for (int i = 99; i >= 0; i--)
{
for (int j = 99; j >= 0; j--)
{
if (m_decor[j][i].icon == 183)
{
cel.x = j;
cel.y = i;
return TRUE;
}
}
}
return FALSE;
for (int i = 99; i >= 0; i--)
{
for (int j = 99; j >= 0; j--)
{
if (m_decor[j][i].icon == 183)
{
cel.x = j;
cel.y = i;
return TRUE;
}
}
}
return FALSE;
}
// BOOL CDecor::IsFloatingObject(int i)
BOOL CDecor::IsFloatingObject(int i)
{
POINT posCurrent = m_moveObject[i]->posCurrent;
int num = (posCurrent.x + 32) / 64;
int num2 = posCurrent.y / 64 + 1;
int icon = m_decor[num, num2]->icon;
return IsPassIcon(icon);
POINT posCurrent = m_moveObject[i]->posCurrent;
int num = (posCurrent.x + 32) / 64;
int num2 = posCurrent.y / 64 + 1;
int icon = m_decor[num, num2]->icon;
return IsPassIcon(icon);
}
// BOOL CDecor::IsNormalJump(POINT pos)
BOOL CDecor::IsNormalJump(POINT pos)
{
pos.x += 32;
pos.y -= 32;
if (m_blupiDir == 1)
{
pos.x -= 15;
}
else
{
pos.x += 15;
}
for (int i = 0; i < 2; i++)
{
int num = pos.x / DIMOBJX;
int num2 = pos.y / DIMOBJY;
if (num2 < 0)
{
return FALSE;
}
int icon = m_decor[num, num2]->icon;
if (!IsPassIcon(icon))
{
return FALSE;
}
pos.y -= 64;
}
return TRUE;
}
pos.x += 32;
pos.y -= 32;
if (m_blupiDir == 1)
{
pos.x -= 15;
}
else
{
pos.x += 15;
}
for (int i = 0; i < 2; i++)
{
int num = pos.x / DIMOBJX;
int num2 = pos.y / DIMOBJY;
if (num2 < 0)
{
return FALSE;
}
int icon = m_decor[num, num2]->icon;
if (!IsPassIcon(icon))
{
return FALSE;
}
pos.y -= 64;
}
return TRUE;
}*/

@ -1,9 +1,6 @@
// Decor.h
#pragma once
#include <Windows.h>
#include "DEF.H"
#include "JAUGE.H"
#include "SOUND.H"
@ -15,16 +12,27 @@
#define MAXNETMESSAGE 20
#define MAXMOVEOBJECT 200
#define MAXNOTIF 4
#define MAXNETPLAYER 4
#define MAXQUART 441
#define SCROLL_SPEED 8
#define SCROLL_MARGX 80
#define SCROLL_MARGY 40
#define BLUPIFLOOR 2
#define BLUPIOFFY 4 + BLUPIFLOOR
#define BLUPISURF 12
#define BLUPISUSPEND 12
#define OVERHEIGHT 80
#define TEXTDELAY 10 // tooltip popup delay
#define NOTIFDELAY 200
// Descripteur d'une cellule du décor.
typedef struct
{
short icon;
}
Cellule;
// Cette structure doit être la plus petite possible, car
// il en existe un tableau de 100x100 = 10'000 cellules !
typedef struct
{
@ -46,11 +54,6 @@ typedef struct
}
MoveObject;
typedef struct
{
}
GameData;
typedef struct
{
char type;
@ -61,6 +64,24 @@ typedef struct
}
NetMessage;
typedef struct
{
short majRev;
short minRev;
short reserve1[100];
POINT posDecor;
POINT dimDecor;
short world;
short music;
short region;
short reserve2[51];
POINT blupiPos[4];
int blupiDir[4];
char name[100];
short reserve3[196];
}
DescFile;
class CDecor
{
public:
@ -69,7 +90,7 @@ public:
// Decor.cpp
void Create(HWND hWnd, CSound *pSound, CPixmap *pPixmap,
CNetwork *pNetwork);
CNetwork *pNetwork);
BOOL LoadImages();
void InitGamer();
void InitDecor();
@ -87,8 +108,9 @@ public:
POINT DecorNextAction();
void SetInput(int keys);
void SetJoystickEnable(BOOL bJoystick);
void SetFieldD814(BOOL param_1);
void SetDemoPlay(BOOL param_1);
void PlaySound(int sound, POINT pos, BOOL bLocal);
void PlaySound(int sound, POINT pos); // hack
void StopSound(int sound);
void AdaptMotorVehicleSound(POINT pos);
void VehicleSoundsPhase(int phase);
@ -132,7 +154,7 @@ public:
int SoundEnviron(int sound, int obstacle);
int IsWorld(POINT pos);
void ActiveSwitch(BOOL bState, POINT cel);
char GetTypeBarre(POINT pos);
int GetTypeBarre(POINT pos);
BOOL IsLave(POINT pos);
BOOL IsPiege(POINT pos);
BOOL IsGoutte(POINT pos, BOOL bAlways);
@ -152,7 +174,7 @@ public:
BOOL IsPassIcon(int icon);
BOOL IsBlocIcon(int icon);
BOOL IsVentillo(POINT pos);
void ModifDecor(POINT pos, int icon, BOOL _foo);
void ModifDecor(POINT pos, int icon, BOOL bMulti=TRUE);
BOOL IsRightBorder(POINT cel, POINT offset);
BOOL IsFromage(POINT cel);
BOOL IsGrotte(POINT cel);
@ -188,12 +210,12 @@ public:
void BlupiDead(int action, int action2);
POINT GetPosDecor(POINT pos);
void BlupiAddFifo(POINT pos);
BOOL DecorDetect(RECT rect, BOOL bCaisse);
BOOL DecorDetect(RECT rect, BOOL bCaisse=TRUE);
void GetBlupiInfo(BOOL *pbHelico, BOOL *pbJeep, BOOL *pbSkate,
BOOL *pbNage);
// DecMove.cpp
BOOL TestPath(RECT rect, POINT start, POINT end);
BOOL TestPath(RECT rect, POINT start, POINT *end);
void MoveObjectPollution();
void MoveObjectPlouf(POINT pos);
void MoveObjectTiplouf(POINT pos);
@ -207,13 +229,14 @@ public:
int SearchDistRight(POINT pos, POINT dir, int type);
void StartSploutchGlu(POINT pos);
BOOL ObjectStart(POINT pos, int type, int speed);
BOOL ObjectStart(POINT pos, int type, int speed, BOOL bMulti);
BOOL ObjectDelete(POINT pos, int type);
void MoveObjectStep();
void MoveObjectStepLine(int i);
void* MoveObjectStepIcon(int i);
void MoveObjectStepIcon(int i);
void DynamiteStart(int i, int dx, int dy);
int AscenseurDetect(RECT rect, POINT oldpos, POINT newpos);
int AscenseurVertigo(int i, BOOL *bVertigoLeft, BOOL *bVertigoRight);
void AscenseurVertigo(int i, BOOL *pbVertigoLeft, BOOL *pbVertigoRight);
BOOL AscenseurShift(int i);
void AscenseurSynchro(int i);
void UpdateCaisse();
@ -246,7 +269,7 @@ public:
void NetFUN_155e0(BYTE _foo, short _bar);
void TreatNetData();
void DoNetSmooth(int player);
void NetFUN_15d50();
void NetAdjustToLift();
void FUN_15da0(int rank, short step);
void NetPlayerCollide(POINT pos, int *out);
void NetMessageIndexFlush();
@ -256,15 +279,15 @@ public:
void NotifPop();
void NotifPush(char *str);
void NotifStep();
// DecIO.cpp
void GetMissionPath(char *out, int gamer, int mission, BOOL bUser);
BOOL CurrentWrite(int gamer, int mission, BOOL bUser);
BOOL CurrentRead(int gamer, int mission, BOOL bUser);
BOOL Write(int gamer, int mission, BOOL bUser);
BOOL Read(int gamer, int mission, BOOL bUser);
BOOL SomethingMissionPath(int gamer, int mission, BOOL bUser);
BOOL MissionStart(int gamer, int mission, BOOL bUser);
BOOL Read(int gamer, int mission, BOOL *pbMission, BOOL *pbPrivate);
BOOL Write(int gamer, int mission, char* param3);
BOOL CurrentRead(int gamer, int mission, BOOL *pbMission, BOOL *pbPrivate);
BOOL CurrentWrite(int gamer, int mission, char* param3);
BOOL SearchWorld(int world, POINT *blupi, int *dir);
BOOL SearchDoor(int n, POINT *cel, POINT *blupi);
@ -275,27 +298,29 @@ public:
void OpenGoldsWin();
void DoorsLost();
inline BOOL IsValidCel(POINT cel);
inline void MoveObjectCopy(MoveObject src, MoveObject dest);
inline void StopVehicleSound();
protected:
HWND m_hWnd;
CSound* m_pSound;
CPixmap* m_pPixmap;
CNetwork* m_pNetwork;
Cellule m_decor[MAXCELX][MAXCELY];
CNetwork* m_pNetwork;
Cellule m_decor[MAXCELX][MAXCELY];
Cellule m_bigDecor[MAXCELX][MAXCELY];
byte m_balleTraj[MAXCELX][MAXCELY/8+1];
byte m_moveTraj[MAXCELX][MAXCELY/8+1];
MoveObject m_moveObject[MAXMOVEOBJECT];
int m_keyPress;
int m_lastKeyPress;
POINT m_posDecor;
POINT m_dimDecor;
POINT m_posCelHili;
byte m_balleTraj[MAXCELX * MAXCELY / 8 + 1];
byte m_moveTraj[MAXCELX * MAXCELY / 8 + 1];
MoveObject m_moveObject[MAXMOVEOBJECT];
int m_keyPress;
int m_lastKeyPress;
POINT m_posDecor;
POINT m_dimDecor;
POINT m_posCelHili;
POINT m_dimCelHili;
int m_2ndPositionCalculationSlot;
int m_phase;
int m_term;
int m_phase;
int m_term;
int m_music;
int m_region;
int m_lastRegion;
@ -303,40 +328,40 @@ protected:
int m_time;
char m_missionTitle[100];
BOOL m_bPause;
int m_nbRankCaisse;
int m_nbRankCaisse;
int m_rankCaisse[MAXMOVEOBJECT];
int m_nbLinkCaisse;
int m_linkCaisse[MAXMOVEOBJECT];
POINT m_blupiPos;
POINT m_blupiValidPos;
int m_blupiAction;
int m_blupiDir;
int m_blupiPhase;
POINT m_blupiVitesse;
int m_blupiIcon;
POINT m_blupiPos;
POINT m_blupiValidPos;
int m_blupiAction;
int m_blupiDir;
int m_blupiPhase;
POINT m_blupiVitesse;
int m_blupiIcon;
int m_blupiSec;
int m_blupiChannel;
POINT m_blupiVector;
int m_blupiTransport;
BOOL m_blupiFocus;
BOOL m_blupiAir;
BOOL m_blupiHelico;
BOOL m_blupiOver;
BOOL m_blupiJeep;
BOOL m_blupiTank;
BOOL m_blupiSkate;
BOOL m_blupiNage;
BOOL m_blupiSurf;
BOOL m_blupiVent;
BOOL m_blupiSuspend;
BOOL m_blupiJumpAie;
BOOL m_blupiShield;
BOOL m_blupiPower;
BOOL m_blupiCloud;
BOOL m_blupiHide;
BOOL m_blupiAir;
BOOL m_blupiHelico;
BOOL m_blupiOver;
BOOL m_blupiJeep;
BOOL m_blupiTank;
BOOL m_blupiSkate;
BOOL m_blupiNage;
BOOL m_blupiSurf;
BOOL m_blupiVent;
BOOL m_blupiSuspend;
BOOL m_blupiJumpAie;
BOOL m_blupiShield;
BOOL m_blupiPower;
BOOL m_blupiCloud;
BOOL m_blupiHide;
BOOL m_blupiInvert;
BOOL m_blupiBalloon;
BOOL m_blupiEcrase;
BOOL m_blupiBalloon;
BOOL m_blupiEcrase;
POINT m_blupiPosHelico;
POINT m_blupiPosMagic;
BOOL m_blupiRestart;
@ -366,7 +391,7 @@ protected:
int m_netIcons[MAXNETPLAYER];
int m_netUnk1[MAXNETPLAYER];
int m_netUnk2[MAXNETPLAYER];
int m_netUnk3[MAXNETPLAYER];
int m_netTransports[MAXNETPLAYER]; // index of lift ridden by each player, or -1
int m_netPlayerPacketsReceived[MAXNETPLAYER];
int m_netPlayerPacketsReceived2[MAXNETPLAYER];
int m_netTimeSincePacket[MAXNETPLAYER];
@ -392,28 +417,28 @@ protected:
BOOL m_bCheatDoors; // opendoors
BOOL m_bSuperBlupi; // megablupi
BOOL m_bDrawSecret; // showsecret
BOOL m_bBuildOfficialMissions; // xmission/xnjttjpo
BOOL m_bNetPacked; // netpacked
BOOL m_bNetMovePredict; // ynosmooth
BOOL m_bNetDebug; // znetdebug
BOOL m_bBuildOfficialMissions; // xmission/xnjttjpo
BOOL m_bNetPacked; // netpacked
BOOL m_bNetMovePredict; // ynosmooth
BOOL m_bNetDebug; // znetdebug
BOOL m_bJoystick;
int m_bD814;
int m_mission;
int m_mission;
BYTE m_doors[200];
int m_nbVies;
int m_nbTresor;
int m_totalTresor;
int m_nbVies;
int m_nbTresor;
int m_totalTresor;
int m_goalPhase;
int m_detectIcon;
int m_D8F8;
POINT m_scrollPoint;
POINT m_scrollAdd;
int m_voyageIcon;
int m_voyageChannel;
int m_voyagePhase;
int m_voyageTotal;
POINT m_voyageStart;
POINT m_voyageEnd;
POINT m_scrollPoint;
POINT m_scrollAdd;
int m_voyageIcon;
int m_voyageChannel;
int m_voyagePhase;
int m_voyageTotal;
POINT m_voyageStart;
POINT m_voyageEnd;
int m_decorAction;
int m_decorPhase;
int m_lastDecorIndexes[200];
@ -421,7 +446,24 @@ protected:
BYTE dummy[100000];
};
POINT GetCel (int x, int y);
POINT GetCel (POINT cel, int x, int y);
inline BOOL IsValidCel (POINT cel);
POINT GetVector (int direct);
POINT GetCel(int x, int y);
POINT GetCel(POINT cel, int x, int y);
POINT GetVector(int direct);
inline BOOL CDecor::IsValidCel(POINT cel)
{
return cel.x >= 0 && cel.x < MAXCELX && cel.y >= 0 && cel.y < MAXCELY;
}
inline void CDecor::MoveObjectCopy(MoveObject src, MoveObject dest)
{
memcpy(&dest, &src, sizeof(dest));
}
inline void CDecor::StopVehicleSound()
{
StopSound(SOUND_HELICOHIGH);
StopSound(SOUND_HELICOLOW);
StopSound(SOUND_JEEPHIGH);
StopSound(SOUND_JEEPLOW);
}

552
src/dectables.h Normal file

@ -0,0 +1,552 @@
#pragma once
#include "obstacle.h"
extern int table_blitz[]
{
0, 7, 15, 18, 26, 27, 32, 39, 45, 47,
50, 58, 60, 62, 64, 66, 68, 70, 71, 72,
-1
};
extern int table_vitesse_march[]
{
2, 4, 6, 8
};
extern int table_vitesse_nage[]
{
2, 1, 5, 10, 8, 6, 4
};
extern int table_vitesse_surf[]
{
0, 2, 5, 8, 3, 0
};
extern int table_bulldozer_left[8]{ 66, 66, 67, 67, 66, 66, 65, 65 };
extern int table_bulldozer_right[8]{ 58, 58, 57, 57, 58, 58, 59, 59 };
extern int table_bulldozer_turn2l[22]
{
58, 59, 59, 59, 60, 60, 60, 61, 61, 62,
62, 63, 63, 64, 64, 64, 65, 65, 65, 66,
66, 66
};
extern int table_bulldozer_turn2r[22]
{
66, 65, 65, 65, 64, 64, 64, 63, 63, 62,
62, 61, 61, 60, 60, 60, 59, 59, 59, 58,
58, 58
};
extern int table_poisson_left[8]{ 82, 82, 81, 81, 82, 82, 83, 83 };
extern int table_poisson_right[8]{ 79, 79, 78, 78, 79, 79, 80, 80 };
extern int table_poisson_turn2l[48]
{
79, 79, 80, 80, 84, 84, 85, 85, 86, 86,
87, 87, 88, 88, 83, 83, 82, 82, 83, 83,
88, 88, 87, 87, 86, 86, 85, 85, 84, 84,
79, 79, 79, 79, 80, 80, 84, 84, 85, 85,
86, 86, 87, 87, 88, 88, 83, 83
};
extern int table_poisson_turn2r[48]
{
82, 82, 83, 83, 88, 88, 87, 87, 86, 86,
85, 85, 84, 84, 79, 79, 79, 79, 80, 80,
84, 84, 85, 85, 86, 86, 87, 87, 88, 88,
83, 83, 82, 82, 83, 83, 88, 88, 87, 87,
86, 86, 85, 85, 84, 84, 79, 79
};
extern int table_oiseau_left[8]{ 98, 99, 100, 101, 102, 103, 104, 105 };
extern int table_oiseau_right[8]{ 90, 91, 92, 93, 94, 95, 96, 97 };
extern int table_oiseau_turn2l[10]{ 106, 107, 108, 109, 110, 111, 112, 113, 105, 105 };
extern int table_oiseau_turn2r[10]{ 114, 115, 116, 117, 118, 119, 120, 121, 97, 97 };
extern int table_guepe_left[6]{ 195, 196, 197, 198, 197, 196 };
extern int table_guepe_right[6]{ 199, 200, 201, 202, 201, 200 };
extern int table_guepe_turn2l[5]{ 207, 206, 205, 204, 203 };
extern int table_guepe_turn2r[5]{ 203, 204, 205, 206, 207 };
extern int table_creature_left[8]{ 247, 248, 249, 250, 251, 250, 249, 248 };
extern int table_creature_right[8]{ 247, 248, 249, 250, 251, 250, 249, 248 };
extern int table_creature_turn2[152]
{
244, 244, 244, 244, 244, 244, 244, 244, 243, 243,
242, 242, 242, 242, 242, 242, 242, 242, 243, 243,
244, 244, 245, 245, 246, 246, 246, 246, 246, 246,
246, 246, 245, 245, 244, 244, 243, 243, 242, 242,
242, 242, 242, 242, 243, 243, 244, 244, 245, 245,
246, 246, 246, 246, 246, 246, 245, 245, 244, 244,
243, 243, 242, 242, 242, 242, 243, 243, 244, 244,
245, 245, 246, 246, 246, 246, 245, 245, 244, 244,
243, 243, 242, 242, 243, 243, 244, 244, 245, 245,
246, 246, 245, 245, 244, 244, 243, 243, 242, 242,
242, 242, 243, 243, 244, 244, 245, 245, 246, 246,
246, 246, 245, 245, 244, 244, 243, 243, 242, 242,
242, 242, 242, 242, 243, 243, 244, 244, 245, 245,
246, 246, 246, 246, 246, 246, 245, 245, 244, 244,
244, 244, 244, 244, 244, 244, 244, 244, 244, 244,
244, 244
};
extern int table_blupih_left[8]{ 66, 67, 68, 67, 66, 69, 70, 69 };
extern int table_blupih_right[8]{ 61, 62, 63, 62, 61, 64, 65, 64 };
extern int table_blupih_turn2l[26]
{
71, 71, 72, 72, 73, 73, 74, 74, 75, 75,
68, 68, 275, 275, 271, 271, 271, 271, 272, 272,
273, 273, 273, 273, 275, 275
};
extern int table_blupih_turn2r[26]
{
75, 75, 74, 74, 73, 73, 72, 72, 71, 71,
63, 63, 274, 274, 271, 271, 271, 271, 272, 272,
273, 273, 273, 273, 274, 274
};
extern int table_blupit_left[8]{ 249, 249, 250, 250, 249, 249, 248, 248 };
extern int table_blupit_right[8]{ 238, 238, 237, 237, 238, 238, 239, 239 };
extern int table_blupit_turn2l[24]
{
238, 238, 251, 251, 238, 238, 238, 239, 240, 241,
242, 243, 244, 245, 246, 247, 248, 249, 249, 249,
252, 252, 249, 249
};
extern int table_blupit_turn2r[24]
{
249, 249, 252, 252, 249, 249, 249, 248, 247, 246,
245, 244, 243, 242, 241, 240, 239, 238, 238, 238,
251, 251, 238, 238
};
extern int table_explo1[39]
{
0, 0, 1, 1, 2, 2, 3, 3, 4, 3,
4, 4, 3, 4, 3, 3, 4, 4, 5, 5,
4, 5, 6, 5, 6, 6, 5, 5, 6, 7,
7, 8, 8, 9, 9, 10, 10, 11, 11
};
extern int table_explo2[20]
{
12, -1, 13, 14, -1, 15, 13, -1, 14, 15,
12, -1, 13, 15, 14, 14, -1, 14, 15, 13
};
extern int table_explo3[20]
{
32, 32, 34, 34, 32, 32, 34, 34, 32, 32,
34, 34, 32, 32, 35, 35, 32, 32, 35, 35
};
extern int table_explo4[9]{ 12, 13, 14, 15, 7, 8, 9, 10, 11 };
extern int table_explo5[12]
{
54, -1, 55, -1, 56, -1, 57, -1, 58, -1,
59, -1
};
extern int table_explo6[6]{ 54, 55, 56, 57, 58, 59 };
extern int table_explo7[128]
{
60, 61, -1, 63, 64, 65, 62, 64, 62, 60,
62, -1, 65, -1, 60, 65, 63, 61, 62, -1,
64, 65, -1, 62, 64, 61, 62, 63, -1, 65,
60, -1, 65, -1, 63, 65, -1, 61, 60, 65,
62, 63, 64, -1, 62, 63, -1, 62, 62, 60,
62, -1, 65, -1, 60, 65, 64, 61, 62, 63,
-1, 65, 60, -1, 63, 61, 62, -1, 64, 65,
-1, 62, 62, 60, 62, -1, 65, -1, 60, 65,
60, 61, -1, 63, 64, 65, 62, 64, 63, 61,
62, -1, 64, 65, -1, 62, 60, 61, -1, 63,
64, 65, 62, 64, -1, 60, -1, -1, 65, -1,
60, -1, 63, -1, 62, -1, -1, 65, -1, -1,
-1, 61, -1, -1, -1, 60, -1, -1
};
extern int table_explo8[5]{ 7, 8, 9, 10, 11 };
extern int table_sploutch1[10]{ 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 };
extern int table_sploutch2[13]
{
-1, -1, -1, 90, 91, 92, 93, 94, 95, 96,
97, 98, 99
};
extern int table_sploutch3[18]
{
-1, -1, -1, -1, -1, -1, -1, -1, 90, 91,
92, 93, 94, 95, 96, 97, 98, 99
};
extern int table_tentacule[45]
{
86, 85, 84, 83, 84, 85, 86, -1, 86, 85,
84, 83, 82, 81, 80, 79, 78, 77, 76, 75,
74, 73, 72, 71, 70, 70, 70, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, -1
};
extern int table_bridge[157]
{
365, 366, 365, 366, 365, 366, 365, 366, 365, 366,
365, 366, 365, 366, 365, 366, 367, 367, 368, 368,
369, 369, 370, 370, 371, 371, 372, 372, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
372, 372, 371, 371, 370, 370, 369, 369, 368, 368,
367, 367, 366, 366, 365, 365, 364
};
extern int table_pollution[8]{ 179, 180, 181, 182, 183, 184, 185, 186 };
extern int table_invertstart[8]{ 179, 180, 181, 182, 183, 184, 185, 186 };
extern int table_invertstop[8]{ 186, 185, 184, 183, 182, 181, 180, 179 };
extern int table_invertpanel[8]{ 187, 188, 189, 190, 191, 192, 193, 194 };
extern int table_plouf[7]{ 99, 100, 101, 102, 101, 100, 99 };
extern int table_tiplouf[3]{ 244, 99, 244 };
extern int table_blup[20]
{
103, 104, 105, 106, 104, 103, 106, 105, 103, 104,
103, 105, 106, 103, 105, 106, 103, 104, 106, 105
};
extern int table_follow1[26]
{
256, 256, 256, 257, 257, 258, 259, 260, 261, 262,
263, 264, 264, 265, 265, 265, 264, 264, 263, 262,
261, 260, 259, 258, 257, 257
};
extern int table_follow2[5]{ 256, 258, 260, 262, 264 };
extern int table_cle[12]
{
122, 123, 124, 125, 126, 127, 128, 127, 126, 125,
124, 123
};
extern int table_cle1[12]
{
209, 210, 211, 212, 213, 214, 215, 214, 213, 212, 211, 210
};
extern int table_cle2[12]
{
220, 221, 222, 221, 220, 219, 218, 217, 216, 217, 218, 219
};
extern int table_cle3[12]
{
229, 228, 227, 226, 225, 224, 223, 224, 225, 226, 227, 228
};
extern int table_decor_action[]
{
1,32,
-4,4, 4,-3, -4,2, 4,5, -4,-1, 4,2, -4,-4, 4,-3, -3,2, 3,2,
-3,-5, 3,4, -3,5, 3,-2, -3,5, 3,4, -2,-2, 2,4, -2,-2, 2,-2,
-2,-4, 2,2, -2,-2, 2,-3, -1,-3, 1,-2, -1,-1, 1,2, -1,-2, 1,-1,
-1,1, 1,2,
2,32,
-4,0, 4,0, -4,0, 4,0, -4,0, 4,0, -4,0, 4,0, -3,0, 3,0,
-3,0, 3,0, -3,0, 3,0, -3,0, 3,0, -2,0, 2,0, -2,0, 2,0,
-2,0, 2,0, -2,0, 2,0, -1,0, 1,0, -1,0, 1,0, -1,0, 1,0,
-1,0, 1,0,
5,192,
0,-32, 0,32, 0,-16, 0,6, 0,-8, 0,8, 0,-4, 0,4, 0,-2, 0,2,
-7,0, -6,0, -5,0, -4,0, -2,0, 0,0, 2,0, 4,0, 5,0, 6,0,
7,0, 7,0, 6,0, 5,0, 4,0, 2,0, 0,0, -2,0, -4,0, -5,0,
-6,0, -7,0, -7,0, -6,0, -5,0, -4,0, -2,0, 0,0, 2,0, 4,0,
5,0, 6,0, 7,0, 7,0, 6,0, 5,0, 4,0, 2,0, 0,0, -2,0, -4,0,
-5,0, -6,0, -7,0, -7,0, -6,0, -5,0, -4,0, -2,0, 0,0, 2,0,
4,0, 5,0, 6,0, 7,0, 7,0, 6,0, 5,0, 4,0, 2,0, 0,0,
-2,0, -4,0, -5,0, -6,0, -7,0, -7,0, -6,0, -5,0, -4,0, -2,0,
0,0, 2,0, 4,0, 5,0, 6,0, 7,0, 7,0, 6,0, 5,0, 4,0,
2,0, 0,0, -2,0, -4,0, -5,0, -6,0, -7,0, -7,0, -6,0, -5,0,
-4,0, -2,0, 0,0, 2,0, 4,0, 5,0, 6,0, 7,0, 7,0, 6,0,
5,0, 4,0, 2,0, 0,0, -2,0, -4,0, -5,0, -6,0, -7,0, -7,0,
-6,0, -5,0, -4,0, -2,0, 0,0, 2,0, 4,0, 5,0, 6,0, 7,0,
7,0, 6,0, 5,0, 4,0, 2,0, 0,0, -2,0, -4,0, -5,0, -6,0,
-7,0, -7,0, -6,0, -5,0, -4,0, -2,0, 0,0, 2,0, 4,0, 5,0,
6,0, 7,0, 7,0, 6,0, 5,0, 4,0, 2,0, 0,0, -2,0, -4,0,
-5,0, -6,0, -7,0, -7,0, -6,0, -5,0, -4,0, -2,0, 0,0, 2,0,
4,0, 5,0, 6,0, 7,0, 7,0, 6,0, 5,0, 4,0, 2,0, 0,0,
-2,0, -4,0, -5,0, -6,0, -7,0, -7,0, -6,0, -5,0, -4,0, -2,0,
-1,0,
0
};
extern int table_dynamitef[100]
{
253, 252, 254, 252, 252, 255, 252, 254, 253, 252,
253, 254, 255, 252, 255, 253, 252, 254, 252, 255,
253, 254, 252, 253, 255, 254, 255, 252, 253, 254,
255, 252, 253, 254, 255, 254, 254, 253, 254, 255,
253, 252, 255, 254, 255, 253, 252, 254, 253, 255,
253, 254, 252, 253, 255, 254, 252, 255, 253, 254,
255, 253, 252, 254, 255, 254, 252, 253, 254, 255,
253, 254, 255, 254, 255, 253, 252, 254, 253, 255,
253, 254, 255, 253, 255, 254, 255, 252, 253, 254,
255, 253, 253, 254, 255, 254, 252, 253, 254, 255
};
extern int table_skate[34]
{
129, 129, 129, 129, 130, 130, 130, 131, 131, 132,
132, 133, 133, 134, 134, 134, 135, 135, 135, 135,
134, 134, 134, 133, 133, 132, 132, 131, 131, 131,
130, 130, 130, 130
};
extern int table_glu[25]
{
168, 168, 169, 169, 170, 170, 171, 171, 170, 170,
169, 169, 168, 168, 169, 169, 169, 168, 168, 169,
169, 170, 170, 169, 168
};
extern int table_clear[70]
{
40, 40, 40, 40, 41, 41, 41, 41, 40, 40,
40, 40, 40, 40, 40, 41, 41, 41, 40, 40,
40, 40, 40, 40, 40, 41, 41, 41, 40, 40,
42, 42, 42, 43, 43, 43, 44, 44, 44, 45,
45, 45, 46, 46, 47, 47, 46, 46, 47, 47,
46, 46, 47, 47, 46, 46, 47, 47, 46, 46,
47, 47, 46, 46, 47, 47, 46, 46, 47, 47
};
extern int table_electro[90]
{
266, 267, 266, 267, 266, 267, 266, 267, 266, 267,
266, 267, 266, 267, 266, 267, 266, 267, 266, 267,
266, 267, 266, 267, 266, 267, 266, 267, 266, 267,
40, 40, 40, 40, 41, 41, 41, 41, 40, 40,
40, 40, 40, 40, 40, 41, 41, 41, 40, 40,
40, 40, 40, 40, 40, 41, 41, 41, 40, 40,
42, 42, 42, 43, 43, 43, 44, 44, 44, 45,
45, 45, 46, 46, 47, 47, 46, 46, 47, 47,
46, 46, 47, 47, 46, 46, 47, 47, 46, 46
};
extern int table_chenille[6]{ 311, 312, 313, 314, 315, 316 };
extern int table_chenillei[6]{ 316, 315, 314, 313, 312, 311 };
extern int table_adapt_decor[144]
{
153, 147, 148, 146, 40, 151, 150, 144, 39, 152,
149, 145, 38, 36, 37, 35, 153, 147, 148, 146,
40, 151, 150, 144, 39, 152, 149, 145, 38, 36,
37, 156, 75, 75, 155, 155, 75, 75, 155, 155,
74, 74, 154, 154, 75, 75, 155, 155, 157, 157,
157, 157, 109, 109, 109, 109, 108, 108, 108, 108,
107, 107, 107, 107, 202, 202, 138, 138, 202, 202,
138, 138, 202, 202, 138, 138, 202, 202, 138, 138,
283, 283, 283, 283, 262, 262, 262, 262, 263, 263,
263, 263, 261, 261, 261, 261, 361, 359, 360, 352,
357, 353, 355, 349, 358, 354, 356, 350, 351, 347,
348, 341, 387, 387, 386, 386, 394, 394, 392, 392,
395, 395, 393, 393, 397, 397, 396, 396, 251, 254,
254, 254, 251, 258, 260, 258, 251, 257, 259, 257,
251, 250, 256, 250
};
extern int table_adapt_fromage[32]
{
-1, 265, 264, 268, 267, 273, 271, 275, 266, 272,
270, 274, 269, 277, 276, 278, -1, 286, 285, 289,
288, 294, 292, 296, 287, 293, 291, 295, 290, 298,
297, 299
};
extern int table_shield[]
{
16,
144, 145, 146, 147, 148, 149, 150, 151, 266, 267,
268, 269, 270, 271, 272, 273
};
extern int table_shield_blupi[]
{
16,
144, 145, 146, 147, 148, 149, 150, 151, 266, 267,
268, 269, 270, 271, 272, 273
};
extern int table_power[]{ 8, 136, 137, 138, 139, 140, 141, 142, 143 };
extern int table_invert[]
{
20,
187, 187, 187, 188, 189, 190, 191, 192, 193, 194,
187, 187, 187, 194, 193, 192, 191, 190, 189, 188
};
extern int table_charge[]{ 6, 238, 239, 240, 241, 242, 243 };
extern int table_magicloop[]{ 5, 152, 153, 154, 155, 156 };
extern int table_magictrack[]
{
24,
152, 153, 154, 155, 156, 152, 153, 154, 155, 156,
157, 158, 159, 160, 157, 158, 159, 160, 161, 162,
163, 164, 165, 166
};
extern int table_shieldloop[]{ 5, 274, 275, 276, 277, 278 };
extern int table_shieldtrack[]
{
20,
274, 275, 276, 277, 278, 274, 275, 276, 277, 278,
279, 280, 281, 282, 283, 284, 285, 286, 287, 288
};
extern int table_drinkeffect[]{ 5, 274, 275, 276, 277, 278 };
extern int table_drinkoffset[]{ 3, 0, 7, 22 };
extern int table_tresortrack[]
{
11,
166, 165, 164, 163, 162, 161, 162, 163, 164, 165,
166
};
extern int table_decor_piege1[]
{
16,
374, 374, 373, 347, 373, 374, 374, 374, 373, 347,
347, 373, 374, 374, 374, 374
};
extern int table_decor_piege2[]{ 4, 374, 373, 347, 373 };
extern int table_decor_goutte[]
{
48,
410, 409, 410, -1, -1, -1, -1, -1, -1, 410,
409, 408, 409, 410, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, 410, 409, 408, 407, 406, 405,
404, 405, 406, 407, 408, 409, 410, -1, -1, -1,
-1, 410, 409, 410, -1, -1, -1, -1
};
extern int table_decor_ecraseur[]{ 10, 317, 317, 318, 319, 320, 321, 322, 323, 323, 323 };
extern int table_decor_scie[]{ 6, 378, 379, 380, 381, 382, 383 };
extern int table_decor_temp[]
{
20,
328, 328, 327, 327, 326, 326, 325, 325, 324, 324,
325, 325, 326, 326, 327, 329, 328, 328, -1, -1
};
extern int table_decor_eau1[]{ 6, 92, 93, 94, 95, 94, 93 };
extern int table_decor_eau2[]{ 6, 91, 96, 97, 98, 97, 96 };
extern int table_decor_ventillod[]{ 3, 129, 130, 131 };
extern int table_decor_ventilloh[]{ 3, 132, 133, 134 };
extern int table_decor_ventillob[]{ 3, 135, 136, 137 };
extern int table_decor_ventd[]{ 4, 114, 115, 116, 117 };
extern int table_decor_venth[]{ 4, 118, 119, 120, 121 };
extern int table_decor_ventb[]{ 4, 122, 123, 124, 125 };
extern int table_marine[]
{
0, 2, 5, 8, 3, 0
};
extern int table_36418[]{ 14, 10, 2, 3, 4, 5, 6, 7, 8, 9, 1, 11, 12, 13, 14 };
extern int table_36458[]{ 10, 19, 20, 21, 23, 24, 25, 26, 27, 28, 29 };
extern int table_36488[]{ 4, 15, 16, 17, 18 };
extern int table_364a0[]{ 2, 73, 22 };
extern int table_364b0[]{ 7, 78, 79, 80, 81, 82, 83, 84 };
extern int table_364d0[]{ 4, 87, 88, 89, 90 };
extern int table_364e8[]{ 2, 85, 86 };
extern int table_364f8[]{ 5, 396, 388, 389, 390, 391 };
extern int table_36510[]{ 3, 398, 399, 400 };
extern int table_36520[]{ 3, 87, 88, 89 };
extern int table_36530[]{ 1, 0x99 };
extern int table_36538[]{ 2, 0x9a, 0x9b };
extern int table_36548[]{ 1, 0xb9 };
extern int table_36550[]{ 7, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f };
extern int table_36570[]{ 12, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xe6, 0xe7, 0xe9, 0xea };
extern int table_365a8[]{ 8, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe8 };
extern int table_365d0[]{ 1, 0x9d };
extern int table_365d8[]{ 5, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f };
extern int table_365f0[]{ 7, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0 };
extern int table_36610[]{ 5, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5 };
extern int table_decor_lave[]{ 8, 68, 69, 70, 71, 72, 71, 70, 69 };
extern int table_36630[]{ 2, 0x5b, 0x5c };
extern int table_decor_ventillog[]{ 3, 126, 127, 128 };
extern int table_decor_ventg[]{ 4, 110, 111, 112, 113 };
extern int table_36670[]{ 11, 0x4c, 0x4d, 0xc7, 0xc6, 0xc8, 0xc9, 0xeb, 0xec, 0x177, 0x178, 0x179 };
extern int table_366a0[]{ 3, 0x193, 0x191, 0x192 };
extern int table_366b0[]{ 3, 20, 21, 22 };
extern int table_366c0[]{ 4, 16, 17, 18, 19 };
extern int table_366d8[]{ 3, 23, 24, 25 };
extern int table_366e8[]{ 2, 0x1a, 0x1b };
extern int table_366f8[]{ 4, 0x1c, 0x1d, 0x1e, 0x1f };
extern int table_36710[]{ 12, 0x2d, 0x2e, 0x2f, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c};
extern int table_36748[]{ 4, 0x42, 0x43, 0x44, 0x45 };
extern int table_ressort[] // i dont really care to look this up right now so heres some bs
{
8,1,2,3,4,5,5,6,7,7
};

File diff suppressed because it is too large Load Diff

4908
src/event.cpp Normal file

File diff suppressed because it is too large Load Diff

@ -1,13 +1,11 @@
// Event.h
#pragma once
/////////////////////////////////////////////////////////////////////////////
#pragma once
using namespace std;
#include "movie.h"
#include "menu.h"
#include "button.h"
@ -28,21 +26,11 @@ typedef struct
UINT phase;
char backName[36];
BOOL bCDrom;
BOOL bUnk;
Button buttons[MAXBUTTON];
}
Phase;
typedef struct
{
int HeaderLength[10];
int DoorsLength[200];
int GamerLength[10 + 200];
int MaxGamer[3];
int TotalLength[10 + (10 + 200) + 3];
BYTE data;
}
GameData;
typedef struct
{
short majRev;
@ -74,16 +62,17 @@ public:
void OutputNetDebug(const char* str);
POINT GetMousePos();
void Create(HINSTANCE hInstance, HWND hWnd, CPixmap *pPixmap, CDecor *pDecor, CSound *pSound, CNetwork *pNetwork, CMovie *pMovie);
void Create(HINSTANCE hInstance, HWND hWnd, CPixmap *pPixmap, CDecor *pDecor, CSound *pSound, CNetwork *pNetwork, CMovie *pMovie );
void SetFullScreen(BOOL bFullScreen);
void SetMouseType(int mouseType);
int GetWorld();
int GetWorldGroup();
void SetMission(int index);
int GetPhysicalWorld();
int GetImageWorld();
BOOL IsHelpHide();
BOOL ChangePhase(UINT phase);
UINT GetPhase();
UINT GetPhase();
void MovieToStart();
BOOL NetworkNuggets(int fuck);
void HandleInputs();
@ -93,20 +82,18 @@ public:
void RestoreGame();
int MissionBack();
void TableSomething();
void SetNbVies(int nbVies);
int GetButtonIndex(int button);
int GetState(int button);
void SetState(int button, int state);
BOOL GetEnable(int button);
void SetEnable(WMessage button, int bEnable);
void SetEnable(int button, int bEnable);
void SetSomething(int button, int bSomething);
BOOL GetHide(int button);
void SetHide(int button, BOOL bHide);
int GetMenu(int button);
void SetMenu(int button, int menu);
void FlushInput();
void PauseStatus(UINT pause, int multiplayer);
void SomethingDecor();
BOOL IsMouseRelease();
void NetSetPause(BOOL bPause, int players);
@ -131,11 +118,6 @@ public:
void FlushInput();
BOOL FlipObject();
void Read(int message);
void Write(int message);
void SetSpeed(int speed);
int GetSpeed();
BOOL GetPause();
@ -154,23 +136,18 @@ public:
BOOL SaveState(int rank);
void SomethingUserMissions(char* lpFilename, LPCSTR fileSomething);
BOOL ClearGamer(int gamer);
BOOL AddPhaseText();
void ReadInput();
void DrawTextCenter(int res, POINT pos, int font=0);
protected:
void DrawTextCenter(int res, int x, int y, int font=0);
BOOL CreateButtons();
BOOL EventButtons(UINT message, WPARAM wParam, LPARAM lParam);
BOOL MouseOnButton(POINT pos);
int SearchPhase(UINT phase);
void DecorShift(int dx, int dy);
BOOL PlayDown(POINT pos, int fwKeys);
BOOL PlayMove(POINT pos, int fwKeys);
BOOL PlayUp(POINT pos, int fwKeys);
void ChangeButtons(int message);
void BuildFloor(POINT cel, int insIcon);
void BuildWater(POINT cel, int insIcon);
BOOL BuildDown(POINT pos, int fwKeys, BOOL bMix=TRUE);
@ -179,8 +156,9 @@ public:
void PrivateLibelle();
BOOL ReadLibelle(int world, BOOL bSchool, BOOL bHelp);
BOOL WriteInfo(int gamer, char* playername);
BOOL ReadInfo(int gamer);
BOOL WriteInfo(int gamer);
BOOL ReadInfo(int gamer);
BOOL LoadState(BOOL save);
void TryPhase();
void UnTryPhase();
int GetTryPhase();
@ -199,8 +177,8 @@ public:
BOOL NetEnumSessions();
int NetSearchPlayer(DPID dpid);
void NetStartPlay();
void NetFUN_1d6b0(UINT message, USHORT data);
void NetDrawMap();
void NetSend(int message, USHORT data);
void NetDraw();
void ChatSend();
void HandleChatBuffer();
void ChatMessageSound(char* data);
@ -208,6 +186,11 @@ public:
void MouseRelease();
void MouseCapture();
void DrawMap();
BOOL CheckCDForWorld1();
void NetAdjustLobbyButtons();
BOOL CopyMission(char *srcFileName, char *dstFileName);
protected:
int m_speed;
@ -217,12 +200,13 @@ protected:
char m_gamerNameList[10][100];
void* m_somethingJoystick;
int m_menuIndex;
int m_fileIndex;
int m_menuDecor[10];
int m_choiceIndex;
int m_saveIndex;
int m_menuDecor[11];
BOOL m_bMouseRelease;
int m_private;
int m_maxMission;
DWORD m_phase;
int m_phase;
int m_index;
int m_playerIndex;
BOOL m_bSchool;
@ -238,7 +222,7 @@ protected:
CMovie* m_pMovie;
CNetwork* m_pNetwork;
char m_movieToStart[MAX_PATH];
UINT m_phaseAfterMovie;
int m_phaseAfterMovie;
CButton m_buttons[MAXBUTTON];
int m_lastFloor[MAXBUTTON];
int m_lastObject[MAXBUTTON];
@ -293,7 +277,7 @@ protected:
BOOL m_bDemoPlay;
DemoEvent* m_pDemoBuffer;
int m_demoTime;
int m_input;
int m_keyPress;
int m_demoIndex;
int m_demoEnd;
int m_demoNumber;
@ -306,13 +290,20 @@ protected:
int m_textHiliEnd;
int m_textCursorIndex;
char m_textInput[100];
char m_gamerName[100];
char m_gamerNameList[10][100];
char m_pPlayerName[100];
int m_lives;
int m_multi;
HINSTANCE m_hInstance;
char m_chatZone[100][5];
char m_text[100];
int m_choicePageOffset;
int m_nbChoices;
int m_0008;
int m_6D30;
BOOL m_b6D34;
int m_96B4;
int m_nbVies;
};
extern

@ -2,12 +2,13 @@
//
using namespace std;
#pragma once
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
#include <minwindef.h>
// #include <minwindef.h>
#include <windef.h>
#include "def.h"
#include "pixmap.h"
@ -52,46 +53,50 @@ BOOL CJauge::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
m_dim.y = DIMJAUGEY;
m_level = 0;
m_bRedraw = TRUE;
return TRUE;
}
// Dessine un bouton dans son état.
void CJauge::Draw()
{
int part;
RECT rect;
RECT rect;
char num2[12];
if (m_bMinimizeRedraw && !m_bRedraw) return;
m_bRedraw = FALSE;
if (m_bMinimizeRedraw && !m_bRedraw) return;
m_bRedraw = FALSE;
if (m_bHide) // bouton caché ?
{
rect = { m_pos.x, m_pos.y, m_pos.x + m_dim.x, m_pos.y + m_dim.y };
m_pPixmap->DrawPart(-1, CHBACK, m_pos, rect, 1); // dessine le fond
return;
}
if (m_bHide) // bouton cach<63> ?
{
rect.right = m_dim.x + m_pos.x;
rect.left = m_pos.x;
rect.top = m_pos.y;
rect.bottom = m_dim.y + m_pos.y;
m_pPixmap->DrawPart(-1, 0, m_pos, rect, 1, FALSE);
return;
}
int num = m_level * 114 / 100;
part = (m_level*(DIMJAUGEX - 6 - 4)) / 100;
*(char*)num2 = (124) / 64;
rect.bottom = 22;
rect.left = LOWORD(num2);
rect.top = HIWORD(num2);
rect.right = HIWORD(num2);
m_pPixmap->DrawPart(-1, 5, m_pos, rect, 0, FALSE);
if (num > 0)
{
rect.bottom = num + 6;
rect.left = m_type * 22;
rect.top = (m_type + 1) * 22;
rect.right = 0;
m_pPixmap->DrawPart(-1, 5, m_pos, rect, 0, FALSE);
}
rect = { 0, 0, DIMJAUGEX, DIMJAUGEY };
m_pPixmap->DrawPart(-1, CHJAUGE, m_pos, rect); // partie noire
if (part > 0)
{
rect = { 0, DIMJAUGEY * m_type, 6 + part, DIMJAUGEY + (m_type + 1) };
m_pPixmap->DrawPart(-1, CHJAUGE, m_pos, rect); // partie colorée
}
}
// Redessine une jauge.
void CJauge::Redraw()
{
m_bRedraw = TRUE;
m_bRedraw = TRUE;
}
// Modifie le niveau.
void CJauge::SetLevel(int level)
{
if ( level < 0 ) level = 0;
@ -116,7 +121,6 @@ int CJauge::GetType()
return m_type;
}
// Modifie le type.
void CJauge::SetType(int type)
{
@ -143,12 +147,3 @@ void CJauge::SetHide(BOOL bHide)
m_bHide = bHide;
}
POINT CJauge::GetPos()
{
return m_pos;
}
void CJauge::SetRedraw()
{
m_bRedraw = TRUE;
}

@ -3,9 +3,9 @@
#pragma once
//////////////////////////////////////////////////////////////////////////
#include <minwindef.h>
#include <Windows.h>
#include "decor.h"
// #include <minwindef.h>
#include "pixmap.h"
#include "sound.h"
class CJauge
{

@ -2,10 +2,7 @@
#pragma once
using namespace std;
//#include <minwindef.h>
#include <windef.h>
// #include <minwindef.h>
#include "decor.h"
#include "pixmap.h"

@ -89,22 +89,6 @@ int Random(int min, int max)
return (int)n;
}
/*
BOOL IntersectRect(RECT dst, RECT src1, RECT src2)
{
dst.left = max(src1.left, src2.left);
dst.right = min(src1.right, src2.right);
dst.top = max(src1.top, src2.top);
dst.bottom = min(src1.bottom, src2.bottom);
return IsRectEmpty(dst);
}
BOOL IsRectEmpty(RECT rect)
{
return rect.left >= rect.right || rect.top >= rect.bottom;
}
*/
void GetCurrentDir(char *pName, int lg)
{
int i;

@ -1,5 +1,8 @@
// misc.h
//
#pragma once
// #include <minwindef.h>
extern void InitHInstance(HINSTANCE hInstance);
extern void OutputDebug(const char *pMessage);
@ -10,13 +13,10 @@ extern POINT ConvLongToPos(LPARAM lParam);
extern void InitRandom();
extern int Random(int min, int max);
extern BOOL IntersectRect(RECT dst, RECT src1, RECT src2);
extern BOOL IsRectEmpty(RECT rect);
extern int Speed(double speed, int max);
extern void GetCurrentDir(char *pName, int lg);
extern void AddCDPath(char *pFilename);
extern void AddUserPath(char *pFilename);
extern void TraceErrorDD(HRESULT hErr, const char *sFile, int nLine);
extern void TraceErrorDS(HRESULT hErr, char *sFile, int nLine);
extern void TraceErrorDS(HRESULT hErr, const char *sFile, int nLine);

@ -14,7 +14,7 @@ using namespace std;
#include <direct.h>
#include <mmsystem.h>
#include <digitalv.h>
//#include <mciapi.h>
// #include <mciapi.h>
#include "def.h"
#include "movie.h"
#include "misc.h"
@ -39,7 +39,7 @@ BOOL CMovie::initAVI()
// set up the open parameters
mciOpen.dwCallback = 0L;
mciOpen.wDeviceID = 0;
mciOpen.lpstrDeviceType = (LPWSTR)AVI_VIDEO;
mciOpen.lpstrDeviceType = AVI_VIDEO;
mciOpen.lpstrElementName = NULL;
mciOpen.lpstrAlias = NULL;
mciOpen.dwStyle = 0;
@ -126,7 +126,7 @@ BOOL CMovie::fileOpenMovie(HWND hWnd, RECT rect, char *pFilename)
mciOpen.dwCallback = 0L;
mciOpen.wDeviceID = 0;
mciOpen.lpstrDeviceType = NULL;
mciOpen.lpstrElementName = (LPWSTR)string;
mciOpen.lpstrElementName = string;
mciOpen.lpstrAlias = NULL;
mciOpen.dwStyle = WS_CHILD;
mciOpen.hWndParent = hWnd;
@ -144,7 +144,7 @@ BOOL CMovie::fileOpenMovie(HWND hWnd, RECT rect, char *pFilename)
mciWindow.dwCallback = 0L;
mciWindow.hWnd = NULL;
mciWindow.nCmdShow = SW_SHOW;
mciWindow.lpstrText = (LPWSTR)NULL;
mciWindow.lpstrText = NULL;
// mciSendCommand(m_wMCIDeviceID, MCI_WINDOW,
// MCI_DGV_WINDOW_STATE,
// (DWORD)(LPMCI_DGV_WINDOW_PARMS)&mciWindow);

@ -1,11 +1,9 @@
// movie.h
//
#pragma once
using namespace std;
//#include <mciapi.h>
// #include <mciapi.h>
class CMovie
{

342
src/network.cpp Normal file

@ -0,0 +1,342 @@
// Network.cpp
//
#include <stdio.h>
#include <windows.h>
#include "dplay.h"
#include "misc.h"
#include "network.h"
// a0f94abe-11c3-d111-be62-0040f6944838
#define APP_GUID { 0xbe4af9a0, 0xc311, 0x11d1, { 0xbe, 0x62, 0x00, 0x40, 0xf6, 0x94, 0x48, 0x38 } };
CNetwork::CNetwork()
{
m_pDP = NULL;
m_dpid = 0;
m_bHost = FALSE;
m_providers.nb = 0;
m_providers.pList = NULL;
m_sessions.nb = 0;
m_sessions.pList = NULL;
m_unknown.nb = 0;
m_unknown.pList = NULL;
}
CNetwork::~CNetwork()
{
FreeProviderList();
FreeSessionList();
FreeUnknownList();
if (m_pDP) m_pDP->Release();
}
static BOOL EnumProvidersCallback(LPGUID lpguidSP, LPSTR lpSPName,
DWORD dwMajorVersion, DWORD dwMinorVersion, NamedGUIDList* lpContext)
{
if (lpContext->nb < MAXSESSION)
{
lpContext->pList[lpContext->nb]->guid = *lpguidSP;
strcpy(lpContext->pList[lpContext->nb]->name, lpSPName);
lpContext->nb++;
}
return TRUE;
}
BOOL CNetwork::EnumProviders()
{
FreeProviderList();
m_providers.nb = 0;
m_providers.pList = (NamedGUID(*)[MAXSESSION]) malloc(MAXSESSION * sizeof(NamedGUID));
if (!m_providers.pList) return FALSE;
#ifdef _UNICODE
if (DirectPlayEnumerate((LPDPENUMDPCALLBACK)EnumProvidersCallback, &m_providers) != DP_OK)
#else
if (DirectPlayEnumerate((LPDPENUMDPCALLBACKA)EnumProvidersCallback, &m_providers) != DP_OK)
#endif
{
FreeProviderList();
return FALSE;
}
return TRUE;
}
int CNetwork::GetNbProviders()
{
return m_providers.nb;
}
char* CNetwork::GetProviderName(int index)
{
if (index >= m_providers.nb) return NULL;
return m_providers.pList[index]->name;
}
BOOL CNetwork::CreateProvider(int index)
{
LPDIRECTPLAY lpDP;
BOOL bOK = FALSE;
if (index >= m_providers.nb) return FALSE;
if (DirectPlayCreate(&m_providers.pList[index]->guid, &lpDP, 0) == DP_OK)
{
if (lpDP->QueryInterface(IID_IDirectPlay2A, (LPVOID*)&m_pDP) == DP_OK)
{
return TRUE;
}
}
if (lpDP) lpDP->Release();
return FALSE;
}
void CNetwork::FreeProviderList()
{
if (m_providers.pList) free(m_providers.pList); // wrong
m_providers.nb = 0;
m_providers.pList = NULL;
}
static BOOL EnumSessionsCallback(LPDPSESSIONDESC2 lpThisSD,
LPDWORD lpdwTimeOut, DWORD dwFlags, NamedGUIDList* lpContext)
{
if (dwFlags & DPESC_TIMEDOUT) return FALSE;
if (lpContext->nb < MAXSESSION)
{
lpContext->pList[lpContext->nb]->guid = lpThisSD->guidInstance;
strcpy(lpContext->pList[lpContext->nb]->name, lpThisSD->lpszSessionNameA);
lpContext->nb++;
}
return TRUE;
}
BOOL CNetwork::EnumSessions()
{
DPSESSIONDESC2 desc;
FreeSessionList();
m_sessions.nb = 0;
m_sessions.pList = (NamedGUID(*)[MAXSESSION]) malloc(MAXSESSION * sizeof(NamedGUID));
if (!m_sessions.pList) return FALSE;
ZeroMemory(&desc, sizeof(desc));
desc.guidApplication = APP_GUID;
desc.dwSize = sizeof(desc);
if (m_pDP->EnumSessions(&desc, 0, (LPDPENUMSESSIONSCALLBACK2)EnumSessionsCallback, &m_sessions, DPENUMSESSIONS_AVAILABLE) != DP_OK)
{
FreeSessionList();
return FALSE;
}
return TRUE;
}
char* CNetwork::GetSessionName(int index)
{
if (index >= m_sessions.nb) return NULL;
return m_sessions.pList[index]->name;
}
BOOL CNetwork::JoinSession(int index, char* pPlayerName)
{
DPNAME name;
DPSESSIONDESC2 desc;
HRESULT hr;
if (index > m_sessions.nb) return FALSE;
ZeroMemory(&desc, sizeof(desc));
desc.guidInstance = m_sessions.pList[index]->guid;
hr = m_pDP->Open(&desc, DPOPEN_OPENSESSION);
if (hr != DP_OK)
{
TraceErrorDP(hr);
return FALSE;
}
name.dwSize = 16;
name.dwFlags = 0;
name.lpszShortNameA = pPlayerName;
name.lpszLongNameA = NULL;
hr = m_pDP->CreatePlayer(&m_dpid, &name, NULL, NULL, 0, 0);
if (hr != DP_OK)
{
TraceErrorDP(hr);
m_pDP->Close();
return FALSE;
}
else
{
m_bHost = FALSE;
return TRUE;
}
}
void CNetwork::FreeSessionList()
{
if (m_sessions.pList) free(m_sessions.pList);
m_sessions.nb = 0;
m_sessions.pList = NULL;
}
BOOL CNetwork::CreateSession(char* pSessionName, char* pPlayerName)
{
DPNAME name;
DPSESSIONDESC2 desc;
HRESULT hr;
ZeroMemory(&desc, sizeof(desc));
desc.guidApplication = APP_GUID;
desc.lpszSessionNameA = pSessionName;
desc.dwSize = sizeof(desc);
desc.dwFlags = DPSESSION_KEEPALIVE | DPSESSION_MIGRATEHOST;
desc.dwMaxPlayers = MAXPLAYERS;
hr = m_pDP->Open(&desc, DPOPEN_CREATE);
if (hr != DP_OK)
{
TraceErrorDP(hr);
return FALSE;
}
else
{
name.dwSize = 16;
name.dwFlags = 0;
name.lpszShortNameA = pPlayerName;
name.lpszLongNameA = NULL;
hr = m_pDP->CreatePlayer(&m_dpid, &name, NULL, NULL, 0, 0);
if (hr != DP_OK)
{
TraceErrorDP(hr);
m_pDP->Close();
return FALSE;
}
else
{
m_bHost = TRUE;
return TRUE;
}
}
}
BOOL CNetwork::Send(LPVOID lpData, DWORD dwDataSize, DWORD dwFlags)
{
HRESULT hr;
if (!m_pDP) return FALSE;
if (hr = m_pDP->Send(m_dpid, 0, !!dwFlags, lpData, dwDataSize), hr != DP_OK)
{
TraceErrorDP(hr);
return FALSE;
}
return TRUE;
}
BOOL CNetwork::Receive(LPVOID pDest, DWORD dwDataSize, LPDWORD lpdwPlayer)
{
DPID from = 0, to = 0, dataSize = 500;
char dataBuffer[500];
HRESULT hr;
hr = m_pDP->Receive(&from, &to, DPRECEIVE_ALL, dataBuffer, &dataSize);
if (hr != DP_OK)
{
if (hr != DPERR_NOMESSAGES) TraceErrorDP(hr);
return FALSE;
}
ZeroMemory(pDest, dwDataSize);
*lpdwPlayer = -1;
for (int i = 0; i < MAXPLAYERS; i++)
{
if (m_players[i].bIsPresent && from == i)
{
*lpdwPlayer = i;
break;
}
}
return TRUE;
}
BOOL CNetwork::Close()
{
return m_pDP->Close() == DP_OK;
}
void CNetwork::FreeUnknownList()
{
if (m_unknown.pList) free(m_unknown.pList);
m_unknown.nb = 0;
m_unknown.pList = NULL;
}
BOOL CNetwork::IsHost()
{
return m_bHost;
}
void TraceErrorDP(HRESULT hErr)
{
char dperr[256];
char err[1024];
switch (hErr)
{
case DPERR_OUTOFMEMORY: sprintf(dperr, "DPERR_OUTOFMEMORY"); break;
case DPERR_UNSUPPORTED: sprintf(dperr, "DPERR_UNSUPPORTED"); break;
case DPERR_NOINTERFACE: sprintf(dperr, "DPERR_NOINTERFACE"); break;
case DPERR_GENERIC: sprintf(dperr, "DPERR_GENERIC"); break;
case DPERR_INVALIDPARAMS: sprintf(dperr, "DPERR_INVALIDPARAMS"); break;
case DPERR_ACTIVEPLAYERS: sprintf(dperr, "DPERR_ACTIVEPLAYERS"); break;
case DPERR_ACCESSDENIED: sprintf(dperr, "DPERR_ACCESSDENIED"); break;
case DPERR_CANTADDPLAYER: sprintf(dperr, "DPERR_CANTADDPLAYER"); break;
case DPERR_CANTCREATEPLAYER: sprintf(dperr, "DPERR_CANTCREATEPLAYER"); break;
case DPERR_CANTCREATEGROUP: sprintf(dperr, "DPERR_CANTCREATEGROUP"); break;
case DPERR_CANTCREATESESSION: sprintf(dperr, "DPERR_CANTCREATESESSION"); break;
case DPERR_CAPSNOTAVAILABLEYET: sprintf(dperr, "DPERR_CAPTSNOTAVAILABLEYET"); break;
case DPERR_ALREADYINITIALIZED: sprintf(dperr, "DPERR_ALREADYINITIALIZED"); break;
case DPERR_INVALIDFLAGS: sprintf(dperr, "DPERR_INVALIDFLAGS"); break;
case DPERR_EXCEPTION: sprintf(dperr, "DPERR_EXCEPTION"); break;
case DPERR_INVALIDPLAYER: sprintf(dperr, "DPERR_INVALIDPLAYER"); break;
case DPERR_INVALIDOBJECT: sprintf(dperr, "DPERR_INVALIDOBJECT"); break;
case DPERR_NOCONNECTION: sprintf(dperr, "DPERR_NOCONNECTION"); break;
case DPERR_NONAMESERVERFOUND: sprintf(dperr, "DPERR_NONAMESERVERFOUND"); break;
case DPERR_NOMESSAGES: sprintf(dperr, "DPERR_NOMESSAGES"); break;
case DPERR_NOSESSIONS: sprintf(dperr, "DPERR_NOSESSIONS"); break;
case DPERR_NOPLAYERS: sprintf(dperr, "DPERR_NOPLAYERS"); break;
case DPERR_TIMEOUT: sprintf(dperr, "DPERR_TIMEOUT"); break;
case DPERR_SENDTOOBIG: sprintf(dperr, "DPERR_SENDTOOBIG"); break;
case DPERR_BUSY: sprintf(dperr, "DPERR_BUSY"); break;
case DPERR_UNAVAILABLE: sprintf(dperr, "DPERR_UNAVAILABLE"); break;
case DPERR_PLAYERLOST: sprintf(dperr, "DPERR_PLAYERLOST"); break;
case DPERR_USERCANCEL: sprintf(dperr, "DPERR_USERCANCEL"); break;
case DPERR_BUFFERTOOLARGE: sprintf(dperr, "DPERR_BUFFERTOOLARGE"); break;
case DPERR_SESSIONLOST: sprintf(dperr, "DPERR_SESSIONLOST"); break;
case DPERR_APPNOTSTARTED: sprintf(dperr, "DPERR_APPNOTSTARTED"); break;
case DPERR_CANTCREATEPROCESS: sprintf(dperr, "DPERR_CANTCREATEPROCESS"); break;
case DPERR_UNKNOWNAPPLICATION: sprintf(dperr, "DPERR_UNKNOWNAPPLICATION"); break;
case DPERR_INVALIDINTERFACE: sprintf(dperr, "DPERR_INVALIDINTERFACE"); break;
case DPERR_NOTLOBBIED: sprintf(dperr, "DPERR_NOTLOBBIED"); break;
case DP_OK: sprintf(dperr, "DP_OK"); break;
default: sprintf(dperr, "Unknown Error"); break;
}
sprintf(err, "DirectPlay Error %s\n", dperr);
OutputDebug(err);
}

@ -7,7 +7,7 @@
/////////////////////////////////////////////////////////////////////////////
#define MAXSESSION 100
#define MAXNETPLAYER 4
#define MAXPLAYERS 4
typedef struct
{
@ -31,7 +31,7 @@ NamedGUID;
typedef struct
{
int nb;
NamedGUID * list[MAXSESSION];
NamedGUID (*pList)[MAXSESSION];
}
NamedGUIDList;
@ -43,14 +43,14 @@ public:
BOOL EnumProviders();
BOOL GetNbProviders();
char * GetProviderName(int index);
char* GetProviderName(int index);
BOOL CreateProvider(int index);
void FreeProviderList();
BOOL EnumSessions();
char * GetSessionName(int index);
BOOL JoinSession(int index);
char* GetSessionName(int index);
BOOL JoinSession(int index, char* pPlayerName);
void FreeSessionList();
BOOL CreateSession(char * pName);
BOOL CreateSession(char* pSessionName, char* pPlayerName);
BOOL Send(LPVOID lpData, DWORD dwDataSize, DWORD dwFlags);
BOOL Receive(LPVOID pDest, DWORD dwDataSize, LPDWORD lpdwPlayer);
BOOL Close();
@ -59,18 +59,21 @@ public:
NetPlayer m_players[4];
DPID m_dpid;
protected:
LPDIRECTPLAY2 m_pDP;
LPDIRECTPLAY2 m_pDP;
NamedGUIDList m_providers;
NamedGUIDList m_sessions;
NamedGUIDList m_unknown;
BOOL m_bHost;
// NetPlayer m_players[4];
};
static BOOL EnumProvidersCallback(LPGUID lpguidSP, LPSTR lpSTName,
DWORD dwMajorVersion, DWORD dwMinorVersion, NamedGUIDList * lpContext);
DWORD dwMajorVersion, DWORD dwMinorVersion, NamedGUIDList* lpContext);
static BOOL EnumSessionsCallback(LPDPSESSIONDESC2 lpThisSD,
LPDWORD lpdwTimeOut, DWORD dwFlags, NamedGUIDList * lpContext);
LPDWORD lpdwTimeOut, DWORD dwFlags, NamedGUIDList* lpContext);
void TraceErrorDP(HRESULT hErr);

589
src/obstacle.h Normal file

@ -0,0 +1,589 @@
#pragma once
#define Q_EMPTY \
0,0,0,0, \
0,0,0,0, \
0,0,0,0, \
0,0,0,0
#define Q_FULL \
1,1,1,1, \
1,1,1,1, \
1,1,1,1, \
1,1,1,1
#define Q_TRIANGLE_RIGHT \
1,1,1,1, \
0,1,1,1, \
0,0,0,1, \
0,0,0,0
#define Q_TRIANGLE_LEFT \
1,1,1,1, \
1,1,1,0, \
1,0,0,0, \
0,0,0,0
#define Q_TOP_HALF \
1,1,1,1, \
1,1,1,1, \
0,0,0,0, \
0,0,0,0
#define Q_TOP_QUARTER \
1,1,1,1, \
0,0,0,0, \
0,0,0,0, \
0,0,0,0
#define Q_TOP_3_QUARTERS \
1,1,1,1, \
1,1,1,1, \
1,1,1,1, \
0,0,0,0
#define Q_PILLAR \
0,1,1,0, \
0,1,1,0, \
0,1,1,0, \
0,1,1,0
extern short table_decor_quart[]
{
Q_FULL, // 0
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_TRIANGLE_RIGHT,
Q_TRIANGLE_RIGHT, // 16
Q_TRIANGLE_LEFT,
Q_TRIANGLE_LEFT,
1,1,1,1,
1,1,1,1,
0,0,1,1,
0,0,0,0,
1,1,1,1,
1,1,1,1,
1,1,0,0,
1,1,0,0,
1,1,1,1,
1,1,1,1,
1,1,0,0,
0,0,0,0,
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_TOP_HALF,
Q_TOP_QUARTER,
Q_FULL,
Q_FULL,
Q_FULL, // 32
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_TOP_3_QUARTERS,
Q_TOP_HALF,
Q_TOP_QUARTER,
Q_FULL, // 48
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL, // 64
Q_FULL,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_TRIANGLE_LEFT,
Q_TRIANGLE_RIGHT,
Q_EMPTY,
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_FULL, // 80
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
1,1,1,1,
1,1,1,1,
1,1,1,1,
1,1,0,0,
1,1,1,1,
1,1,1,1,
1,1,0,0,
1,1,0,0,
1,1,1,1,
1,1,1,1,
1,1,1,1,
0,1,1,1,
1,1,1,1,
1,1,1,1,
0,0,1,1,
0,0,1,1,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_FULL, // 96
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
1,1,1,1,
1,1,1,1,
1,1,1,0,
1,1,1,0,
1,1,1,1,
1,1,1,1,
0,1,1,1,
0,1,1,1,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 112
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
0,0,0,1,
0,0,0,1,
0,0,0,1,
0,0,0,1,
Q_EMPTY,
Q_EMPTY, // 128
1,0,0,0,
1,0,0,0,
1,0,0,0,
1,0,0,0,
Q_EMPTY,
Q_EMPTY,
0,0,0,0,
0,0,0,0,
0,0,0,0,
1,1,1,1,
Q_EMPTY,
Q_EMPTY,
Q_TOP_QUARTER,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL, // 144
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_TRIANGLE_LEFT,
Q_TRIANGLE_RIGHT,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 160
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 176
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_PILLAR,
Q_PILLAR,
Q_EMPTY,
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL, // 192
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 208
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL, // 224
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 240
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_TOP_3_QUARTERS,
Q_TOP_3_QUARTERS,
1,1,1,1,
1,1,1,1,
1,1,1,0,
0,0,0,0,
Q_FULL,
Q_FULL,
Q_TOP_3_QUARTERS, // 256
Q_FULL,
Q_FULL,
Q_TOP_3_QUARTERS,
Q_TOP_3_QUARTERS,
Q_FULL,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 272
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 288
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_FULL, // 304
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_TOP_HALF,
Q_TOP_HALF,
Q_TOP_HALF,
Q_TOP_HALF,
Q_TOP_HALF,
Q_TOP_HALF,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 320
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_TOP_QUARTER,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
1,1,1,1,
1,1,1,1,
0,1,1,0,
0,1,1,0,
1,1,1,1,
1,1,1,1,
0,1,1,0,
0,1,1,0,
1,1,1,1,
1,1,1,1,
0,1,1,0,
0,1,1,0,
1,1,1,1,
1,1,1,1,
0,1,1,0,
0,1,1,0,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR, // 336
Q_EMPTY,
Q_FULL,
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL, // 352
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_TOP_QUARTER,
Q_TOP_QUARTER,
Q_TOP_QUARTER,
Q_EMPTY,
Q_EMPTY, // 368
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 384
Q_EMPTY,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_FULL,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 400
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY, // 416
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_EMPTY,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR, // 432
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR,
Q_PILLAR
};

@ -11,9 +11,9 @@
#include "pixmap.h"
#include "misc.h"
#include "ddutil.h"
#include "blupi.cpp"
#include "pixtables.h"
#pragma comment(lib, "ddraw.lib")
#define DIRECTDRAW_VERSION 0x0500
/////////////////////////////////////////////////////////////////////////////
@ -27,7 +27,7 @@ CPixmap::CPixmap()
m_bFullScreen = FALSE;
m_bBenchmarkSuccess = TRUE;
m_bTrueColor = FALSE;
m_bTrueColorBack = FALSE;
m_bTrueColorDecor = FALSE;
m_mouseType = MOUSETYPEGRA;
m_bDebug = TRUE;
@ -126,18 +126,24 @@ BOOL CPixmap::Create(HWND hwnd, POINT dim,
BOOL bFullScreen, int mouseType, BOOL bTrueColorDecor, BOOL bTrueColor)
{
DDSURFACEDESC ddsd;
int devcap;
HRESULT ddrval;
POINT pos;
HDC hdc;
DWORD colorMode;
hdc = CreateCompatibleDC(NULL);
if (hdc == NULL) {
if (hdc == NULL)
{
bTrueColor = 0;
bTrueColorDecor = 0;
}
else {
ddrval = GetDeviceCaps(hdc, SIZEPALETTE);
if ((ddrval != 0) && (ddrval < 257)) {
else
{
devcap = GetDeviceCaps(hdc, SIZEPALETTE);
if ((devcap != NULL) && (devcap < 257))
{
bTrueColor = 0;
bTrueColorDecor = 0;
}
@ -149,7 +155,7 @@ BOOL CPixmap::Create(HWND hwnd, POINT dim,
m_mouseType = mouseType;
m_dim = dim;
m_bTrueColorDecor = bTrueColorDecor;
m_bTrueColor = bTrueColor;
m_bTrueColorBack = bTrueColor;
if ( m_mouseType == MOUSETYPEGRA )
{
@ -190,9 +196,14 @@ BOOL CPixmap::Create(HWND hwnd, POINT dim,
}
// Set the video mode to 640x480x8.
if ( m_bFullScreen )
if ( m_bFullScreen != FALSE)
{
ddrval = m_lpDD->SetDisplayMode(dim.x, dim.y, bTrueColor || bTrueColorDecor ? 16 : 8);
if ((bTrueColor != 0) || (colorMode = 8, bTrueColorDecor != FALSE))
{
colorMode = 16;
}
ddrval = m_lpDD->SetDisplayMode(dim.x, dim.y, colorMode);
if ( ddrval != DD_OK )
{
OutputDebug("Fatal error: SetDisplayMode\n");
@ -299,91 +310,73 @@ BOOL CPixmap::Restore()
void CPixmap::QuickIcon(int channel, int rank, POINT pos)
{
int num;
tagRECT rect;
RECT rect;
if (channel == CHOBJECT)
{
if (g_objectMax <= rank)
{
return;
}
num = rank * 12;
rect.left = (LONG)g_object[rank * 6];
rect.top = (LONG)g_object[rank * 6 + 1];
rect.right = g_object[rank * 6 + 4] + rect.left;
rect.bottom = g_object[rank * 6 + 2];
pos.x = pos.x + g_object[rank * 6 + 2];
num = (int)g_object[rank * 6 + 3];
if (table_icon_object[0] <= rank) return;
rect.left = table_icon_object[rank * 6 + 0 + 1];
rect.top = table_icon_object[rank * 6 + 1 + 1];
rect.right = rect.left + table_icon_object[rank * 6 + 4 + 1];
rect.bottom = rect.top + table_icon_object[rank * 6 + 5 + 1];
pos.x += table_icon_object[rank * 6 + 2 + 1];
pos.y += table_icon_object[rank * 6 + 3 + 1];
}
else if (channel == CHELEMENT)
{
if (g_elementMax <= rank)
{
return;
}
num = rank * 12;
rect.left = (LONG)g_element[rank * 6];
rect.top = (LONG)g_element[rank * 6 + 1];
rect.right = g_element[rank * 6 + 4] + rect.left;
rect.bottom = g_element[rank * 6 + 5] + rect.top;
pos.x = pos.x + g_element[rank * 6 + 2];
num = (int)g_element[rank * 6 + 3];
if (table_icon_element[0] <= rank) return;
rect.left = table_icon_element[rank * 6 + 0 + 1];
rect.top = table_icon_element[rank * 6 + 1 + 1];
rect.right = rect.left + table_icon_element[rank * 6 + 4 + 1];
rect.bottom = rect.top + table_icon_element[rank * 6 + 5 + 1];
pos.x += table_icon_element[rank * 6 + 2 + 1];
pos.y += table_icon_element[rank * 6 + 3 + 1];
}
else if ((((channel == CHBLUPI) || (channel == CHBLUPI1)) || (channel == CHBLUPI2)) || (channel == CHBLUPI3))
else if (IsBlupiChannel(channel))
{
if (g_blupiMax <= rank)
{
return;
}
num = rank * 12;
rect.left = (LONG)g_blupiCh[rank * 6];
rect.top = (LONG)g_blupiCh[rank * 6 + 1];
rect.right = g_blupiCh[rank * 6 + 4] + rect.left;
rect.bottom = g_blupiCh[rank * 6 + 5] + rect.top;
pos.x = pos.x + g_blupiCh[rank * 6 + 2];
num = (int)g_blupiCh[rank * 6 + 3];
if (table_icon_blupi[0] <= rank) return;
rect.left = table_icon_blupi[rank * 6 + 0 + 1];
rect.top = table_icon_blupi[rank * 6 + 1 + 1];
rect.right = rect.left + table_icon_blupi[rank * 6 + 4 + 1];
rect.bottom = rect.top + table_icon_blupi[rank * 6 + 5 + 1];
pos.x += table_icon_blupi[rank * 6 + 2 + 1];
pos.y += table_icon_blupi[rank * 6 + 3 + 1];
}
else if (channel == CHEXPLO)
{
if (table_icon_explo[0] <= rank) return;
rect.left = table_icon_explo[rank * 6 + 0 + 1];
rect.top = table_icon_explo[rank * 6 + 1 + 1];
rect.right = rect.left + table_icon_explo[rank * 6 + 4 + 1];
rect.bottom = rect.top + table_icon_explo[rank * 6 + 5 + 1];
pos.x += table_icon_explo[rank * 6 + 2 + 1];
pos.y += table_icon_explo[rank * 6 + 3 + 1];
}
else
{
if (channel != CHEXPLO)
{
rect.right = m_iconDim[channel].x;
num = m_totalDim[channel].x / rect.right;
rect.bottom = m_iconDim[channel].y;
if (rank < 0)
{
return;
}
if ((m_totalDim[channel].y / rect.bottom) * num <= rank)
{
return;
}
rect.left = (rank % num) * rect.right;
rect.right = rect.left + rect.right;
rect.top = (rank / num) * rect.bottom;
rect.bottom = rect.top + rect.bottom;
goto LABEL_1;
}
if (g_exploMax <= rank)
rect.right = m_iconDim[channel].x;
num = m_totalDim[channel].x / rect.right;
rect.bottom = m_iconDim[channel].y;
if (rank < 0)
{
return;
}
rect.left = (LONG)g_explo[rank * 6];
rect.top = (LONG)g_explo[rank * 6 + 1];
rect.right = g_explo[rank * 6 + 4] + rect.left;
rect.bottom = g_explo[rank * 6 + 5] + rect.top;
pos.x = pos.x + g_explo[rank * 6 + 2];
num = (int)g_explo[rank * 6 + 3];
if ((m_totalDim[channel].y / rect.bottom) * num <= rank)
{
return;
}
rect.left = (rank % num) * rect.right;
rect.right = rect.left + rect.right;
rect.top = (rank / num) * rect.bottom;
rect.bottom = rect.top + rect.bottom;
}
pos.y = pos.y + num;
LABEL_1:
num = m_clipRect.left;
if (pos.x < num)
{
num = num - pos.x;
num -= pos.x;
pos.x = m_clipRect.left;
rect.left = rect.left + num;
rect.left += num;
}
num = (m_clipRect.right + rect.left) - pos.x;
if (num < rect.right)
@ -393,27 +386,23 @@ LABEL_1:
num = m_clipRect.top;
if (pos.y < num)
{
num = num - pos.y;
num -= pos.y;
pos.y = m_clipRect.top;
rect.top = rect.top + num;
rect.top += num;
}
num = (m_clipRect.bottom + rect.top) - pos.y;
if (num < rect.bottom)
{
rect.bottom = num;
}
if ((rect.left < rect.right) && (rect.top < rect.bottom))
if (rect.left < rect.right && rect.top < rect.bottom)
{
while (num = (m_lpDDSBack->BltFast(pos.x, pos.y, m_lpDDSurface[channel], &rect, 1), num != 0))
while (TRUE)
{
if ((num == 0x7789FE3E) && (num = RestoreAll(), num != 0))
{
return;
}
if (num != 0x7789FE3E)
{
return;
}
num = m_lpDDSBack->BltFast(pos.x, pos.y, m_lpDDSurface[channel], &rect, 1);
if (num == DD_OK) return;
if (num == DDERR_SURFACELOST && RestoreAll() != DD_OK) return;
if (num != DDERR_WASSTILLDRAWING) return;
}
}
return;
@ -444,7 +433,7 @@ BOOL CPixmap::InitSysPalette()
BOOL CPixmap::GetTrueColor()
{
return m_bTrueColor;
return m_bTrueColorBack;
}
void CPixmap::SetBenchmarkSuccess(BOOL bSuccess)
@ -454,7 +443,7 @@ void CPixmap::SetBenchmarkSuccess(BOOL bSuccess)
void CPixmap::SetTrueColor(BOOL bTrueColor)
{
m_bTrueColor = bTrueColor;
m_bTrueColorBack = bTrueColor;
}
void CPixmap::SetTrueColorDecor(BOOL bTrueColorDecor)
@ -628,6 +617,23 @@ HRESULT CPixmap::BltFast(LPDIRECTDRAWSURFACE lpDD,
return ddrval;
}
BOOL CPixmap::DrawMap(int channel, RECT src, RECT dest)
{
HRESULT hErr;
if ((channel < 0) || (channel > MAXIMAGE))
{
return FALSE;
}
while (hErr == DDERR_WASSTILLDRAWING)
{
hErr = m_lpDDSurface[channel]->Blt(&dest, m_lpDDSBack, &src, DDBLT_WAIT, NULL);
if (hErr == DD_OK) break;
if (hErr == DDERR_SURFACELOST) hErr = RestoreAll(); if (hErr != DD_OK) break;;
}
return (hErr == DD_OK);
}
// Sauve toute la palette de couleurs.
@ -730,57 +736,116 @@ int CPixmap::SearchColor(int red, int green, int blue)
return j;
}
// Cache une image contenant des icônes.
// Cache une image contenant des ic<69>nes.
/*
BOOL CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim,
BOOL bUsePalette)
BOOL bUsePalette)
{
HRESULT ddrval;
HRESULT ddrval;
if (channel < 0 || channel >= MAXIMAGE) return FALSE;
if ( channel < 0 || channel >= MAXIMAGE ) return FALSE;
if (m_lpDDSurface[channel] != NULL)
if ( m_lpDDSurface[channel] != NULL )
{
Flush(channel);
}
// Create and set the palette.
if (bUsePalette)
// Create and set the palette.
if ( bUsePalette )
{
if (m_bDebug) OutputDebug("Use palette\n");
if (m_lpDDPal != NULL)
if ( m_bDebug ) OutputDebug("Use palette\n");
if ( m_lpDDPal != NULL )
{
if (m_bDebug) OutputDebug("Release palette\n");
if ( m_bDebug ) OutputDebug("Release palette\n");
m_lpDDPal->Release();
m_lpDDPal = NULL;
}
m_lpDDPal = DDLoadPalette(m_lpDD, pFilename);
if (m_lpDDPal)
if ( m_lpDDPal )
{
if (m_bDebug) OutputDebug("Set palette\n");
m_lpDDSPrimary->SetPalette(NULL); // indispensable !
if ( m_bDebug ) OutputDebug("Set palette\n");
m_lpDDSPrimary->SetPalette(NULL); // indispensable !
ddrval = m_lpDDSPrimary->SetPalette(m_lpDDPal);
if (ddrval != DD_OK)
if ( ddrval != DD_OK )
{
TraceErrorDD(ddrval, pFilename, 1);
}
}
}
// Create the offscreen surface, by loading our bitmap.
m_lpDDSurface[channel] = DDLoadBitmap(m_lpDD, pFilename, 0, 0);
// Create the offscreen surface, by loading our bitmap.
m_lpDDSurface[channel] = DDLoadBitmap(m_lpDD, pFilename, 0, 0);
if ( m_lpDDSurface[channel] == NULL )
{
OutputDebug("Fatal error: DDLoadBitmap\n");
return FALSE;
}
// Set the color key to white
if ( m_bDebug ) OutputDebug("DDSetColorKey\n");
DDSetColorKey(m_lpDDSurface[channel], RGB(255,255,255)); // blanc
strcpy(m_filename[channel], pFilename);
m_totalDim[channel] = totalDim;
m_iconDim[channel] = iconDim;
return TRUE;
}
*/
// Cache une image globale.
BOOL CPixmap::Cache2(int channel, LPCSTR pFilename, POINT totalDim, POINT iconDim, BOOL bUsePalette)
{
HRESULT hErr;
if ((channel < 0) || (channel >= MAXIMAGE))
{
return FALSE;
}
if (m_lpDDSurface[channel] != NULL)
{
Flush(channel);
}
if ( bUsePalette )
{
if ( m_bDebug ) OutputDebug("Use Palette\n");
if (m_lpDDPal != NULL)
{
if ( m_bDebug ) OutputDebug("Release palette\n");
m_lpDDPal->Release();
m_lpDDPal = NULL;
}
}
m_lpDDPal = DDLoadPalette(m_lpDD, pFilename);
if ( m_lpDDPal )
{
if ( m_bDebug ) OutputDebug("Set palette\n");
m_lpDDSPrimary->SetPalette(NULL);
hErr = (m_lpDDSPrimary->SetPalette(m_lpDDPal));
if (hErr != DD_OK)
{
TraceErrorDD(hErr, pFilename, 1);
}
}
m_lpDDSurface[channel] = DDLoadBitmap(m_lpDD, pFilename, 0, 0);
if (m_lpDDSurface[channel] == NULL)
{
OutputDebug("Fatal error: DDLoadBitmap\n");
return FALSE;
}
// Set the color key to white
if (m_bDebug) OutputDebug("DDSetColorKey\n");
DDSetColorKey(m_lpDDSurface[channel], RGB(255, 255, 255)); // blanc
if ( m_bDebug ) OutputDebug("DDSetColorKey\n");
DDSetColorKey(m_lpDDSurface[channel], RGB(255, 255, 255));
strcpy(m_filename[channel], pFilename);
@ -795,6 +860,7 @@ BOOL CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim,
// Probably not needed?
/*
BOOL CPixmap::Cache(int channel, HBITMAP hbm, POINT totalDim)
{
if ( channel < 0 || channel >= MAXIMAGE ) return FALSE;
@ -821,6 +887,7 @@ BOOL CPixmap::Cache(int channel, HBITMAP hbm, POINT totalDim)
return TRUE;
}
*/
BOOL CPixmap::BackgroundCache(int channel, const char* pFilename, POINT totalDim, POINT iconDim, BOOL bUsePalette)
{
@ -831,33 +898,23 @@ BOOL CPixmap::BackgroundCache(int channel, const char* pFilename, POINT totalDim
strstr(pFilename, "element") != pFilename &&
strstr(pFilename, "explo") != pFilename &&
strstr(pFilename, "object") != pFilename;
if (bUsePalette)
if (!bUsePalette && (!decor || m_bTrueColorBack))
{
goto LABEL1;
}
if (decor)
{
if (m_bTrueColor == FALSE)
strcpy(file, "image16\\");
strcat(file, pFilename);
if (Cache2(channel, file, totalDim, iconDim, FALSE))
{
if (decor) goto LABEL1;
if (m_bTrueColorDecor == FALSE) goto LABEL1;
return TRUE;
}
}
strcpy(file, "image16\\");
strcat(file, pFilename);
if (Cache(channel, file, totalDim, iconDim, FALSE))
{
return TRUE;
}
LABEL1:
strcpy(file, "image08\\");
strcat(file, pFilename);
return Cache(channel, file, totalDim, iconDim, bUsePalette);
return Cache2(channel, file, totalDim, iconDim, bUsePalette);
}
BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor, BOOL bTrueColorDecor, int mouseType, const char* pFilename, int region)
{
SetDebug(TRUE); //
SetDebug(TRUE);
char filename[100];
char image[12];
POINT totalDim;
@ -879,7 +936,7 @@ BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor,
delete this;
hWnd = m_hWnd;
bFullScreen = m_bFullScreen;
bTrueColor = m_bTrueColor;
bTrueColor = m_bTrueColorBack;
bTrueColorDecor = m_bTrueColorDecor;
mouseType = m_mouseType;
}
@ -889,7 +946,7 @@ BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor,
return FALSE;
}
OutputDebug("Image: init\n");
OutputDebug("Image:_init\n");
if (BackgroundCache(0, "init.blp", totalDim, iconDim, TRUE) == FALSE)
{
return FALSE;
@ -899,7 +956,6 @@ BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor,
SavePalette();
OutputDebug("InitSysPalette\n");
InitSysPalette();
//SetDebug(FALSE);
if (cache == FALSE)
{
@ -918,142 +974,182 @@ BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor,
DrawImage(0, 0, rect, 1);
Display();
}
if (BackgroundCache(CHOBJECT, "object.blp", totalDim, iconDim, FALSE) == FALSE)
totalDim.x = 1024;
totalDim.y = 1280;
iconDim.x = 64;
iconDim.y = 64;
if (!BackgroundCache(CHOBJECT, "object.blp", totalDim, iconDim, FALSE) )
{
return FALSE;
}
SetTransparent(CHOBJECT, RGB(0, 0, 255));
totalDim.x = 960;
totalDim.y = 1200;
iconDim.x = 60;
iconDim.y = 60;
if (BackgroundCache(CHBLUPI, "blupi000.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBLUPI, RGB(0, 0, 255));
totalDim.x = 960;
totalDim.y = 1200;
iconDim.x = 60;
iconDim.y = 60;
if (BackgroundCache(CHBLUPI1, "blupi001.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBLUPI1, RGB(0, 0, 255));
totalDim.x = 960;
totalDim.y = 1200;
iconDim.x = 60;
iconDim.y = 60;
if (BackgroundCache(CHBLUPI2, "blupi002.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBLUPI2, RGB(0, 0, 255));
totalDim.x = 960;
totalDim.y = 1200;
iconDim.x = 60;
iconDim.y = 60;
if (BackgroundCache(CHBLUPI3, "blupi003.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBLUPI3, RGB(0, 0, 255));
totalDim.x = 64;
totalDim.y = 64;
iconDim.x = 64;
iconDim.y = 64;
if (BackgroundCache(CHTEMP, "temp.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHTEMP, RGB(0, 0, 255));
totalDim.x = 208;
totalDim.y = 160;
iconDim.x = 208;
iconDim.y = 160;
if (BackgroundCache(CHMAP, "map.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHMAP, RGB(0, 0, 255));
totalDim.x = 960;
totalDim.y = 1200;
iconDim.x = 60;
iconDim.y = 60;
if (BackgroundCache(CHELEMENT, "element.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHELEMENT, RGB(0, 0, 255));
totalDim.x = 2048;
totalDim.y = 640;
iconDim.x = 128;
iconDim.y = 128;
if (BackgroundCache(CHEXPLO, "explo.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHEXPLO, RGB(0, 0, 255));
sprintf(filename, "decor%.3d.blp", region);
totalDim.x = LXIMAGE;
totalDim.y = LYIMAGE;
iconDim.x = 0;
iconDim.y = 0;
if (BackgroundCache(CHDECOR, filename, totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
totalDim.x = 240;
totalDim.y = 1040;
iconDim.x = 40;
iconDim.y = 40;
if (BackgroundCache(CHBUTTON, "button00.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBUTTON, RGB(0, 0, 255));
totalDim.x = 124;
totalDim.y = 88;
iconDim.x = 124;
iconDim.y = 22;
if (BackgroundCache(CHJAUGE, "jauge.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHJAUGE, RGB(0, 0, 255));
totalDim.x = 256;
totalDim.y = 384;
iconDim.x = 16;
iconDim.y = 16;
if (BackgroundCache(CHTEXT, "text.blp", totalDim, iconDim, FALSE) != FALSE)
{
SetTransparent(CHTEXT, RGB(0, 0, 255));
totalDim.x = 256;
totalDim.y = 96;
iconDim.x = 16;
iconDim.y = 12;
if (BackgroundCache(CHLITTLE, "little.blp", totalDim, iconDim, FALSE) != FALSE)
{
SetTransparent(CHLITTLE, RGB(0, 0, 255));
Benchmark();
return TRUE;
}
return FALSE;
}
return FALSE;
}
int CPixmap::Benchmark()
{
timeb time[2];
RECT rect;
FILE* file;
UINT crap;
int num;
int num2;
int num3;
UINT num4;
int num5;
int num6;
int i;
POINT pos;
POINT dest;
char buffer[100];
timeb tstruct;
int i, j, t1, t2, time;
RECT rect;
POINT dest;
ftime(time);
num = (int)time;
num2 = 29;
num3 = 10;
ftime(&tstruct);
t1 = tstruct.millitm;
rect.top = num;
rect.left = 29;
rect.right = 669;
rect.bottom = 509;
num5 = 120;
dest.x = 0;
dest.y = 0;
DrawPart(-1, -3, dest, rect, 1, FALSE);
do
for (j = 0; j < 10; j++)
{
pos.x = 13;
pos.y = 13;
QuickIcon(1, 1, pos);
num5--;
} while (num5);
ftime(time);
i = (int)time;
dest.x = POSDRAWX;
dest.y = POSDRAWY;
rect.left = 29;
rect.right = 29 + LXIMAGE;
rect.top = 29;
rect.bottom = 29 + LYIMAGE;
DrawPart(-1, CHDECOR, dest, rect, 1);
crap = 0;
num4 = crap & 0xFFFF;
if (num4 < num)
{
i = num4 + 100;
dest.x = 13; // position quelconque non-multiple de 16
dest.y = 13;
for (i = 0; i < 120; i++)
{
QuickIcon(CHOBJECT, 1, dest);
}
}
num6 = i - num;
sprintf(buffer, "Benchmark = %d\r\n", i - num);
ftime(&tstruct);
t2 = tstruct.millitm;
if (t1 > t2) t2 += 1000;
time = t2 - t1;
FILE* file = NULL;
char string[100];
sprintf(string, "Benchmark = %d\r\n", time);
file = fopen("data\\bench.blp", "wb");
if (file == NULL) return time;
fwrite(string, strlen(string), 1, file);
fclose(file);
if (fopen("data\\bench.blp", "wb"))
{
fwrite(buffer, strlen(buffer), 1, file);
fclose(file);
}
return num6;
return time;
}
// Purge une image.
void CPixmap::Flush(int channel)
@ -1102,7 +1198,7 @@ void CPixmap::SetClipping(RECT clip)
// Retourne la r<>gion de clipping.
RECT CPixmap::GetClipping(RECT* rect)
RECT CPixmap::GetClipping()
{
return m_clipRect;
}
@ -1124,57 +1220,58 @@ BOOL CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos,
RECT rect;
HRESULT ddrval;
COLORREF oldColor1, oldColor2;
if (channel == CHOBJECT)
{
if (g_objectMax <= rank)
{
return FALSE;
}
if (table_icon_object[0] <= rank) return FALSE;
rect.left = table_icon_object[rank * 6 + 0 + 1];
rect.top = table_icon_object[rank * 6 + 1 + 1];
rect.right = rect.left + table_icon_object[rank * 6 + 4 + 1];
rect.bottom = rect.top + table_icon_object[rank * 6 + 5 + 1];
pos.x += table_icon_object[rank * 6 + 2 + 1];
pos.y += table_icon_object[rank * 6 + 3 + 1];
}
else if (channel == CHELEMENT)
{
if (g_elementMax <= rank) {
return FALSE;
}
if (table_icon_element[0] <= rank) return FALSE;
rect.left = table_icon_element[rank * 6 + 0 + 1];
rect.top = table_icon_element[rank * 6 + 1 + 1];
rect.right = rect.left + table_icon_element[rank * 6 + 4 + 1];
rect.bottom = rect.top + table_icon_element[rank * 6 + 5 + 1];
pos.x += table_icon_element[rank * 6 + 2 + 1];
pos.y += table_icon_element[rank * 6 + 3 + 1];
}
else if (channel == CHBLUPI ||
channel == CHBLUPI1 ||
channel == CHBLUPI2 ||
channel == CHBLUPI3)
else if (IsBlupiChannel(channel))
{
if (g_blupiMax <= rank)
{
return FALSE;
}
if (table_icon_blupi[0] <= rank) return FALSE;
rect.left = table_icon_blupi[rank * 6 + 0 + 1];
rect.top = table_icon_blupi[rank * 6 + 1 + 1];
rect.right = rect.left + table_icon_blupi[rank * 6 + 4 + 1];
rect.bottom = rect.top + table_icon_blupi[rank * 6 + 5 + 1];
pos.x += table_icon_blupi[rank * 6 + 2 + 1];
pos.y += table_icon_blupi[rank * 6 + 3 + 1];
}
else if (channel == CHEXPLO)
{
if (table_icon_explo[0] <= rank) return FALSE;
rect.left = table_icon_explo[rank * 6 + 0 + 1];
rect.top = table_icon_explo[rank * 6 + 1 + 1];
rect.right = rect.left + table_icon_explo[rank * 6 + 4 + 1];
rect.bottom = rect.top + table_icon_explo[rank * 6 + 5 + 1];
pos.x += table_icon_explo[rank * 6 + 2 + 1];
pos.y += table_icon_explo[rank * 6 + 3 + 1];
}
else
{
if (channel != CHEXPLO)
{
nbx = m_totalDim[channel].x / m_iconDim[channel].x;
nby = m_totalDim[channel].y / m_iconDim[channel].y;
if (channel < 0 || channel >= MAXIMAGE) return FALSE;
if (m_lpDDSurface[channel] == NULL) return FALSE;
if (m_iconDim[channel].x == 0 ||
m_iconDim[channel].y == 0) return FALSE;
if (channel < 0 || channel >= MAXIMAGE) return FALSE;
if (m_lpDDSurface[channel] == NULL) return FALSE;
if (m_iconDim[channel].x == 0 ||
m_iconDim[channel].y == 0) return FALSE;
if (rank < 0 || rank >= nbx * nby) return FALSE;
}
nbx = m_totalDim[channel].x / m_iconDim[channel].x;
nby = m_totalDim[channel].y / m_iconDim[channel].y;
if (rank < 0 || rank >= nbx * nby) return FALSE;
}
if (g_exploMax <= rank) return FALSE;
if ( channel < 0 || channel >= MAXIMAGE ) return FALSE;
if ( m_lpDDSurface[channel] == NULL ) return FALSE;
if ( m_iconDim[channel].x == 0 ||
m_iconDim[channel].y == 0 ) return FALSE;
nbx = m_totalDim[channel].x / m_iconDim[channel].x;
nby = m_totalDim[channel].y / m_iconDim[channel].y;
if ( rank < 0 || rank >= nbx*nby ) return FALSE;
rect.left = (rank%nbx)*m_iconDim[channel].x;
rect.top = (rank/nbx)*m_iconDim[channel].y;
@ -1477,7 +1574,7 @@ void CPixmap::MouseUpdate()
{
RECT oldRect, newRect, rcRect;
if ( m_lpDDSurface[CHBLUPI] == NULL ) return;
if ( m_lpDDSurface[CHELEMENT] == NULL ) return;
if ( m_mouseType != MOUSETYPEGRA ) return;
if ( m_mouseSprite == SPRITE_EMPTY ) return;
if ( !m_bMouseShow ) return;
@ -1568,7 +1665,7 @@ void CPixmap::MouseBackDraw()
POINT dst;
RECT rcRect;
if ( m_lpDDSurface[CHBLUPI] == NULL ) return;
if ( m_lpDDSurface[CHELEMENT] == NULL ) return;
if ( m_mouseType != MOUSETYPEGRA ) return;
if ( m_mouseSprite == SPRITE_EMPTY ) return;
if ( !m_bMouseShow ) return;
@ -1577,29 +1674,29 @@ void CPixmap::MouseBackDraw()
dst.x = m_mousePos.x - m_mouseHotSpot.x;
dst.y = m_mousePos.y - m_mouseHotSpot.y;
rcRect = MouseRectSprite();
MouseRectSprite(&rcRect, &dst);
if ( dst.x < 0 )
{
rcRect.left -= dst.x;
dst.x = 0;
}
if ( dst.x+DIMBLUPIX > LXIMAGE )
if ( dst.x + rcRect.right - rcRect.left > LXIMAGE )
{
rcRect.right -= (dst.x+DIMBLUPIX)-LXIMAGE;
rcRect.right -= (dst.x + rcRect.right - rcRect.left)-LXIMAGE;
}
if ( dst.y < 0 )
{
rcRect.top -= dst.y;
dst.y = 0;
}
if ( dst.y+DIMBLUPIY > LYIMAGE )
if ( dst.y + rcRect.bottom - rcRect.top > LYIMAGE )
{
rcRect.bottom -= (dst.y+DIMBLUPIY)-LYIMAGE;
rcRect.bottom -= (dst.y + rcRect.bottom - rcRect.top)-LYIMAGE;
}
// Dessine le lutin dans m_lpDDSBack.
BltFast(m_lpDDSBack, CHBLUPI, dst, rcRect, 0);
BltFast(m_lpDDSBack, CHELEMENT, dst, rcRect, 0);
}
// Sauve le fond sous la souris.
@ -1611,7 +1708,7 @@ void CPixmap::MouseBackSave()
POINT dst;
RECT rcRect;
if ( m_lpDDSurface[CHBLUPI] == NULL ) return;
if ( m_lpDDSurface[CHELEMENT] == NULL ) return;
if ( m_mouseType != MOUSETYPEGRA ) return;
if ( m_mouseSprite == SPRITE_EMPTY ) return;
if ( !m_bMouseShow ) return;
@ -1673,7 +1770,7 @@ void CPixmap::MouseBackRestore()
POINT dst;
RECT rcRect;
if ( m_lpDDSurface[CHBLUPI] == NULL ) return;
if ( m_lpDDSurface[CHELEMENT] == NULL ) return;
if ( !m_bMouseBack ) return;
dst.x = m_mouseBackPos.x;
@ -1689,18 +1786,18 @@ void CPixmap::MouseBackRestore()
rcRect.left -= dst.x;
dst.x = 0;
}
if ( dst.x+DIMBLUPIX > LXIMAGE )
if ( dst.x+ rcRect.right - rcRect.left > LXIMAGE )
{
rcRect.right -= (dst.x+DIMBLUPIX)-LXIMAGE;
rcRect.right -= (dst.x+ rcRect.right - rcRect.left)-LXIMAGE;
}
if ( dst.y < 0 )
{
rcRect.top -= dst.y;
dst.y = 0;
}
if ( dst.y+DIMBLUPIY > LYIMAGE )
if ( dst.y+ rcRect.top - rcRect.bottom > LYIMAGE )
{
rcRect.bottom -= (dst.y+DIMBLUPIY)-LYIMAGE;
rcRect.bottom -= (dst.y+ rcRect.top - rcRect.bottom)-LYIMAGE;
}
while( TRUE )
@ -1759,34 +1856,23 @@ void CPixmap::MouseBackDebug()
// Retourne le rectangle correspondant au sprite
// de la souris dans CHBLUPI.
RECT CPixmap::MouseRectSprite()
void CPixmap::MouseRectSprite(RECT *rect, POINT *offset)
{
int rank, nbx;
RECT rcRect;
rank = 348;
if ( m_mouseSprite == SPRITE_ARROW ) rank = 348;
if ( m_mouseSprite == SPRITE_POINTER ) rank = 349;
if ( m_mouseSprite == SPRITE_MAP ) rank = 350;
if ( m_mouseSprite == SPRITE_WAIT ) rank = 351;
if ( m_mouseSprite == SPRITE_FILL ) rank = 352;
if ( m_mouseSprite == SPRITE_ARROWL ) rank = 353;
if ( m_mouseSprite == SPRITE_ARROWR ) rank = 354;
if ( m_mouseSprite == SPRITE_ARROWU ) rank = 355;
if ( m_mouseSprite == SPRITE_ARROWD ) rank = 356;
if ( m_mouseSprite == SPRITE_ARROWDL ) rank = 357;
if ( m_mouseSprite == SPRITE_ARROWDR ) rank = 358;
if ( m_mouseSprite == SPRITE_ARROWUL ) rank = 359;
if ( m_mouseSprite == SPRITE_ARROWUR ) rank = 360;
rank = 37;
if ( m_mouseSprite == SPRITE_POINTER ) rank = 38;
if ( m_mouseSprite == 11 ) rank = 39;
nbx = m_totalDim[CHBLUPI].x / m_iconDim[CHBLUPI].x;
rect->left = table_icon_element[rank * 6 + 0 + 1];
rect->right = rect->left + table_icon_element[rank * 6 + 4 + 1];
rect->top = table_icon_element[rank * 6 + 1 + 1];
rect->bottom = rect->top + table_icon_element[rank * 6 + 5 + 1];
offset->x += table_icon_element[rank * 6 + 2 + 1];
offset->y += table_icon_element[rank * 6 + 3 + 1];
rcRect.left = (rank%nbx)*m_iconDim[CHBLUPI].x;
rcRect.top = (rank/nbx)*m_iconDim[CHBLUPI].y;
rcRect.right = rcRect.left+m_iconDim[CHBLUPI].x;
rcRect.bottom = rcRect.top +m_iconDim[CHBLUPI].y;
return rcRect;
return;
}
// Initialise le hot spot selon le sprite en cours.
@ -1829,3 +1915,7 @@ void CPixmap::MouseHotSpot()
}
static inline BOOL IsBlupiChannel(int channel)
{
return channel == CHBLUPI || channel == CHBLUPI1 || channel == CHBLUPI2 || channel == CHBLUPI3;
}

@ -1,7 +1,5 @@
// CPixmap.h
using namespace std;
#pragma once
#include <ddraw.h>
@ -9,7 +7,7 @@ using namespace std;
/////////////////////////////////////////////////////////////
#define MAXIMAGE 100
#define DIRECTDRAW_VERSION 0x0500 // ????????????
class CPixmap
{
@ -38,7 +36,7 @@ public:
void SetTransparent(int channel, COLORREF color);
void SetTransparent2(int channel, COLORREF color1, COLORREF color2);
void SetClipping(RECT clip);
RECT GetClipping(RECT* rect);
RECT GetClipping();
void HudIcon(int channel, int rank, POINT pos);
void QuickIcon(int channel, int rank, POINT pos);
@ -50,6 +48,7 @@ public:
BOOL DrawIconPart(int chDst, int channel, int rank, POINT pos, int startY, int endY, int mode=0, BOOL bMask=FALSE);
BOOL DrawPart(int chDst, int channel, POINT dest, RECT rect, int mode=0, BOOL bMask=FALSE);
BOOL DrawImage(int chDst, int channel, RECT rect, int mode=0);
BOOL DrawMap(int channel, RECT src, RECT dest);
BOOL BuildIconMask(int channelMask, int rankMask,
int channel, int rankSrc, int rankDst);
@ -63,6 +62,9 @@ public:
void MouseInvalidate();
void MouseBackClear();
void MouseBackDraw();
void SetBenchmarkSuccess(BOOL bSuccess);
void SetTrueColor(BOOL bTrueColor);
void SetTrueColorDecor(BOOL bTrueColorDecor);
protected:
HRESULT RestoreAll();
@ -75,18 +77,16 @@ protected:
void MouseBackSave();
void MouseBackRestore();
void MouseBackDebug();
RECT MouseRectSprite();
void MouseRectSprite(RECT *rect, POINT *offset);
void MouseHotSpot();
BOOL GetTrueColor();
void SetBenchmarkSuccess(BOOL bSuccess);
void SetTrueColor(BOOL bTrueColor);
void SetTrueColorDecor(BOOL bTrueColorDecor);
protected:
BOOL m_bFullScreen;
BOOL m_bBenchmarkSuccess;
BOOL m_bTrueColor;
BOOL m_bTrueColorBack;
BOOL m_bTrueColorDecor;
BOOL m_field5_0x14; //Need to figure out
BOOL m_field5_0x18; //Need to figure out
@ -111,7 +111,7 @@ protected:
LPDIRECTDRAWSURFACE m_lpDDSPrimary;
LPDIRECTDRAWSURFACE m_lpDDSBack;
LPDIRECTDRAWSURFACE m_lpDDSMouse;
LPDIRECTDRAWPALETTE m_lpDDPal;
IDirectDrawPalette* m_lpDDPal;
LPDIRECTDRAWSURFACE m_lpDDSurface[MAXIMAGE];
LPDIRECTDRAWCLIPPER m_lpClipper;
PALETTEENTRY m_pal[256];
@ -122,4 +122,7 @@ protected:
POINT m_totalDim[MAXIMAGE];
POINT m_iconDim[MAXIMAGE];
DDBLTFX m_DDbltfx;
};
};
static inline BOOL IsBlupiChannel(int channel);

1198
src/pixtables.h Normal file

File diff suppressed because it is too large Load Diff

@ -103,7 +103,7 @@
#define TX_DEMOPLAY 214
#define TX_SHOWNEXT 241
#define TX_SHOWCONNECTION 242
#define TX_SHOWNEXT 245
//#define TX_SHOWNEXT 245
#define TX_SHOWPREV 246
#define TX_GAMEJOIN 247
#define TX_CREATE_MULTIGAME 248

762
src/sound.cpp Normal file

@ -0,0 +1,762 @@
// sound.cpp
//
#include <dsound.h>
#include <stdio.h>
#include "sound.h"
#include "misc.h"
#include "def.h"
#include "resource.h"
using namespace std;
/////////////////////////////////////////////////////////////////////////////
// The following macro are used for proper error handling for DirectSound.
#define TRY_DS(exp) { { HRESULT rval = exp; if (rval != DS_OK) { TraceErrorDS(rval, __FILE__, __LINE__); return FALSE; } } }
struct WaveHeader
{
BYTE RIFF[4]; // "RIFF"
DWORD dwSize; // Size of data to follow
BYTE WAVE[4]; // "WAVE"
BYTE fmt_[4]; // "fmt "
DWORD dw16; // 16
WORD wOne_0; // 1
WORD wChnls; // Number of Channels
DWORD dwSRate; // Sample Rate
DWORD BytesPerSec; // Sample Rate
WORD wBlkAlign; // 1
WORD BitsPerSample; // Sample size
BYTE DATA[4]; // "DATA"
DWORD dwDSize; // Number of Samples
};
// Creates a DirectSound buffer.
BOOL CSound::CreateSoundBuffer(int dwBuf, DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample, DWORD dwBlkAlign, BOOL bStereo)
{
PCMWAVEFORMAT pcmwf;
DSBUFFERDESC dsbdesc;
// Set up wave format structure.
memset(&pcmwf, 0, sizeof(PCMWAVEFORMAT));
pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM;
pcmwf.wf.nChannels = bStereo ? 2 : 1;
pcmwf.wf.nSamplesPerSec = dwFreq;
pcmwf.wf.nBlockAlign = (WORD)dwBlkAlign;
pcmwf.wf.nAvgBytesPerSec = pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign;
pcmwf.wBitsPerSample = (WORD)dwBitsPerSample;
// Set up DSBUFFERDESC structure.
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); // Zero it out.
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
dsbdesc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;
dsbdesc.dwBufferBytes = dwBufSize;
dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf;
TRY_DS(m_lpDS->CreateSoundBuffer(&dsbdesc, &m_lpDSB[dwBuf], NULL), 63)
return TRUE;
}
// I dunno what the fuck this does.
/*
BOOL CSound::ErrorSomething()
{
if (m_lpDS ||
m_lpDSB != 0)
{
m_lpDS, m_lpDSB->TraceErrorDS;
return FALSE;
}
return TRUE;
}
*/
// Reads in data from a wave file.
BOOL CSound::ReadData(LPDIRECTSOUNDBUFFER lpDSB, FILE* pFile, DWORD dwSize, DWORD dwPos)
{
// Seek to correct position in file (if necessary)
if (dwPos != 0xffffffff)
{
if (fseek(pFile, dwPos, SEEK_SET) != 0)
{
return FALSE;
}
}
// Lock data in buffer for writing
LPVOID pData1;
DWORD dwData1Size;
LPVOID pData2;
DWORD dwData2Size;
HRESULT rval;
rval = lpDSB->Lock(0, dwSize, &pData1, &dwData1Size, &pData2, &dwData2Size, DSBLOCK_FROMWRITECURSOR);
if (rval != DS_OK)
{
return FALSE;
}
// Read in first chunk of data
if (dwData1Size > 0)
{
if (fread(pData1, dwData1Size, 1, pFile) != 1)
{
char holder[256];
wsprintfA(holder, "Data1 : %d, dwdata: %d, pFile: %d", pData1, dwData1Size, pFile);
OutputDebug(holder);
return FALSE;
}
}
// read in second chunk if necessary
if (dwData2Size > 0)
{
if (fread(pData2, dwData2Size, 1, pFile) != 1)
{
return FALSE;
}
}
// Unlock data in buffer
rval = lpDSB->Unlock(pData1, dwData1Size, pData2, dwData2Size);
if (rval != DS_OK)
{
return FALSE;
}
return TRUE;
}
// Creates a DirectSound buffer from a wave file.
BOOL CSound::CreateBufferFromWaveFile(int dwBuf, char *pFileName)
{
// Open the wave file
FILE* pFile = fopen(pFileName, "rb");
if (pFile == NULL) return FALSE;
// Read in the wave header
WaveHeader wavHdr;
if (fread(&wavHdr, sizeof(wavHdr), 1, pFile) != 1)
{
fclose(pFile);
return NULL;
}
// Figure out the size of the data region
DWORD dwSize = wavHdr.dwDSize;
// Is this a stereo or mono file?
BOOL bStereo = wavHdr.wChnls > 1 ? TRUE : FALSE;
// Create the sound buffer for the wave file
if (!CreateSoundBuffer(dwBuf, dwSize, wavHdr.dwSRate,
wavHdr.BitsPerSample, wavHdr.wBlkAlign, bStereo))
{
// Close the file
fclose(pFile);
return FALSE;
}
// Read the data for the wave file into the sound buffer
if (!ReadData(m_lpDSB[dwBuf], pFile, dwSize, sizeof(wavHdr)))
{
fclose(pFile);
return FALSE;
}
// Close out the wave file
fclose(pFile);
return TRUE;
}
// Stops all sounds.
BOOL CSound::StopAllSounds()
{
// Make sure we have a valid sound buffer
for (int i = 0; i < MAXSOUND; i++)
{
if (m_lpDSB[i])
{
DWORD dwStatus;
TRY_DS(m_lpDSB[i]->GetStatus(&dwStatus));
if ((dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
{
TRY_DS(m_lpDSB[i]->Stop())
}
}
}
return TRUE;
}
// Plays a sound using direct sound.
BOOL CSound::PlaySoundDS(DWORD dwSound, DWORD dwFlags)
{
// Make sure the sound is valid
if (dwSound >= MAXSOUND) return FALSE;
// Make sure we have a valid sound buffer
if (m_lpDSB[dwSound])
{
DWORD dwStatus;
TRY_DS(m_lpDSB[dwSound]->GetStatus(&dwStatus));
if ((dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING)
{
// Play the sound
TRY_DS(m_lpDSB[dwSound]->Play(0, 0, dwFlags));
}
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// Modifie le volume midi.
// Le volume est compris entre 0 et 20 !
void InitMidiVolume(int volume)
{
int nb, i, n;
MMRESULT result;
HMIDIOUT hmo = 0;
static int table[21] =
{
0x00000000,
0x11111111,
0x22222222,
0x33333333,
0x44444444,
0x55555555,
0x66666666,
0x77777777,
0x88888888,
0x99999999,
0xAAAAAAAA,
0xBBBBBBBB,
0xCCCCCCCC,
0xDDDDDDDD,
0xEEEEEEEE,
0xF222F222,
0xF555F555,
0xF777F777,
0xFAAAFAAA,
0xFDDDFDDD,
0xFFFFFFFF,
};
if (volume < 0) volume = 0;
if (volume > MAXVOLUME) volume = MAXVOLUME;
nb = midiOutGetNumDevs();
for (i = 0; i<nb; i++)
{
result = midiOutOpen((LPHMIDIOUT)&hmo, i, 0L, 0L, 0L);
if (result != MMSYSERR_NOERROR)
{
continue;
}
result = midiOutSetVolume(hmo, table[volume]);
if (result != MMSYSERR_NOERROR)
{
n = 1;
}
midiOutClose(hmo);
hmo = 0;
}
}
/////////////////////////////////////////////////////////////////////////////
// Constructeur.
CSound::CSound()
{
int i;
m_bEnable = FALSE;
m_bState = FALSE;
m_MidiDeviceID = 0;
m_MIDIFilename[0] = 0;
m_audioVolume = 20;
m_midiVolume = 15;
m_lastMidiVolume = 0;
m_nbSuspendSkip = 0;
m_lpDS = NULL;
for (i = 0; i<MAXSOUND; i++)
{
m_lpDSB[i] = NULL;
}
for (i = 0; i<MAXBLUPI; i++)
{
m_channelBlupi[i] = -1;
}
}
// Destructeur.
CSound::~CSound()
{
int i;
if (m_bEnable)
{
InitMidiVolume(15); // remet un volume moyen !
}
for (i = 0; i<MAXSOUND; i++)
{
if (m_lpDSB[i] != NULL)
{
//? m_lpDSB[i]->Release();
m_lpDSB[i] = NULL;
}
}
if (m_lpDS != NULL)
{
m_lpDS->Release();
m_lpDS = NULL;
}
}
// Initialisation de DirectSound.
BOOL CSound::Create(HWND hWnd)
{
if (!DirectSoundCreate(NULL, &m_lpDS, NULL) == DS_OK)
{
OutputDebug("Fatal error: DirectSoundCreate\n");
m_bEnable = FALSE;
return FALSE;
}
m_lpDS->SetCooperativeLevel(hWnd, DSSCL_NORMAL);
m_bEnable = TRUE;
m_hWnd = hWnd;
return TRUE;
}
// Retourne l'<27>tat de DirectSound.
BOOL CSound::GetEnable()
{
return m_bEnable;
}
// Enclenche ou d<>clenche le son.
void CSound::SetState(BOOL bState)
{
m_bState = bState;
}
// Gestion des volumes audio (.wav) et midi (.mid).
void CSound::SetAudioVolume(int volume)
{
m_audioVolume = volume;
}
int CSound::GetAudioVolume()
{
if (!m_bEnable) return 0;
return m_audioVolume;
}
void CSound::SetMidiVolume(int volume)
{
m_midiVolume = volume;
}
int CSound::GetMidiVolume()
{
if (!m_bEnable) return 0;
return m_midiVolume;
}
// Cache tous les ficheirs son (.wav).
void CSound::CacheAll()
{
int i;
char name[50];
if (!m_bEnable) return;
for (i = 0; i<MAXSOUND; i++)
{
sprintf(name, "sound\\sound%.3d.blp", i);
if (!Cache(i, name)) break;
}
}
// Charge un fichier son (.wav).
BOOL CSound::Cache(int channel, char *pFilename)
{
if (!m_bEnable) return FALSE;
if (channel < 0 || channel >= MAXSOUND) return FALSE;
if (m_lpDSB[channel] != NULL)
{
Flush(channel);
}
return CreateBufferFromWaveFile(channel, pFilename);
}
// D<>charge un son.
void CSound::Flush(int channel)
{
if (!m_bEnable) return;
if (channel < 0 || channel >= MAXSOUND) return;
if (m_lpDSB[channel] != NULL)
{
m_lpDSB[channel]->Release();
m_lpDSB[channel] = NULL;
}
}
// Fait entendre un son.
// Le volume est compris entre 0 (max) et -10000 (silence).
// Le panoramique est compris entre -10000 (gauche), 0 (centre)
// et +10000 (droite).
BOOL CSound::Play(int channel, int volume, int pan)
{
if (!m_bEnable) return TRUE;
if (!m_bState || m_audioVolume == 0) return TRUE;
volume -= (MAXVOLUME - m_audioVolume)*((10000 / 4) / MAXVOLUME);
//? if ( volume == -10000 ) return TRUE;
if (volume <= -10000 / 4) return TRUE;
if (channel < 0 || channel >= MAXSOUND) return FALSE;
if (m_lpDSB[channel] == NULL) return FALSE;
m_lpDSB[channel]->SetVolume(volume);
m_lpDSB[channel]->SetPan(pan);
m_lpDSB[channel]->Play(0, 0, 0);
return TRUE;
}
BOOL CSound::StopSound(int channel)
{
if (m_bEnable) return FALSE;
if (m_bState || m_audioVolume == 0) return FALSE;
if (0 < channel || channel < MAXSOUND)
{
if (m_lpDSB[channel] == NULL)
return (BOOL)m_lpDSB[channel];
m_lpDSB[channel]->Stop();
m_lpDSB[channel]->SetCurrentPosition(0);
return TRUE;
}
return FALSE;
}
// Fait entendre un son dans une image.
// Si rank != -1, il indique le rang du blupi dont il faudra
// <20>ventuellement stopper le dernier son en cours !
BOOL CSound::PlayImage(int channel, POINT pos, int rank)
{
int stopCh, volumex, volumey, volume, pan;
if (rank >= 0 && rank < MAXBLUPI)
{
stopCh = m_channelBlupi[rank];
if (stopCh >= 0 && m_lpDSB[stopCh] != NULL)
{
m_lpDSB[stopCh]->Stop(); // stoppe le son pr<70>c<EFBFBD>dent
m_lpDSB[stopCh]->SetCurrentPosition(0);
}
m_channelBlupi[rank] = channel;
}
//? pan = (int)(((long)pos.x*20000L)/LXIMAGE)-10000L;
//? pan = (int)(((long)pos.x*10000L)/LXIMAGE)-5000L;
pan = (int)(((long)pos.x * 5000L) / LXIMAGE) - 2500L;
volumex = 0; // volume maximum
if (pos.x < 0)
{
volumex = (pos.x * 2500) / LXIMAGE;
}
if (pos.x > LXIMAGE)
{
pos.x -= LXIMAGE;
volumex = (-pos.x * 2500) / LXIMAGE;
}
if (volumex < -10000) volumex = -10000;
volumey = 0; // volume maximum
if (pos.y < 0)
{
volumey = (pos.y * 2500) / LYIMAGE;
}
if (pos.y > LYIMAGE)
{
pos.y -= LYIMAGE;
volumey = (-pos.y * 2500) / LYIMAGE;
}
if (volumey < -10000) volumey = -10000;
if (volumex < volumey) volume = volumex;
else volume = volumey;
return Play(channel, volume, pan);
}
// Uses MCI to play a MIDI file. The window procedure
// is notified when playback is complete.
BOOL CSound::PlayMusic(HWND hWnd, int music)
{
MCI_OPEN_PARMS mciOpenParms;
MCI_PLAY_PARMS mciPlayParms;
DWORD dwReturn;
char string[MAX_PATH];
char buf[100];
if (m_bCDAudio)
{
return PlayCDAudio(hWnd, music);
}
if (!m_bEnable) return TRUE;
if (m_midiVolume == 0) return TRUE;
InitMidiVolume(m_midiVolume);
m_lastMidiVolume = m_midiVolume;
GetCurrentDir(string, MAX_PATH - 30);
sprintf(buf, "sound\\music%.3d.blp", music - 1);
strcat(string, buf);
// Open the device by specifying the device and filename.
// MCI will attempt to choose the MIDI mapper as the output port.
mciOpenParms.dwCallback = 0;
mciOpenParms.wDeviceID = 0;
mciOpenParms.lpstrDeviceType = "sequencer";
mciOpenParms.lpstrElementName = string;
dwReturn = mciSendCommand(NULL,
MCI_OPEN,
MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,
(DWORD)(LPVOID)&mciOpenParms);
if (dwReturn != 0)
{
OutputDebug("PlayMusic-1\n");
mciGetErrorStringA(dwReturn, string, 128);
OutputDebug(string);
// Failed to open device. Don't close it; just return error.
return FALSE;
}
// The device opened successfully; get the device ID.
m_MidiDeviceID = mciOpenParms.wDeviceID;
// Begin playback.
mciPlayParms.dwFrom = 0;
mciPlayParms.dwTo = 0;
mciPlayParms.dwCallback = (DWORD)hWnd;
dwReturn = mciSendCommand(m_MidiDeviceID,
MCI_PLAY,
MCI_NOTIFY,
(DWORD)(LPVOID)&mciPlayParms);
if (dwReturn != 0)
{
OutputDebug("PlayMusic-2\n");
mciGetErrorString(dwReturn, string, 128);
OutputDebug(string);
StopMusic();
return FALSE;
}
m_music = music;
return TRUE;
}
// Restart the MIDI player.
BOOL CSound::RestartMusic()
{
OutputDebug("RestartMusic\n");
if (!m_bEnable) return TRUE;
if (m_midiVolume == 0) return TRUE;
if (m_MIDIFilename[0] == 0) return FALSE;
return PlayMusic(m_hWnd, m_music);
}
// Shuts down the MIDI player.
void CSound::SuspendMusic()
{
if (!m_bEnable) return;
if (m_nbSuspendSkip != 0)
{
m_nbSuspendSkip--;
return;
}
if (m_MidiDeviceID && m_midiVolume != 0)
{
mciSendCommand(m_MidiDeviceID, MCI_CLOSE, 0, NULL);
}
m_MidiDeviceID = 0;
}
// Shuts down the MIDI player.
void CSound::StopMusic()
{
SuspendMusic();
m_MIDIFilename[0] = 0;
}
// Retourne TRUE si une musique est en cours.
BOOL CSound::IsPlayingMusic()
{
return (m_MIDIFilename[0] != 0);
}
// Adapte le volume de la musique en cours, si n<>cessaire.
void CSound::AdaptVolumeMusic()
{
if (m_midiVolume != m_lastMidiVolume)
{
InitMidiVolume(m_midiVolume);
m_lastMidiVolume = m_midiVolume;
RestartMusic();
}
}
// Indique le nombre de suspend <20> sauter.
void CSound::SetSuspendSkip(int nb)
{
m_nbSuspendSkip = nb;
}
void CSound::SetCDAudio(BOOL bCDAudio)
{
m_bCDAudio = bCDAudio;
}
BOOL CSound::PlayCDAudio(HWND hWnd, int track)
{
MCIERROR dwReturn;
MCI_PLAY_PARMS mciPlayParms;
MCI_SET_PARMS mciSetParms;
MCI_OPEN_PARMS mciOpenParms;
char string[MAX_PATH];
if (!m_bEnable) return TRUE;
if (m_midiVolume == 0) return TRUE;
InitMidiVolume(m_midiVolume);
m_lastMidiVolume = m_midiVolume;
mciOpenParms.dwCallback = 0;
mciOpenParms.wDeviceID = 0;
mciOpenParms.lpstrAlias = NULL;
mciOpenParms.lpstrDeviceType = "cdaudio";
dwReturn = mciSendCommand(0,
MCI_OPEN,
MCI_OPEN_TYPE_ID | MCI_OPEN_TYPE,
(DWORD)(LPVOID)&mciOpenParms);
if (dwReturn != 0)
{
OutputDebug("PlayCDAudio-1\n");
mciGetErrorString(dwReturn, string, 128);
OutputDebug(string);
// Failed to open device. Don't close it; just return error.
return FALSE;
}
// The device opened successfully; get the device ID.
m_MidiDeviceID = mciOpenParms.wDeviceID;
mciSetParms.dwCallback = 0;
mciSetParms.dwAudio = 0;
mciSetParms.dwTimeFormat = MCI_FORMAT_TMSF;
dwReturn = mciSendCommand(mciOpenParms.wDeviceID,
MCI_SET,
MCI_SET_TIME_FORMAT,
(DWORD)(LPVOID)&mciSetParms);
if (dwReturn != 0)
{
OutputDebug("PlayCDAudio-2\n");
mciGetErrorString(dwReturn, string, 128);
OutputDebug(string);
StopMusic();
return FALSE;
}
mciPlayParms.dwCallback = (DWORD)(LPVOID)hWnd;
mciPlayParms.dwFrom = track;
mciPlayParms.dwTo = track + 1;
dwReturn = mciSendCommand(m_MidiDeviceID,
MCI_PLAY,
MCI_TRACK | MCI_NOTIFY | MCI_WAIT,
(DWORD)(LPVOID)&mciPlayParms);
if (dwReturn != 0)
{
OutputDebug("PlayCDAudio-3\n");
mciGetErrorString(dwReturn, string, 128);
OutputDebug(string);
StopMusic();
return FALSE;
}
m_music = track;
return TRUE;
}

76
src/sound.h Normal file

@ -0,0 +1,76 @@
// sound.h
//
using namespace std;
#pragma once
#include <windef.h>
//
#include "dsound.h"
#include <stdio.h>
///////////////////////////////////////////////////////////////////////////
#define MAXSOUND 100
#define MAXVOLUME 20
#define MAXBLUPI 100
#define WIN32_LEAN_AND_MEAN
class CSound
{
public:
CSound();
~CSound();
BOOL ErrorSomething();
BOOL Create(HWND hWnd);
void SetState(BOOL bState);
BOOL GetEnable();
void SetAudioVolume(int volume);
int GetAudioVolume();
void SetMidiVolume(int volume);
int GetMidiVolume();
void SetCDAudio(BOOL bCDAudio);
void CacheAll();
BOOL Cache(int channel, char *pFilename);
void Flush(int channel);
BOOL Play(int channel, int volume = 0, int pan = 0);
BOOL StopSound(int channel);
BOOL PlayImage(int channel, POINT pos, int rank = -1);
BOOL PlayMusic(HWND hWnd, int music);
BOOL RestartMusic();
void SuspendMusic();
void StopMusic();
BOOL IsPlayingMusic();
void AdaptVolumeMusic();
void SetSuspendSkip(int nb);
BOOL PlayCDAudio(HWND hWnd, int track);
protected:
BOOL CreateSoundBuffer(int dwBuf, DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample, DWORD dwBlkAlign, BOOL bStereo);
BOOL ReadData(LPDIRECTSOUNDBUFFER lpDSB, FILE* pFile, DWORD dwSize, DWORD dwPos);
BOOL CreateBufferFromWaveFile(int dwBuf, char *pFileName);
BOOL StopAllSounds();
BOOL PlaySoundDS(DWORD dwSound, DWORD dwFlags);
protected:
HWND m_hWnd;
BOOL m_bEnable;
BOOL m_bState;
BOOL m_bCDAudio;
LPDIRECTSOUND m_lpDS;
LPDIRECTSOUNDBUFFER m_lpDSB[MAXSOUND];
short m_channelBlupi[MAXBLUPI];
UINT m_MidiDeviceID;
int m_music;
char m_MIDIFilename[50];
int m_audioVolume;
int m_midiVolume;
int m_lastMidiVolume;
int m_nbSuspendSkip;
};

317
src/text.cpp Normal file

@ -0,0 +1,317 @@
// Text.cpp
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
#include "def.h"
#include "pixmap.h"
#include "text.h"
#include "texttables.h"
#pragma warning (disable: 4996)
/////////////////////////////////////////////////////////////////////////////
// Retourne l'offset pour un caract<63>re donn<6E>.
int GetOffset(char c)
{
int i;
static unsigned char table_accents[15] =
{
0xFC, 0xE0, 0xE2, 0xE9, 0xE8, 0xEB, 0xEA, 0xEF,
0xEE, 0xF4, 0xF9, 0xFB, 0xE4, 0xF6, 0xE7
};
for (i = 0; i < 15; i++)
{
if ( (unsigned char)c == table_accents[i] )
{
return 15+i;
}
}
if ( c<0 || c>128 ) return 1; // carr<72>
return c;
}
// Retourne la longueur d'un caract<63>re.
int GetCharWidth(char c, int font)
{
static unsigned char table_width[128] =
{
9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,8,
9,9,8,8,8,8,5,5,8,8,8,9,8,8,10,10,
5,6,9,13,11,12,12,6,6,6,12,12,5,9,6,9,
8,8,9,9,8,9,8,8,9,9,6,6,8,9,10,11,
12,8,9,9,9,8,8,8,9,4,8,9,8,10,9,9,
8,9,8,9,10,8,9,11,9,8,10,7,10,7,13,13,
9,9,8,8,8,8,6,8,8,4,6,8,4,12,8,8,
8,8,7,6,7,8,8,10,8,8,7,6,6,6,10,0,
};
static unsigned char table_width_little[128] =
{
6,6,6,6,6,6,6,6,6,6,6,6,5,6,6,7,
6,6,6,6,6,6,3,3,6,6,6,6,6,6,5,5,
3,3,5,8,5,11,9,3,4,4,6,6,3,4,3,6,
5,5,5,5,5,5,5,5,5,5,3,3,7,6,7,6,
9,8,6,7,7,5,5,8,7,2,4,7,5,10,7,8,
6,8,7,6,6,6,8,12,7,6,6,3,5,3,6,8,
4,6,6,6,6,6,4,6,6,2,3,5,2,10,6,6,
6,6,3,5,3,6,6,8,6,6,5,4,6,4,7,0,
};
if ( font == FONTLITTLE )
{
return table_width_little[GetOffset(c)];
}
else
{
return table_width[GetOffset(c)]-1;
}
}
// Affiche un texte.
void DrawText(CPixmap *pPixmap, POINT pos, char *pText, int font)
{
int rank;
if ( font == FONTLITTLE )
{
while ( *pText != 0 )
{
rank = GetOffset(*pText);
pPixmap->DrawIcon(-1, CHLITTLE, rank, pos);
pos.x += GetCharWidth(*pText++, font);
}
}
else
{
while ( *pText != 0 )
{
rank = GetOffset(*pText);
rank += 128*font;
pPixmap->DrawIcon(-1, CHTEXT, rank, pos);
pos.x += GetCharWidth(*pText++, font);
}
}
}
void DrawTextLeft(CPixmap* pPixmap, POINT pos, char *text, int font)
{
DrawText(pPixmap, pos, text, font);
return;
}
//Implement later
void DrawChar(CPixmap* pPixmap, POINT* pos, char c, int font)
{
POINT pos1;
int width;
UINT index;
index = (UINT)(BYTE)c;
}
void DrawCharSingle(CPixmap pPixmap, POINT pos, char* pText, int font)
{
if (font == FONTLITTLE)
{
pPixmap.DrawIcon(-1, CHLITTLE, (int)pText, pos, 0, FALSE);
return;
}
pPixmap.DrawIcon(-1, CHTEXT, (int)(pText + font * 128), pos, 0, FALSE);
return;
}
// Affiche un texte pench<63>.
void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText,
int pente, int font)
{
int rank, lg, rel, start;
start = pos.y;
rel = 0;
while ( *pText != 0 )
{
rank = GetOffset(*pText);
rank += 128*font;
pPixmap->DrawIcon(-1, CHTEXT, rank, pos);
lg = GetCharWidth(*pText++, font);
rel += lg;
pos.x += lg;
pos.y = start + rel/pente;
}
}
// Affiche un pav<61> de texte.
// Une ligne vide est affich<63>e avec un demi interligne !
// Si part != -1, n'affiche que les lignes qui commencent
// par "n|", avec n=part.
void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
int pente, int font, int part)
{
char text[100];
char* pDest;
int itl;
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while ( *pText != 0 )
{
pDest = text;
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
{
*pDest++ = *pText++;
}
*pDest = 0;
if ( *pText == '\r' ) pText ++; // saute '\r'
if ( *pText == '\n' ) pText ++; // saute '\n'
pDest = text;
if ( text[0] != 0 && text[1] == '|' ) // commence par "n|" ?
{
if ( part != -1 && part != text[0]-'0' ) continue;
pDest += 2; // saute "n|"
}
else
{
if ( part != -1 ) continue;
}
if ( pente == 0 )
{
DrawText(pPixmap, pos, pDest, font);
}
else
{
DrawTextPente(pPixmap, pos, pDest, pente, font);
}
if ( pDest[0] == 0 ) // ligne vide ?
{
pos.y += itl/2; // descend de 1/2 ligne
}
else
{
pos.y += itl; // passe <20> la ligne suivante
}
}
}
// Affiche un texte centr<74> pouvant <20>ventuellement
// contenir plusieurs lignes s<>par<61>es par des '\n'.
void DrawTextCenter(CPixmap *pPixmap, POINT pos, char *pText, int font)
{
char text[100];
char* pDest;
int itl;
POINT start;
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while ( *pText != 0 )
{
pDest = text;
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
{
*pDest++ = *pText++;
}
*pDest = 0;
if ( *pText == '\r' ) pText ++; // saute '\r'
if ( *pText == '\n' ) pText ++; // saute '\n'
pDest = text;
start.x = pos.x - GetTextWidth(pDest)/2;
start.y = pos.y;
DrawText(pPixmap, start, pDest, font);
if ( pDest[0] == 0 ) // ligne vide ?
{
pos.y += itl/2; // descend de 1/2 ligne
}
else
{
pos.y += itl; // passe <20> la ligne suivante
}
}
}
// Retourne la hauteur d'un texte.
int GetTextHeight(char *pText, int font, int part)
{
char text[100];
char* pDest;
int itl;
int h=0;
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while ( *pText != 0 )
{
pDest = text;
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
{
*pDest++ = *pText++;
}
*pDest = 0;
if ( *pText == '\r' ) pText ++; // saute '\r'
if ( *pText == '\n' ) pText ++; // saute '\n'
pDest = text;
if ( text[0] != 0 && text[1] == '|' ) // commence par "n|" ?
{
if ( part != -1 && part != text[0]-'0' ) continue;
pDest += 2; // saute "n|"
}
else
{
if ( part != -1 ) continue;
}
if ( pDest[0] == 0 ) // ligne vide ?
{
h += itl/2; // descend de 1/2 ligne
}
else
{
h += itl; // passe <20> la ligne suivante
}
}
return h;
}
// Retourne la longueur d'un texte.
int GetTextWidth(char *pText, int font)
{
int width = 0;
while ( *pText != 0 )
{
width += GetCharWidth(*pText++, font);
}
return width;
}

61
src/text.h Normal file

@ -0,0 +1,61 @@
// Text.h
#pragma once
#define FONTWHITE 0
#define FONTRED 1
#define FONTSLIM 2
#define FONTLITTLE 10
typedef struct
{
char charIcon;
char charOffsetX;
char charOffsetY;
char accentIcon;
char accentOffsetX;
char accentOffsetY;
}
CharOffset;
extern
void DrawText(CPixmap *pPixmap, POINT pos, char *pText, int font);
extern
void DrawTextLeft(CPixmap* pPixmap, POINT pos, char *text, int font);
extern
void DrawTextNew(CPixmap *pPixmap, POINT pos, char* pText, int font);
extern
void DrawChar(CPixmap* pPixmap, POINT pos, char* pText, double size);
extern
void DrawCharSingle(CPixmap* pPixmap, POINT pos, int rank, double size);
extern
void DrawTextNew(CPixmap* pPixmap, POINT pos, char* pText, int font);
extern
void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText,
int pente, int font=0);
extern
void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
int pente, int font=0, int part=-1);
extern
void DrawTextCenter(CPixmap *pPixmap, POINT pos, char *pText, int font=0);
extern
int GetTextHeight(char *pText, int font=0, int part=-1);
extern
int GetTextWidth(char *pText, int font=0);
extern
void DrawBignum(CPixmap *pPixmap, POINT pos, int num);
extern
int GetBignumWidth(int num);

553
text.cpp

@ -1,553 +0,0 @@
// Text.cpp
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
#include "def.h"
#include "pixmap.h"
#include "text.h"
#include "texttables.h"
/////////////////////////////////////////////////////////////////////////////
static CharProperties table_char[] =
{
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ ' ', 0, 0, -1, 0, 0 },
{ '!', 0, 0, -1, 0, 0 },
{ '"', 0, 0, -1, 0, 0 },
{ '#', 0, 0, -1, 0, 0 },
{ '$', 0, 0, -1, 0, 0 },
{ '%', 0, 0, -1, 0, 0 },
{ '&', 0, 0, -1, 0, 0 },
{ '\'', 0, 0, -1, 0, 0 },
{ '(', 0, 0, -1, 0, 0 },
{ ')', 0, 0, -1, 0, 0 },
{ '*', 0, 0, -1, 0, 0 },
{ '+', 0, 0, -1, 0, 0 },
{ ',', 0, 0, -1, 0, 0 },
{ '-', 0, 0, -1, 0, 0 },
{ '.', 0, 0, -1, 0, 0 },
{ '/', 0, 0, -1, 0, 0 },
{ '0', 0, 0, -1, 0, 0 },
{ '1', 0, 0, -1, 0, 0 },
{ '2', 0, 0, -1, 0, 0 },
{ '3', 0, 0, -1, 0, 0 },
{ '4', 0, 0, -1, 0, 0 },
{ '5', 0, 0, -1, 0, 0 },
{ '6', 0, 0, -1, 0, 0 },
{ '7', 0, 0, -1, 0, 0 },
{ '8', 0, 0, -1, 0, 0 },
{ '9', 0, 0, -1, 0, 0 },
{ ':', 0, 0, -1, 0, 0 },
{ ';', 0, 0, -1, 0, 0 },
{ '<', 0, 0, -1, 0, 0 },
{ '=', 0, 0, -1, 0, 0 },
{ '>', 0, 0, -1, 0, 0 },
{ '?', 0, 0, -1, 0, 0 },
{ '@', 0, 0, -1, 0, 0 },
{ 'A', 0, 0, -1, 0, 0 },
{ 'B', 0, 0, -1, 0, 0 },
{ 'C', 0, 0, -1, 0, 0 },
{ 'D', 0, 0, -1, 0, 0 },
{ 'E', 0, 0, -1, 0, 0 },
{ 'F', 0, 0, -1, 0, 0 },
{ 'G', 0, 0, -1, 0, 0 },
{ 'H', 0, 0, -1, 0, 0 },
{ 'I', 0, 0, -1, 0, 0 },
{ 'J', 0, 0, -1, 0, 0 },
{ 'K', 0, 0, -1, 0, 0 },
{ 'L', 0, 0, -1, 0, 0 },
{ 'M', 0, 0, -1, 0, 0 },
{ 'N', 0, 0, -1, 0, 0 },
{ 'O', 0, 0, -1, 0, 0 },
{ 'P', 0, 0, -1, 0, 0 },
{ 'Q', 0, 0, -1, 0, 0 },
{ 'R', 0, 0, -1, 0, 0 },
{ 'S', 0, 0, -1, 0, 0 },
{ 'T', 0, 0, -1, 0, 0 },
{ 'U', 0, 0, -1, 0, 0 },
{ 'V', 0, 0, -1, 0, 0 },
{ 'W', 0, 0, -1, 0, 0 },
{ 'X', 0, 0, -1, 0, 0 },
{ 'Y', 0, 0, -1, 0, 0 },
{ 'Z', 0, 0, -1, 0, 0 },
{ '[', 0, 0, -1, 0, 0 },
{ '\\', 0, 0, -1, 0, 0 },
{ ']', 0, 0, -1, 0, 0 },
{ '^', 0, 0, -1, 0, 0 },
{ '_', 0, 0, -1, 0, 0 },
{ '`', 0, 0, -1, 0, 0 },
{ 'a', 0, 0, -1, 0, 0 },
{ 'b', 0, 0, -1, 0, 0 },
{ 'c', 0, 0, -1, 0, 0 },
{ 'd', 0, 0, -1, 0, 0 },
{ 'e', 0, 0, -1, 0, 0 },
{ 'f', 0, 0, -1, 0, 0 },
{ 'g', 0, 0, -1, 0, 0 },
{ 'h', 0, 0, -1, 0, 0 },
{ 'i', 0, 0, -1, 0, 0 },
{ 'j', 0, 0, -1, 0, 0 },
{ 'k', 0, 0, -1, 0, 0 },
{ 'l', 0, 0, -1, 0, 0 },
{ 'm', 0, 0, -1, 0, 0 },
{ 'n', 0, 0, -1, 0, 0 },
{ 'o', 0, 0, -1, 0, 0 },
{ 'p', 0, 0, -1, 0, 0 },
{ 'q', 0, 0, -1, 0, 0 },
{ 'r', 0, 0, -1, 0, 0 },
{ 's', 0, 0, -1, 0, 0 },
{ 't', 0, 0, -1, 0, 0 },
{ 'u', 0, 0, -1, 0, 0 },
{ 'v', 0, 0, -1, 0, 0 },
{ 'w', 0, 0, -1, 0, 0 },
{ 'x', 0, 0, -1, 0, 0 },
{ 'y', 0, 0, -1, 0, 0 },
{ 'z', 0, 0, -1, 0, 0 },
{ '{', 0, 0, -1, 0, 0 },
{ '|', 0, 0, -1, 0, 0 },
{ '}', 0, 0, -1, 0, 0 },
{ '~', 0, 0, -1, 0, 0 },
{ 0x7f, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 0x05, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 0x04, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 0x10, 0, 0, -1, 0, 0 },
{ 'a', 0, 0, 2, 2, 0 },
{ 0x11, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 0x1b, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 0x1d, 0, 0, -1, 0, 0 },
{ 0x13, 0, 0, -1, 0, 0 },
{ 0x12, 0, 0, -1, 0, 0 },
{ 0x15, 0, 0, -1, 0, 0 },
{ 0x14, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 'i', 0, 0, 2, -1, 0 },
{ 0x17, 0, 0, -1, 0, 0 },
{ 0x16, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 'n', 0, 0, '~', -1, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 'o', 0, 0, 2, 1, 0 },
{ 0x18, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 0x1c, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 0x19, 0, 0, -1, 0, 0 },
{ 'u', 0, 0, 2, 2, 0 },
{ 0x1a, 0, 0, -1, 0, 0 },
{ 0x0f, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 },
{ 1, 0, 0, -1, 0, 0 }
};
// Retourne l'offset pour un caractère donné.
int GetOffset(char c)
{
int i;
static unsigned char table_accents[15] =
{
0xFC, 0xE0, 0xE2, 0xE9, 0xE8, 0xEB, 0xEA, 0xEF,
0xEE, 0xF4, 0xF9, 0xFB, 0xE4, 0xF6, 0xE7
};
for ( i=0 ; i<15 ; i++ )
{
if ( (unsigned char)c == table_accents[i] )
{
return 15+i;
}
}
if ( c<0 || c>128 ) return 1; // carr<72>
return c;
}
// Retourne la longueur d'un caract<63>re.
int GetCharWidthB(char c, int font)
{
static unsigned char table_width[128] =
{
9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,8,
9,9,8,8,8,8,5,5,8,8,8,9,8,8,10,10,
5,6,9,13,11,12,12,6,6,6,12,12,5,9,6,9,
8,8,9,9,8,9,8,8,9,9,6,6,8,9,10,11,
12,8,9,9,9,8,8,8,9,4,8,9,8,10,9,9,
8,9,8,9,10,8,9,11,9,8,10,7,10,7,13,13,
9,9,8,8,8,8,6,8,8,4,6,8,4,12,8,8,
8,8,7,6,7,8,8,10,8,8,7,6,6,6,10,0,
};
static unsigned char table_width_little[128] =
{
6,6,6,6,6,6,6,6,6,6,6,6,5,6,6,7,
6,6,6,6,6,6,3,3,6,6,6,6,6,6,5,5,
3,3,5,8,5,11,9,3,4,4,6,6,3,4,3,6,
5,5,5,5,5,5,5,5,5,5,3,3,7,6,7,6,
9,8,6,7,7,5,5,8,7,2,4,7,5,10,7,8,
6,8,7,6,6,6,8,12,7,6,6,3,5,3,6,8,
4,6,6,6,6,6,4,6,6,2,3,5,2,10,6,6,
6,6,3,5,3,6,6,8,6,6,5,4,6,4,7,0,
};
if ( font == FONTLITTLE )
{
return table_width_little[GetOffset(c)];
}
else
{
return table_width[GetOffset(c)]-1;
}
}
void DrawCharSingle(CPixmap *pPixmap, POINT pos, char *pText, int font)
{
if (font == FONTLITTLE)
{
pPixmap->DrawIcon(-1, CHLITTLE, *pText, pos, 0, FALSE);
}
else
{
pPixmap->DrawIcon(-1, CHTEXT, *pText + font * 128, pos, 0, FALSE);
}
}
void DrawChar(CPixmap *pPixmap, POINT *pos, char c, int font)
{
POINT pos2 { table_char[c].charOffsetX + pos->x, table_char[c].charOffsetY + pos->y };
DrawCharSingle(pPixmap, pos2, &table_char[c].charIcon, font);
if (table_char[c].accentIcon != -1)
{
pos2 = { table_char[c].accentOffsetX + pos->x, table_char[c].accentOffsetY + pos->y };
DrawCharSingle(pPixmap, pos2, &table_char[c].accentIcon, font);
}
pos->x += GetCharWidthB(c, font);
}
void DrawTextLeft(CPixmap *pPixmap, POINT pos, char *pText, int font)
{
DrawText(pPixmap, pos, pText, font);
}
// Affiche un texte.
void DrawText(CPixmap *pPixmap, POINT pos, char *pText, int font)
{
while (*pText != 0)
{
DrawChar(pPixmap, &pos, *pText++, font);
}
}
// Affiche un texte penché.
void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText,
int pente, int font)
{
int rank, lg, rel, start;
start = pos.y;
rel = 0;
while (*pText != 0)
{
rank = GetOffset(*pText);
rank += 128 * font;
pPixmap->DrawIcon(-1, CHTEXT, rank, pos);
lg = GetCharWidthB(*pText++, font);
rel += lg;
pos.x += lg;
pos.y = start + rel / pente;
}
}
// Affiche un pavé de texte.
// Une ligne vide est affichée avec un demi interligne !
// Si part != -1, n'affiche que les lignes qui commencent
// par "n|", avec n=part.
void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
int pente, int font, int part)
{
char text[100];
char* pDest;
int itl;
if (font == FONTLITTLE) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while (*pText != 0)
{
pDest = text;
while (*pText != 0 && *pText != '\r' && *pText != '\n')
{
*pDest++ = *pText++;
}
*pDest = 0;
if (*pText == '\r') pText++; // saute '\r'
if (*pText == '\n') pText++; // saute '\n'
pDest = text;
if (text[0] != 0 && text[1] == '|') // commence par "n|" ?
{
if (part != -1 && part != text[0] - '0') continue;
pDest += 2; // saute "n|"
}
else
{
if (part != -1) continue;
}
if (pente == 0)
{
DrawText(pPixmap, pos, pDest, font);
}
else
{
DrawTextPente(pPixmap, pos, pDest, pente, font);
}
if (pDest[0] == 0) // ligne vide ?
{
pos.y += itl / 2; // descend de 1/2 ligne
}
else
{
pos.y += itl; // passe à la ligne suivante
}
}
}
// Affiche un texte centré pouvant éventuellement
// contenir plusieurs lignes séparées par des '\n'.
void DrawTextCenter(CPixmap *pPixmap, POINT pos, char *pText, int font)
{
char text[100];
char* pDest;
int itl;
POINT start;
if (font == FONTLITTLE) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while (*pText != 0)
{
pDest = text;
while (*pText != 0 && *pText != '\r' && *pText != '\n')
{
*pDest++ = *pText++;
}
*pDest = 0;
if (*pText == '\r') pText++; // saute '\r'
if (*pText == '\n') pText++; // saute '\n'
pDest = text;
start.x = pos.x - GetTextWidth(pDest) / 2;
start.y = pos.y;
DrawText(pPixmap, start, pDest, font);
if (pDest[0] == 0) // ligne vide ?
{
pos.y += itl / 2; // descend de 1/2 ligne
}
else
{
pos.y += itl; // passe à la ligne suivante
}
}
}
// Retourne la hauteur d'un texte.
int GetTextHeight(char *pText, int font, int part)
{
char text[100];
char* pDest;
int itl;
int h = 0;
if (font == FONTLITTLE) itl = DIMLITTLEY;
else itl = DIMTEXTY;
while (*pText != 0)
{
pDest = text;
while (*pText != 0 && *pText != '\r' && *pText != '\n')
{
*pDest++ = *pText++;
}
*pDest = 0;
if (*pText == '\r') pText++; // saute '\r'
if (*pText == '\n') pText++; // saute '\n'
pDest = text;
if (text[0] != 0 && text[1] == '|') // commence par "n|" ?
{
if (part != -1 && part != text[0] - '0') continue;
pDest += 2; // saute "n|"
}
else
{
if (part != -1) continue;
}
if (pDest[0] == 0) // ligne vide ?
{
h += itl / 2; // descend de 1/2 ligne
}
else
{
h += itl; // passe à la ligne suivante
}
}
return h;
}
// Retourne la longueur d'un texte.
int GetTextWidth(char *pText, int font)
{
int width = 0;
while (*pText != 0)
{
width += GetCharWidthB(*pText++, font);
}
return width;
}

49
text.h

@ -1,49 +0,0 @@
// Text.h
#pragma once
#define FONTWHITE 0
#define FONTRED 1
#define FONTSLIM 2
#define FONTLITTLE 10
typedef struct
{
char charIcon;
char charOffsetX;
char charOffsetY;
char accentIcon;
char accentOffsetX;
char accentOffsetY;
}
CharProperties;
extern
void DrawCharSingle(CPixmap *pPixmap, POINT pos, char *pText, int font);
extern
void DrawChar(CPixmap *pPixmap, POINT *pos, char c, int font);
extern
void DrawTextLeft(CPixmap *pPixmap, POINT pos, char *pText, int font);
extern
void DrawText(CPixmap *pPixmap, POINT pos, char *pText, int font = 0);
extern
void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText,
int pente, int font = 0);
extern
void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
int pente, int font = 0, int part = -1);
extern
void DrawTextCenter(CPixmap *pPixmap, POINT pos, char *pText, int font = 0);
extern
int GetTextHeight(char *pText, int font = 0, int part = -1);
extern
int GetTextWidth(char *pText, int font = 0);

@ -0,0 +1,68 @@
# JUMMY WAS HERE
# extract phase table from speedy blupi 2.2 english ver
import sys
import io
offset = 0x3d400
outs = []
with io.open('BLUPI.exe', 'rb') as f:
data = f.read()
outs.append('static Phase table[] =')
outs.append('{')
for i in range(39):
poff = offset + i * 7084
p = int.from_bytes(data[poff : poff + 4], 'little')
if p == 0:
outs.append('{0}')
break
outs.append('{')
outs.append(str(p) + ',')
outs.append('"' + data[poff + 4 : poff + 36].decode('ascii').rstrip('\x00') + '",')
outs.append('TRUE,' if int.from_bytes(data[poff + 36 : poff + 40], 'little') != 0 else 'FALSE,')
outs.append('TRUE,' if int.from_bytes(data[poff + 40 : poff + 44], 'little') != 0 else 'FALSE,')
outs.append('{')
for j in range(40):
boff = poff + 44 + j * 176
b = int.from_bytes(data[boff : boff + 4], 'little')
if b == 0:
outs.append('{0}')
break
else:
outs.append('{')
outs.append(str(b) + ',')
s = ''
s += str(int.from_bytes(data[boff + 4 : boff + 8], 'little')) + ', '
m = int.from_bytes(data[boff + 8 : boff + 12], 'little')
if m == 0:
s += '{0},'
else:
s += '{' + str(m) + ', '
for k in range(m):
moff = boff + 12 + k * 4
s += str(int.from_bytes(data[moff : moff + 4], 'little')) + ', '
s += '},'
outs.append(str(s))
outs.append(str(int.from_bytes(data[boff + 88 : boff + 92], 'little')) + ', ' + str(int.from_bytes(data[boff + 92 : boff + 96], 'little')) + ',')
s = ''
t = int.from_bytes(data[boff + 96 : boff + 100], 'little')
if t == 0:
s += '{0}'
else:
s += '{ ' + str(t) + ', '
for k in range(t):
toff = boff + 100 + k * 4
s += str(int.from_bytes(data[toff : toff + 4], 'little')) + ', '
s += '}'
outs.append(str(s))
outs.append('},')
outs.append('},')
outs.append('},')
outs.append('},')
outs.append('};')
with io.open('out.h', 'wb') as f2:
f2.write(bytearray('\n'.join(outs), 'ascii'))

31
util/extract_pixtables.py Normal file

@ -0,0 +1,31 @@
# JUMMY WAS HERE
# extract pixtables from speedy blupi 2.2 english ver
import sys
import io
offsets = {}
offsets['table_icon_blupi'] = 0x81bf8
offsets['table_icon_element'] = 0x84070
offsets['table_icon_explo'] = 0x84e00
offsets['table_icon_object'] = 0x82bc0
outs = {}
with io.open('BLUPI.exe', 'rb') as f:
data = f.read()
for k, v in offsets.items():
lg = int.from_bytes(data[v : v + 2], 'little')
outs[k] = []
outs[k].append("extern short " + k + "[]{");
outs[k].append(str(lg) + ',');
for i in range(lg):
string = ''
for j in range(6):
string += str(int.from_bytes(data[v + i*12 + j*2 + 2 : v + i*12 + j*2 + 4], 'little')) + ','
if j % 2 == 1:
string += ' '
outs[k].append(string)
outs[k].append('};')
with io.open('out.h', 'wb') as f2:
f2.write(bytearray(('\n\n'.join(['\n'.join(w) for w in [v for _, v in outs.items()]])), 'ascii'))