1
0
mirror of https://github.com/jummy0/sb2-decomp synced 2025-03-14 20:23:30 +01:00
This commit is contained in:
jummy 2024-08-31 23:22:24 -05:00
parent cdb3010957
commit 19a0234c74
41 changed files with 13286 additions and 22128 deletions

View File

@ -74,9 +74,11 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>dxsdk3\sdk\inc</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE</UndefinePreprocessorDefinitions>
<PrecompiledHeaderFile />
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
@ -84,6 +86,7 @@
<AdditionalOptions>/FORCE:MULTIPLE /DYNAMICBASE "legacy_stdio_definitions.lib" %(AdditionalOptions) /VERBOSE</AdditionalOptions>
<AdditionalLibraryDirectories>dxsdk3\sdk\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<TreatLinkerWarningAsErrors>false</TreatLinkerWarningAsErrors>
<AdditionalDependencies>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|Win32'">
@ -95,6 +98,7 @@
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>dxsdk3\sdk\inc</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -111,6 +115,7 @@
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>dxsdk3\sdk\inc</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -127,6 +132,7 @@
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>dxsdk3\sdk\inc</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>UNICODE;_UNICODE</UndefinePreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@ -157,9 +163,13 @@
<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\dectables.cpp" />
<ClCompile Include="src\event.cpp" />
<ClCompile Include="src\jauge.cpp" />
<ClCompile Include="src\menu.cpp" />
@ -172,21 +182,18 @@
<ClCompile Include="src\wave.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\action.h" />
<ClInclude Include="src\actions.h" />
<ClInclude Include="src\button.h" />
<ClInclude Include="src\ddutil.h" />
<ClInclude Include="src\decmove.h" />
<ClInclude Include="src\decor.h" />
<ClInclude Include="src\dectables.h" />
<ClInclude Include="src\def.h" />
<ClInclude Include="src\event.h" />
<ClInclude Include="src\fifo.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\resource.h" />
<ClInclude Include="src\resource1.h" />

View File

@ -80,9 +80,6 @@
<ClCompile Include="src\decor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\dectables.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="src\event.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -113,6 +110,21 @@
<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\button.h">
@ -121,9 +133,6 @@
<ClInclude Include="src\ddutil.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\decmove.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\decor.h">
<Filter>Source Files</Filter>
</ClInclude>
@ -136,9 +145,6 @@
<ClInclude Include="src\event.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\fifo.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\jauge.h">
<Filter>Source Files</Filter>
</ClInclude>
@ -169,18 +175,15 @@
<ClInclude Include="src\wave.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\action.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\actions.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\resource.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\resource1.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="src\obstacle.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="resource\IDR_MAINFRAME.ico">

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<RemoteDebuggerServerName>KAYLABARKS-PC:4027</RemoteDebuggerServerName>
<RemoteDebuggerDebuggerType>NativeOnly</RemoteDebuggerDebuggerType>
<DeploymentDirectory>C:\BlupiDebug\Debug</DeploymentDirectory>
<RemoteDebuggerDeployCppRuntime>true</RemoteDebuggerDeployCppRuntime>
<RemoteDebuggerCommand>C:\BlupiDebug\Debug\Speedy Eggbert 2 Source.exe</RemoteDebuggerCommand>
<RemoteDebuggerWorkingDirectory>C:\BlupiDebug\Debug</RemoteDebuggerWorkingDirectory>
</PropertyGroup>
</Project>

Binary file not shown.

BIN
resource/cursor1.cur Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

View File

@ -1,16 +0,0 @@
extern
BOOL Action(short action, short direct,
short &phase, short &step,
short &channel, short &icon, POINT &pos, short &posZ,
short &sound);
extern
BOOL Rotate (short &icon, short direct);
extern
int GetIconDirect(short icon);
extern
int GetAmplitude(short action);

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
#include <minwindef.h>
// #include <minwindef.h>
#include <windef.h>
#include "def.h"
#include "pixmap.h"

View File

@ -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:

781
src/decblock.cpp Normal file
View File

@ -0,0 +1,781 @@
// 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;
}
void CDecor::ModifDecor(POINT pos, int icon)
{
ModifDecor(pos, icon, TRUE);
}
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

655
src/decdesign.cpp Normal file
View File

@ -0,0 +1,655 @@
// 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
}
}
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
}
}
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
}
}
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
}
}
char* CDecor::GetMissionTitle()
{
return m_missionTitle;
}
void CDecor::SetMissionTitle(char *str)
{
strcpy(m_missionTitle, str);
}

49
src/decio.cpp Normal file
View 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::CurrentWrite(int gamer, int mission, BOOL bUser)
{
return FALSE; //TODO
}
BOOL CDecor::CurrentRead(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::Read(int gamer, int mission, BOOL *pbMission, BOOL *pbPrivate)
{
return FALSE; //TODO
}
BOOL CDecor::Write(int gamer, int mission, char* param3)
{
return FALSE; //TODO
}

2213
src/decmove.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +0,0 @@
#pragma once
short* GetListMoves(int rank);
short* GetListIcons(int rank);

197
src/decnet.cpp Normal file
View File

@ -0,0 +1,197 @@
// 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_netUnk3[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::NetFUN_15d50()
{
}
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--;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,21 +0,0 @@
#pragma once
extern int table_shield_blupi[]
{
144,
145,
146,
147,
148,
149,
150,
151,
266,
267,
268,
269,
270,
271,
272,
273
};

File diff suppressed because it is too large Load Diff

1602
src/def.h

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,6 @@
#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;
@ -65,40 +53,6 @@ typedef struct
}
DemoEvent;
typedef enum
{
cheat_cleanall = 2,
cheat_funskate = 6,
cheat_givecopter = 7,
cheat_jeepdrive = 8,
cheat_alltreasure = 9,
cheat_endgoal = 10,
cheat_roundshield = 12,
cheat_quicklollipop = 13,
cheat_tenbombs = 14,
cheat_birdlime = 15,
cheat_drivetank = 16,
cheat_powercharge = 17,
cheat_hidedrink = 18,
cheat_iovercraft = 22,
cheat_udynamite = 23,
cheat_wellkeys = 24
}
cheat;
typedef enum
{
KEY_NONE,
KEY_LEFT,
KEY_RIGHT,
KEY_UP,
KEY_DOWN,
KEY_JUMP,
INPUT_DOWN,
INPUT_UP,
KEY_FIRE
};
class CEvent
{
public:
@ -108,7 +62,7 @@ public:
void OutputNetDebug(const char* str);
POINT GetMousePos();
void Create(HINSTANCE hInstance, HWND hWnd, CPixmap *pPixmap, CDecor *pDecor, CSound *pSound, CMovie *pMovie, CNetwork *pNetwork);
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();
@ -133,13 +87,14 @@ public:
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 SomethingDecor();
BOOL IsMouseRelease();
void NetSetPause(BOOL bPause, int players);
void NetSendLobby();
@ -230,7 +185,7 @@ protected:
BOOL NetEnumSessions();
int NetSearchPlayer(DPID dpid);
void NetStartPlay();
void NetSend(NetMessageType message, USHORT data);
void NetSend(int message, USHORT data);
void NetDraw();
void ChatSend();
void HandleChatBuffer();
@ -260,7 +215,7 @@ protected:
BOOL m_bSchool;
BOOL m_bPrivate;
BOOL m_bMulti;
BOOL m_bAccessBuild;
BOOL m_bBuildOfficialMissions;
BOOL m_bFullScreen;
int m_mouseType;
HWND m_hWnd;
@ -270,7 +225,7 @@ protected:
CMovie* m_pMovie;
CNetwork* m_pNetwork;
char m_movieToStart[MAX_PATH];
WMessage m_phaseAfterMovie;
int m_phaseAfterMovie;
CButton m_buttons[MAXBUTTON];
int m_lastFloor[MAXBUTTON];
int m_lastObject[MAXBUTTON];

View File

@ -1,33 +0,0 @@
#pragma once
typedef struct
{
long pos;
long dist;
}
Element;
class CPileTriee
{
private:
long m_taille;
long m_max;
long m_out;
Element* m_data;
public:
CPileTriee(long taille);
~CPileTriee();
void put(long pos, long dist);
long get();
};

View File

@ -8,7 +8,7 @@ using namespace std;
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
#include <minwindef.h>
// #include <minwindef.h>
#include <windef.h>
#include "def.h"
#include "pixmap.h"
@ -75,7 +75,7 @@ void CJauge::Draw()
}
int num = m_level * 114 / 100;
*(char*)num2 = (124) << 64;
*(char*)num2 = (124) / 64;
rect.bottom = 22;
rect.left = LOWORD(num2);
rect.top = HIWORD(num2);

View File

@ -1,19 +1,11 @@
// Jauge.h
using namespace std;
#pragma once
//////////////////////////////////////////////////////////////////////////
#include <minwindef.h>
#include <stdio.h>
#include <stdlib.h>
#include <windef.h>
#include <Windows.h>
#include "decor.h"
#pragma once
#define WIN32_LEAN_AND_MEAN
// #include <minwindef.h>
#include "pixmap.h"
#include "sound.h"
class CJauge
{

View File

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

View File

@ -1,9 +1,8 @@
// misc.h
//
#pragma once
#include <stdio.h>
#include <minwindef.h>
using namespace std;
// #include <minwindef.h>
extern void InitHInstance(HINSTANCE hInstance);
extern void OutputDebug(const char *pMessage);
@ -14,9 +13,9 @@ 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);

View File

@ -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);

View File

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

View File

@ -57,7 +57,7 @@ BOOL CNetwork::EnumProviders()
if (!m_providers.list) return FALSE;
if (DirectPlayEnumerate((LPDPENUMDPCALLBACK)EnumProvidersCallback, &m_providers) != DP_OK)
if (DirectPlayEnumerate((LPDPENUMDPCALLBACKA)EnumProvidersCallback, &m_providers) != DP_OK)
{
FreeProviderList();
return FALSE;

View File

@ -9,8 +9,6 @@
#define MAXSESSION 100
#define MAXPLAYERS 4
#define _CRT_SECURE_NO_WARNINGS_GLOBALS
#define WIN32_LEAN_AND_MEAN
typedef struct
{
@ -38,26 +36,6 @@ typedef struct
}
NamedGUIDList;
typedef struct
{
BYTE messageType;
BYTE data1;
short x;
short y;
short channel;
}
NetMessage;
typedef enum
{
MESS_RESUME,
MESS_PAUSE,
MESS_START,
MESS_LEAVE,
MESS_LOST,
}
NetMessageType;
class CNetwork
{
public:

589
src/obstacle.h Normal file
View 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
};

View File

@ -311,85 +311,68 @@ 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 (g_nbIconPackObject <= rank) return;
rect.left = g_iconPackObject[rank].pos.x;
rect.top = g_iconPackObject[rank].pos.y;
rect.right = rect.left + g_iconPackObject[rank].size.x;
rect.bottom = rect.top + g_iconPackObject[rank].size.y;
pos.x += g_iconPackObject[rank].offset.x;
pos.y += g_iconPackObject[rank].offset.y;
}
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 (g_nbIconPackElement <= rank) return;
rect.left = g_iconPackElement[rank].pos.x;
rect.top = g_iconPackElement[rank].pos.y;
rect.right = rect.left + g_iconPackElement[rank].size.x;
rect.bottom = rect.top + g_iconPackElement[rank].size.y;
pos.x += g_iconPackElement[rank].offset.x;
pos.y += g_iconPackElement[rank].offset.y;
}
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 (g_nbIconPackBlupi <= rank) return;
rect.left = g_iconPackBlupi[rank].pos.x;
rect.top = g_iconPackBlupi[rank].pos.y;
rect.right = rect.left + g_iconPackBlupi[rank].size.x;
rect.bottom = rect.top + g_iconPackBlupi[rank].size.y;
pos.x += g_iconPackBlupi[rank].offset.x;
pos.y += g_iconPackBlupi[rank].offset.y;
}
else if (channel == CHEXPLO)
{
if (g_nbIconPackExplo <= rank) return;
rect.left = g_iconPackExplo[rank].pos.x;
rect.top = g_iconPackExplo[rank].pos.y;
rect.right = rect.left + g_iconPackExplo[rank].size.x;
rect.bottom = rect.top + g_iconPackExplo[rank].size.y;
pos.x += g_iconPackExplo[rank].offset.x;
pos.y += g_iconPackExplo[rank].offset.y;
}
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)
{
@ -1139,12 +1122,12 @@ BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor,
int CPixmap::Benchmark()
{
struct _timeb tstruct;
timeb tstruct;
int i, j, t1, t2, time;
RECT rect;
POINT dest;
_ftime(&tstruct);
ftime(&tstruct);
t1 = tstruct.millitm;
for (j = 0; j < 10; j++)
@ -1165,7 +1148,7 @@ int CPixmap::Benchmark()
}
}
_ftime(&tstruct);
ftime(&tstruct);
t2 = tstruct.millitm;
if (t1 > t2) t2 += 1000;
@ -1231,7 +1214,7 @@ void CPixmap::SetClipping(RECT clip)
// Retourne la r<>gion de clipping.
RECT CPixmap::GetClipping(RECT* rect)
RECT CPixmap::GetClipping()
{
return m_clipRect;
}
@ -1256,7 +1239,7 @@ BOOL CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos,
if (channel == CHOBJECT)
{
if (g_objectMax <= rank)
if (g_nbIconPackObject <= rank)
{
return FALSE;
}
@ -1264,16 +1247,13 @@ BOOL CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos,
}
else if (channel == CHELEMENT)
{
if (g_elementMax <= rank) {
if (g_nbIconPackElement <= rank) {
return FALSE;
}
}
else if (channel == CHBLUPI ||
channel == CHBLUPI1 ||
channel == CHBLUPI2 ||
channel == CHBLUPI3)
else if (IsBlupiChannel(channel))
{
if (g_blupiMax <= rank)
if (g_nbIconPackBlupi <= rank)
{
return FALSE;
}
@ -1292,7 +1272,7 @@ BOOL CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos,
if (rank < 0 || rank >= nbx * nby) return FALSE;
}
}
if (g_exploMax <= rank) return FALSE;
if (g_nbIconPackExplo <= rank) return FALSE;
if ( channel < 0 || channel >= MAXIMAGE ) return FALSE;
if ( m_lpDDSurface[channel] == NULL ) return FALSE;
@ -1958,3 +1938,7 @@ void CPixmap::MouseHotSpot()
}
static inline BOOL IsBlupiChannel(int channel)
{
return channel == CHBLUPI || channel == CHBLUPI1 || channel == CHBLUPI2 || channel == CHBLUPI3;
}

View File

@ -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
#define DIRECTDRAW_VERSION 0x0500 // ????????????
class CPixmap
{
@ -39,7 +37,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);
@ -125,4 +123,6 @@ protected:
POINT m_totalDim[MAXIMAGE];
POINT m_iconDim[MAXIMAGE];
DDBLTFX m_DDbltfx;
};
};
static inline BOOL IsBlupiChannel(int channel);

View File

@ -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

View File

@ -3,7 +3,7 @@
#include <dsound.h>
#include <stdio.h>
#include <mciapi.h>
//#include <mciapi.h>
#include "sound.h"
#include "misc.h"
#include "def.h"
@ -25,19 +25,19 @@ using namespace std;
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
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
};
@ -47,189 +47,189 @@ struct WaveHeader
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;
PCMWAVEFORMAT pcmwf;
DSBUFFERDESC dsbdesc;
// 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;
// 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;
TRY_DS(m_lpDS->CreateSoundBuffer(&dsbdesc, &m_lpDSB[dwBuf], NULL), 63)
return TRUE;
// 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;
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)
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;
}
}
// 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;
// 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;
}
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 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;
}
}
// 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;
}
// Unlock data in buffer
rval = lpDSB->Unlock(pData1, dwData1Size, pData2, dwData2Size);
if (rval != DS_OK)
{
return FALSE;
}
return TRUE;
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;
// 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;
}
// 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;
// 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;
// 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;
}
// Create the sound buffer for the wave file
if (!CreateSoundBuffer(dwBuf, dwSize, wavHdr.dwSRate,
wavHdr.BitsPerSample, wavHdr.wBlkAlign, bStereo))
{
// Close the file
fclose(pFile);
// Read the data for the wave file into the sound buffer
if ( !ReadData(m_lpDSB[dwBuf], pFile, dwSize, sizeof(wavHdr)) )
{
fclose(pFile);
return FALSE;
}
return FALSE;
}
// Close out the wave file
fclose(pFile);
// Read the data for the wave file into the sound buffer
if (!ReadData(m_lpDSB[dwBuf], pFile, dwSize, sizeof(wavHdr)))
{
fclose(pFile);
return FALSE;
}
return TRUE;
// 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));
// 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())
}
}
}
if ((dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
{
TRY_DS(m_lpDSB[i]->Stop())
}
}
}
return TRUE;
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 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));
// 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));
}
}
if ((dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING)
{
// Play the sound
TRY_DS(m_lpDSB[dwSound]->Play(0, 0, dwFlags));
}
}
return TRUE;
return TRUE;
}
@ -271,20 +271,20 @@ void InitMidiVolume(int volume)
0xFFFFFFFF,
};
if ( volume < 0 ) volume = 0;
if ( volume > MAXVOLUME ) volume = MAXVOLUME;
if (volume < 0) volume = 0;
if (volume > MAXVOLUME) volume = MAXVOLUME;
nb = midiOutGetNumDevs();
for ( i=0 ; i<nb ; i++ )
for (i = 0; i<nb; i++)
{
result = midiOutOpen((LPHMIDIOUT)&hmo, i, 0L, 0L, 0L);
if ( result != MMSYSERR_NOERROR )
if (result != MMSYSERR_NOERROR)
{
continue;
}
result = midiOutSetVolume(hmo, table[volume]);
if ( result != MMSYSERR_NOERROR )
if (result != MMSYSERR_NOERROR)
{
n = 1;
}
@ -302,24 +302,24 @@ void InitMidiVolume(int volume)
CSound::CSound()
{
int i;
m_bEnable = FALSE;
m_bState = FALSE;
m_MidiDeviceID = 0;
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_audioVolume = 20;
m_midiVolume = 15;
m_lastMidiVolume = 0;
m_nbSuspendSkip = 0;
m_lpDS = NULL;
for ( i=0 ; i<MAXSOUND ; i++ )
for (i = 0; i<MAXSOUND; i++)
{
m_lpDSB[i] = NULL;
}
for ( i=0 ; i<MAXBLUPI ; i++ )
for (i = 0; i<MAXBLUPI; i++)
{
m_channelBlupi[i] = -1;
}
@ -331,21 +331,21 @@ CSound::~CSound()
{
int i;
if ( m_bEnable )
if (m_bEnable)
{
InitMidiVolume(15); // remet un volume moyen !
}
for ( i=0 ; i<MAXSOUND ; i++ )
for (i = 0; i<MAXSOUND; i++)
{
if ( m_lpDSB[i] != NULL )
if (m_lpDSB[i] != NULL)
{
//? m_lpDSB[i]->Release();
m_lpDSB[i]= NULL;
//? m_lpDSB[i]->Release();
m_lpDSB[i] = NULL;
}
}
if ( m_lpDS != NULL )
if (m_lpDS != NULL)
{
m_lpDS->Release();
m_lpDS = NULL;
@ -357,7 +357,7 @@ CSound::~CSound()
BOOL CSound::Create(HWND hWnd)
{
if ( !DirectSoundCreate(NULL, &m_lpDS, NULL) == DS_OK )
if (!DirectSoundCreate(NULL, &m_lpDS, NULL) == DS_OK)
{
OutputDebug("Fatal error: DirectSoundCreate\n");
m_bEnable = FALSE;
@ -366,7 +366,7 @@ BOOL CSound::Create(HWND hWnd)
m_lpDS->SetCooperativeLevel(hWnd, DSSCL_NORMAL);
m_bEnable = TRUE;
m_hWnd = hWnd;
m_hWnd = hWnd;
return TRUE;
}
@ -396,7 +396,7 @@ void CSound::SetAudioVolume(int volume)
int CSound::GetAudioVolume()
{
if ( !m_bEnable ) return 0;
if (!m_bEnable) return 0;
return m_audioVolume;
}
@ -407,7 +407,7 @@ void CSound::SetMidiVolume(int volume)
int CSound::GetMidiVolume()
{
if ( !m_bEnable ) return 0;
if (!m_bEnable) return 0;
return m_midiVolume;
}
@ -419,27 +419,27 @@ void CSound::CacheAll()
int i;
char name[50];
if ( !m_bEnable ) return;
if (!m_bEnable) return;
for ( i=0 ; i<MAXSOUND ; i++ )
for (i = 0; i<MAXSOUND; i++)
{
sprintf(name, "sound\\sound%.3d.blp", i);
if ( !Cache(i, name) ) break;
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_bEnable) return FALSE;
if (channel < 0 || channel >= MAXSOUND) return FALSE;
if ( m_lpDSB[channel] != NULL )
if (m_lpDSB[channel] != NULL)
{
Flush(channel);
}
return CreateBufferFromWaveFile(channel, pFilename);
}
@ -447,13 +447,13 @@ BOOL CSound::Cache(int channel, char *pFilename)
void CSound::Flush(int channel)
{
if ( !m_bEnable ) return;
if ( channel < 0 || channel >= MAXSOUND ) return;
if (!m_bEnable) return;
if (channel < 0 || channel >= MAXSOUND) return;
if ( m_lpDSB[channel] != NULL )
if (m_lpDSB[channel] != NULL)
{
m_lpDSB[channel]->Release();
m_lpDSB[channel]= NULL;
m_lpDSB[channel] = NULL;
}
}
@ -464,16 +464,16 @@ void CSound::Flush(int channel)
BOOL CSound::Play(int channel, int volume, int pan)
{
if ( !m_bEnable ) return TRUE;
if ( !m_bState || m_audioVolume == 0 ) return TRUE;
if (!m_bEnable) return TRUE;
if (!m_bState || m_audioVolume == 0) return TRUE;
volume -= (MAXVOLUME-m_audioVolume)*((10000/4)/MAXVOLUME);
volume -= (MAXVOLUME - m_audioVolume)*((10000 / 4) / MAXVOLUME);
//? if ( volume == -10000 ) return TRUE;
if ( volume <= -10000/4 ) return TRUE;
//? 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;
if (channel < 0 || channel >= MAXSOUND) return FALSE;
if (m_lpDSB[channel] == NULL) return FALSE;
m_lpDSB[channel]->SetVolume(volume);
m_lpDSB[channel]->SetPan(pan);
@ -482,7 +482,7 @@ BOOL CSound::Play(int channel, int volume, int pan)
return TRUE;
}
BOOL CSound::StopSound(Sound channel)
BOOL CSound::StopSound(int channel)
{
if (m_bEnable) return FALSE;
if (m_bState || m_audioVolume == 0) return FALSE;
@ -506,10 +506,10 @@ BOOL CSound::PlayImage(int channel, POINT pos, int rank)
{
int stopCh, volumex, volumey, volume, pan;
if ( rank >= 0 && rank < MAXBLUPI )
if (rank >= 0 && rank < MAXBLUPI)
{
stopCh = m_channelBlupi[rank];
if ( stopCh >= 0 && m_lpDSB[stopCh] != NULL )
if (stopCh >= 0 && m_lpDSB[stopCh] != NULL)
{
m_lpDSB[stopCh]->Stop(); // stoppe le son pr<70>c<EFBFBD>dent
m_lpDSB[stopCh]->SetCurrentPosition(0);
@ -518,35 +518,35 @@ BOOL CSound::PlayImage(int channel, POINT pos, int rank)
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;
//? 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 )
if (pos.x < 0)
{
volumex = (pos.x*2500)/LXIMAGE;
volumex = (pos.x * 2500) / LXIMAGE;
}
if ( pos.x > LXIMAGE )
if (pos.x > LXIMAGE)
{
pos.x -= LXIMAGE;
volumex = (-pos.x*2500)/LXIMAGE;
volumex = (-pos.x * 2500) / LXIMAGE;
}
if ( volumex < -10000 ) volumex = -10000;
if (volumex < -10000) volumex = -10000;
volumey = 0; // volume maximum
if ( pos.y < 0 )
if (pos.y < 0)
{
volumey = (pos.y*2500)/LYIMAGE;
volumey = (pos.y * 2500) / LYIMAGE;
}
if ( pos.y > LYIMAGE )
if (pos.y > LYIMAGE)
{
pos.y -= LYIMAGE;
volumey = (-pos.y*2500)/LYIMAGE;
volumey = (-pos.y * 2500) / LYIMAGE;
}
if ( volumey < -10000 ) volumey = -10000;
if (volumey < -10000) volumey = -10000;
if ( volumex < volumey ) volume = volumex;
if (volumex < volumey) volume = volumex;
else volume = volumey;
return Play(channel, volume, pan);
@ -563,30 +563,30 @@ BOOL CSound::PlayMusic(HWND hWnd, LPSTR lpszMIDIFilename)
DWORD dwReturn;
char string[MAX_PATH];
if ( !m_bEnable ) return TRUE;
if ( m_midiVolume == 0 ) return TRUE;
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..." ?
if (lpszMIDIFilename[1] == ':') // nom complet "D:\REP..." ?
{
strcpy(string, lpszMIDIFilename);
}
else
{
GetCurrentDir(string, MAX_PATH-30);
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;
mciOpenParms.lpstrDeviceType = "sequencer";
mciOpenParms.lpstrElementName = string;
dwReturn = mciSendCommand(NULL,
MCI_OPEN,
MCI_OPEN_TYPE|MCI_OPEN_ELEMENT,
(DWORD)(LPVOID)&mciOpenParms);
if ( dwReturn != 0 )
MCI_OPEN,
MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,
(DWORD)(LPVOID)&mciOpenParms);
if (dwReturn != 0)
{
OutputDebug("PlayMusic-1\n");
mciGetErrorStringA(dwReturn, string, 128);
@ -601,10 +601,10 @@ BOOL CSound::PlayMusic(HWND hWnd, LPSTR lpszMIDIFilename)
// Begin playback.
mciPlayParms.dwCallback = (DWORD)hWnd;
dwReturn = mciSendCommand(m_MidiDeviceID,
MCI_PLAY,
MCI_NOTIFY,
(DWORD)(LPVOID)&mciPlayParms);
if ( dwReturn != 0 )
MCI_PLAY,
MCI_NOTIFY,
(DWORD)(LPVOID)&mciPlayParms);
if (dwReturn != 0)
{
OutputDebug("PlayMusic-2\n");
mciGetErrorStringA(dwReturn, string, 128);
@ -623,9 +623,9 @@ BOOL CSound::PlayMusic(HWND hWnd, LPSTR lpszMIDIFilename)
BOOL CSound::RestartMusic()
{
OutputDebug("RestartMusic\n");
if ( !m_bEnable ) return TRUE;
if ( m_midiVolume == 0 ) return TRUE;
if ( m_MIDIFilename[0] == 0 ) return FALSE;
if (!m_bEnable) return TRUE;
if (m_midiVolume == 0) return TRUE;
if (m_MIDIFilename[0] == 0) return FALSE;
return PlayMusic(m_hWnd, m_MIDIFilename);
}
@ -634,15 +634,15 @@ BOOL CSound::RestartMusic()
void CSound::SuspendMusic()
{
if ( !m_bEnable ) return;
if (!m_bEnable) return;
if ( m_nbSuspendSkip != 0 )
if (m_nbSuspendSkip != 0)
{
m_nbSuspendSkip --;
m_nbSuspendSkip--;
return;
}
if ( m_MidiDeviceID && m_midiVolume != 0 )
if (m_MidiDeviceID && m_midiVolume != 0)
{
mciSendCommand(m_MidiDeviceID, MCI_CLOSE, 0, NULL);
}
@ -668,7 +668,7 @@ BOOL CSound::IsPlayingMusic()
void CSound::AdaptVolumeMusic()
{
if ( m_midiVolume != m_lastMidiVolume )
if (m_midiVolume != m_lastMidiVolume)
{
InitMidiVolume(m_midiVolume);
m_lastMidiVolume = m_midiVolume;

View File

@ -6,41 +6,10 @@ using namespace std;
#pragma once
#include <windef.h>
#include <minwindef.h>
//
#include "dsound.h"
#include <stdio.h>
typedef enum
{
SOUND_3_JUMPEND,
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_41_RESSORT,
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
@ -51,52 +20,54 @@ Sound;
class CSound
{
public:
CSound();
~CSound();
CSound();
~CSound();
BOOL Create(HWND hWnd);
void SetState(BOOL bState);
BOOL GetEnable();
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 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);
void CacheAll();
BOOL Cache(int channel, char *pFilename);
void Flush(int channel);
BOOL Play (int channel, int volume=0, int pan=0);
BOOL StopSound(Sound 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);
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);
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;
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;
};

View File

@ -78,7 +78,7 @@ int GetCharWidth(char c, int font)
// Affiche un texte.
void DrawTextB(CPixmap *pPixmap, POINT pos, char *pText, int font)
void DrawText(CPixmap *pPixmap, POINT pos, char *pText, int font)
{
int rank;
@ -107,7 +107,7 @@ void DrawTextB(CPixmap *pPixmap, POINT pos, char *pText, int font)
void DrawTextLeft(CPixmap* pPixmap, POINT pos, char *text, int font)
{
DrawTextB(pPixmap, pos, text, font);
DrawText(pPixmap, pos, text, font);
return;
}
@ -196,7 +196,7 @@ void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
if ( pente == 0 )
{
DrawTextB(pPixmap, pos, pDest, font);
DrawText(pPixmap, pos, pDest, font);
}
else
{
@ -241,7 +241,7 @@ void DrawTextCenter(CPixmap *pPixmap, POINT pos, char *pText, int font)
pDest = text;
start.x = pos.x - GetTextWidth(pDest)/2;
start.y = pos.y;
DrawTextB(pPixmap, start, pDest, font);
DrawText(pPixmap, start, pDest, font);
if ( pDest[0] == 0 ) // ligne vide ?
{
@ -315,64 +315,3 @@ int GetTextWidth(char *pText, int font)
return width;
}
// Retourne la longueur d'un grand chiffre.
void GetBignumInfo(int num, int &start, int &lg)
{
static int table[11] =
{
0,53,87,133,164,217,253,297,340,382,426
};
start = table[num];
lg = table[num+1]-table[num];
}
// Affiche un grand nombre.
void DrawBignum(CPixmap *pPixmap, POINT pos, int num)
{
char string[10];
int i = 0;
int start, lg;
RECT rect;
sprintf(string, "%d", num);
rect.top = 0;
rect.bottom = 52;
while ( string[i] != 0 )
{
GetBignumInfo(string[i]-'0', start, lg);
rect.left = start;
rect.right = start+lg;
pPixmap->DrawPart(-1, CHBIGNUM, pos, rect);
pos.x += lg+4;
i ++;
}
}
// Retourne la longueur d'un grand nombre.
int GetBignumWidth(int num)
{
char string[10];
int i = 0;
int start, lg;
int width = -4;
sprintf(string, "%d", num);
while ( string[i] != 0 )
{
GetBignumInfo(string[i]-'0', start, lg);
width += lg+4;
i ++;
}
return width;
}

View File

@ -19,7 +19,7 @@ typedef struct
CharOffset;
extern
void DrawTextB(CPixmap *pPixmap, POINT pos, char *pText, int font);
void DrawText(CPixmap *pPixmap, POINT pos, char *pText, int font);
extern
void DrawTextLeft(CPixmap* pPixmap, POINT pos, char *text, int font);