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-08-16 21:47:08 -05:00
commit d433d7b3fa
19 changed files with 2462 additions and 520 deletions

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
@ -29,26 +29,26 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141_xp</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset>v140_xp</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
@ -73,13 +73,16 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<SDLCheck>false</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<TreatWChar_tAsBuiltInType>false</TreatWChar_tAsBuiltInType>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalOptions>/FORCE:MULTIPLE /DYNAMICBASE "legacy_stdio_definitions.lib" %(AdditionalOptions) </AdditionalOptions>
<AdditionalLibraryDirectories>./dxsdk3/sdk/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -96,6 +99,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>./dxsdk3/sdk/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -104,14 +108,11 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>
</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>
</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>./dxsdk3/sdk/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -128,9 +129,11 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>./dxsdk3/sdk/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="action.h" />
<ClInclude Include="button.h" />
<ClInclude Include="ddraw.h" />
<ClInclude Include="ddutil.h" />
@ -140,6 +143,7 @@
<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" />
@ -158,7 +162,6 @@
<ClCompile Include="blupi.cpp" />
<ClCompile Include="button.cpp" />
<ClCompile Include="ddutil.cpp" />
<ClCompile Include="decblupi.cpp" />
<ClCompile Include="decor.cpp" />
<ClCompile Include="event.cpp" />
<ClCompile Include="jauge.cpp" />
@ -172,7 +175,6 @@
<ClCompile Include="wave.cpp" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\..\Music\StringTable.rc" />
<ResourceCompile Include="Eggbert2.rc" />
</ItemGroup>
<ItemGroup>

View File

@ -98,9 +98,6 @@
<ClCompile Include="ddutil.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="decblupi.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="decor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -136,9 +133,6 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\..\..\Music\StringTable.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
<ResourceCompile Include="Eggbert2.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>

226
blupi.cpp
View File

@ -3,11 +3,21 @@
#define WIN32_LEAN_AND_MEAN
#pragma once
#pragma comment(lib, "winmm.lib")
using namespace std;
#include <windows.h>
#include <windowsx.h>
#include <stdlib.h>
#include <stdio.h>
#include <mmsystem.h>
#include <time.h>
#include <sys/timeb.h>
//#include <mmiscapi2.h>
#include <WinBase.h>
#include "def.h"
#include "resource.h"
#include "ddutil.h"
@ -22,6 +32,8 @@
#include "misc.h"
#include "network.h"
#pragma warning (disable : 4996)
// Define Globals
#define NAME "Blupi"
@ -54,10 +66,15 @@ int g_something;
MMRESULT g_updateTimer; // timer général
BOOL g_bActive = TRUE; // is application active ?
BOOL g_bTermInit = FALSE; // initialisation en cours
int g_timer;
int g_objectMax;
int g_elementMax;
int g_blupiMax;
int g_exploMax;
short g_object[6];
short g_element[6];
short g_blupiCh[6];
short g_explo[6];
UINT g_lastPhase = 999;
@ -239,9 +256,6 @@ void UpdateFrame(void)
{
int phase, term;
g_pEvent->ReadInput();
g_pEvent->ReadInput();
phase = g_pEvent->GetPhase();
if (phase == WM_PHASE_PLAY || phase == WM_PHASE_PLAYTEST || phase == WM_PHASE_BUILD)
@ -256,72 +270,79 @@ void UpdateFrame(void)
}
}
if (phase == WM_PHASE_INIT)
{
g_pEvent->DemoStep();
}
if (phase == WM_PHASE_PLAYMOVIE || phase == WM_PHASE_WINMOVIE || phase == WM_PHASE_WINMOVIEDESIGN || phase == WM_PHASE_WINMOVIEMULTI)
{
g_pEvent->MovieToStart();
}
if (phase == WM_PHASE_INSERT)
{
g_pEvent->TryInsert();
}
if (phase == WM_PHASE_PLAY)
{
term = g_pDecor->IsTerminated();
if (g_pEvent->IsPrivate())
if (phase == WM_PHASE_INIT)
{
if (term == -1)
{
g_pEvent->ChangePhase(WM_PHASE_HISTORY1);
return;
}
if (term != 0)
{
g_pEvent->ChangePhase(WM_PHASE_HELP);
return;
}
g_pEvent->DemoStep(); // d?marre ?v. d?mo automatique
}
else
if (phase == WM_PHASE_PLAYMOVIE || phase == WM_PHASE_WINMOVIE || WM_PHASE_WINMOVIEDESIGN || WM_PHASE_WINMOVIEMULTI)
{
if (g_pEvent->IsMulti())
g_pEvent->MovieToStart();
}
if (phase == WM_PHASE_INSERT)
{
g_pEvent->TryInsert();
}
if (phase == WM_PHASE_PLAY)
{
if (g_pEvent->IsPrivate() == FALSE)
{
if (term == -1) {
g_pEvent->ChangePhase(WM_PHASE_H0MOVIE);
return;
if (g_pEvent->IsMulti() == FALSE)
{
if (g_pDecor->IsTerminated() == -1)
{
g_pEvent->GetWorldGroup();
g_pEvent->SetLives(g_pDecor->GetNbVies());
g_pEvent->ChangePhase(WM_PHASE_LOST);
}
if (g_pDecor->IsTerminated() == -2)
{
g_pEvent->SetLives(g_pDecor->GetNbVies());
g_pEvent->ChangePhase(WM_PHASE_WINMOVIE);
}
if (0 < g_pDecor->IsTerminated())
{
g_pEvent->SetLives(g_pDecor->GetNbVies());
g_pEvent->SetMission(g_pDecor->IsTerminated());
g_pEvent->ChangePhase(WM_PHASE_PLAY);
}
}
if (term != 0) {
g_pEvent->ChangePhase(WM_PHASE_H2MOVIE);
return;
else
{
if (g_pDecor->IsTerminated() == -1)
{
g_pEvent->ChangePhase(WM_PHASE_WINm);
return;
}
if (g_pDecor->IsTerminated() != 0)
{
g_pEvent->ChangePhase(WM_PHASE_WINMOVIEm);
return;
}
}
}
else
{
if (term == -1) {
g_pEvent->GetWorldGroup(); // probably intended to be a variable assignment? wtf ghidra
g_pEvent->SetNbVies(g_pDecor->GetNbVies());
g_pEvent->ChangePhase(WM_PHASE_LOST);
if (g_pDecor->IsTerminated() == -1)
{
g_pEvent->ChangePhase(WM_PHASE_LOSTd);
return;
}
if (term == -2) {
g_pEvent->SetNbVies(g_pDecor->GetNbVies());
g_pEvent->ChangePhase(WM_PHASE_PLAYMOVIE);
}
if (term > 0) {
g_pEvent->SetNbVies(g_pDecor->GetNbVies());
g_pDecor->SetMission(term);
g_pEvent->ChangePhase(WM_PHASE_PLAY);
if (g_pDecor->IsTerminated() != 0)
{
g_pEvent->ChangePhase(WM_PHASE_WINMOVIEd);
return;
}
}
}
}
return;
}
// Incomplete
void SetDecor()
@ -329,6 +350,7 @@ void SetDecor()
RECT rect;
UINT phase;
POINT posMouse;
char test[12];
g_pPixmap->MouseBackClear();
posMouse = g_pEvent->GetLastMousePos();
@ -366,6 +388,7 @@ int Benchmark()
// Restitue le jeu après une activation en mode fullScreen.
BOOL RestoreGame()
{
if ( g_pPixmap == NULL ) return FALSE;
@ -434,14 +457,6 @@ LRESULT CALLBACK WindowProc (HWND hWnd, UINT message,
{
static HINSTANCE hInstance;
POINT mousePos, totalDim, iconDim;
#if 0
if ( message != WM_TIMER )
{
char s[100];
sprintf(s, "message=%d,%d\n", message, wParam);
OutputDebug(s);
}
#endif
// La touche F10 envoie un autre message pour activer
// le menu dans les applications Windows standard !
@ -605,6 +620,16 @@ LRESULT CALLBACK WindowProc (HWND hWnd, UINT message,
}
LPTIMECALLBACK TimerStep()
{
if (g_bActive && g_timer == 0)
{
g_timer = 1;
PostMessageA(g_hWnd, WM_UPDATE, 0, 0);
}
return NULL;
}
// Erreur dans DoInit.
@ -623,9 +648,54 @@ BOOL InitFail(char *msg, BOOL bDirectX)
return FALSE;
}
//[Space for SetTimer]
int Benchmark()
{
timeb time[6];
int num0;
int num;
int num2;
int num3;
int i;
short crap[6];
FILE* open;
int frame;
_MEMORYSTATUS buffer;
char file[100];
// Initialisation de l'application.
ftime(time);
num = (int)time;
frame = 10;
do
{
UpdateFrame();
SetDecor();
g_pPixmap->Display();
frame++;
} while (frame);
ftime(time);
i = (int)time;
num0 = HIWORD(crap) & 0xFFFF;
if (num0 < num)
{
num0 = num0 + 1000;
}
num3 = i - num0;
buffer.dwLength = 32;
GlobalMemoryStatus(&buffer);
sprintf(file, "CheckTime = %d\r\nMemory = %d", num3, buffer.dwTotalPhys);
if (fopen("data\\time.blp", "wb"))
{
fwrite(file, strlen(file), 1, fopen("data\\time.blp", "wb"));
fclose(fopen("data\\time.blp", "wb"));
}
return num3;
}
static BOOL DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
{
@ -714,14 +784,23 @@ static BOOL DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
g_pPixmap = new CPixmap;
if (g_pPixmap == NULL) return InitFail("New pixmap", TRUE);
g_pPixmap->SetBenchmarkSuccess(g_bBenchmarkSuccess);
totalDim.x = LXIMAGE;
totalDim.y = LYIMAGE;
if (!g_pPixmap->Create(g_hWnd, totalDim, g_bFullScreen, g_mouseType, g_bTrueColorBack, g_bTrueColorDecor))
return InitFail("Create pixmap", TRUE);
#if _INTRO
if (!g_pPixmap->CacheAll(TRUE, g_hWnd, g_bFullScreen, g_bTrueColor, g_bTrueColorDecor, g_mouseType, "intro1.blp", FALSE))
#else
if (!g_pPixmap->CacheAll(TRUE, g_hWnd, g_bFullScreen, g_bTrueColorBack, g_bTrueColorDecor, g_mouseType, "init.blp", FALSE))
#endif
OutputDebug("Image: init\n");
totalDim.x = LXIMAGE;
totalDim.y = LYIMAGE;
iconDim.x = 0;
iconDim.y = 0;
if (!g_pPixmap->CacheAll(TRUE, g_hWnd, g_bFullScreen, g_bTrueColor, g_bTrueColorDecor, g_mouseType, "init.blp", 0))
return FALSE;
OutputDebug("SavePalette\n");
g_pPixmap->SavePalette();
OutputDebug("InitSysPalette\n");
g_pPixmap->InitSysPalette();
g_pSound = new CSound;
if (g_pSound == NULL) return InitFail("New sound", TRUE);
@ -775,6 +854,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
MSG msg;
LPTIMECALLBACK timeStep;
if ( !DoInit(hInstance, lpCmdLine, nCmdShow) )
{
@ -782,13 +862,13 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
}
Benchmark();
timeSetEvent(g_timerInterval, g_timerInterval >> 2, (LPTIMECALLBACK)TimerStep, 0, 1);
g_hWnd = (HWND)timeSetEvent(g_timerInterval, (g_timerInterval + (g_timerInterval >> 31 & 3U)) >> 2, TimerStep(), 0, 1);
while ( TRUE )
while (TRUE)
{
if ( PeekMessage(&msg, NULL, 0,0, PM_NOREMOVE) )
if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if ( !GetMessage(&msg, NULL, 0, 0) )
if (!GetMessage(&msg, NULL, 0, 0))
{
return msg.wParam;
}

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"
@ -46,10 +46,7 @@ CButton::~CButton()
// Create a new Button
BOOL CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
POINT pos, int type, BOOL bMinimizeRedraw,
/*int *pMenu, int nbMenu,
int *pToolTips, int nbToolTips,
int region,*/ UINT message)
POINT pos, int type, BOOL bMinimizeRedraw, int region, UINT message)
{
POINT iconDim;
//int i, icon;
@ -382,7 +379,6 @@ BOOL CButton::MouseDown(POINT pos)
m_bRedraw = TRUE;
PostMessage(m_hWnd, WM_UPDATE, 0, 0);
m_pSound->PlayImage(SOUND_CLICK, pos);
return TRUE;
}

View File

@ -1,4 +1,4 @@
#include <minwindef.h>
//#include <minwindef.h>
#include <windef.h>
#include "decor.h"
#include "sound.h"
@ -8,17 +8,6 @@
using namespace std;
typedef struct
{
int message;
int type;
int iconMenu[20];
POINT pos;
int toolTips[20];
}
Button;
class CButton
{
public:
@ -26,10 +15,7 @@ public:
~CButton();
BOOL Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
POINT pos, int type, BOOL bMinimizeRedraw,
/*int *pMenu, int nbMenu,
int *pTooltips, int nbToolTips,
int region,*/ UINT message);
POINT pos, int type, BOOL bMinimizeRedraw, int region, UINT message);
void SetSomethingMenu(int somethingMenu);
void Draw();
void Redraw();

View File

@ -36,7 +36,7 @@ void DDSetDebug(BOOL bDebug)
* create a DirectDrawSurface from a bitmap resource.
*
*/
extern "C" IDirectDrawSurface * DDConnectBitmap(IDirectDraw *pdd, HBITMAP hbm)
extern IDirectDrawSurface * DDConnectBitmap(IDirectDraw *pdd, HBITMAP hbm)
{
BITMAP bm;
DDSURFACEDESC ddsd;
@ -77,7 +77,7 @@ extern "C" IDirectDrawSurface * DDConnectBitmap(IDirectDraw *pdd, HBITMAP hbm)
* create a DirectDrawSurface from a bitmap resource.
*
*/
extern "C" IDirectDrawSurface * DDLoadBitmap(IDirectDraw *pdd, LPCSTR szBitmap, int dx, int dy)
extern IDirectDrawSurface * DDLoadBitmap(IDirectDraw *pdd, LPCSTR szBitmap, int dx, int dy)
{
HBITMAP hbm;
BITMAP bm;
@ -175,7 +175,7 @@ HRESULT DDReLoadBitmap(IDirectDrawSurface *pdds, LPCSTR szBitmap)
* draw a bitmap into a DirectDrawSurface
*
*/
extern "C" HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int x, int y, int dx, int dy)
extern HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int x, int y, int dx, int dy)
{
HDC hdcImage;
HDC hdc;
@ -242,7 +242,7 @@ extern "C" HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int x, in
// if the resource does not exist or NULL is passed create a
// default 332 palette.
//
extern "C" IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap)
extern IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap)
{
IDirectDrawPalette* ddpal;
int i;
@ -267,7 +267,7 @@ extern "C" IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap)
//
// get a pointer to the bitmap resource.
//
if (szBitmap && (h = FindResourceA(NULL, szBitmap, RT_BITMAP)))
if (szBitmap && (h = FindResourceA(NULL, szBitmap, (LPCSTR)RT_BITMAP)))
{
if ( g_bDebug ) OutputDebug("DDLoadPalette -a\n");
lpbi = (LPBITMAPINFOHEADER)LockResource(LoadResource(NULL, h));
@ -346,7 +346,7 @@ extern "C" IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap)
* 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)
extern DWORD DDColorMatch(IDirectDrawSurface *pdds, COLORREF rgb)
{
COLORREF rgbT;
HDC hdc;
@ -397,7 +397,7 @@ extern "C" DWORD DDColorMatch(IDirectDrawSurface *pdds, COLORREF 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)
extern HRESULT DDSetColorKey(IDirectDrawSurface *pdds, COLORREF rgb)
{
DDCOLORKEY ddck;
@ -406,7 +406,7 @@ extern "C" HRESULT DDSetColorKey(IDirectDrawSurface *pdds, COLORREF rgb)
return pdds->SetColorKey(DDCKEY_SRCBLT, &ddck);
}
extern "C" HRESULT DDSetColorKey2(IDirectDrawSurface *pdds, COLORREF rgb1,
extern HRESULT DDSetColorKey2(IDirectDrawSurface *pdds, COLORREF rgb1,
COLORREF rgb2)
{
DDCOLORKEY ddck;

View File

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

File diff suppressed because it is too large Load Diff

31
event.h
View File

@ -4,10 +4,14 @@
/////////////////////////////////////////////////////////////////////////////
#pragma once
using namespace std;
#include "movie.h"
#include "menu.h"
#include "button.h"
#include "decor.h"
typedef struct
{
@ -95,7 +99,7 @@ public:
int GetState(int button);
void SetState(int button, int state);
BOOL GetEnable(int button);
void SetEnable(int button, BOOL bEnable);
void SetEnable(WMessage button, int bEnable);
void SetSomething(int button, int bSomething);
BOOL GetHide(int button);
void SetHide(int button, BOOL bHide);
@ -144,6 +148,13 @@ public:
void DebugDisplay(char m);
void IntroStep();
void SetLives(int lives);
void ReadAll();
BOOL SaveState(int rank);
void SomethingUserMissions(char* lpFilename, LPCSTR fileSomething);
BOOL AddPhaseText();
void ReadInput();
@ -168,13 +179,14 @@ public:
void PrivateLibelle();
BOOL ReadLibelle(int world, BOOL bSchool, BOOL bHelp);
BOOL WriteInfo();
BOOL WriteInfo(int gamer, char* playername);
BOOL ReadInfo(int gamer);
void TryPhase();
void UnTryPhase();
int GetTryPhase();
BOOL ReadPlayer();
void SetLives(int lives);
void PutTextInputBox(POINT pos);
void DemoRecStart();
void DemoRecStop();
@ -190,6 +202,8 @@ public:
void NetFUN_1d6b0(UINT message, USHORT data);
void NetDrawMap();
void ChatSend();
void HandleChatBuffer();
void ChatMessageSound(char* data);
void MouseRelease();
void MouseCapture();
@ -200,8 +214,10 @@ protected:
int m_exercice;
int m_mission;
char m_gamerName[100];
char m_gamerNameList[10][100];
void* m_somethingJoystick;
int m_menuIndex;
int m_fileIndex;
int m_menuDecor[10];
BOOL m_bMouseRelease;
int m_private;
@ -295,6 +311,9 @@ protected:
int m_lives;
int m_multi;
HINSTANCE m_hInstance;
char m_chatZone[100][5];
char m_chatZone[100][5];
char m_text[100];
};
};
extern
int DirectoryThing(LPCSTR filename);

4
menu.h
View File

@ -4,8 +4,10 @@
using namespace std;
#include <minwindef.h>
//#include <minwindef.h>
#include <windef.h>
#include "decor.h"
#include "pixmap.h"
//////////////////////////////////////////////////////////////////////

View File

@ -347,7 +347,7 @@ void TraceErrorDD(HRESULT hErr, const char *sFile, int nLine)
//
//----------------------------------------------------------------------
void TraceErrorDS(HRESULT hErr, char *sFile, int nLine)
void TraceErrorDS(HRESULT hErr, const char *sFile, int nLine)
{
char dserr[256];
char err[1024];

View File

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

View File

@ -1,6 +1,12 @@
// movie.h
//
#pragma once
using namespace std;
//#include <mciapi.h>
class CMovie
{
public:

View File

@ -5,12 +5,15 @@
#include <stdlib.h>
#include <stdio.h>
#include <ddraw.h>
#include <time.h>
#include <sys/timeb.h>
#include "def.h"
#include "pixmap.h"
#include "misc.h"
#include "ddutil.h"
#include "blupi.cpp"
#pragma comment(lib, "ddraw.lib")
/////////////////////////////////////////////////////////////////////////////
@ -125,6 +128,21 @@ BOOL CPixmap::Create(HWND hwnd, POINT dim,
DDSURFACEDESC ddsd;
HRESULT ddrval;
POINT pos;
HDC hdc;
hdc = CreateCompatibleDC(NULL);
if (hdc == NULL) {
bTrueColor = 0;
bTrueColorDecor = 0;
}
else {
ddrval = GetDeviceCaps(hdc, SIZEPALETTE);
if ((ddrval != 0) && (ddrval < 257)) {
bTrueColor = 0;
bTrueColorDecor = 0;
}
DeleteDC(hdc);
}
m_hWnd = hwnd;
m_bFullScreen = bFullScreen;
@ -174,7 +192,7 @@ BOOL CPixmap::Create(HWND hwnd, POINT dim,
// Set the video mode to 640x480x8.
if ( m_bFullScreen )
{
ddrval = m_lpDD->SetDisplayMode(dim.x, dim.y, 8);
ddrval = m_lpDD->SetDisplayMode(dim.x, dim.y, bTrueColor || bTrueColorDecor ? 16 : 8);
if ( ddrval != DD_OK )
{
OutputDebug("Fatal error: SetDisplayMode\n");
@ -278,24 +296,129 @@ BOOL CPixmap::Restore()
return TRUE;
}
/*
void HudIcon(int channel, int rank, POINT pos)
{
pos.x = (int)((double)pos.x + CPixmap::originX)
}
void CPixmap::QuickIcon(int channel, int rank, POINT pos)
{
RECT rect;
int num;
tagRECT rect;
if (channel == CHOBJECT)
{
rect.left = pos.x;
rect.top = pos.y;
rect.right = pos.x;
rect.bottom = pos.y;
};
DrawIcon(channel, rank, rect, 1.0, TRUE);
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];
}
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];
}
else if ((((channel == CHBLUPI) || (channel == CHBLUPI1)) || (channel == CHBLUPI2)) || (channel == CHBLUPI3))
{
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];
}
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)
{
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];
}
pos.y = pos.y + num;
LABEL_1:
num = m_clipRect.left;
if (pos.x < num)
{
num = num - pos.x;
pos.x = m_clipRect.left;
rect.left = rect.left + num;
}
num = (m_clipRect.right + rect.left) - pos.x;
if (num < rect.right)
{
rect.right = num;
}
num = m_clipRect.top;
if (pos.y < num)
{
num = num - pos.y;
pos.y = m_clipRect.top;
rect.top = 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))
{
while (num = (m_lpDDSBack->BltFast(pos.x, pos.y, m_lpDDSurface[channel], &rect, 1), num != 0))
{
if ((num == 0x7789FE3E) && (num = RestoreAll(), num != 0))
{
return;
}
if (num != 0x7789FE3E)
{
return;
}
}
}
return;
}
*/
// Initialise la palette syst<73>me.
@ -607,49 +730,14 @@ 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::Cache1(int channel, char *pFilename, POINT totalDim, BOOL bUsePalette)
{
POINT iconDim;
if (strstr(pFilename, "blupi") == pFilename)
{
return FALSE;
}
else
{
if (strstr(pFilename, "element") == pFilename)
{
return FALSE;
}
if (strstr(pFilename, "explo") == pFilename)
{
return FALSE;
}
if (strstr(pFilename, "object") == pFilename)
{
return FALSE;
}
return TRUE;
}
if (bUsePalette != 0)
{
//TODO: more
}
}
// Cache une image globale.
BOOL CPixmap::Cache2(int channel, char *pFilename, POINT totalDim, POINT iconDim,
BOOL CPixmap::Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim,
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)
{
@ -659,10 +747,10 @@ BOOL CPixmap::Cache2(int channel, char *pFilename, POINT totalDim, POINT iconDim
// Create and set the palette.
if (bUsePalette)
{
if (m_bDebug) OutputDebug("Use palette\n");
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;
}
@ -671,8 +759,8 @@ BOOL CPixmap::Cache2(int channel, char *pFilename, POINT totalDim, POINT iconDim
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)
{
@ -691,8 +779,8 @@ BOOL CPixmap::Cache2(int channel, char *pFilename, POINT totalDim, POINT iconDim
}
// 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)); // blanc
strcpy(m_filename[channel], pFilename);
@ -702,16 +790,89 @@ BOOL CPixmap::Cache2(int channel, char *pFilename, POINT totalDim, POINT iconDim
return TRUE;
}
BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor, BOOL bTrueColorDecor, int mouseType, char* pFilename, int region)
{
char filename[100];
// Cache une image provenant d'un bitmap.
// Probably not needed?
BOOL CPixmap::Cache(int channel, HBITMAP hbm, POINT totalDim)
{
if ( channel < 0 || channel >= MAXIMAGE ) return FALSE;
if ( m_lpDDSurface[channel] != NULL )
{
Flush(channel);
}
// Create the offscreen surface, by loading our bitmap.
m_lpDDSurface[channel] = DDConnectBitmap(m_lpDD, hbm);
if ( m_lpDDSurface[channel] == NULL )
{
OutputDebug("Fatal error: DDLoadBitmap\n");
return FALSE;
}
// Set the color key to white
DDSetColorKey(m_lpDDSurface[channel], RGB(255,255,255)); // blanc
m_totalDim[channel] = totalDim;
m_iconDim[channel] = totalDim;
return TRUE;
}
BOOL CPixmap::BackgroundCache(int channel, const char* pFilename, POINT totalDim, POINT iconDim, BOOL bUsePalette)
{
BOOL decor;
char file[100];
decor = strstr(pFilename, "blupi") != pFilename &&
strstr(pFilename, "element") != pFilename &&
strstr(pFilename, "explo") != pFilename &&
strstr(pFilename, "object") != pFilename;
if (bUsePalette)
{
goto LABEL1;
}
if (decor)
{
if (m_bTrueColor == FALSE)
{
if (decor) goto LABEL1;
if (m_bTrueColorDecor == FALSE) goto LABEL1;
}
}
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);
}
BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor, BOOL bTrueColorDecor, int mouseType, const char* pFilename, int region)
{
SetDebug(TRUE); //
char filename[100];
char image[12];
POINT totalDim;
POINT iconDim;
RECT rect;
POINT dim;
m_dim = dim;
totalDim.x = 640;
totalDim.y = 480;
iconDim.x = 0;
iconDim.y = 0;
dim.x = LXIMAGE;
dim.y = LYIMAGE;
if (cache == FALSE)
{
@ -728,8 +889,8 @@ BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor,
return FALSE;
}
OutputDebug("Image:_init\n");
if (Cache2(0, "init.blp", totalDim, iconDim, TRUE) == FALSE)
OutputDebug("Image: init\n");
if (BackgroundCache(0, "init.blp", totalDim, iconDim, TRUE) == FALSE)
{
return FALSE;
}
@ -738,104 +899,160 @@ BOOL CPixmap::CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor,
SavePalette();
OutputDebug("InitSysPalette\n");
InitSysPalette();
SetDebug(FALSE);
//SetDebug(FALSE);
if (cache == FALSE)
{
if (Cache2(0, pFilename, totalDim, iconDim, FALSE) == NULL)
if (BackgroundCache(0, pFilename, totalDim, iconDim, FALSE) == FALSE)
{
return NULL;
return FALSE;
}
}
else
{
*(char*)image = (LXIMAGE) << 64;
rect.bottom = LYIMAGE;
rect.left = LOWORD(image);
rect.top = HIWORD(image);
rect.right = HIWORD(image);
DrawImage(0, 0, rect, 1);
Display();
}
if (Cache2(CHOBJECT, "object.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHOBJECT, "object.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHOBJECT, RGB(0, 0, 255));
if (Cache2(CHBLUPI, "blupi000.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHBLUPI, "blupi000.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBLUPI, RGB(0, 0, 255));
if (Cache2(CHBLUPI1, "blupi001.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHBLUPI1, "blupi001.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBLUPI1, RGB(0, 0, 255));
if (Cache2(CHBLUPI2, "blupi002.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHBLUPI2, "blupi002.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBLUPI2, RGB(0, 0, 255));
if (Cache2(CHBLUPI3, "blupi003.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHBLUPI3, "blupi003.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBLUPI3, RGB(0, 0, 255));
if (Cache2(CHTEMP, "temp.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHTEMP, "temp.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHTEMP, RGB(0, 0, 255));
if (Cache2(CHMAP, "map.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHMAP, "map.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHMAP, RGB(0, 0, 255));
if (Cache2(CHELEMENT, "element.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHELEMENT, "element.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHELEMENT, RGB(0, 0, 255));
if (Cache2(CHEXPLO, "explo.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHEXPLO, "explo.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHEXPLO, RGB(0, 0, 255));
sprintf(filename, "decor%.3d.blp", region);
if (Cache2(CHDECOR, filename, totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHDECOR, filename, totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
if (Cache2(CHBUTTON, "button00.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHBUTTON, "button00.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHBUTTON, RGB(0, 0, 255));
if (Cache2(CHJAUGE, "jauge.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHJAUGE, "jauge.blp", totalDim, iconDim, FALSE) == FALSE)
{
return FALSE;
}
SetTransparent(CHJAUGE, RGB(0, 0, 255));
if (Cache2(CHTEXT, "text.blp", totalDim, iconDim, FALSE) == FALSE)
if (BackgroundCache(CHTEXT, "text.blp", totalDim, iconDim, FALSE) != FALSE)
{
return FALSE;
}
SetTransparent(CHTEXT, RGB(0, 0, 255));
if (Cache2(CHLITTLE, "little.blp", totalDim, iconDim, FALSE) == FALSE)
{
SetTransparent(CHLITTLE, RGB(0, 0, 255));
Benchmark();
return TRUE;
SetTransparent(CHTEXT, RGB(0, 0, 255));
if (BackgroundCache(CHLITTLE, "little.blp", totalDim, iconDim, FALSE) != FALSE)
{
SetTransparent(CHLITTLE, RGB(0, 0, 255));
Benchmark();
return TRUE;
}
}
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];
ftime(time);
num = (int)time;
num2 = 29;
num3 = 10;
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
{
pos.x = 13;
pos.y = 13;
QuickIcon(1, 1, pos);
num5--;
} while (num5);
ftime(time);
i = (int)time;
crap = 0;
num4 = crap & 0xFFFF;
if (num4 < num)
{
i = num4 + 100;
}
num6 = i - num;
sprintf(buffer, "Benchmark = %d\r\n", i - num);
file = fopen("data\\bench.blp", "wb");
if (fopen("data\\bench.blp", "wb"))
{
fwrite(buffer, strlen(buffer), 1, file);
fclose(file);
}
return num6;
}
void CPixmap::SetDebug(BOOL bDebug)
{
m_bDebug = bDebug;
DDSetDebug(bDebug);
}
// Purge une image.
@ -885,7 +1102,7 @@ void CPixmap::SetClipping(RECT clip)
// Retourne la r<>gion de clipping.
RECT CPixmap::GetClipping()
RECT CPixmap::GetClipping(RECT* rect)
{
return m_clipRect;
}
@ -894,73 +1111,7 @@ RECT CPixmap::GetClipping()
// Teste si un point fait partie d'une ic<69>ne.
//Rough rewritten code, might need improvement
BOOL CPixmap::IsIconPixel(int channel, int rank, POINT pos)
{
int nbx, nby;
COLORREF rgb;
HDC hDC;
if (channel == 1)
{
if (g_objectMax <= rank)
{
return;
}
}
else if (channel == 10)
{
if (g_elementMax <= rank)
{
return;
}
}
else if (channel == CHBLUPI || channel == CHBLUPI1 || channel == CHBLUPI2 || channel == CHBLUPI3)
{
if (g_blupiMax <= rank)
{
return;
}
}
else
{
if (channel != CHEXPLO)
{
if (rank < 0)
return;
}
if (rank < 0 || rank >= nbx * nby)
{
return;
}
if (g_exploMax <= rank)
{
return;
}
}
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;
pos.x += (rank%nbx)*m_iconDim[channel].x;
pos.y += (rank/nbx)*m_iconDim[channel].y;
if ( m_lpDDSurface[channel]->GetDC(&hDC) != DD_OK ) return FALSE;
rgb = GetPixel(hDC, pos.x, pos.y);
m_lpDDSurface[channel]->ReleaseDC(hDC);
if ( rgb == m_colorSurface[2*channel+0] ||
rgb == m_colorSurface[2*channel+1] ) return FALSE;
return TRUE;
}
// Dessine une partie d'image rectangulaire.
@ -980,6 +1131,7 @@ BOOL CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos,
{
return FALSE;
}
}
else if (channel == CHELEMENT)
{
@ -1001,6 +1153,9 @@ BOOL CPixmap::DrawIcon(int chDst, int channel, int rank, POINT pos,
{
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 ||

149
pixmap.h
View File

@ -1,57 +1,59 @@
// CPixmap.h
using namespace std;
#pragma once
#include <ddraw.h>
/////////////////////////////////////////////////////////////
#define MAXIMAGE 100
#define MAXIMAGE 100
class CPixmap
{
public:
CPixmap();
~CPixmap();
CPixmap();
~CPixmap();
BOOL CacheAll(BOOL _foo, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor,
BOOL bTrueColorDecor, int mouseType, char *_str, int _baz);
int Benchmark();
void SetDebug(BOOL bDebug);
BOOL Create(HWND hwnd, POINT dim, BOOL bFullScreen, BOOL bTrueColor,
BOOL bTrueColorDecor, int mouseType);
BOOL Flush();
BOOL Restore();
BOOL InitSysPalette();
BOOL GetTrueColor();
void SetBenchmarkSuccess(BOOL bSuccess);
void SetTrueColor(BOOL bTrueColor);
void SetTrueColorDecor(BOOL bTrueColorDecor);
BOOL FUN_28f60(int channel);
void SetDebug(BOOL bDebug);
BOOL IsPalette();
void Fill(RECT rect, COLORREF color);
BOOL Create(HWND hwnd, POINT dim, BOOL bFullScreen, int mouseType, BOOL bTrueColor, BOOL bTrueColorDecor);
BOOL Flush();
BOOL Restore();
BOOL InitSysPalette();
BOOL IsPalette();
void Fill(RECT rect, COLORREF color);
BOOL SavePalette();
BOOL RestorePalette();
int SearchColor(int red, int green, int blue);
BOOL Cache(int channel, char *pFilename, POINT totalDim, POINT iconDim, BOOL bUsePalette);
BOOL Cache(int channel, HBITMAP hbm, POINT totalDim);
BOOL BackgroundCache(int channel, const char* pFilename, POINT totalDim, POINT iconDim, BOOL bUsePalette);
BOOL CacheAll(BOOL cache, HWND hWnd, BOOL bFullScreen, BOOL bTrueColor, BOOL bTrueColorDecor, int mouseType, const char* pFilename, int region);
int Benchmark();
void Flush(int channel);
void SetTransparent(int channel, COLORREF color);
void SetTransparent2(int channel, COLORREF color1, COLORREF color2);
void SetClipping(RECT clip);
RECT GetClipping(RECT* rect);
void HudIcon(int channel, int rank, POINT pos);
void QuickIcon(int channel, int rank, POINT pos);
BOOL SavePalette();
BOOL RestorePalette();
int SearchColor(int red, int green, int blue);
BOOL BackgroundCache(int channel, char *pFilename, POINT totalDim, POINT iconDim, BOOL bUsePalette);
BOOL Cache2(int channel, char *pFilename, POINT totalDim, POINT iconDim, BOOL bUsePalette);
void Flush(int channel);
void SetTransparent(int channel, COLORREF color);
void SetTransparent2(int channel, COLORREF color1, COLORREF color2);
void SetClipping(RECT clip);
RECT GetClipping();
void QuickIcon(int channel, int rank, POINT pos);
BOOL IsIconPixel(int channel, int rank, POINT pos);
BOOL IsIconPixel(int channel, int rank, POINT pos);
BOOL DrawIcon(int chDst, int channel, int rank, POINT pos, 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);
void DrawChar(int rank, POINT pos, double size);
BOOL DrawIcon(int chDst, int channel, int rank, POINT pos, int mode=0, BOOL bMask=FALSE);
BOOL DrawIconDemi(int chDst, int channel, int rank, POINT pos, int mode=0, BOOL bMask=FALSE);
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 BuildIconMask(int channelMask, int rankMask,
int channel, int rankSrc, int rankDst);
BOOL Display();
void SetMousePosSprite(POINT pos, int sprite, BOOL bDemoPlay);
@ -66,7 +68,7 @@ protected:
HRESULT RestoreAll();
HRESULT BltFast(int chDst, int channel, POINT dst, RECT rcRect, int mode);
HRESULT BltFast(LPDIRECTDRAWSURFACE lpDD,
int channel, POINT dst, RECT rcRect, int mode);
int channel, POINT dst, RECT rcRect, int mode);
void MouseUpdate();
BOOL MouseQuickDraw(RECT rect);
@ -75,42 +77,49 @@ protected:
void MouseBackDebug();
RECT MouseRectSprite();
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_bTrueColorDecor;
BOOL m_field5_0x14; //Need to figure out
BOOL m_field5_0x18; //Need to figure out
int m_mouseType;
BOOL m_bDebug;
BOOL m_bPalette;
HWND m_hWnd;
POINT m_dim;
RECT m_clipRect;
BOOL m_bFullScreen;
BOOL m_bBenchmarkSuccess;
BOOL m_bTrueColor;
BOOL m_bTrueColorDecor;
BOOL m_field5_0x14; //Need to figure out
BOOL m_field5_0x18; //Need to figure out
int m_mouseType;
BOOL m_bDebug;
BOOL m_bPalette;
HWND m_hWnd;
POINT m_dim;
RECT m_clipRect;
double originX;
double originY;
POINT m_mousePos;
int m_mouseSprite;
POINT m_mouseHotSpot;
POINT m_mouseBackPos;
BOOL m_bMouseBack;
BOOL m_bMouseShow;
BOOL m_bBackDisplayed;
POINT m_mousePos;
int m_mouseSprite;
POINT m_mouseHotSpot;
POINT m_mouseBackPos;
BOOL m_bMouseBack;
BOOL m_bMouseShow;
BOOL m_bBackDisplayed;
LPDIRECTDRAW m_lpDD;
LPDIRECTDRAWSURFACE m_lpDDSPrimary;
LPDIRECTDRAWSURFACE m_lpDDSBack;
LPDIRECTDRAWSURFACE m_lpDDSMouse;
LPDIRECTDRAWPALETTE m_lpDDPal;
LPDIRECTDRAWSURFACE m_lpDDSurface[MAXIMAGE];
LPDIRECTDRAWCLIPPER m_lpClipper;
PALETTEENTRY m_pal[256];
PALETTEENTRY m_sysPal[256];
COLORREF m_colorSurface[2 * MAXIMAGE];
LPDIRECTDRAW m_lpDD;
LPDIRECTDRAWSURFACE m_lpDDSPrimary;
LPDIRECTDRAWSURFACE m_lpDDSBack;
LPDIRECTDRAWSURFACE m_lpDDSMouse;
LPDIRECTDRAWPALETTE m_lpDDPal;
LPDIRECTDRAWSURFACE m_lpDDSurface[MAXIMAGE];
LPDIRECTDRAWCLIPPER m_lpClipper;
PALETTEENTRY m_pal[256];
PALETTEENTRY m_sysPal[256];
COLORREF m_colorSurface[2*MAXIMAGE];
char m_filename[MAXIMAGE][20];
POINT m_totalDim[MAXIMAGE];
POINT m_iconDim[MAXIMAGE];
DDBLTFX m_DDbltfx;
};
char m_filename[MAXIMAGE][20];
POINT m_totalDim[MAXIMAGE];
POINT m_iconDim[MAXIMAGE];
DDBLTFX m_DDbltfx;
};

View File

@ -37,124 +37,85 @@
#define TX_ACTION_REPEAT 33
#define TX_ACTION_QARMURE 34
#define TX_ACTION_FABARMURE 35
#define TX_IONAMEEX 100
#define TX_IOFREE 101
#define IDR_MENU 102
#define TX_TERMMIN 102
#define TX_TERMMAX 103
#define TX_BUTTON_JOUER 104
#define TX_BUTTON_APPRENDRE 105
#define TX_BUTTON_QUITTER 106
#define TX_BUTTON_PREVP 107
#define TX_BUTTON_NEXTP 108
#define TX_BUTTON_PLAYP 109
#define TX_BUTTON_BUILDP 110
#define TX_BUTTON_TERM 111
#define TX_BUTTON_READP 112
#define TX_BUTTON_WRITEP 113
#define TX_BUTTON_CANCELP 114
#define TX_BUTTON_CONTP 115
#define TX_BUTTON_REPEAT 116
#define TX_BUTTON_BUTTON 117
#define TX_BUTTON_CTERM 118
#define TX_BUTTON_TERMC 119
#define TX_BUTTON_TERMHBLUPI 120
#define TX_BUTTON_TERMHPLANCHE 121
#define TX_BUTTON_TERMFIRE 122
#define TX_BUTTON_TERMDEC 123
#define TX_BUTTON_TERMINC 124
#define TX_PAUSE 125
#define TX_JAUGE1 126
#define TX_JAUGE2 127
#define TX_BUTTON_SETUP 128
#define TX_BUTTON_MUSIC 129
#define TX_BUTTON_SETUP1 130
#define TX_BUTTON_SETUP2 131
#define TX_BUTTON_SETUP3 132
#define TX_BUTTON_SETUP4 133
#define TX_BUTTON_MUSIC1 134
#define TX_BUTTON_MUSIC2 135
#define TX_BUTTON_MUSIC3 136
#define TX_BUTTON_MUSIC4 137
#define TX_BUTTON_MUSIC5 138
#define TX_BUTTON_MUSIC6 139
#define TX_BUTTON_MUSIC7 140
#define TX_BUTTON_MUSIC8 141
#define TX_BUTTON_MUSIC9 142
#define TX_BUTTON_MUSIC10 143
#define TX_BUTTON_REGION 144
#define TX_BUTTON_TERMMBLUPI 145
#define TX_BUTTON_TERMKILL 146
#define TX_TERM 147
#define TX_BUTTON 148
#define TX_MUSIC 149
#define TX_SCHOOL 150
#define TX_MISSION 151
#define TX_IONAMEMI 152
#define TX_BUTTON_TERMHTOMATE 153
#define TX_BUTTON_SETUP5 154
#define TX_BUTTON_SETUP6 155
#define TX_BUTTON_SETUP7 156
#define TX_BUTTON_SETUP8 157
#define TX_OUI 158
#define TX_NON 159
#define TX_BUTTON_SETUP9 160
#define TX_BUTTON_SETUP10 161
#define TX_INFO_SETUP1 162
#define TX_INFO_SETUP2 163
#define TX_INFO_SETUP3 164
#define TX_INFO_SETUP4 165
#define TX_INFO_SETUP5 166
#define TX_INFO_SETUP6 167
#define TX_INFO_SETUP7 168
#define TX_INFO_SETUP8 169
#define TX_INFO_SETUP9 170
#define TX_INFO_SETUP10 171
#define TX_INFO_SETUP10b 172
#define TX_INFO_NOSCROLL 173
#define TX_BUTTON_REGION1 174
#define TX_BUTTON_REGION2 175
#define TX_BUTTON_REGION3 176
#define TX_BUTTON_REGION4 177
#define TX_REGION 178
#define TX_BUTTON_PLAY_STOP 179
#define TX_BUTTON_PLAY_SETUP 180
#define TX_BUTTON_PLAY_WRITE 181
#define TX_INSERT 182
#define TX_BUTTON_PREVH 183
#define TX_BUTTON_NEXTH 184
#define TX_BUTTON_TERMHMETAL 185
#define TX_BUTTON_HELP 186
#define TX_HELP 187
#define TX_BUTTON_PRIVE 188
#define TX_PRIVATE 189
#define TX_IONAMEPR 190
#define TX_PRIVATE_HACHBLUPI 191
#define TX_PRIVATE_HACHPLANCHE 192
#define TX_PRIVATE_HACHTOMATE 193
#define TX_PRIVATE_HACHMETAL 194
#define TX_PRIVATE_STOPFIRE 195
#define TX_PRIVATE_HOMEBLUPI 196
#define TX_PRIVATE_KILLROBOTS 197
#define TX_BUTTON_UNDO 198
#define TX_DEMO_END1 199
#define TX_DEMO_END2 200
#define TX_DEMO_END3 201
#define TX_DEMO_END4 202
#define TX_FULL_END1 203
#define TX_FULL_END2 204
#define TX_FULL_END3 205
#define TX_FULL_END4 206
#define TX_PRIVATE_OBJECTIF 207
#define TX_PRIVATE_NBBLUPI 208
#define TX_BUTTON_SKILL 209
#define TX_SKILL1 210
#define TX_SKILL2 211
#define TX_BUTTON_DEMO 212
#define TX_DEMOREC 213
#define TX_DEMOPLAY 214
#define TX_BUTTON_TERMHROBOT 215
#define TX_PRIVATE_HACHROBOT 216
#define TX_IONAMEEX 100
#define TX_IOFREE 101
#define TX_OWNMISSION 102
#define TX_TESTMISSION 103
#define TX_BUTTON_JOUER 104
#define TX_BUTTON_APPRENDRE 105
#define TX_BUTTON_QUITTER 106
#define TX_BUTTON_PREVP 107
#define TX_BUTTON_NEXTP 108
#define TX_BUTTON_PLAYP 109
#define TX_BUTTON_BUILDP 110
#define TX_BUTTON_TERM 111
#define TX_BUTTON_READP 112
#define TX_BUTTON_WRITEP 113
#define TX_BUTTON_CANCELP 114
#define TX_BUTTON_CONTP 115
#define TX_BUTTON_REPEAT 116
#define TX_CHOOSEPLAYER 117
#define TX_PLAYERSNAME 118
#define TX_BUTTON_TERMC 119
#define TX_CHOOSESIZE 120
#define TX_BUTTON_HVSCROLL 121
#define TX_BUTTON_ONLYHSCROLL 122
#define TX_BUTTON_ONLYVSCROLL 123
#define TX_BUTTON_TESTMISSION 124
#define TX_PAUSE 125
#define TX_CLEARPLAYER 127
#define TX_SETTINGS 128
#define TX_BUTTON_SETUP1 130
#define TX_BUTTON_SETUP2 131
#define TX_BUTTON_SETUP3 132
#define TX_BUTTON_SETUP4 133
#define TX_BUTTON_REGION 144
#define TX_DISCARDGAME 145
#define TX_DESIGNMISSION 147
#define TX_CHOOSEGAMER 148
#define TX_MUSIC 149
#define TX_BUTTON_SETUP5 154
#define TX_BUTTON_SETUP6 155
#define TX_BUTTON_SETUP7 156
#define TX_BUTTON_SETUP8 157
#define TX_READINFO 167
#define TX_CONFIRM 174
#define TX_CANCEL 175
#define TX_YES 176
#define TX_NO 177
#define TX_REGION 178
#define TX_BUTTON_SETUP 180
#define TX_INSERT 182
#define TX_DELETEMISSION 184
#define TX_NONAME 187
#define TX_DESIGN 188
#define TX_MISSIONNUM 189
#define TX_SINGLEPLAYER 195
#define TX_MUTLIPLAYER 196
#define TX_GAMEPAUSE 197
#define TX_FULL_END1 203
#define TX_FULL_END2 204
#define TX_FULL_END3 205
#define TX_FULL_END4 206
#define TX_BUTTON_SKILL 209
#define TX_BUTTON_DEMO 212
#define TX_DEMOREC 213
#define TX_DEMOPLAY 214
#define TX_SHOWNEXT 241
#define TX_SHOWCONNECTION 242
#define TX_SHOWNEXT 245
#define TX_SHOWPREV 246
#define TX_GAMEJOIN 247
#define TX_CREATE_MULTIGAME 248
#define TX_UPDATELIST 249
#define TX_MULTI_CREATE 250
#define TX_MULTI_GNAME 251
#define TX_OPEN 264
#define TX_LOAD_CGAME 269
#define TX_SAVE_CGAME 270
#define TX_GAMESAVED 288
#define TX_NOTINDEMO 289
#define TX_REPEAT_CULTIVE 500
#define TX_REPEAT_FLEUR 501
#define TX_REPEAT_FLEURQ 502
@ -269,6 +230,7 @@
#define TX_LASTWIN2 3201
#define TX_LASTWIN3 3202
#define IDM_EXIT 40001
#define TX_BUTTON_CREATE 6900
// Next default values for new objects
//

View File

@ -3,11 +3,17 @@
#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;
/////////////////////////////////////////////////////////////////////////////
@ -60,7 +66,7 @@ BOOL CSound::CreateSoundBuffer(int dwBuf, DWORD dwBufSize, DWORD dwFreq, DWORD d
dsbdesc.dwBufferBytes = dwBufSize;
dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf;
TRY_DS(m_lpDS->CreateSoundBuffer(&dsbdesc, &m_lpDSB[dwBuf], NULL))
TRY_DS(m_lpDS->CreateSoundBuffer(&dsbdesc, &m_lpDSB[dwBuf], NULL), 63)
return TRUE;
}
@ -476,23 +482,19 @@ BOOL CSound::Play(int channel, int volume, int pan)
return TRUE;
}
BOOL CSound::StopSound(int channel, int volume, int pan)
BOOL CSound::StopSound(Sound channel)
{
if (m_bEnable) return FALSE;
if (m_bState || m_audioVolume == 0) return FALSE;
volume -= (MAXVOLUME - m_audioVolume) * ((10000 / 4) / MAXVOLUME);
if (0 < channel || channel < MAXSOUND)
{
if (m_lpDSB[channel] == NULL)
return;
return (BOOL)m_lpDSB[channel];
m_lpDSB[channel]->Stop();
m_lpDSB[channel]->SetCurrentPosition(0);
return TRUE;
}
m_lpDSB[channel]->SetVolume(volume);
m_lpDSB[channel]->SetPan(pan);
m_lpDSB[channel]->Play(0, 0, 0);
return FALSE;
}
@ -578,8 +580,8 @@ BOOL CSound::PlayMusic(HWND hWnd, LPSTR lpszMIDIFilename)
// Open the device by specifying the device and filename.
// MCI will attempt to choose the MIDI mapper as the output port.
mciOpenParms.lpstrDeviceType = "sequencer";
mciOpenParms.lpstrElementName = string;
mciOpenParms.lpstrDeviceType = (LPCWSTR)"sequencer";
mciOpenParms.lpstrElementName = (LPCWSTR)string;
dwReturn = mciSendCommand(NULL,
MCI_OPEN,
MCI_OPEN_TYPE|MCI_OPEN_ELEMENT,

35
sound.h
View File

@ -1,17 +1,50 @@
// sound.h
//
using namespace std;
#pragma once
#include <dsound.h>
#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
{

View File

@ -131,9 +131,8 @@ extern int table_width[]
0
};
// WindowsPhoneSpeedyBlupi.Text
// Token: 0x0400035A RID: 858
extern int table_char[]
extern char table_char[]
{
0,
0,