Cleanup
BIN
IDC_ARROW.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_ARROWD.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_ARROWDL.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_ARROWDR.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_ARROWL.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_ARROWR.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_ARROWU.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_ARROWUL.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_ARROWUR.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_EMPTY.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_FILL.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_MAP.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_POINTER.cur
Before Width: | Height: | Size: 326 B |
BIN
IDC_WAIT.cur
Before Width: | Height: | Size: 326 B |
Before Width: | Height: | Size: 766 B |
16
action.h
@ -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);
|
|
14
actions.h
@ -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;
|
|
888
blupi.cpp
@ -1,888 +0,0 @@
|
|||||||
// blupi.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
#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"
|
|
||||||
#include "pixmap.h"
|
|
||||||
#include "sound.h"
|
|
||||||
#include "decor.h"
|
|
||||||
#include "movie.h"
|
|
||||||
#include "button.h"
|
|
||||||
#include "menu.h"
|
|
||||||
#include "jauge.h"
|
|
||||||
#include "event.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "network.h"
|
|
||||||
|
|
||||||
#pragma warning (disable : 4996)
|
|
||||||
|
|
||||||
// Define Globals
|
|
||||||
|
|
||||||
#define NAME "Blupi"
|
|
||||||
#define TITLE "Eggbert"
|
|
||||||
#define MMTIMER TRUE
|
|
||||||
#define THREAD FALSE
|
|
||||||
|
|
||||||
// Variables Globals
|
|
||||||
|
|
||||||
HWND g_hWnd; // handle <20> la fen<65>tre
|
|
||||||
CEvent* g_pEvent = NULL;
|
|
||||||
CPixmap* g_pPixmap = NULL; // pixmap principal
|
|
||||||
CSound* g_pSound = NULL; // sound principal
|
|
||||||
CMovie* g_pMovie = NULL; // movie principal
|
|
||||||
CDecor* g_pDecor = NULL;
|
|
||||||
CNetwork* g_pNetwork;
|
|
||||||
char g_CDPath[MAX_PATH]; // chemin d'acc<63>s au CD-Rom
|
|
||||||
BOOL g_bFullScreen = FALSE; // FALSE si mode de test
|
|
||||||
int g_speedRate = 1;
|
|
||||||
int g_timerInterval = 50; // inverval = 50ms
|
|
||||||
int g_mouseType = MOUSETYPEGRA;
|
|
||||||
int g_benchmark;
|
|
||||||
BOOL g_bBenchmarkSuccess;
|
|
||||||
BOOL g_bTrueColor;
|
|
||||||
BOOL g_bTrueColorBack;
|
|
||||||
BOOL g_bTrueColorDecor;
|
|
||||||
MMRESULT g_updateTimer; // timer g<>n<EFBFBD>ral
|
|
||||||
BOOL g_bActive = TRUE; // is application active ?
|
|
||||||
BOOL g_bTermInit = FALSE; // initialisation en cours
|
|
||||||
int g_bTimer;
|
|
||||||
int g_nbTimer;
|
|
||||||
HANDLE g_hScreenMutex;
|
|
||||||
HANDLE g_hRunMutex;
|
|
||||||
HANDLE g_threadNr;
|
|
||||||
HANDLE g_hThread;
|
|
||||||
LPDWORD* g_threadID;
|
|
||||||
int g_objectMax;
|
|
||||||
int g_elementMax;
|
|
||||||
int g_blupiMax;
|
|
||||||
int g_exploMax[100];
|
|
||||||
short g_object[6];
|
|
||||||
short g_element[6];
|
|
||||||
short g_blupiCh[6];
|
|
||||||
short g_explo[6];
|
|
||||||
|
|
||||||
UINT g_lastPhase = 999;
|
|
||||||
|
|
||||||
int GetNum(char *p)
|
|
||||||
{
|
|
||||||
int n = 0;
|
|
||||||
|
|
||||||
while ( *p >= '0' && *p <= '9' )
|
|
||||||
{
|
|
||||||
n *= 10;
|
|
||||||
n += (*p++)-'0';
|
|
||||||
}
|
|
||||||
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL ReadConfig (LPSTR lpCmdLine)
|
|
||||||
{
|
|
||||||
FILE* file = NULL;
|
|
||||||
char buffer[200];
|
|
||||||
char* pText;
|
|
||||||
int nb;
|
|
||||||
int i;
|
|
||||||
_MEMORYSTATUS memstatus;
|
|
||||||
|
|
||||||
file = fopen("data\\config.def", "rb");
|
|
||||||
if ( file == NULL ) return FALSE;
|
|
||||||
nb = fread(buffer, sizeof(char), 200-1, file);
|
|
||||||
buffer[nb] = 0;
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
pText = strstr(buffer, "CD-Rom=");
|
|
||||||
if ( pText == NULL )
|
|
||||||
{
|
|
||||||
#if _DEMO
|
|
||||||
GetCurrentDirectory(MAX_PATH, g_CDPath);
|
|
||||||
i = strlen (g_CDPath);
|
|
||||||
if ( i > 0 && g_CDPath [i-1] != '\\' )
|
|
||||||
{
|
|
||||||
g_CDPath[i++] = '\\';
|
|
||||||
g_CDPath[i] = 0;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return FALSE;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pText += 7;
|
|
||||||
i = 0;
|
|
||||||
while ( pText[i] != 0 && pText[i] != '\n' && pText[i] != '\r' )
|
|
||||||
{
|
|
||||||
g_CDPath[i] = pText[i];
|
|
||||||
i ++;
|
|
||||||
}
|
|
||||||
if ( i > 0 && g_CDPath[i-1] != '\\' )
|
|
||||||
{
|
|
||||||
g_CDPath[i++] = '\\';
|
|
||||||
}
|
|
||||||
g_CDPath[i] = 0; // met le terminateur
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !_DEMO & !_EGAMES
|
|
||||||
if ( strstr(lpCmdLine, "-nocd") == NULL )
|
|
||||||
{
|
|
||||||
char drive[10];
|
|
||||||
|
|
||||||
drive[0] = g_CDPath[0];
|
|
||||||
drive[1] = ':';
|
|
||||||
drive[2] = '\\';
|
|
||||||
drive[3] = 0;
|
|
||||||
nb = GetDriveType(drive);
|
|
||||||
if ( nb != DRIVE_CDROM ) return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
pText = strstr(buffer, "SpeedRate=");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
g_speedRate = GetNum(pText+10);
|
|
||||||
if ( g_speedRate < 1 ) g_speedRate = 1;
|
|
||||||
if ( g_speedRate > 2 ) g_speedRate = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
pText = strstr(buffer, "Timer=");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
g_timerInterval = GetNum(pText+6);
|
|
||||||
if ( g_timerInterval < 10 ) g_timerInterval = 10;
|
|
||||||
if ( g_timerInterval > 1000 ) g_timerInterval = 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
pText = strstr(buffer, "FullScreen=");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
g_bFullScreen = GetNum(pText+11);
|
|
||||||
if ( g_bFullScreen != 0 ) g_bFullScreen = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pText = strstr(buffer, "MouseType=");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
g_mouseType = GetNum(pText+10);
|
|
||||||
if ( g_mouseType < 1 ) g_mouseType = 1;
|
|
||||||
if ( g_mouseType > 9 ) g_mouseType = 9;
|
|
||||||
}
|
|
||||||
|
|
||||||
pText = strstr(buffer, "Benchmark=");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
g_benchmark = GetNum(pText+10);
|
|
||||||
if ( g_benchmark < 0 ) g_benchmark = 0;
|
|
||||||
if ( g_benchmark > 100000 ) g_benchmark = 100000;
|
|
||||||
if ( g_benchmark > 3099 ) g_bBenchmarkSuccess = 1, g_bTrueColor = 1, g_bTrueColorDecor;
|
|
||||||
}
|
|
||||||
|
|
||||||
pText = strstr(buffer, "TrueColor=");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
i = GetNum(pText + 10);
|
|
||||||
if (i == 8) g_bTrueColor = FALSE;
|
|
||||||
if (i == 16) g_bTrueColor = TRUE;
|
|
||||||
g_bTrueColorDecor = g_bTrueColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
pText = strstr(buffer, "TrueColorBack=");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
i = GetNum(pText+14);
|
|
||||||
if (i == 8) g_bTrueColor = FALSE;
|
|
||||||
|
|
||||||
if (i == 16) g_bTrueColor = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
pText = strstr(buffer, "TrueColorDecor=");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
i = GetNum(pText + 15);
|
|
||||||
if (i == 8) g_bTrueColorDecor = FALSE;
|
|
||||||
|
|
||||||
if (i == 16) g_bTrueColorDecor = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
memstatus.dwLength = 32;
|
|
||||||
GlobalMemoryStatus(&memstatus);
|
|
||||||
if (memstatus.dwTotalPhys < 32000000)
|
|
||||||
{
|
|
||||||
g_bBenchmarkSuccess = FALSE;
|
|
||||||
}
|
|
||||||
if (g_bBenchmarkSuccess == FALSE)
|
|
||||||
{
|
|
||||||
g_bTrueColorBack = FALSE;
|
|
||||||
g_bTrueColorDecor = FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rewrite Variables
|
|
||||||
|
|
||||||
void UpdateFrame(void)
|
|
||||||
{
|
|
||||||
RECT clip, rcRect;
|
|
||||||
UINT phase;
|
|
||||||
BOOL type;
|
|
||||||
POINT posMouse;
|
|
||||||
int i, term, speed, targetlevel;
|
|
||||||
|
|
||||||
g_pEvent->ReadInput();
|
|
||||||
phase = g_pEvent->GetPhase();
|
|
||||||
|
|
||||||
if (phase == g_lastPhase &&
|
|
||||||
phase == WM_PHASE_PLAY || phase == WM_PHASE_PLAYTEST || phase == WM_PHASE_BUILD)
|
|
||||||
{
|
|
||||||
type = g_pDecor->GetPause();
|
|
||||||
if (type == FALSE)
|
|
||||||
{
|
|
||||||
speed = g_pEvent->GetSpeed();
|
|
||||||
term = 0;
|
|
||||||
speed = speed * g_speedRate;
|
|
||||||
if (0 < speed)
|
|
||||||
{
|
|
||||||
do {
|
|
||||||
g_pDecor->MoveStep();
|
|
||||||
g_pEvent->DemoStep();
|
|
||||||
term++;
|
|
||||||
} while (term < speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (phase == WM_PHASE_INIT)
|
|
||||||
{
|
|
||||||
g_pEvent->DemoStep(); // d<>marre <20>v. d<>mo automatique
|
|
||||||
}
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
if (g_pEvent->IsPrivate() == FALSE)
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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 (g_pDecor->IsTerminated() == -1)
|
|
||||||
{
|
|
||||||
g_pEvent->ChangePhase(WM_PHASE_LOSTd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (g_pDecor->IsTerminated() != 0)
|
|
||||||
{
|
|
||||||
g_pEvent->ChangePhase(WM_PHASE_WINMOVIEd);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Incomplete
|
|
||||||
|
|
||||||
void SetDecor()
|
|
||||||
{
|
|
||||||
RECT rect;
|
|
||||||
UINT phase;
|
|
||||||
POINT posMouse;
|
|
||||||
char test[12];
|
|
||||||
|
|
||||||
g_pPixmap->MouseBackClear();
|
|
||||||
g_pEvent->GetLastMousePos();
|
|
||||||
phase = g_pEvent->GetPhase();
|
|
||||||
|
|
||||||
if (phase == WM_PHASE_PLAY || phase == WM_PHASE_PLAYTEST || phase == WM_PHASE_BUILD)
|
|
||||||
{
|
|
||||||
rect.top = 0;
|
|
||||||
rect.left = 0;
|
|
||||||
rect.bottom = LYIMAGE;
|
|
||||||
rect.right = LXIMAGE;
|
|
||||||
g_pDecor->Build(rect);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rect.top = 0;
|
|
||||||
rect.left = 0;
|
|
||||||
rect.bottom = LYIMAGE;
|
|
||||||
rect.right = LXIMAGE;
|
|
||||||
g_pPixmap->DrawImage(-1, CHBACK, rect, 1);
|
|
||||||
}
|
|
||||||
g_pEvent->DrawButtons();
|
|
||||||
g_lastPhase = phase;
|
|
||||||
g_pPixmap->MouseBackDraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL RestoreGame()
|
|
||||||
{
|
|
||||||
if ( g_pPixmap == NULL ) return FALSE;
|
|
||||||
|
|
||||||
g_pEvent->RestoreGame();
|
|
||||||
return g_pPixmap->Restore();
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL FlushGame()
|
|
||||||
{
|
|
||||||
if ( g_pPixmap == NULL ) return FALSE;
|
|
||||||
|
|
||||||
return g_pPixmap->Flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void FinishObjects(void)
|
|
||||||
{
|
|
||||||
if ( g_pMovie != NULL )
|
|
||||||
{
|
|
||||||
g_pEvent->StopMovie();
|
|
||||||
|
|
||||||
delete g_pMovie;
|
|
||||||
g_pMovie = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( g_pEvent != NULL )
|
|
||||||
{
|
|
||||||
delete g_pEvent;
|
|
||||||
g_pEvent = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( g_pDecor != NULL )
|
|
||||||
{
|
|
||||||
delete g_pDecor;
|
|
||||||
g_pDecor = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_pSound != NULL )
|
|
||||||
{
|
|
||||||
g_pSound->StopMusic();
|
|
||||||
|
|
||||||
delete g_pSound;
|
|
||||||
g_pSound = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (g_pNetwork != NULL )
|
|
||||||
{
|
|
||||||
delete g_pNetwork;
|
|
||||||
g_pNetwork = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( g_pPixmap != NULL )
|
|
||||||
{
|
|
||||||
delete g_pPixmap;
|
|
||||||
g_pPixmap = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LRESULT CALLBACK WindowProc (HWND hWnd, UINT message,
|
|
||||||
WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
static HINSTANCE hInstance;
|
|
||||||
POINT mousePos, totalDim, iconDim;
|
|
||||||
|
|
||||||
if ( message == WM_SYSKEYDOWN && wParam == VK_F10 )
|
|
||||||
{
|
|
||||||
message = WM_KEYDOWN;
|
|
||||||
}
|
|
||||||
if ( message == WM_SYSKEYUP && wParam == VK_F10 )
|
|
||||||
{
|
|
||||||
message = WM_KEYUP;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( g_pEvent != NULL &&
|
|
||||||
g_pEvent->TreatEvent(message, wParam, lParam) ) return 0;
|
|
||||||
|
|
||||||
switch( message )
|
|
||||||
{
|
|
||||||
case WM_TIMER:
|
|
||||||
case WM_SYSCOLORCHANGE:
|
|
||||||
OutputDebug("Event WM_SYSCOLORCHANGE\n");
|
|
||||||
break;
|
|
||||||
case WM_CREATE:
|
|
||||||
hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
|
|
||||||
return 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_ACTIVATEAPP:
|
|
||||||
g_bActive = (wParam != 0);
|
|
||||||
if (g_pEvent != NULL)
|
|
||||||
{
|
|
||||||
g_pEvent->FlushInput();
|
|
||||||
}
|
|
||||||
if ( g_bActive )
|
|
||||||
{
|
|
||||||
if ( g_bFullScreen )
|
|
||||||
{
|
|
||||||
RestoreGame();
|
|
||||||
g_lastPhase = 999;
|
|
||||||
}
|
|
||||||
if ( !g_bFullScreen && g_bTermInit )
|
|
||||||
{
|
|
||||||
totalDim.x = 256;
|
|
||||||
totalDim.y = 96;
|
|
||||||
iconDim.x = DIMLITTLEX;
|
|
||||||
iconDim.y = DIMLITTLEY;
|
|
||||||
g_pPixmap->BackgroundCache(CHLITTLE, "little.blp", totalDim, iconDim, TRUE);
|
|
||||||
g_pPixmap->SetTransparent(CHLITTLE, RGB(0,0,255));
|
|
||||||
|
|
||||||
g_pPixmap->SavePalette();
|
|
||||||
g_pPixmap->InitSysPalette();
|
|
||||||
}
|
|
||||||
SetWindowTextA(hWnd, "Blupi");
|
|
||||||
if ( g_pSound != NULL ) g_pSound->RestartMusic();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( g_bFullScreen )
|
|
||||||
{
|
|
||||||
FlushGame();
|
|
||||||
}
|
|
||||||
SetWindowTextA(hWnd, "Blupi -- stop");
|
|
||||||
if ( g_pSound != NULL ) g_pSound->SuspendMusic();
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case WM_KEYDOWN:
|
|
||||||
switch( wParam )
|
|
||||||
{
|
|
||||||
case VK_F5:
|
|
||||||
g_pEvent->SetSpeed(1);
|
|
||||||
break;
|
|
||||||
case VK_F6:
|
|
||||||
g_pEvent->SetSpeed(2);
|
|
||||||
break;
|
|
||||||
case VK_F7:
|
|
||||||
g_pEvent->SetSpeed(4);
|
|
||||||
break;
|
|
||||||
case VK_F8:
|
|
||||||
g_pEvent->SetSpeed(8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_DISPLAYCHANGE:
|
|
||||||
OutputDebug("Event WM_DISPLAYCHANGE\n");
|
|
||||||
break;
|
|
||||||
case WM_QUERYNEWPALETTE:
|
|
||||||
OutputDebug("Event WM_QUERYNEWPALETTE\n");
|
|
||||||
break;
|
|
||||||
case WM_PALETTECHANGED:
|
|
||||||
OutputDebug("Event WM_PALLETECHANGED\n");
|
|
||||||
break;
|
|
||||||
case MM_MCINOTIFY:
|
|
||||||
OutputDebug("Event MM_MCINOTIFY\n");
|
|
||||||
if ( g_pEvent->IsMovie() )
|
|
||||||
{
|
|
||||||
if ( wParam == MCI_NOTIFY_SUCCESSFUL )
|
|
||||||
{
|
|
||||||
g_pEvent->StopMovie();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
g_pSound->SuspendMusic();
|
|
||||||
if ( wParam == MCI_NOTIFY_SUCCESSFUL )
|
|
||||||
{
|
|
||||||
OutputDebug("Event MCI_NOTIFY_SUCCESSFUL\n");
|
|
||||||
g_pSound->RestartMusic();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char s[50];
|
|
||||||
sprintf(s, "wParam=%d\n", wParam);
|
|
||||||
OutputDebug(s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_LBUTTONDOWN:
|
|
||||||
GetCursorPos(&mousePos);
|
|
||||||
ScreenToClient(hWnd, &mousePos);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_DESTROY:
|
|
||||||
KillTimer(g_hWnd, 1);
|
|
||||||
FinishObjects();
|
|
||||||
PostQuitMessage(0);
|
|
||||||
break;
|
|
||||||
case WM_SETCURSOR:
|
|
||||||
// ChangeSprite();
|
|
||||||
// SetCursor(NULL);
|
|
||||||
return TRUE;
|
|
||||||
case WM_UPDATE:
|
|
||||||
if ( !g_pEvent->IsMovie() )
|
|
||||||
{
|
|
||||||
if ( g_bActive )
|
|
||||||
{
|
|
||||||
UpdateFrame();
|
|
||||||
}
|
|
||||||
g_pPixmap->Display();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
LPTIMECALLBACK TimerStep()
|
|
||||||
{
|
|
||||||
if ((g_bActive != FALSE) && (g_bTimer == 0))
|
|
||||||
{
|
|
||||||
g_bTimer = 1;
|
|
||||||
PostAppMessageA(g_hWnd, 1025, 0, 0);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL InitFail(const char *msg, BOOL bDirectX)
|
|
||||||
{
|
|
||||||
char buffer[100];
|
|
||||||
|
|
||||||
if ( bDirectX ) strcpy(buffer, "DirectX Init FAILED\n(while ");
|
|
||||||
else strcpy(buffer, "Error (");
|
|
||||||
strcat(buffer, msg);
|
|
||||||
strcat(buffer, ")");
|
|
||||||
MessageBoxA(g_hWnd, buffer, TITLE, MB_OK);
|
|
||||||
|
|
||||||
FinishObjects();
|
|
||||||
DestroyWindow(g_hWnd);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int Benchmark()
|
|
||||||
{
|
|
||||||
struct _timeb tstruct;
|
|
||||||
int i, j, t1, t2, time;
|
|
||||||
RECT rect;
|
|
||||||
POINT dest;
|
|
||||||
_MEMORYSTATUS mem;
|
|
||||||
|
|
||||||
_ftime(&tstruct);
|
|
||||||
t1 = tstruct.millitm;
|
|
||||||
|
|
||||||
for (j = 0; j < 10; j++)
|
|
||||||
{
|
|
||||||
UpdateFrame();
|
|
||||||
SetDecor();
|
|
||||||
g_pPixmap->Display();
|
|
||||||
}
|
|
||||||
|
|
||||||
_ftime(&tstruct);
|
|
||||||
t2 = tstruct.millitm;
|
|
||||||
|
|
||||||
if (t1 > t2) t2 += 1000;
|
|
||||||
time = t2 - t1;
|
|
||||||
|
|
||||||
mem.dwLength = 32;
|
|
||||||
GlobalMemoryStatus(&mem);
|
|
||||||
FILE* file = NULL;
|
|
||||||
char string[100];
|
|
||||||
sprintf(string, "CheckTime = %d Memory = %d\r\n", time, mem.dwTotalPhys);
|
|
||||||
file = fopen("data\\time.blp", "wb");
|
|
||||||
if (file == NULL) return time;
|
|
||||||
fwrite(string, strlen(string), 1, file);
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
return time;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL DoInit(HINSTANCE hInstance, LPSTR lpCmdLine, int nCmdShow)
|
|
||||||
{
|
|
||||||
WNDCLASSA wc;
|
|
||||||
POINT totalDim, iconDim;
|
|
||||||
RECT rcRect;
|
|
||||||
BOOL bOK;
|
|
||||||
|
|
||||||
bOK = ReadConfig(lpCmdLine);
|
|
||||||
|
|
||||||
InitHInstance(hInstance);
|
|
||||||
|
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
|
||||||
wc.lpfnWndProc = WindowProc;
|
|
||||||
wc.cbClsExtra = 0;
|
|
||||||
wc.cbWndExtra = 0;
|
|
||||||
wc.hInstance = hInstance;
|
|
||||||
wc.hIcon = LoadIconA(hInstance, "IDR_MAINFRAME");
|
|
||||||
wc.hCursor = LoadCursorA(hInstance, "IDC_POINTER");
|
|
||||||
wc.hbrBackground = GetStockBrush(BLACK_BRUSH);
|
|
||||||
wc.lpszMenuName = NAME;
|
|
||||||
wc.lpszClassName = NAME;
|
|
||||||
RegisterClassA(&wc);
|
|
||||||
|
|
||||||
if (g_bFullScreen)
|
|
||||||
{
|
|
||||||
g_hWnd = CreateWindowExA
|
|
||||||
(
|
|
||||||
WS_EX_TOPMOST,
|
|
||||||
NAME,
|
|
||||||
TITLE,
|
|
||||||
WS_POPUP,
|
|
||||||
0, 0,
|
|
||||||
GetSystemMetrics(SM_CXSCREEN),
|
|
||||||
GetSystemMetrics(SM_CYSCREEN),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
hInstance,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int sx, sy;
|
|
||||||
RECT WindowRect;
|
|
||||||
|
|
||||||
sx = GetSystemMetrics(SM_CXSCREEN);
|
|
||||||
sy = GetSystemMetrics(SM_CYSCREEN);
|
|
||||||
|
|
||||||
SetRect(&WindowRect, (sx - LXIMAGE) / 2, (sy - LYIMAGE) / 2,
|
|
||||||
(sx + LXIMAGE) / 2, (sy + LYIMAGE) / 2);
|
|
||||||
AdjustWindowRect(&WindowRect, WS_POPUPWINDOW | WS_CAPTION, TRUE);
|
|
||||||
WindowRect.top += GetSystemMetrics(SM_CYCAPTION);
|
|
||||||
|
|
||||||
g_hWnd = CreateWindowA
|
|
||||||
(
|
|
||||||
NAME,
|
|
||||||
TITLE,
|
|
||||||
WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE,
|
|
||||||
(sx - LXIMAGE) / 2, (sy - LYIMAGE) / 2,
|
|
||||||
WindowRect.right - WindowRect.left,
|
|
||||||
WindowRect.bottom - WindowRect.top,
|
|
||||||
HWND_DESKTOP,
|
|
||||||
NULL,
|
|
||||||
hInstance,
|
|
||||||
NULL
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!g_hWnd) return FALSE;
|
|
||||||
|
|
||||||
ShowWindow(g_hWnd, nCmdShow);
|
|
||||||
UpdateWindow(g_hWnd);
|
|
||||||
SetFocus(g_hWnd);
|
|
||||||
|
|
||||||
ChangeSprite(SPRITE_WAIT);
|
|
||||||
|
|
||||||
//ZeroMemory(&g_pPixmap, sizeof(7068));
|
|
||||||
|
|
||||||
if (!bOK)
|
|
||||||
{
|
|
||||||
return InitFail("Game not correctly installed", FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
g_pPixmap = new CPixmap;
|
|
||||||
if (g_pPixmap == NULL) return InitFail("New pixmap", TRUE);
|
|
||||||
|
|
||||||
totalDim.x = LXIMAGE;
|
|
||||||
totalDim.y = LYIMAGE;
|
|
||||||
if (!g_pPixmap->Create(g_hWnd, totalDim, g_bFullScreen, g_mouseType, g_bTrueColor, g_bTrueColorDecor))
|
|
||||||
return InitFail("Create pixmap", TRUE);
|
|
||||||
|
|
||||||
g_pPixmap->SetBenchmarkSuccess(g_bBenchmarkSuccess);
|
|
||||||
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 InitFail("CacheAll", TRUE);
|
|
||||||
|
|
||||||
OutputDebug("SavePalette\n");
|
|
||||||
g_pPixmap->SavePalette();
|
|
||||||
OutputDebug("InitSysPalette\n");
|
|
||||||
g_pPixmap->InitSysPalette();
|
|
||||||
g_pPixmap->SetTrueColor(TRUE);
|
|
||||||
g_pPixmap->SetTrueColorDecor(TRUE);
|
|
||||||
|
|
||||||
//ZeroMemory(&g_pSound, sizeof(644));
|
|
||||||
|
|
||||||
g_pSound = new CSound;
|
|
||||||
if (g_pSound == NULL) return InitFail("New sound", TRUE);
|
|
||||||
|
|
||||||
g_pSound->Create(g_hWnd);
|
|
||||||
g_pSound->CacheAll();
|
|
||||||
g_pSound->SetState(TRUE);
|
|
||||||
|
|
||||||
//ZeroMemory(&g_pMovie, sizeof(164));
|
|
||||||
|
|
||||||
g_pMovie = new CMovie;
|
|
||||||
if (g_pMovie == NULL) return InitFail("New movie", FALSE);
|
|
||||||
|
|
||||||
g_pMovie->Create();
|
|
||||||
|
|
||||||
//ZeroMemory(&g_pDecor, sizeof(156448));
|
|
||||||
|
|
||||||
g_pDecor = new CDecor;
|
|
||||||
if (g_pDecor == NULL) return InitFail("New decor", FALSE);
|
|
||||||
|
|
||||||
g_pDecor->Create(g_hWnd, g_pSound, g_pPixmap, g_pNetwork);
|
|
||||||
|
|
||||||
//ZeroMemory(&g_pEvent, sizeof(39904));
|
|
||||||
|
|
||||||
g_pEvent = new CEvent;
|
|
||||||
if (g_pEvent == NULL) return InitFail("New event", FALSE);
|
|
||||||
|
|
||||||
g_pEvent->Create(hInstance, g_hWnd, g_pPixmap, g_pDecor, g_pSound, g_pMovie, g_pNetwork);
|
|
||||||
g_pEvent->SetFullScreen(g_bFullScreen);
|
|
||||||
g_pEvent->SetMouseType(g_mouseType);
|
|
||||||
g_pEvent->ChangePhase(WM_PHASE_INIT);
|
|
||||||
|
|
||||||
//ZeroMemory(&g_pNetwork, sizeof(20));
|
|
||||||
|
|
||||||
g_pNetwork = new CNetwork;
|
|
||||||
if (g_pNetwork == NULL) return InitFail("New network", FALSE);
|
|
||||||
g_pNetwork->CreateProvider(0);
|
|
||||||
|
|
||||||
g_bTermInit = TRUE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MMTIMER
|
|
||||||
void CALLBACK UpdateTimer_Proc(UINT uIDm, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
|
|
||||||
{
|
|
||||||
if (g_bActive && g_nbTimer == 0)
|
|
||||||
{
|
|
||||||
g_nbTimer++;
|
|
||||||
PostMessageA(g_hWnd, WM_UPDATE, NULL, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|
||||||
LPSTR lpCmdLine, int nCmdShow)
|
|
||||||
{
|
|
||||||
MSG msg;
|
|
||||||
LPTIMECALLBACK timeStep;
|
|
||||||
|
|
||||||
if ( !DoInit(hInstance, lpCmdLine, nCmdShow) )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Benchmark();
|
|
||||||
|
|
||||||
#if MMTIMER
|
|
||||||
g_updateTimer = timeSetEvent(g_timerInterval, g_timerInterval / 4, UpdateTimer_Proc, NULL, TIME_PERIODIC);
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
SetTimer(g_hWnd, 1, g_timerInterval, NULL);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if THREAD
|
|
||||||
g_hScreenMutex = CreateMutex(NULL, FALSE, NULL);
|
|
||||||
g_hRunMutex = CreateMutex(NULL, TRUE, NULL);
|
|
||||||
g_threadNr = 0;
|
|
||||||
|
|
||||||
g_hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ThreadDisplay, 0, DETACHED_PROCESS, &g_threadID);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while ( TRUE )
|
|
||||||
{
|
|
||||||
if ( PeekMessageA(&msg, NULL, 0,0, PM_NOREMOVE) )
|
|
||||||
{
|
|
||||||
if ( !GetMessage(&msg, NULL, 0, 0) )
|
|
||||||
{
|
|
||||||
return msg.wParam;
|
|
||||||
}
|
|
||||||
TranslateMessage(&msg);
|
|
||||||
DispatchMessageA(&msg);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( !g_bActive ) WaitMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return msg.wParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if THREAD
|
|
||||||
// Thread d'affichage.
|
|
||||||
|
|
||||||
static void ThreadDisplay(char* MyID)
|
|
||||||
{
|
|
||||||
UINT phase;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
phase = g_pEvent->GetPhase();
|
|
||||||
if (phase == WM_PHASE_PLAY)
|
|
||||||
{
|
|
||||||
// Wait for display to be available, then lock it.
|
|
||||||
WaitForSingleObject(g_hScreenMutex, INFINITE);
|
|
||||||
|
|
||||||
SetDecor();
|
|
||||||
g_pPixmap->Display();
|
|
||||||
|
|
||||||
// Clear screen lock.
|
|
||||||
ReleaseMutex(g_hScreenMutex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Repeat while RunMutex is still taken.
|
|
||||||
while (WaitForSingleObject(g_hRunMutex, 10L) == WAIT_TIMEOUT);
|
|
||||||
}
|
|
||||||
#endif
|
|
424
button.cpp
@ -1,424 +0,0 @@
|
|||||||
// Button.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ddraw.h>
|
|
||||||
#include <minwindef.h>
|
|
||||||
#include <windef.h>
|
|
||||||
#include "def.h"
|
|
||||||
#include "pixmap.h"
|
|
||||||
#include "sound.h"
|
|
||||||
#include "decor.h"
|
|
||||||
#include "button.h"
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
|
|
||||||
CButton::CButton()
|
|
||||||
{
|
|
||||||
m_type = 0;
|
|
||||||
m_bEnable = TRUE;
|
|
||||||
m_bHide = FALSE;
|
|
||||||
m_bSomething = FALSE;
|
|
||||||
m_state = 0;
|
|
||||||
m_mouseState = 0;
|
|
||||||
m_nbMenu = 0;
|
|
||||||
m_nbToolTips = 0;
|
|
||||||
m_selMenu = 0;
|
|
||||||
m_bMouseDown = FALSE;
|
|
||||||
m_bMinimizeRedraw = FALSE;
|
|
||||||
m_bRedraw = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
|
|
||||||
CButton::~CButton()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Create a new Button
|
|
||||||
|
|
||||||
BOOL CButton::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
|
||||||
POINT pos, int type, BOOL bMinimizeRedraw, UINT message)
|
|
||||||
{
|
|
||||||
POINT iconDim;
|
|
||||||
int i, icon;
|
|
||||||
|
|
||||||
static int ttypes[] =
|
|
||||||
{
|
|
||||||
DIMBUTTONX,DIMBUTTONY,
|
|
||||||
};
|
|
||||||
|
|
||||||
if ( type < 0 || type > 0 ) return FALSE;
|
|
||||||
|
|
||||||
|
|
||||||
iconDim.x = ttypes[type * 2 + 0];
|
|
||||||
iconDim.y = ttypes[type * 2 + 1];
|
|
||||||
|
|
||||||
m_hWnd = hWnd;
|
|
||||||
m_pPixmap = pPixmap;
|
|
||||||
m_pSound = pSound;
|
|
||||||
m_type = type;
|
|
||||||
m_bMinimizeRedraw = bMinimizeRedraw;
|
|
||||||
m_bEnable = TRUE;
|
|
||||||
m_bHide = FALSE;
|
|
||||||
m_bSomething = FALSE;
|
|
||||||
m_message = message;
|
|
||||||
m_pos.x = pos.x;
|
|
||||||
m_pos.y = pos.y;
|
|
||||||
m_dim.x = iconDim.x;
|
|
||||||
m_dim.y = iconDim.y;
|
|
||||||
m_nbMenu = 0;
|
|
||||||
m_nbToolTips = 0;
|
|
||||||
m_selMenu = 0;
|
|
||||||
m_state = 0;
|
|
||||||
m_mouseState = 0;
|
|
||||||
m_bMouseDown = FALSE;
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButton::SetIconMenu(int* icon, int iconMenu)
|
|
||||||
{
|
|
||||||
int i = iconMenu;
|
|
||||||
int* iconMenu2;
|
|
||||||
|
|
||||||
if (0 < iconMenu)
|
|
||||||
{
|
|
||||||
iconMenu2 = m_iconMenu;
|
|
||||||
for (i = 0; i < iconMenu; i++)
|
|
||||||
{
|
|
||||||
icon++;
|
|
||||||
m_iconMenu[i] = icon[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_nbMenu = iconMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButton::SetToolTips(int* menu, int menuTooltips)
|
|
||||||
{
|
|
||||||
int toolTips;
|
|
||||||
int* menuTool;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (0 < menuTooltips)
|
|
||||||
{
|
|
||||||
menuTool = m_toolTips;
|
|
||||||
i = menuTooltips;
|
|
||||||
for (i = 0; i < menuTooltips; i++)
|
|
||||||
{
|
|
||||||
menu++;
|
|
||||||
m_toolTips[i] = menu[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_nbToolTips = menuTooltips;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a button in its state
|
|
||||||
|
|
||||||
void CButton::Draw()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
POINT pos;
|
|
||||||
RECT rect;
|
|
||||||
|
|
||||||
if ( m_bMinimizeRedraw && !m_bRedraw ) return;
|
|
||||||
m_bRedraw = FALSE, m_bSomething = FALSE;
|
|
||||||
|
|
||||||
if ( m_bHide ) // Hidden button
|
|
||||||
{
|
|
||||||
pos.y = m_pos.y;
|
|
||||||
pos.x = m_pos.x;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( m_bEnable )
|
|
||||||
{
|
|
||||||
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, m_mouseState, m_pos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, 4, m_pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_nbMenu == 0 ) return;
|
|
||||||
|
|
||||||
pos = m_pos;
|
|
||||||
if ( m_nbMenu > 0 )
|
|
||||||
{
|
|
||||||
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type,
|
|
||||||
m_iconMenu[m_selMenu]+6, pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_nbMenu == 1 || !m_bEnable || !m_bMouseDown ) return;
|
|
||||||
|
|
||||||
pos = m_pos;
|
|
||||||
pos.x += m_dim.x+2;
|
|
||||||
for ( i=0 ; i<m_nbMenu ; i++ )
|
|
||||||
{
|
|
||||||
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, i==m_selMenu?1:0, pos);
|
|
||||||
m_pPixmap->DrawIcon(-1, CHBUTTON+m_type, m_iconMenu[i]+6, pos);
|
|
||||||
pos.x += m_dim.x-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
/Needed Yet?
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
void CButton::Redraw()
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
//////////////////////////////////////////////
|
|
||||||
*/
|
|
||||||
|
|
||||||
int CButton::GetState()
|
|
||||||
{
|
|
||||||
return m_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButton::SetState(int state)
|
|
||||||
{
|
|
||||||
if ( m_state != state ||
|
|
||||||
m_mouseState != state )
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_state = state;
|
|
||||||
m_mouseState = state;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CButton::GetMenu()
|
|
||||||
{
|
|
||||||
return m_selMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButton::SetMenu(int menu)
|
|
||||||
{
|
|
||||||
if ( m_selMenu != menu )
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_selMenu = menu;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButton::SetEnable(BOOL bEnable)
|
|
||||||
{
|
|
||||||
if ( m_bEnable != bEnable )
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bEnable = bEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CButton::SetSomething(BOOL bSomething)
|
|
||||||
{
|
|
||||||
if (m_bSomething != bSomething)
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bSomething = bSomething;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
// Needed Yet?
|
|
||||||
/////////////////////////////////////////
|
|
||||||
BOOL CButton::GetHide()
|
|
||||||
{
|
|
||||||
return m_bHide;
|
|
||||||
}
|
|
||||||
/////////////////////////////////////////
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
void CButton::SetHide(BOOL bHide)
|
|
||||||
{
|
|
||||||
if ( m_bHide != bHide )
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bHide = bHide;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CButton::TreatEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
POINT pos;
|
|
||||||
|
|
||||||
if ( m_bHide || !m_bEnable ) return FALSE;
|
|
||||||
|
|
||||||
pos = ConvLongToPos(lParam);
|
|
||||||
|
|
||||||
switch( message )
|
|
||||||
{
|
|
||||||
case WM_LBUTTONDOWN:
|
|
||||||
case WM_RBUTTONDOWN:
|
|
||||||
if ( MouseDown(pos) ) return TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
|
||||||
if ( MouseMove(pos) ) return TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
case WM_RBUTTONUP:
|
|
||||||
if ( MouseUp(pos) ) return FALSE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// All buttons must receive the BUTTONUP event!
|
|
||||||
|
|
||||||
// Indicates whether the mouse is over this button.
|
|
||||||
|
|
||||||
BOOL CButton::MouseOnButton(POINT pos)
|
|
||||||
{
|
|
||||||
return Detect(pos);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return the tooltips for a button, depending
|
|
||||||
// on mouse position.
|
|
||||||
|
|
||||||
int CButton::GetToolTips(POINT pos)
|
|
||||||
{
|
|
||||||
int width = m_dim.x;
|
|
||||||
int rank;
|
|
||||||
|
|
||||||
if ( m_bHide || !m_bEnable ) return -1;
|
|
||||||
|
|
||||||
if ( m_nbMenu > 1 && m_bMouseDown ) // Drop-down submenu?
|
|
||||||
{
|
|
||||||
width += 2+(m_dim.x-1)*m_nbMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pos.x < m_pos.x ||
|
|
||||||
pos.x > m_pos.x+width ||
|
|
||||||
pos.y < m_pos.y ||
|
|
||||||
pos.y > m_pos.y+m_dim.y ) return -1;
|
|
||||||
|
|
||||||
rank = (pos.x=-(m_pos.x+2+1))/(m_dim.x-1);
|
|
||||||
if ( rank < 0 ) rank = 0;
|
|
||||||
if ( rank > m_nbToolTips ) return -1;
|
|
||||||
|
|
||||||
if ( m_nbMenu > 1 )
|
|
||||||
{
|
|
||||||
if ( m_bMouseDown && rank > 0 )
|
|
||||||
{
|
|
||||||
rank --;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rank = m_selMenu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_toolTips[rank];
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CButton::Detect(POINT pos)
|
|
||||||
{
|
|
||||||
int width = m_dim.x;
|
|
||||||
|
|
||||||
if ( m_bHide || !m_bEnable ) return FALSE;
|
|
||||||
|
|
||||||
if ( m_nbMenu > 1 && m_bMouseDown )
|
|
||||||
{
|
|
||||||
width += 2+(m_dim.x-1)*m_nbMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pos.x < m_pos.x ||
|
|
||||||
pos.x > m_pos.x+width ||
|
|
||||||
pos.y < m_pos.y ||
|
|
||||||
pos.y > m_pos.y+m_dim.y ) return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CButton::MouseDown(POINT pos)
|
|
||||||
{
|
|
||||||
if ( !Detect(pos) ) return FALSE;
|
|
||||||
|
|
||||||
m_mouseState = 1;
|
|
||||||
m_bMouseDown = TRUE;
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
// PostMessage(m_hWnd, WM_UPDATE, 0, 0);
|
|
||||||
|
|
||||||
m_pSound->PlayImage(SOUND_1_CLICK, pos);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CButton::MouseMove(POINT pos)
|
|
||||||
{
|
|
||||||
BOOL bDetect;
|
|
||||||
int iState, iMenu;
|
|
||||||
|
|
||||||
iState = m_mouseState;
|
|
||||||
iMenu = m_selMenu;
|
|
||||||
|
|
||||||
bDetect = Detect(pos);
|
|
||||||
|
|
||||||
if ( m_bMouseDown )
|
|
||||||
{
|
|
||||||
if ( bDetect ) m_mouseState = 1;
|
|
||||||
else m_mouseState = m_state;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( bDetect ) m_mouseState = m_state+2;
|
|
||||||
else m_mouseState = m_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_nbMenu > 1 &&
|
|
||||||
m_bMouseDown &&
|
|
||||||
pos.x > m_pos.x+m_dim.x+2 )
|
|
||||||
{
|
|
||||||
m_selMenu = (pos.x-(m_pos.x+m_dim.x+2))/(m_dim.x-1);
|
|
||||||
if ( m_selMenu >= m_nbMenu )
|
|
||||||
{
|
|
||||||
m_selMenu = m_nbMenu-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( iState != m_mouseState ||
|
|
||||||
iMenu != m_selMenu )
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
PostMessage(m_hWnd, WM_UPDATE, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_bMouseDown;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CButton::MouseUp(POINT pos)
|
|
||||||
{
|
|
||||||
BOOL bDetect;
|
|
||||||
|
|
||||||
bDetect = Detect(pos);
|
|
||||||
|
|
||||||
m_mouseState = m_state;
|
|
||||||
m_bMouseDown = FALSE;
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
|
|
||||||
if ( !bDetect ) return FALSE;
|
|
||||||
|
|
||||||
if ( m_message != -1 )
|
|
||||||
{
|
|
||||||
PostMessage(m_hWnd, m_message, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
71
button.h
@ -1,71 +0,0 @@
|
|||||||
#include <minwindef.h>
|
|
||||||
#include <windef.h>
|
|
||||||
#include "decor.h"
|
|
||||||
#include "sound.h"
|
|
||||||
#include "pixmap.h"
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
class CButton
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CButton();
|
|
||||||
~CButton();
|
|
||||||
|
|
||||||
BOOL Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
|
||||||
POINT pos, int type, BOOL bMinimizeRedraw, UINT message);
|
|
||||||
void SetIconMenu(int* icon, int iconMenu);
|
|
||||||
void SetToolTips(int* menu, int menuTooltips);
|
|
||||||
void Draw();
|
|
||||||
void Redraw();
|
|
||||||
|
|
||||||
int GetState();
|
|
||||||
void SetState(int state);
|
|
||||||
|
|
||||||
int GetMenu();
|
|
||||||
void SetMenu(int menu);
|
|
||||||
|
|
||||||
BOOL GetEnable();
|
|
||||||
void SetEnable(BOOL bEnable);
|
|
||||||
|
|
||||||
void SetSomething(BOOL bSomething);
|
|
||||||
|
|
||||||
BOOL GetHide();
|
|
||||||
void SetHide(BOOL bHide);
|
|
||||||
|
|
||||||
BOOL TreatEvent(UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
BOOL MouseOnButton(POINT pos);
|
|
||||||
int GetToolTips(POINT pos);
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
BOOL Detect(POINT pos);
|
|
||||||
BOOL MouseDown(POINT pos);
|
|
||||||
BOOL MouseMove(POINT pos);
|
|
||||||
BOOL MouseUp(POINT pos);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
HWND m_hWnd;
|
|
||||||
CPixmap* m_pPixmap;
|
|
||||||
CDecor* m_pDecor;
|
|
||||||
CSound* m_pSound;
|
|
||||||
int m_type; // type de bouton
|
|
||||||
BOOL m_bEnable; // TRUE si bouton actif
|
|
||||||
BOOL m_bHide; // TRUE si bouton cach<63>
|
|
||||||
UINT m_message; // message envoy<6F> si bouton actionn<6E>
|
|
||||||
POINT m_pos; // coin sup/gauche
|
|
||||||
POINT m_dim; // dimensions
|
|
||||||
int m_state;
|
|
||||||
int m_mouseState;
|
|
||||||
int m_iconMenu[20]; // ic<69>nes du sous-menu
|
|
||||||
int m_toolTips[20]; // info-bulles
|
|
||||||
int m_nbMenu; // nb de case du sous-menu
|
|
||||||
int m_nbToolTips; // nb d'info-bulles
|
|
||||||
int m_selMenu;
|
|
||||||
int m_bSomething; // sous-menu s<>lectionn<6E>
|
|
||||||
BOOL m_bMouseDown; // TRUE -> bouton souris press<73>
|
|
||||||
BOOL m_bMinimizeRedraw;
|
|
||||||
BOOL m_bRedraw;
|
|
||||||
};
|
|
BIN
cursor1.cur
Before Width: | Height: | Size: 326 B |
346
ddutil.cpp
@ -1,346 +0,0 @@
|
|||||||
/*==========================================================================
|
|
||||||
*
|
|
||||||
* Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* File: ddutil.cpp
|
|
||||||
* Content: Routines for loading bitmap and palettes from resources
|
|
||||||
*
|
|
||||||
***************************************************************************/
|
|
||||||
#undef WIN32_LEAN_AND_MEAN
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h>
|
|
||||||
#include <ddraw.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "ddutil.h"
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#define DIRECTDRAW_VERSION 0x0500
|
|
||||||
|
|
||||||
BOOL g_bDebug = TRUE;
|
|
||||||
|
|
||||||
void DDSetDebug(BOOL bDebug)
|
|
||||||
{
|
|
||||||
g_bDebug = bDebug;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DDLoadBitmap
|
|
||||||
*
|
|
||||||
* create a DirectDrawSurface from a bitmap resource.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
extern "C" IDirectDrawSurface * DDLoadBitmap(IDirectDraw *pdd, LPCSTR szBitmap, int dx, int dy)
|
|
||||||
{
|
|
||||||
HBITMAP hbm;
|
|
||||||
BITMAP bm;
|
|
||||||
DDSURFACEDESC ddsd;
|
|
||||||
IDirectDrawSurface *pdds;
|
|
||||||
|
|
||||||
//
|
|
||||||
// try to load the bitmap as a resource, if that fails, try it as a file
|
|
||||||
//
|
|
||||||
hbm = (HBITMAP)LoadImageA(GetModuleHandle(NULL), szBitmap, IMAGE_BITMAP, dx, dy, LR_CREATEDIBSECTION);
|
|
||||||
|
|
||||||
if (hbm == NULL)
|
|
||||||
hbm = (HBITMAP)LoadImageA(NULL, szBitmap, IMAGE_BITMAP, dx, dy, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
|
|
||||||
|
|
||||||
if (hbm == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// get size of the bitmap
|
|
||||||
//
|
|
||||||
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
|
|
||||||
|
|
||||||
//
|
|
||||||
// create a DirectDrawSurface for this bitmap
|
|
||||||
//
|
|
||||||
ZeroMemory(&ddsd, sizeof(ddsd));
|
|
||||||
ddsd.dwSize = sizeof(ddsd);
|
|
||||||
ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT |DDSD_WIDTH;
|
|
||||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
|
||||||
ddsd.dwWidth = bm.bmWidth;
|
|
||||||
ddsd.dwHeight = bm.bmHeight;
|
|
||||||
|
|
||||||
if (pdd->CreateSurface(&ddsd, &pdds, NULL) != DD_OK)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
DDCopyBitmap(pdds, hbm, 0, 0, 0, 0);
|
|
||||||
|
|
||||||
DeleteObject(hbm);
|
|
||||||
|
|
||||||
return pdds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DDReLoadBitmap
|
|
||||||
*
|
|
||||||
* load a bitmap from a file or resource into a directdraw surface.
|
|
||||||
* normaly used to re-load a surface after a restore.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
HRESULT DDReLoadBitmap(IDirectDrawSurface *pdds, LPCSTR szBitmap)
|
|
||||||
{
|
|
||||||
HBITMAP hbm;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
//
|
|
||||||
// try to load the bitmap as a resource, if that fails, try it as a file
|
|
||||||
//
|
|
||||||
hbm = (HBITMAP)LoadImageA(GetModuleHandle(NULL), szBitmap, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION);
|
|
||||||
|
|
||||||
if (hbm == NULL)
|
|
||||||
hbm = (HBITMAP)LoadImageA(NULL, szBitmap, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_CREATEDIBSECTION);
|
|
||||||
|
|
||||||
if (hbm == NULL)
|
|
||||||
{
|
|
||||||
OutputDebugStringA("handle is null\n");
|
|
||||||
return E_FAIL;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr = DDCopyBitmap(pdds, hbm, 0, 0, 0, 0);
|
|
||||||
if (hr != DD_OK)
|
|
||||||
{
|
|
||||||
OutputDebugStringA("ddcopybitmap failed\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DeleteObject(hbm);
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DDCopyBitmap
|
|
||||||
*
|
|
||||||
* draw a bitmap into a DirectDrawSurface
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
extern "C" HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int x, int y, int dx, int dy)
|
|
||||||
{
|
|
||||||
HDC hdcImage;
|
|
||||||
HDC hdc;
|
|
||||||
BITMAP bm;
|
|
||||||
DDSURFACEDESC ddsd;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
if (hbm == NULL || pdds == NULL)
|
|
||||||
return E_FAIL;
|
|
||||||
|
|
||||||
//
|
|
||||||
// make sure this surface is restored.
|
|
||||||
//
|
|
||||||
pdds->Restore();
|
|
||||||
|
|
||||||
//
|
|
||||||
// select bitmap into a memoryDC so we can use it.
|
|
||||||
//
|
|
||||||
hdcImage = CreateCompatibleDC(NULL);
|
|
||||||
if (!hdcImage)
|
|
||||||
OutputDebugStringA("createcompatible dc failed\n");
|
|
||||||
SelectObject(hdcImage, hbm);
|
|
||||||
|
|
||||||
//
|
|
||||||
// get size of the bitmap
|
|
||||||
//
|
|
||||||
GetObject(hbm, sizeof(bm), &bm); // get size of bitmap
|
|
||||||
dx = dx == 0 ? bm.bmWidth : dx; // use the passed size, unless zero
|
|
||||||
dy = dy == 0 ? bm.bmHeight : dy;
|
|
||||||
|
|
||||||
//
|
|
||||||
// get size of surface.
|
|
||||||
//
|
|
||||||
ddsd.dwSize = sizeof(ddsd);
|
|
||||||
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
|
|
||||||
pdds->GetSurfaceDesc(&ddsd);
|
|
||||||
|
|
||||||
if ((hr = pdds->GetDC(&hdc)) == DD_OK)
|
|
||||||
{
|
|
||||||
StretchBlt(hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage, x, y, dx, dy, SRCCOPY);
|
|
||||||
pdds->ReleaseDC(hdc);
|
|
||||||
}
|
|
||||||
|
|
||||||
DeleteDC(hdcImage);
|
|
||||||
|
|
||||||
return hr;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// DDLoadPalette
|
|
||||||
//
|
|
||||||
// Create a DirectDraw palette object from a bitmap resoure
|
|
||||||
//
|
|
||||||
// if the resource does not exist or NULL is passed create a
|
|
||||||
// default 332 palette.
|
|
||||||
//
|
|
||||||
extern "C" IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap)
|
|
||||||
{
|
|
||||||
IDirectDrawPalette* ddpal;
|
|
||||||
int i;
|
|
||||||
int n;
|
|
||||||
int fh;
|
|
||||||
HRSRC h;
|
|
||||||
LPBITMAPINFOHEADER lpbi;
|
|
||||||
PALETTEENTRY ape[256];
|
|
||||||
RGBQUAD * prgb;
|
|
||||||
|
|
||||||
//
|
|
||||||
// build a 332 palette as the default.
|
|
||||||
//
|
|
||||||
for (i=0; i<256; i++)
|
|
||||||
{
|
|
||||||
ape[i].peRed = (BYTE)(((i >> 5) & 0x07) * 255 / 7);
|
|
||||||
ape[i].peGreen = (BYTE)(((i >> 2) & 0x07) * 255 / 7);
|
|
||||||
ape[i].peBlue = (BYTE)(((i >> 0) & 0x03) * 255 / 3);
|
|
||||||
ape[i].peFlags = (BYTE)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// get a pointer to the bitmap resource.
|
|
||||||
//
|
|
||||||
if (szBitmap && (h = FindResourceA(NULL, szBitmap, (LPCSTR)RT_BITMAP)))
|
|
||||||
{
|
|
||||||
lpbi = (LPBITMAPINFOHEADER)LockResource(LoadResource(NULL, h));
|
|
||||||
if (!lpbi)
|
|
||||||
OutputDebugStringA("lock resource failed\n");
|
|
||||||
prgb = (RGBQUAD*)((BYTE*)lpbi + lpbi->biSize);
|
|
||||||
|
|
||||||
if (lpbi == NULL || lpbi->biSize < sizeof(BITMAPINFOHEADER))
|
|
||||||
n = 0;
|
|
||||||
else if (lpbi->biBitCount > 8)
|
|
||||||
n = 0;
|
|
||||||
else if (lpbi->biClrUsed == 0)
|
|
||||||
n = 1 << lpbi->biBitCount;
|
|
||||||
else
|
|
||||||
n = lpbi->biClrUsed;
|
|
||||||
|
|
||||||
//
|
|
||||||
// a DIB color table has its colors stored BGR not RGB
|
|
||||||
// so flip them around.
|
|
||||||
//
|
|
||||||
for(i=0; i<n; i++ )
|
|
||||||
{
|
|
||||||
ape[i].peRed = prgb[i].rgbRed;
|
|
||||||
ape[i].peGreen = prgb[i].rgbGreen;
|
|
||||||
ape[i].peBlue = prgb[i].rgbBlue;
|
|
||||||
ape[i].peFlags = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (szBitmap && (fh = _lopen(szBitmap, OF_READ)) != -1)
|
|
||||||
{
|
|
||||||
BITMAPFILEHEADER bf;
|
|
||||||
BITMAPINFOHEADER bi;
|
|
||||||
|
|
||||||
_lread(fh, &bf, sizeof(bf));
|
|
||||||
_lread(fh, &bi, sizeof(bi));
|
|
||||||
_lread(fh, ape, sizeof(ape));
|
|
||||||
_lclose(fh);
|
|
||||||
|
|
||||||
if (bi.biSize != sizeof(BITMAPINFOHEADER))
|
|
||||||
n = 0;
|
|
||||||
else if (bi.biBitCount > 8)
|
|
||||||
n = 0;
|
|
||||||
else if (bi.biClrUsed == 0)
|
|
||||||
n = 1 << bi.biBitCount;
|
|
||||||
else
|
|
||||||
n = bi.biClrUsed;
|
|
||||||
|
|
||||||
//
|
|
||||||
// a DIB color table has its colors stored BGR not RGB
|
|
||||||
// so flip them around.
|
|
||||||
//
|
|
||||||
for(i=0; i<n; i++ )
|
|
||||||
{
|
|
||||||
BYTE r = ape[i].peRed;
|
|
||||||
ape[i].peRed = ape[i].peBlue;
|
|
||||||
ape[i].peBlue = r;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pdd->CreatePalette(DDPCAPS_8BIT, ape, &ddpal, NULL);
|
|
||||||
|
|
||||||
return ddpal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DDColorMatch
|
|
||||||
*
|
|
||||||
* convert a RGB color to a pysical color.
|
|
||||||
*
|
|
||||||
* we do this by leting GDI SetPixel() do the color matching
|
|
||||||
* then we lock the memory and see what it got mapped to.
|
|
||||||
*/
|
|
||||||
extern "C" DWORD DDColorMatch(IDirectDrawSurface *pdds, COLORREF rgb)
|
|
||||||
{
|
|
||||||
COLORREF rgbT;
|
|
||||||
HDC hdc;
|
|
||||||
DWORD dw = CLR_INVALID;
|
|
||||||
DDSURFACEDESC ddsd;
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
//
|
|
||||||
// use GDI SetPixel to color match for us
|
|
||||||
//
|
|
||||||
if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK)
|
|
||||||
{
|
|
||||||
rgbT = GetPixel(hdc, 0, 0); // save current pixel value
|
|
||||||
SetPixel(hdc, 0, 0, rgb); // set our value
|
|
||||||
pdds->ReleaseDC(hdc);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// now lock the surface so we can read back the converted color
|
|
||||||
//
|
|
||||||
ddsd.dwSize = sizeof(ddsd);
|
|
||||||
while ((hres = pdds->Lock(NULL, &ddsd, 0, NULL)) == DDERR_WASSTILLDRAWING)
|
|
||||||
;
|
|
||||||
|
|
||||||
if (hres == DD_OK)
|
|
||||||
{
|
|
||||||
dw = *(DWORD *)ddsd.lpSurface; // get DWORD
|
|
||||||
if(ddsd.ddpfPixelFormat.dwRGBBitCount < 32)
|
|
||||||
dw &= (1 << ddsd.ddpfPixelFormat.dwRGBBitCount)-1; // mask it to bpp
|
|
||||||
pdds->Unlock(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// now put the color that was there back.
|
|
||||||
//
|
|
||||||
if (rgb != CLR_INVALID && pdds->GetDC(&hdc) == DD_OK)
|
|
||||||
{
|
|
||||||
SetPixel(hdc, 0, 0, rgbT);
|
|
||||||
pdds->ReleaseDC(hdc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return dw;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DDSetColorKey
|
|
||||||
*
|
|
||||||
* set a color key for a surface, given a RGB.
|
|
||||||
* if you pass CLR_INVALID as the color key, the pixel
|
|
||||||
* in the upper-left corner will be used.
|
|
||||||
*/
|
|
||||||
extern "C" HRESULT DDSetColorKey(IDirectDrawSurface *pdds, COLORREF rgb)
|
|
||||||
{
|
|
||||||
DDCOLORKEY ddck;
|
|
||||||
|
|
||||||
ddck.dwColorSpaceLowValue = DDColorMatch(pdds, rgb);
|
|
||||||
ddck.dwColorSpaceHighValue = ddck.dwColorSpaceLowValue;
|
|
||||||
return pdds->SetColorKey(DDCKEY_SRCBLT, &ddck);
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" HRESULT DDSetColorKey2(IDirectDrawSurface* pdds, COLORREF rgb1,
|
|
||||||
COLORREF rgb2)
|
|
||||||
{
|
|
||||||
DDCOLORKEY ddck;
|
|
||||||
|
|
||||||
ddck.dwColorSpaceLowValue = DDColorMatch(pdds, rgb1);
|
|
||||||
ddck.dwColorSpaceHighValue = DDColorMatch(pdds, rgb2);
|
|
||||||
return pdds->SetColorKey(DDCKEY_SRCBLT, &ddck);
|
|
||||||
}
|
|
32
ddutil.h
@ -1,32 +0,0 @@
|
|||||||
/*==========================================================================
|
|
||||||
*
|
|
||||||
* Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* File: ddutil.cpp
|
|
||||||
* Content: Routines for loading bitmap and palettes from resources
|
|
||||||
*
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#define DIRECTDRAW_VERSION 0x0500
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include <ddraw.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" { /* Assume C declarations for C++ */
|
|
||||||
#endif /* __cplusplus */
|
|
||||||
|
|
||||||
extern void DDSetDebug(BOOL bDebug);
|
|
||||||
extern IDirectDrawPalette * DDLoadPalette(IDirectDraw *pdd, LPCSTR szBitmap);
|
|
||||||
extern IDirectDrawSurface * DDLoadBitmap(IDirectDraw *pdd, LPCSTR szBitmap, int dx, int dy);
|
|
||||||
extern HRESULT DDReLoadBitmap(IDirectDrawSurface *pdds, LPCSTR szBitmap);
|
|
||||||
extern HRESULT DDCopyBitmap(IDirectDrawSurface *pdds, HBITMAP hbm, int x, int y, int dx, int dy);
|
|
||||||
extern DWORD DDColorMatch(IDirectDrawSurface *pdds, COLORREF rgb);
|
|
||||||
extern HRESULT DDSetColorKey(IDirectDrawSurface *pdds, COLORREF rgb);
|
|
||||||
extern HRESULT DDSetColorKey2(IDirectDrawSurface* pdds, COLORREF rgb1, COLORREF rgb2);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif /* __cplusplus */
|
|
42
decblupi.cpp
@ -1,42 +0,0 @@
|
|||||||
// DecBlupi.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "DEF.H"
|
|
||||||
#include "DECOR.H"
|
|
||||||
#include "ACTION.H"
|
|
||||||
#include "MISC.H"
|
|
||||||
#include "RESOURCE.H"
|
|
||||||
|
|
||||||
void CDecor::BlupiCheat(int cheat)
|
|
||||||
{
|
|
||||||
int rank;
|
|
||||||
Perso *persos;
|
|
||||||
PersoType persosType;
|
|
||||||
|
|
||||||
m_persos = persos;
|
|
||||||
|
|
||||||
for (rank = 0; rank < MAXBLUPI; rank++)
|
|
||||||
{
|
|
||||||
if (cheat == 2)
|
|
||||||
{
|
|
||||||
if (persosType == perso_bomb ||
|
|
||||||
persosType == perso_hangingbomb ||
|
|
||||||
persosType == perso_homingbomb ||
|
|
||||||
persosType == perso_hombingbombactive ||
|
|
||||||
persosType == perso_bulldozer ||
|
|
||||||
persosType == perso_movingbomb)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
void CDecor::GetBlupiHitbox(RECT *out, POINT pos)
|
|
||||||
{
|
|
||||||
int rect.top;
|
|
||||||
int rect.bottom;
|
|
||||||
int rect.left;
|
|
||||||
int rect.right;
|
|
||||||
|
|
||||||
if
|
|
||||||
}
|
|
||||||
*/
|
|
@ -1,4 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
short* GetListMoves(int rank);
|
|
||||||
short* GetListIcons(int rank);
|
|
@ -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
|
|
||||||
};
|
|
9720
dectables.h
542
def.h
@ -1,542 +0,0 @@
|
|||||||
// Def.h
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <Windows.h>
|
|
||||||
|
|
||||||
#define _DEMO FALSE // TRUE=demo, FALSE=complet
|
|
||||||
#define _INTRO FALSE // TRUE si images d'introduction
|
|
||||||
#define _EGAMES FALSE // TRUE version pour eGames
|
|
||||||
#define _SE FALSE // TRUE eGames Special Edition
|
|
||||||
|
|
||||||
|
|
||||||
#define LXIMAGE 640 // dimensions de la fen<65>tre de jeu
|
|
||||||
#define LYIMAGE 480
|
|
||||||
|
|
||||||
#define POSDRAWX 144 // surface de dessin
|
|
||||||
#define POSDRAWY 15
|
|
||||||
#define DIMDRAWX 480
|
|
||||||
#define DIMDRAWY 450
|
|
||||||
|
|
||||||
#define POSMAPX 8 // surface pour la carte
|
|
||||||
#define POSMAPY 15
|
|
||||||
#define DIMMAPX 128
|
|
||||||
#define DIMMAPY 128
|
|
||||||
|
|
||||||
#define MAXCELX 200 // nb max de cellules d'un monde
|
|
||||||
#define MAXCELY 200
|
|
||||||
|
|
||||||
#define DIMCELX 60 // dimensions d'une cellule (d<>cor)
|
|
||||||
#define DIMCELY 30
|
|
||||||
|
|
||||||
#define DIMOBJX 120 // dimensions d'un objet
|
|
||||||
#define DIMOBJY 120
|
|
||||||
|
|
||||||
#define DIMBLUPIX 60 // dimensions de blupi
|
|
||||||
#define DIMBLUPIY 60
|
|
||||||
#define SHIFTBLUPIY 5 // petit d<>calage vers le haut
|
|
||||||
|
|
||||||
#define DIMEXPLOX 128
|
|
||||||
#define DIMEXPLOY 128
|
|
||||||
|
|
||||||
#define DIMBUTTONX 40 // dimensions d'un button
|
|
||||||
#define DIMBUTTONY 40
|
|
||||||
|
|
||||||
#define DIMJAUGEX 124 // dimensions de la jauge
|
|
||||||
#define DIMJAUGEY 22
|
|
||||||
|
|
||||||
#define POSSTATX 12 // statistiques
|
|
||||||
#define POSSTATY 220
|
|
||||||
#define DIMSTATX 60
|
|
||||||
#define DIMSTATY 30
|
|
||||||
|
|
||||||
#define DIMTEXTX 16 // dimensions max d'un caract<63>re
|
|
||||||
#define DIMTEXTY 16
|
|
||||||
|
|
||||||
#define DIMLITTLEX 16 // dimensions max d'un petit caract<63>re
|
|
||||||
#define DIMLITTLEY 12
|
|
||||||
|
|
||||||
#define CHBACK 0
|
|
||||||
#define CHFLOOR 1
|
|
||||||
#define CHOBJECT 1
|
|
||||||
#define CHBLUPI 2
|
|
||||||
#define CHDECOR 3
|
|
||||||
#define CHBUTTON 4
|
|
||||||
#define CHJAUGE 5
|
|
||||||
#define CHTEXT 6
|
|
||||||
#define CHMAP 8
|
|
||||||
#define CHEXPLO 9
|
|
||||||
#define CHELEMENT 10
|
|
||||||
#define CHBLUPI1 11
|
|
||||||
#define CHBLUPI2 12
|
|
||||||
#define CHBLUPI3 13
|
|
||||||
#define CHPAD 14
|
|
||||||
#define CHSPEEDYBLUPI 15
|
|
||||||
#define CHBLUPIYOUPIE 16
|
|
||||||
#define CHGEAR 17
|
|
||||||
#define CHLITTLE 18
|
|
||||||
#define CHBIGNUM 19
|
|
||||||
|
|
||||||
#define CHTEMP 14
|
|
||||||
|
|
||||||
#define MAXMOVEOBJECT 200
|
|
||||||
|
|
||||||
#define MESS_LOBBY 4
|
|
||||||
#define NETEVENTMAX 20
|
|
||||||
|
|
||||||
#define PK_PLAYSOUND 40
|
|
||||||
|
|
||||||
|
|
||||||
// Directions :
|
|
||||||
|
|
||||||
#define DIRECT_E (0*16) // est
|
|
||||||
#define DIRECT_SE (1*16) // sud-est
|
|
||||||
#define DIRECT_S (2*16) // sud
|
|
||||||
#define DIRECT_SO (3*16) // sud-ouest
|
|
||||||
#define DIRECT_O (4*16) // ouest
|
|
||||||
#define DIRECT_NO (5*16) // nord-ouest
|
|
||||||
#define DIRECT_N (6*16) // nord
|
|
||||||
#define DIRECT_NE (7*16) // nord-est
|
|
||||||
|
|
||||||
// NO
|
|
||||||
// O | N
|
|
||||||
// \ | /
|
|
||||||
// \ | /
|
|
||||||
// \|/
|
|
||||||
// SO -------o------- NE
|
|
||||||
// /|\
|
|
||||||
// / | \
|
|
||||||
// / | \
|
|
||||||
// S | E
|
|
||||||
// (y) SE (x)
|
|
||||||
|
|
||||||
|
|
||||||
// Actions :
|
|
||||||
|
|
||||||
#define ACTION_STOP 1 // arr<72>t
|
|
||||||
#define ACTION_MARCH 2
|
|
||||||
#define ACTION_TURN 3
|
|
||||||
#define ACTION_JUMP 4
|
|
||||||
#define ACTION_AIR 5
|
|
||||||
#define ACTION_DOWN 6
|
|
||||||
|
|
||||||
// Sons :
|
|
||||||
|
|
||||||
/*
|
|
||||||
#define SOUND_CLICK 0
|
|
||||||
#define SOUND_JUMP1 1
|
|
||||||
#define SOUND_JUMP2 2
|
|
||||||
#define SOUND_JUMPEND 3
|
|
||||||
#define SOUND_JUMPTOC 4
|
|
||||||
#define SOUND_TURN 5
|
|
||||||
#define SOUND_VERTIGO 6
|
|
||||||
#define SOUND_DOWN 7
|
|
||||||
#define SOUND_FALL 8
|
|
||||||
#define SOUND_NEW 9
|
|
||||||
#define SOUND_BOUM 10
|
|
||||||
#define SOUND_TRESOR 11
|
|
||||||
#define SOUND_EGG 12
|
|
||||||
#define SOUND_ENDKO 13
|
|
||||||
#define SOUND_ENDOK 14
|
|
||||||
#define SOUND_HELICOSTART 15
|
|
||||||
#define SOUND_HELICOHIGH 16
|
|
||||||
#define SOUND_HELICOSTOP 17
|
|
||||||
#define SOUND_HELICOLOW 18
|
|
||||||
#define SOUND_LASTTRESOR 19
|
|
||||||
#define SOUND_UP 20
|
|
||||||
#define SOUND_LOOKUP 21
|
|
||||||
#define SOUND_JUMP0 22
|
|
||||||
#define SOUND_PLOUF 23
|
|
||||||
#define SOUND_BLUP 24
|
|
||||||
#define SOUND_SURF 25
|
|
||||||
#define SOUND_DROWN 26
|
|
||||||
#define SOUND_ERROR 27
|
|
||||||
#define SOUND_JEEPSTART 28
|
|
||||||
#define SOUND_JEEPHIGH 29
|
|
||||||
#define SOUND_JEEPSTOP 30
|
|
||||||
#define SOUND_JEEPLOW 31
|
|
||||||
#define SOUND_BYE 32
|
|
||||||
#define SOUND_DOOR 33
|
|
||||||
#define SOUND_SUSPENDTOC 34
|
|
||||||
#define SOUND_SUSPENDJUMP 35
|
|
||||||
#define SOUND_SINGE 36
|
|
||||||
#define SOUND_PATIENT 37
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define SOUND_MOVIE 99
|
|
||||||
|
|
||||||
// Boutons (play) :
|
|
||||||
|
|
||||||
#define MAXBUTTON 40
|
|
||||||
|
|
||||||
#define BUTTON_GO 0
|
|
||||||
#define BUTTON_STOP 1
|
|
||||||
#define BUTTON_MANGE 2
|
|
||||||
#define BUTTON_CARRY 3
|
|
||||||
#define BUTTON_DEPOSE 4
|
|
||||||
#define BUTTON_ABAT 5
|
|
||||||
#define BUTTON_ROC 6
|
|
||||||
#define BUTTON_CULTIVE 7
|
|
||||||
#define BUTTON_BUILD1 8
|
|
||||||
#define BUTTON_BUILD2 9
|
|
||||||
#define BUTTON_BUILD3 10
|
|
||||||
#define BUTTON_BUILD4 11
|
|
||||||
#define BUTTON_BUILD5 12
|
|
||||||
#define BUTTON_BUILD6 13
|
|
||||||
#define BUTTON_MUR 14
|
|
||||||
#define BUTTON_PALIS 15
|
|
||||||
#define BUTTON_ABATn 16
|
|
||||||
#define BUTTON_ROCn 17
|
|
||||||
#define BUTTON_PONT 18
|
|
||||||
#define BUTTON_TOUR 19
|
|
||||||
#define BUTTON_BOIT 20
|
|
||||||
#define BUTTON_LABO 21
|
|
||||||
#define BUTTON_FLEUR 22
|
|
||||||
#define BUTTON_FLEURn 23
|
|
||||||
#define BUTTON_DYNAMITE 24
|
|
||||||
#define BUTTON_BATEAU 25
|
|
||||||
#define BUTTON_DJEEP 26
|
|
||||||
#define BUTTON_DRAPEAU 27
|
|
||||||
#define BUTTON_EXTRAIT 28
|
|
||||||
#define BUTTON_FABJEEP 29
|
|
||||||
#define BUTTON_FABMINE 30
|
|
||||||
#define BUTTON_FABDISC 31
|
|
||||||
#define BUTTON_REPEAT 32
|
|
||||||
#define BUTTON_DARMURE 33
|
|
||||||
#define BUTTON_FABARMURE 34
|
|
||||||
|
|
||||||
|
|
||||||
// Erreurs :
|
|
||||||
|
|
||||||
#define ERROR_MISC 1
|
|
||||||
#define ERROR_GROUND 2
|
|
||||||
#define ERROR_FREE 3
|
|
||||||
#define ERROR_PONTOP 4
|
|
||||||
#define ERROR_PONTTERM 5
|
|
||||||
#define ERROR_TOURISOL 6
|
|
||||||
#define ERROR_TOUREAU 7
|
|
||||||
#define ERROR_TELE2 8
|
|
||||||
|
|
||||||
|
|
||||||
// Lutins pour la souris
|
|
||||||
|
|
||||||
#define SPRITE_ARROW 1
|
|
||||||
#define SPRITE_POINTER 2
|
|
||||||
#define SPRITE_MAP 3
|
|
||||||
#define SPRITE_ARROWU 4
|
|
||||||
#define SPRITE_ARROWD 5
|
|
||||||
#define SPRITE_ARROWL 6
|
|
||||||
#define SPRITE_ARROWR 7
|
|
||||||
#define SPRITE_ARROWUL 8
|
|
||||||
#define SPRITE_ARROWUR 9
|
|
||||||
#define SPRITE_ARROWDL 10
|
|
||||||
#define SPRITE_ARROWDR 11
|
|
||||||
#define SPRITE_WAIT 12
|
|
||||||
#define SPRITE_EMPTY 13
|
|
||||||
#define SPRITE_FILL 14
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define MAXMOVEOBJECT = 200;
|
|
||||||
#define INPUT_LEFT 1
|
|
||||||
#define INPUT_RIGHT 2
|
|
||||||
|
|
||||||
|
|
||||||
// User define message
|
|
||||||
|
|
||||||
#define WM_UPDATE (WM_USER+1)
|
|
||||||
|
|
||||||
#define WM_DECOR1 (WM_USER+20)
|
|
||||||
#define WM_DECOR2 (WM_USER+21)
|
|
||||||
#define WM_DECOR3 (WM_USER+22)
|
|
||||||
#define WM_DECOR4 (WM_USER+23)
|
|
||||||
#define WM_DECOR5 (WM_USER+24)
|
|
||||||
#define WM_DECOR6 1049
|
|
||||||
#define WM_DECOR7 1050
|
|
||||||
#define WM_DECOR8 1051
|
|
||||||
#define WM_DECOR9 1052
|
|
||||||
#define WM_DECOR10 1053
|
|
||||||
#define WM_DECOR11 1054
|
|
||||||
|
|
||||||
#define WM_ACTION_ABAT1 (WM_USER+31)
|
|
||||||
#define WM_ACTION_ABAT2 (WM_USER+32)
|
|
||||||
#define WM_ACTION_ABAT3 (WM_USER+33)
|
|
||||||
#define WM_ACTION_ABAT4 (WM_USER+34)
|
|
||||||
#define WM_ACTION_ABAT5 (WM_USER+35)
|
|
||||||
#define WM_ACTION_ABAT6 (WM_USER+36)
|
|
||||||
#define WM_ACTION_BUILD1 (WM_USER+37)
|
|
||||||
#define WM_ACTION_BUILD2 (WM_USER+38)
|
|
||||||
#define WM_ACTION_BUILD3 (WM_USER+39)
|
|
||||||
#define WM_ACTION_BUILD4 (WM_USER+40)
|
|
||||||
#define WM_ACTION_BUILD5 (WM_USER+41)
|
|
||||||
#define WM_ACTION_BUILD6 (WM_USER+42)
|
|
||||||
#define WM_ACTION_STOP (WM_USER+43)
|
|
||||||
#define WM_ACTION_CARRY (WM_USER+44)
|
|
||||||
#define WM_ACTION_DEPOSE (WM_USER+45)
|
|
||||||
#define WM_ACTION_ROC1 (WM_USER+46)
|
|
||||||
#define WM_ACTION_ROC2 (WM_USER+47)
|
|
||||||
#define WM_ACTION_ROC3 (WM_USER+48)
|
|
||||||
#define WM_ACTION_ROC4 (WM_USER+49)
|
|
||||||
#define WM_ACTION_ROC5 (WM_USER+50)
|
|
||||||
#define WM_ACTION_ROC6 (WM_USER+51)
|
|
||||||
#define WM_ACTION_ROC7 (WM_USER+52)
|
|
||||||
#define WM_ACTION_MUR (WM_USER+53)
|
|
||||||
#define WM_ACTION_CULTIVE (WM_USER+54)
|
|
||||||
#define WM_ACTION_CULTIVE2 (WM_USER+55)
|
|
||||||
#define WM_ACTION_MANGE (WM_USER+56)
|
|
||||||
#define WM_ACTION_MAKE (WM_USER+57)
|
|
||||||
#define WM_ACTION_BUILD (WM_USER+58)
|
|
||||||
#define WM_ACTION_PALIS (WM_USER+59)
|
|
||||||
#define WM_ACTION_NEWBLUPI (WM_USER+60)
|
|
||||||
#define WM_ACTION_PONTE (WM_USER+61)
|
|
||||||
#define WM_ACTION_PONTS (WM_USER+62)
|
|
||||||
#define WM_ACTION_PONTO (WM_USER+63)
|
|
||||||
#define WM_ACTION_PONTN (WM_USER+64)
|
|
||||||
#define WM_ACTION_PONTEL (WM_USER+65)
|
|
||||||
#define WM_ACTION_PONTSL (WM_USER+66)
|
|
||||||
#define WM_ACTION_PONTOL (WM_USER+67)
|
|
||||||
#define WM_ACTION_PONTNL (WM_USER+68)
|
|
||||||
#define WM_ACTION_TOUR (WM_USER+69)
|
|
||||||
#define WM_ACTION_CARRY2 (WM_USER+70)
|
|
||||||
#define WM_ACTION_DEPOSE2 (WM_USER+71)
|
|
||||||
#define WM_ACTION_MANGE2 (WM_USER+72)
|
|
||||||
#define WM_ACTION_BOIT (WM_USER+73)
|
|
||||||
#define WM_ACTION_BOIT2 (WM_USER+74)
|
|
||||||
#define WM_ACTION_LABO (WM_USER+75)
|
|
||||||
#define WM_ACTION_FLEUR1 (WM_USER+76)
|
|
||||||
#define WM_ACTION_FLEUR2 (WM_USER+77)
|
|
||||||
#define WM_ACTION_DYNAMITE (WM_USER+78)
|
|
||||||
#define WM_ACTION_DYNAMITE2 (WM_USER+79)
|
|
||||||
#define WM_ACTION_T_DYNAMITE (WM_USER+80)
|
|
||||||
#define WM_ACTION_FLEUR3 (WM_USER+81)
|
|
||||||
#define WM_ACTION_R_BUILD1 (WM_USER+82)
|
|
||||||
#define WM_ACTION_R_BUILD2 (WM_USER+83)
|
|
||||||
#define WM_ACTION_R_BUILD3 (WM_USER+84)
|
|
||||||
#define WM_ACTION_R_BUILD4 (WM_USER+85)
|
|
||||||
#define WM_ACTION_R_MAKE1 (WM_USER+86)
|
|
||||||
#define WM_ACTION_R_MAKE2 (WM_USER+87)
|
|
||||||
#define WM_ACTION_R_MAKE3 (WM_USER+88)
|
|
||||||
#define WM_ACTION_R_MAKE4 (WM_USER+89)
|
|
||||||
#define WM_ACTION_R_BUILD5 (WM_USER+90)
|
|
||||||
#define WM_ACTION_R_MAKE5 (WM_USER+91)
|
|
||||||
#define WM_ACTION_BATEAUE (WM_USER+92)
|
|
||||||
#define WM_ACTION_BATEAUS (WM_USER+93)
|
|
||||||
#define WM_ACTION_BATEAUO (WM_USER+94)
|
|
||||||
#define WM_ACTION_BATEAUN (WM_USER+95)
|
|
||||||
#define WM_ACTION_BATEAUDE (WM_USER+96)
|
|
||||||
#define WM_ACTION_BATEAUDS (WM_USER+97)
|
|
||||||
#define WM_ACTION_BATEAUDO (WM_USER+98)
|
|
||||||
#define WM_ACTION_BATEAUDN (WM_USER+99)
|
|
||||||
#define WM_ACTION_BATEAUAE (WM_USER+100)
|
|
||||||
#define WM_ACTION_BATEAUAS (WM_USER+101)
|
|
||||||
#define WM_ACTION_BATEAUAO (WM_USER+102)
|
|
||||||
#define WM_ACTION_BATEAUAN (WM_USER+103)
|
|
||||||
#define WM_ACTION_MJEEP (WM_USER+104)
|
|
||||||
#define WM_ACTION_DJEEP (WM_USER+105)
|
|
||||||
#define WM_ACTION_DRAPEAU (WM_USER+106)
|
|
||||||
#define WM_ACTION_DRAPEAU2 (WM_USER+107)
|
|
||||||
#define WM_ACTION_DRAPEAU3 (WM_USER+108)
|
|
||||||
#define WM_ACTION_EXTRAIT (WM_USER+109)
|
|
||||||
#define WM_ACTION_FABJEEP (WM_USER+110)
|
|
||||||
#define WM_ACTION_FABMINE (WM_USER+111)
|
|
||||||
#define WM_ACTION_MINE (WM_USER+112)
|
|
||||||
#define WM_ACTION_MINE2 (WM_USER+113)
|
|
||||||
#define WM_ACTION_R_BUILD6 (WM_USER+114)
|
|
||||||
#define WM_ACTION_R_MAKE6 (WM_USER+115)
|
|
||||||
#define WM_ACTION_E_RAYON (WM_USER+116)
|
|
||||||
#define WM_ACTION_ELECTRO (WM_USER+117)
|
|
||||||
#define WM_ACTION_ELECTROm (WM_USER+118)
|
|
||||||
#define WM_ACTION_GRILLE (WM_USER+119)
|
|
||||||
#define WM_ACTION_MAISON (WM_USER+120)
|
|
||||||
#define WM_ACTION_FABDISC (WM_USER+121)
|
|
||||||
#define WM_ACTION_A_MORT (WM_USER+122)
|
|
||||||
#define WM_ACTION_REPEAT (WM_USER+123)
|
|
||||||
#define WM_ACTION_TELEPORTE00 (WM_USER+124)
|
|
||||||
#define WM_ACTION_TELEPORTE10 (WM_USER+125)
|
|
||||||
#define WM_ACTION_TELEPORTE01 (WM_USER+126)
|
|
||||||
#define WM_ACTION_TELEPORTE11 (WM_USER+127)
|
|
||||||
#define WM_ACTION_FABARMURE (WM_USER+128)
|
|
||||||
#define WM_ACTION_MARMURE (WM_USER+129)
|
|
||||||
#define WM_ACTION_DARMURE (WM_USER+130)
|
|
||||||
|
|
||||||
#define WM_BUTTON0 (WM_USER+200)
|
|
||||||
#define WM_BUTTON1 (WM_USER+201)
|
|
||||||
#define WM_BUTTON2 (WM_USER+202)
|
|
||||||
#define WM_BUTTON3 (WM_USER+203)
|
|
||||||
#define WM_BUTTON4 (WM_USER+204)
|
|
||||||
#define WM_BUTTON5 (WM_USER+205)
|
|
||||||
#define WM_BUTTON6 (WM_USER+206)
|
|
||||||
#define WM_BUTTON7 (WM_USER+207)
|
|
||||||
#define WM_BUTTON8 (WM_USER+208)
|
|
||||||
#define WM_BUTTON9 (WM_USER+209)
|
|
||||||
#define WM_BUTTON10 (WM_USER+210)
|
|
||||||
#define WM_BUTTON11 (WM_USER+211)
|
|
||||||
#define WM_BUTTON12 (WM_USER+212)
|
|
||||||
#define WM_BUTTON13 (WM_USER+213)
|
|
||||||
#define WM_BUTTON14 (WM_USER+214)
|
|
||||||
#define WM_BUTTON15 (WM_USER+215)
|
|
||||||
#define WM_BUTTON16 (WM_USER+216)
|
|
||||||
#define WM_BUTTON17 (WM_USER+217)
|
|
||||||
#define WM_BUTTON18 (WM_USER+218)
|
|
||||||
#define WM_BUTTON19 (WM_USER+219)
|
|
||||||
#define WM_BUTTON20 (WM_USER+220)
|
|
||||||
#define WM_BUTTON21 (WM_USER+221)
|
|
||||||
#define WM_BUTTON22 (WM_USER+222)
|
|
||||||
#define WM_BUTTON23 (WM_USER+223)
|
|
||||||
#define WM_BUTTON24 (WM_USER+224)
|
|
||||||
#define WM_BUTTON25 (WM_USER+225)
|
|
||||||
#define WM_BUTTON26 (WM_USER+226)
|
|
||||||
#define WM_BUTTON27 (WM_USER+227)
|
|
||||||
#define WM_BUTTON28 (WM_USER+228)
|
|
||||||
#define WM_BUTTON29 (WM_USER+229)
|
|
||||||
#define WM_BUTTON30 (WM_USER+230)
|
|
||||||
#define WM_BUTTON31 (WM_USER+231)
|
|
||||||
#define WM_BUTTON32 (WM_USER+232)
|
|
||||||
#define WM_BUTTON33 (WM_USER+233)
|
|
||||||
#define WM_BUTTON34 (WM_USER+234)
|
|
||||||
#define WM_BUTTON35 (WM_USER+235)
|
|
||||||
#define WM_BUTTON36 (WM_USER+236)
|
|
||||||
#define WM_BUTTON37 (WM_USER+237)
|
|
||||||
#define WM_BUTTON38 (WM_USER+238)
|
|
||||||
#define WM_BUTTON39 (WM_USER+239)
|
|
||||||
|
|
||||||
#define WM_READ0 (WM_USER+300)
|
|
||||||
#define WM_READ1 (WM_USER+301)
|
|
||||||
#define WM_READ2 (WM_USER+302)
|
|
||||||
#define WM_READ3 (WM_USER+303)
|
|
||||||
#define WM_READ4 (WM_USER+304)
|
|
||||||
#define WM_READ5 (WM_USER+305)
|
|
||||||
#define WM_READ6 (WM_USER+306)
|
|
||||||
#define WM_READ7 (WM_USER+307)
|
|
||||||
#define WM_READ8 (WM_USER+308)
|
|
||||||
#define WM_READ9 (WM_USER+309)
|
|
||||||
|
|
||||||
#define WM_WRITE0 (WM_USER+310)
|
|
||||||
#define WM_WRITE1 (WM_USER+311)
|
|
||||||
#define WM_WRITE2 (WM_USER+312)
|
|
||||||
#define WM_WRITE3 (WM_USER+313)
|
|
||||||
#define WM_WRITE4 (WM_USER+314)
|
|
||||||
#define WM_WRITE5 (WM_USER+315)
|
|
||||||
#define WM_WRITE6 (WM_USER+316)
|
|
||||||
#define WM_WRITE7 (WM_USER+317)
|
|
||||||
#define WM_WRITE8 (WM_USER+318)
|
|
||||||
#define WM_WRITE9 (WM_USER+319)
|
|
||||||
|
|
||||||
#define WM_PHASE_INIT (WM_USER+500)
|
|
||||||
#define WM_PHASE_PLAY (WM_USER+501)
|
|
||||||
#define WM_PHASE_BUILD (WM_USER+502)
|
|
||||||
#define WM_PHASE_READ (WM_USER+503)
|
|
||||||
#define WM_PHASE_WRITE (WM_USER+504)
|
|
||||||
#define WM_PHASE_INFO (WM_USER+505)
|
|
||||||
#define WM_PHASE_BUTTON (WM_USER+506)
|
|
||||||
#define WM_PHASE_TERM (WM_USER+507)
|
|
||||||
#define WM_PHASE_WIN (WM_USER+508)
|
|
||||||
#define WM_PHASE_LOST (WM_USER+509)
|
|
||||||
|
|
||||||
|
|
||||||
#define WM_PHASE_MUSIC (WM_USER+512)
|
|
||||||
#define WM_PHASE_PLAYMOVIE (WM_USER+513)
|
|
||||||
#define WM_PHASE_WINMOVIE (WM_USER+514)
|
|
||||||
#define WM_PHASE_SCHOOL (WM_USER+515)
|
|
||||||
#define WM_PHASE_MISSION (WM_USER+516)
|
|
||||||
#define WM_PHASE_LASTWIN (WM_USER+517)
|
|
||||||
#define WM_PHASE_WRITEp (WM_USER+518)
|
|
||||||
#define WM_PHASE_SETUPp (WM_USER+519)
|
|
||||||
#define WM_PHASE_REGION (WM_USER+520)
|
|
||||||
#define WM_PHASE_INSERT (WM_USER+521)
|
|
||||||
#define WM_PHASE_HISTORY0 (WM_USER+522)
|
|
||||||
#define WM_PHASE_HISTORY1 (WM_USER+523)
|
|
||||||
#define WM_PHASE_HELP 1583
|
|
||||||
#define WM_PHASE_H0MOVIE (WM_USER+525)
|
|
||||||
#define WM_PHASE_H1MOVIE (WM_USER+526)
|
|
||||||
#define WM_PHASE_H2MOVIE (WM_USER+527)
|
|
||||||
#define WM_PHASE_TESTCD (WM_USER+528)
|
|
||||||
#define WM_PHASE_MANUEL (WM_USER+529)
|
|
||||||
#define WM_PHASE_PRIVATE (WM_USER+530)
|
|
||||||
#define WM_PHASE_UNDO (WM_USER+531)
|
|
||||||
#define WM_PHASE_BYE (WM_USER+532)
|
|
||||||
#define WM_PHASE_SKILL1 (WM_USER+533)
|
|
||||||
#define WM_PHASE_SKILL2 (WM_USER+534)
|
|
||||||
#define WM_PHASE_DEMO 1557
|
|
||||||
#define WM_PHASE_INTRO1 (WM_USER+536)
|
|
||||||
#define WM_PHASE_INTRO2 (WM_USER+537)
|
|
||||||
#define WM_PHASE_PLAYTEST (WM_USER+538)
|
|
||||||
#define WM_PHASE_WINMOVIEDESIGN (WM_USER+539)
|
|
||||||
#define WM_PHASE_WINMOVIEMULTI (WM_USER+540)
|
|
||||||
|
|
||||||
#define WM_PREV (WM_USER+600)
|
|
||||||
#define WM_NEXT (WM_USER+601)
|
|
||||||
#define WM_MOVIE (WM_USER+602)
|
|
||||||
#define WM_PHASE_CREATE 1579
|
|
||||||
#define WM_PHASE_608 1544
|
|
||||||
|
|
||||||
#define WM_PHASE_NAMEg 1527
|
|
||||||
#define WM_PHASE_CLEARg 1528
|
|
||||||
#define WM_PHASE_SETUP 1534
|
|
||||||
#define WM_PHASE_DOPLAY 1539
|
|
||||||
#define WM_PHASE_WINd 1546
|
|
||||||
#define WM_PHASE_LOSTd 1547
|
|
||||||
#define WM_PHASE_WINMOVIEd 1548
|
|
||||||
#define WM_PHASE_WINm 1549
|
|
||||||
#define WM_PHASE_LOSTm 1550
|
|
||||||
#define WM_PHASE_WINMOVIEm 1551
|
|
||||||
#define WM_PHASE_PRIVATE 1554
|
|
||||||
#define WM_PHASE_NAMEd 1558
|
|
||||||
#define WM_PHASE_WRITEd 1559
|
|
||||||
#define WM_PHASE_READd 1560
|
|
||||||
#define WM_PHASE_CONFIRM 1562
|
|
||||||
#define WM_PHASE_YES 1563
|
|
||||||
#define WM_PHASE_61C 1564
|
|
||||||
#define WM_PHASE_61F 1567
|
|
||||||
#define WM_PHASE_SERVICE 1568
|
|
||||||
#define WM_PHASE_DPLAY_DO_SERVICE 1569
|
|
||||||
#define WM_PHASE_DPLAY_CANCEL_SERVICE 1570
|
|
||||||
#define WM_PHASE_SESSION 1571
|
|
||||||
#define WM_PHASE_JOINGAME 1572
|
|
||||||
#define WM_PHASE_DPLAY_CREATE_LOBBY 1573
|
|
||||||
#define WM_PHASE_DPLAY_REFRESH 1574
|
|
||||||
#define WM_PHASE_DPLAY_CANCEL_SESSION 1575
|
|
||||||
#define WM_PHASE_MULTI 1576
|
|
||||||
#define WM_PHASE_DPLAY_START_GAME_2 1577
|
|
||||||
#define WM_PHASE_DPLAY_CANCEL_MULTI 1578
|
|
||||||
#define WM_PHASE_DPLAY_CREATE 1580
|
|
||||||
#define WM_PHASE_DPLAY_CANCEL_CREATE 1581
|
|
||||||
#define WM_PHASE_STOP 1582
|
|
||||||
#define WM_PHASE_634 1588
|
|
||||||
#define WM_PHASE_GWRITE 1584
|
|
||||||
#define WM_PHASE_GREADp 1585
|
|
||||||
#define WM_PHASE_GREAD 1586
|
|
||||||
#define WM_PHASE_DOQUIT 1587
|
|
||||||
#define WM_PHASE_GAMER 1545
|
|
||||||
#define WM_PHASE_CLEARg 1528
|
|
||||||
#define WM_PHASE_CLEARd 1561
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Types de gestion de la souris.
|
|
||||||
|
|
||||||
#define MOUSETYPEGRA 1
|
|
||||||
#define MOUSETYPEWIN 2
|
|
||||||
#define MOUSETYPEWINPOS 3
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Conditions pour gagner.
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
short bHachBlupi; // blupi sur dalle hachur<75>e
|
|
||||||
short bHachPlanche; // planches sur dalle hachur<75>e
|
|
||||||
short bStopFire; // feu <20>teint
|
|
||||||
short nbMinBlupi; // nb de blupi n<>cessaires
|
|
||||||
short nbMaxBlupi; // nb de blupi n<>cessaires
|
|
||||||
short bHomeBlupi; // blupi <20> la maison
|
|
||||||
short bKillRobots; // plus d'ennemis
|
|
||||||
short bHachTomate; // tomates sur dalle hachur<75>e
|
|
||||||
short bHachMetal; // m<>tal sur dalle hachur<75>e
|
|
||||||
short bHachRobot; // robot sur dalle hachur<75>e
|
|
||||||
short reserve[14];
|
|
||||||
}
|
|
||||||
Term;
|
|
||||||
|
|
357
event.h
@ -1,357 +0,0 @@
|
|||||||
// Event.h
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include "movie.h"
|
|
||||||
#include "menu.h"
|
|
||||||
#include "button.h"
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
UINT message;
|
|
||||||
int type;
|
|
||||||
int iconMenu[20];
|
|
||||||
int x, y;
|
|
||||||
int toolTips[20];
|
|
||||||
}
|
|
||||||
Button;
|
|
||||||
|
|
||||||
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;
|
|
||||||
short minRev;
|
|
||||||
short bSchool;
|
|
||||||
short bPrivate;
|
|
||||||
short world;
|
|
||||||
short skill;
|
|
||||||
short reserve1[99];
|
|
||||||
}
|
|
||||||
DemoHeader;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int time;
|
|
||||||
short input;
|
|
||||||
UINT message;
|
|
||||||
WPARAM wParam;
|
|
||||||
LPARAM lParam;
|
|
||||||
}
|
|
||||||
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:
|
|
||||||
CEvent();
|
|
||||||
~CEvent();
|
|
||||||
|
|
||||||
|
|
||||||
void OutputNetDebug(const char* str);
|
|
||||||
POINT GetMousePos();
|
|
||||||
void Create(HINSTANCE hInstance, HWND hWnd, CPixmap *pPixmap, CDecor *pDecor, CSound *pSound, CMovie *pMovie, CNetwork *pNetwork);
|
|
||||||
void SetFullScreen(BOOL bFullScreen);
|
|
||||||
void SetMouseType(int mouseType);
|
|
||||||
int GetWorld();
|
|
||||||
int GetWorldGroup();
|
|
||||||
void SetMission(int index);
|
|
||||||
int GetPhysicalWorld();
|
|
||||||
int GetImageWorld();
|
|
||||||
BOOL IsHelpHide();
|
|
||||||
BOOL ChangePhase(UINT phase);
|
|
||||||
UINT GetPhase();
|
|
||||||
void MovieToStart();
|
|
||||||
BOOL NetworkNuggets(int fuck);
|
|
||||||
void HandleInputs();
|
|
||||||
void ReadInput();
|
|
||||||
void TryInsert();
|
|
||||||
void SomethingUserMissions(LPCSTR lpFileName, LPCSTR thing);
|
|
||||||
void RestoreGame();
|
|
||||||
int MissionBack();
|
|
||||||
void TableSomething();
|
|
||||||
|
|
||||||
int GetButtonIndex(int button);
|
|
||||||
int GetState(int button);
|
|
||||||
void SetState(int button, int state);
|
|
||||||
BOOL GetEnable(int button);
|
|
||||||
void SetEnable(int button, int bEnable);
|
|
||||||
void SetIconMenu(int button, int* icon, int iconMenu);
|
|
||||||
BOOL GetHide(int button);
|
|
||||||
void SetHide(int button, BOOL bHide);
|
|
||||||
int GetMenu(int button);
|
|
||||||
void SetMenu(int button, int menu);
|
|
||||||
void SomethingDecor();
|
|
||||||
|
|
||||||
void NetSetPause(BOOL bPause, int players);
|
|
||||||
void NetSendLobby();
|
|
||||||
|
|
||||||
BOOL DrawButtons();
|
|
||||||
BOOL TextSomething();
|
|
||||||
int MousePosToSprite(POINT pos);
|
|
||||||
void MouseSprite(POINT pos);
|
|
||||||
void WaitMouse(BOOL bWait);
|
|
||||||
void HideMouse(BOOL bHide);
|
|
||||||
void FillMouse(int bFill);
|
|
||||||
POINT GetLastMousePos();
|
|
||||||
BOOL TreatEvent(UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
BOOL TreatEventBase(UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
void DecorAutoShift(POINT pos);
|
|
||||||
|
|
||||||
BOOL StartMovie(char *pFilename);
|
|
||||||
void StopMovie();
|
|
||||||
BOOL IsMovie();
|
|
||||||
|
|
||||||
void FlushInput();
|
|
||||||
|
|
||||||
BOOL FlipObject();
|
|
||||||
|
|
||||||
void Read(int message);
|
|
||||||
void Write(int message);
|
|
||||||
|
|
||||||
void SetSpeed(int speed);
|
|
||||||
int GetSpeed();
|
|
||||||
BOOL GetPause();
|
|
||||||
void GetDoors(int doors);
|
|
||||||
BOOL IsShift();
|
|
||||||
BOOL IsMulti();
|
|
||||||
BOOL IsPrivate();
|
|
||||||
|
|
||||||
void DemoStep();
|
|
||||||
void DebugDisplay(char m);
|
|
||||||
|
|
||||||
void IntroStep();
|
|
||||||
void SetLives(int lives);
|
|
||||||
|
|
||||||
void ReadAll();
|
|
||||||
BOOL SaveState(int rank);
|
|
||||||
BOOL LoadDecorRegion();
|
|
||||||
BOOL CreateCelPosForMenu(UINT celX, UINT celY, WPARAM wParam);
|
|
||||||
void SomethingUserMissions(char* lpFilename, LPCSTR fileSomething);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void DrawTextCenter(int res, int x, int y, int font=0);
|
|
||||||
BOOL CreateButtons();
|
|
||||||
BOOL EventButtons(UINT message, WPARAM wParam, LPARAM lParam);
|
|
||||||
BOOL MouseOnButton(POINT pos);
|
|
||||||
int SearchPhase(UINT phase);
|
|
||||||
void DecorShift(int dx, int dy);
|
|
||||||
|
|
||||||
BOOL PlayDown(POINT pos, int fwKeys);
|
|
||||||
BOOL PlayMove(POINT pos, int fwKeys);
|
|
||||||
BOOL PlayUp(POINT pos, int fwKeys);
|
|
||||||
void ChangeButtons(int message);
|
|
||||||
|
|
||||||
void BuildFloor(POINT cel, int insIcon);
|
|
||||||
void BuildWater(POINT cel, int insIcon);
|
|
||||||
BOOL BuildDown(POINT pos, int fwKeys, BOOL bMix=TRUE);
|
|
||||||
BOOL BuildMove(POINT pos, int fwKeys);
|
|
||||||
BOOL BuildUp();
|
|
||||||
BOOL PlaceMenu(int celX, int celY, int WPARAM, int* object);
|
|
||||||
|
|
||||||
void PrivateLibelle();
|
|
||||||
BOOL ReadLibelle(int world, BOOL bSchool, BOOL bHelp);
|
|
||||||
BOOL WriteInfo(int gamer, char* playername);
|
|
||||||
BOOL ReadInfo(int gamer);
|
|
||||||
BOOL LoadState(BOOL save);
|
|
||||||
void TryPhase();
|
|
||||||
void UnTryPhase();
|
|
||||||
int GetTryPhase();
|
|
||||||
BOOL ReadPlayer(int gamer);
|
|
||||||
void PutTextInputBox(POINT pos);
|
|
||||||
void ChatLength();
|
|
||||||
|
|
||||||
|
|
||||||
void DemoRecStart();
|
|
||||||
void DemoRecStop();
|
|
||||||
BOOL DemoPlayStart();
|
|
||||||
void DemoPlayStop();
|
|
||||||
void DemoRecEvent(UINT message, UINT input, WPARAM wParam, LPARAM lParam);
|
|
||||||
|
|
||||||
// Network Functions
|
|
||||||
BOOL NetCreate(int session);
|
|
||||||
BOOL NetEnumSessions();
|
|
||||||
int NetSearchPlayer(DPID dpid);
|
|
||||||
void NetStartPlay();
|
|
||||||
void NetSend(NetMessageType message, USHORT data);
|
|
||||||
void NetDraw();
|
|
||||||
void ChatSend();
|
|
||||||
void HandleChatBuffer();
|
|
||||||
void ChatMessageSound(char* data);
|
|
||||||
|
|
||||||
void MouseRelease();
|
|
||||||
void MouseCapture();
|
|
||||||
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int m_speed;
|
|
||||||
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_saveIndex;
|
|
||||||
int m_menuDecor[10];
|
|
||||||
BOOL m_bMouseRelease;
|
|
||||||
int m_private;
|
|
||||||
int m_maxMission;
|
|
||||||
int m_phase;
|
|
||||||
int m_index;
|
|
||||||
int m_playerIndex;
|
|
||||||
BOOL m_bSchool;
|
|
||||||
BOOL m_bPrivate;
|
|
||||||
BOOL m_bMulti;
|
|
||||||
BOOL m_bAccessBuild;
|
|
||||||
BOOL m_bFullScreen;
|
|
||||||
BOOL m_bDrawMap;
|
|
||||||
int m_mouseType;
|
|
||||||
HWND m_hWnd;
|
|
||||||
CPixmap* m_pPixmap;
|
|
||||||
CDecor* m_pDecor;
|
|
||||||
CSound* m_pSound;
|
|
||||||
CMovie* m_pMovie;
|
|
||||||
CNetwork* m_pNetwork;
|
|
||||||
char m_movieToStart[MAX_PATH];
|
|
||||||
WMessage m_phaseAfterMovie;
|
|
||||||
CButton m_buttons[MAXBUTTON];
|
|
||||||
int m_lastFloor[MAXBUTTON];
|
|
||||||
int m_lastObject[MAXBUTTON];
|
|
||||||
int m_lastHome[MAXBUTTON];
|
|
||||||
BOOL m_bRunMovie;
|
|
||||||
BOOL m_bBuildModify;
|
|
||||||
CJauge m_jauges[2];
|
|
||||||
CMenu m_menu;
|
|
||||||
BOOL m_bMenu;
|
|
||||||
POINT m_menuPos;
|
|
||||||
int m_menuNb;
|
|
||||||
int m_menuButtons[MAXBUTTON];
|
|
||||||
int m_menuErrors[MAXBUTTON];
|
|
||||||
int m_menuPerso;
|
|
||||||
POINT m_menuCel;
|
|
||||||
POINT m_oldMousePos;
|
|
||||||
BOOL m_bMousePress;
|
|
||||||
BOOL m_bMouseDown;
|
|
||||||
BOOL m_bHili;
|
|
||||||
int m_fileWorld[10];
|
|
||||||
int m_fileTime[10];
|
|
||||||
POINT m_posToolTips;
|
|
||||||
char m_textToolTips[50];
|
|
||||||
int m_mouseSprite;
|
|
||||||
BOOL m_bFillMouse;
|
|
||||||
BOOL m_bWaitMouse;
|
|
||||||
BOOL m_bHideMouse;
|
|
||||||
BOOL m_bShowMouse;
|
|
||||||
int m_rankCheat;
|
|
||||||
int m_posCheat;
|
|
||||||
BOOL m_bMovie;
|
|
||||||
BOOL m_bSpeed;
|
|
||||||
BOOL m_bHelp;
|
|
||||||
BOOL m_bAllMissions;
|
|
||||||
BOOL m_bChangeCheat;
|
|
||||||
int m_scrollSpeed;
|
|
||||||
BOOL m_bPause;
|
|
||||||
BOOL m_bShift;
|
|
||||||
int m_shiftPhase;
|
|
||||||
POINT m_shiftVector;
|
|
||||||
POINT m_shiftOffset;
|
|
||||||
char m_libelle[1000];
|
|
||||||
char m_filenameBuffer[100][256];
|
|
||||||
int m_tryPhase;
|
|
||||||
int m_tryInsertCount;
|
|
||||||
POINT m_posInfoButton;
|
|
||||||
POINT m_posHelpButton;
|
|
||||||
BOOL m_bHiliInfoButton;
|
|
||||||
BOOL m_bHiliHelpButton;
|
|
||||||
BOOL m_bInfoHelp;
|
|
||||||
BOOL m_bDemoRec;
|
|
||||||
BOOL m_bDemoPlay;
|
|
||||||
DemoEvent* m_pDemoBuffer;
|
|
||||||
int m_demoTime;
|
|
||||||
int m_input;
|
|
||||||
int m_demoIndex;
|
|
||||||
int m_demoEnd;
|
|
||||||
int m_demoNumber;
|
|
||||||
BOOL m_bCtrlDown;
|
|
||||||
POINT m_debugPos;
|
|
||||||
int m_introTime;
|
|
||||||
int m_joyID;
|
|
||||||
int m_gamer;
|
|
||||||
int m_textHiliStart;
|
|
||||||
int m_textHiliEnd;
|
|
||||||
int m_textCursorIndex;
|
|
||||||
char m_textInput[100];
|
|
||||||
char m_pPlayerName[100];
|
|
||||||
int m_lives;
|
|
||||||
int m_multi;
|
|
||||||
HINSTANCE m_hInstance;
|
|
||||||
char m_chatZone[100][5];
|
|
||||||
char m_text[100];
|
|
||||||
};
|
|
||||||
|
|
||||||
extern
|
|
||||||
int DirectoryThing(LPCSTR filename);
|
|
33
fifo.h
@ -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();
|
|
||||||
};
|
|
149
jauge.cpp
@ -1,149 +0,0 @@
|
|||||||
// Jauge.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ddraw.h>
|
|
||||||
#include <minwindef.h>
|
|
||||||
#include <windef.h>
|
|
||||||
#include "def.h"
|
|
||||||
#include "pixmap.h"
|
|
||||||
#include "sound.h"
|
|
||||||
#include "decor.h"
|
|
||||||
#include "jauge.h"
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
// Constructor
|
|
||||||
|
|
||||||
CJauge::CJauge()
|
|
||||||
{
|
|
||||||
m_type = 0;
|
|
||||||
m_bHide = TRUE;
|
|
||||||
m_bMinimizeRedraw = FALSE;
|
|
||||||
m_bRedraw = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructor
|
|
||||||
|
|
||||||
CJauge::~CJauge()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new Button.
|
|
||||||
|
|
||||||
BOOL CJauge::Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
|
||||||
POINT pos, int type, BOOL bMinimizeRedraw)
|
|
||||||
{
|
|
||||||
m_hWnd = hWnd;
|
|
||||||
m_pPixmap = pPixmap;
|
|
||||||
m_pSound = pSound;
|
|
||||||
m_type = type;
|
|
||||||
m_bMinimizeRedraw = bMinimizeRedraw;
|
|
||||||
m_bHide = TRUE;
|
|
||||||
m_pos = pos;
|
|
||||||
m_dim.x = DIMJAUGEX;
|
|
||||||
m_dim.y = DIMJAUGEY;
|
|
||||||
m_level = 0;
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CJauge::Draw()
|
|
||||||
{
|
|
||||||
RECT rect;
|
|
||||||
char num2[12];
|
|
||||||
|
|
||||||
if (m_bMinimizeRedraw && !m_bRedraw) return;
|
|
||||||
m_bRedraw = FALSE;
|
|
||||||
|
|
||||||
if (m_bHide) // bouton cach<63> ?
|
|
||||||
{
|
|
||||||
rect.right = m_dim.x + m_pos.x;
|
|
||||||
rect.left = m_pos.x;
|
|
||||||
rect.top = m_pos.y;
|
|
||||||
rect.bottom = m_dim.y + m_pos.y;
|
|
||||||
m_pPixmap->DrawPart(-1, 0, m_pos, rect, 1, FALSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int num = m_level * 114 / 100;
|
|
||||||
|
|
||||||
*(char*)num2 = (124) << 64;
|
|
||||||
rect.bottom = 22;
|
|
||||||
rect.left = LOWORD(num2);
|
|
||||||
rect.top = HIWORD(num2);
|
|
||||||
rect.right = HIWORD(num2);
|
|
||||||
m_pPixmap->DrawPart(-1, 5, m_pos, rect, 0, FALSE);
|
|
||||||
if (num > 0)
|
|
||||||
{
|
|
||||||
rect.bottom = num + 6;
|
|
||||||
rect.left = m_type * 22;
|
|
||||||
rect.top = (m_type + 1) * 22;
|
|
||||||
rect.right = 0;
|
|
||||||
m_pPixmap->DrawPart(-1, 5, m_pos, rect, 0, FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void CJauge::Redraw()
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CJauge::SetLevel(int level)
|
|
||||||
{
|
|
||||||
if ( level < 0 ) level = 0;
|
|
||||||
if ( level > 100 ) level = 100;
|
|
||||||
|
|
||||||
if ( m_level != level )
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_level = level;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CJauge::GetLevel()
|
|
||||||
{
|
|
||||||
return m_level;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int CJauge::GetType()
|
|
||||||
{
|
|
||||||
return m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void CJauge::SetType(int type)
|
|
||||||
{
|
|
||||||
if ( m_type != type )
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_type = type;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CJauge::GetHide()
|
|
||||||
{
|
|
||||||
return m_bHide;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CJauge::SetHide(BOOL bHide)
|
|
||||||
{
|
|
||||||
if ( m_bHide != bHide )
|
|
||||||
{
|
|
||||||
m_bRedraw = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_bHide = bHide;
|
|
||||||
}
|
|
||||||
|
|
53
jauge.h
@ -1,53 +0,0 @@
|
|||||||
// Jauge.h
|
|
||||||
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
#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
|
|
||||||
|
|
||||||
class CJauge
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CJauge();
|
|
||||||
~CJauge();
|
|
||||||
|
|
||||||
BOOL Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
|
||||||
POINT pos, int type, BOOL bMinimizeRedraw);
|
|
||||||
void Draw();
|
|
||||||
void Redraw();
|
|
||||||
|
|
||||||
void SetLevel(int level);
|
|
||||||
int GetLevel();
|
|
||||||
void SetType(int type);
|
|
||||||
int GetType();
|
|
||||||
|
|
||||||
BOOL GetHide();
|
|
||||||
void SetHide(BOOL bHide);
|
|
||||||
|
|
||||||
POINT GetPos();
|
|
||||||
void SetRedraw();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
HWND m_hWnd;
|
|
||||||
CPixmap* m_pPixmap;
|
|
||||||
CSound* m_pSound;
|
|
||||||
BOOL m_bHide;
|
|
||||||
POINT m_pos;
|
|
||||||
POINT m_dim;
|
|
||||||
int m_type;
|
|
||||||
int m_level;
|
|
||||||
BOOL m_bMinimizeRedraw;
|
|
||||||
BOOL m_bRedraw;
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
|
168
menu.cpp
@ -1,168 +0,0 @@
|
|||||||
// Menu.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ddraw.h>
|
|
||||||
#include "def.h"
|
|
||||||
#include "resource.h"
|
|
||||||
#include "pixmap.h"
|
|
||||||
#include "sound.h"
|
|
||||||
#include "decor.h"
|
|
||||||
#include "button.h"
|
|
||||||
#include "menu.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
#define MARGMENU 0
|
|
||||||
|
|
||||||
|
|
||||||
static short table_button_icon[] =
|
|
||||||
{
|
|
||||||
24, // go
|
|
||||||
40, // stop
|
|
||||||
32, // mange
|
|
||||||
30, // carry
|
|
||||||
31, // depose
|
|
||||||
22, // abat
|
|
||||||
27, // roc
|
|
||||||
28, // cultive
|
|
||||||
19, // build1 (cabane)
|
|
||||||
25, // build2 (couveuse)
|
|
||||||
35, // build3 (laboratoire)
|
|
||||||
61, // build4 (mine)
|
|
||||||
59, // build5 (usine)
|
|
||||||
101, // build6 (t<>l<EFBFBD>porteur)
|
|
||||||
20, // mur
|
|
||||||
26, // palis
|
|
||||||
42, // abat n
|
|
||||||
43, // roc n
|
|
||||||
23, // pont
|
|
||||||
33, // tour
|
|
||||||
34, // boit
|
|
||||||
39, // labo
|
|
||||||
54, // fleur
|
|
||||||
55, // fleur n
|
|
||||||
41, // dynamite
|
|
||||||
58, // bateau
|
|
||||||
60, // djeep
|
|
||||||
64, // drapeau
|
|
||||||
62, // extrait du fer
|
|
||||||
65, // fabrique jeep
|
|
||||||
63, // fabrique mine
|
|
||||||
83, // fabrique disciple
|
|
||||||
100, // repeat
|
|
||||||
107, // qarmure
|
|
||||||
106, // fabarmure
|
|
||||||
};
|
|
||||||
|
|
||||||
void GetText(int rank, char *pBuffer, int lgBuffer)
|
|
||||||
{
|
|
||||||
LoadString(TX_ACTION_GO+rank, pBuffer, lgBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetErr(int rank, char *pBuffer, int lgBuffer)
|
|
||||||
{
|
|
||||||
LoadString(TX_ERROR_MISC+rank, pBuffer, lgBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
CMenu::CMenu()
|
|
||||||
{
|
|
||||||
m_nbButtons = 0;
|
|
||||||
m_selRank = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
CMenu::~CMenu()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMenu::Delete()
|
|
||||||
{
|
|
||||||
m_nbButtons = 0;
|
|
||||||
m_selRank = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMenu::TreatEvent(UINT message, WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
|
||||||
POINT pos;
|
|
||||||
|
|
||||||
if ( m_nbButtons == 0 ) return FALSE;
|
|
||||||
|
|
||||||
pos = ConvLongToPos(lParam);
|
|
||||||
|
|
||||||
switch( message )
|
|
||||||
{
|
|
||||||
case WM_LBUTTONDOWN:
|
|
||||||
case WM_RBUTTONDOWN:
|
|
||||||
if ( MouseDown(pos) ) return TRUE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
|
||||||
if ( MouseMove(pos) ) return TRUE;
|
|
||||||
break;
|
|
||||||
case WM_LBUTTONUP:
|
|
||||||
case WM_RBUTTONUP:
|
|
||||||
if ( MouseUp(pos) ) return TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CMenu::Detect(POINT pos)
|
|
||||||
{
|
|
||||||
int rank;
|
|
||||||
|
|
||||||
if ( pos.x < m_pos.x || pos.x > m_pos.x+m_dim.x ||
|
|
||||||
pos.y < m_pos.y || pos.y > m_pos.y+m_dim.y ) return -1;
|
|
||||||
|
|
||||||
rank = (pos.y-m_pos.y)/(DIMBUTTONY+MARGMENU);
|
|
||||||
rank += ((pos.x-m_pos.x)/(DIMBUTTONX+MARGMENU))*m_nbCel.y;
|
|
||||||
|
|
||||||
if ( rank >= m_nbButtons ) return -1;
|
|
||||||
return rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMenu::MouseDown(POINT pos)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMenu::MouseMove(POINT pos)
|
|
||||||
{
|
|
||||||
m_mousePos = pos;
|
|
||||||
m_selRank = Detect(pos);
|
|
||||||
|
|
||||||
if ( pos.x < m_pos.x-(DIMBUTTONX+MARGMENU) ||
|
|
||||||
pos.x > m_pos.x+m_dim.x+(DIMBUTTONX+MARGMENU) ||
|
|
||||||
pos.y < m_pos.y-(DIMBUTTONY+MARGMENU) ||
|
|
||||||
pos.y > m_pos.y+m_dim.y+(DIMBUTTONY+MARGMENU) )
|
|
||||||
{
|
|
||||||
Delete(); // enl<6E>ve le menu si souris trop loin !
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CMenu::MouseUp(POINT pos)
|
|
||||||
{
|
|
||||||
m_mousePos = pos;
|
|
||||||
m_selRank = Detect(pos);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CMenu::Message()
|
|
||||||
{
|
|
||||||
if ( m_selRank != -1 )
|
|
||||||
{
|
|
||||||
PostMessage(m_hWnd, WM_BUTTON0+m_selRank, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
55
menu.h
@ -1,55 +0,0 @@
|
|||||||
// Menu.h
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <minwindef.h>
|
|
||||||
#include <windef.h>
|
|
||||||
#include "decor.h"
|
|
||||||
#include "pixmap.h"
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class CMenu
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMenu();
|
|
||||||
~CMenu();
|
|
||||||
|
|
||||||
BOOL Create(HWND hWnd, CPixmap *pPixmap, CSound *pSound,
|
|
||||||
POINT pos, int nbm, int *pButtons, int *pErrors,
|
|
||||||
int perso);
|
|
||||||
void Update(int nb, int *pButtons, int *pErrors);
|
|
||||||
void Delete();
|
|
||||||
void Draw();
|
|
||||||
int GetSel();
|
|
||||||
int GetRank();
|
|
||||||
BOOL IsError();
|
|
||||||
BOOL IsExist();
|
|
||||||
void Message();
|
|
||||||
|
|
||||||
BOOL TreatEvent(UINT message, WPARAM wParam, LPARAM lPararm);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int Detect(POINT pos);
|
|
||||||
BOOL MouseDown(POINT pos);
|
|
||||||
BOOL MouseMove(POINT pos);
|
|
||||||
BOOL MouseUp(POINT pos);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
HWND m_hWnd;
|
|
||||||
CPixmap* m_pPixmap;
|
|
||||||
CDecor* m_pDecor;
|
|
||||||
CSound* m_pSound;
|
|
||||||
POINT m_pos;
|
|
||||||
POINT m_dim;
|
|
||||||
int m_nbButtons;
|
|
||||||
POINT m_nbCel;
|
|
||||||
int m_perso;
|
|
||||||
int m_buttons[MAXBUTTON];
|
|
||||||
int m_errors[MAXBUTTON];
|
|
||||||
UINT m_messages[MAXBUTTON];
|
|
||||||
int m_selRank;
|
|
||||||
POINT m_mousePos;
|
|
||||||
};
|
|
379
misc.cpp
@ -1,379 +0,0 @@
|
|||||||
// Misc.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#include <dsound.h>
|
|
||||||
#include <ddraw.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "def.h"
|
|
||||||
|
|
||||||
#pragma warning (disable : 4996)
|
|
||||||
|
|
||||||
|
|
||||||
// Global Variables
|
|
||||||
|
|
||||||
HINSTANCE g_hInstance;
|
|
||||||
int g_lastSprite = 0;
|
|
||||||
extern BOOL g_bFullScreen;
|
|
||||||
extern int g_mouseType;
|
|
||||||
extern char g_CDPath[MAX_PATH];
|
|
||||||
|
|
||||||
//Initalize HInstance.
|
|
||||||
|
|
||||||
void InitHInstance(HINSTANCE hInstance)
|
|
||||||
{
|
|
||||||
g_hInstance = hInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutputDebug(const char *pMessage)
|
|
||||||
{
|
|
||||||
#ifdef _DEBUG
|
|
||||||
OutputDebugStringA(pMessage);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadString(UINT nID, char *pBuffer, int lgBuffer)
|
|
||||||
{
|
|
||||||
LoadStringA(g_hInstance, nID, pBuffer, lgBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ChangeSprite(int sprite)
|
|
||||||
{
|
|
||||||
HCURSOR hCursor = nullptr;
|
|
||||||
|
|
||||||
if ( g_mouseType == MOUSETYPEGRA ) return;
|
|
||||||
if ( g_lastSprite == sprite ) return;
|
|
||||||
|
|
||||||
if ( sprite == SPRITE_ARROW ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROW");
|
|
||||||
if ( sprite == SPRITE_POINTER ) hCursor = LoadCursorA(g_hInstance, "IDC_POINTER");
|
|
||||||
if ( sprite == SPRITE_MAP ) hCursor = LoadCursorA(g_hInstance, "IDC_MAP");
|
|
||||||
if ( sprite == SPRITE_ARROWU ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROWU");
|
|
||||||
if ( sprite == SPRITE_ARROWD ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROWD");
|
|
||||||
if ( sprite == SPRITE_ARROWL ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROWL");
|
|
||||||
if ( sprite == SPRITE_ARROWR ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROWR");
|
|
||||||
if ( sprite == SPRITE_ARROWUL ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROWUL");
|
|
||||||
if ( sprite == SPRITE_ARROWUR ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROWUR");
|
|
||||||
if ( sprite == SPRITE_ARROWDL ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROWDL");
|
|
||||||
if ( sprite == SPRITE_ARROWDR ) hCursor = LoadCursorA(g_hInstance, "IDC_ARROWDR");
|
|
||||||
if ( sprite == SPRITE_WAIT ) hCursor = LoadCursorA(g_hInstance, "IDC_WAIT");
|
|
||||||
if ( sprite == SPRITE_EMPTY ) hCursor = LoadCursorA(g_hInstance, "IDC_EMPTY");
|
|
||||||
if ( sprite == SPRITE_FILL ) hCursor = LoadCursorA(g_hInstance, "IDC_FILL");
|
|
||||||
SetCursor(hCursor);
|
|
||||||
|
|
||||||
g_lastSprite = sprite;
|
|
||||||
}
|
|
||||||
|
|
||||||
POINT ConvLongToPos(LPARAM lParam)
|
|
||||||
{
|
|
||||||
POINT pos;
|
|
||||||
|
|
||||||
pos.x = LOWORD(lParam);
|
|
||||||
pos.y = HIWORD(lParam);
|
|
||||||
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitRandom()
|
|
||||||
{
|
|
||||||
srand(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
int Random(int min, int max)
|
|
||||||
{
|
|
||||||
long n;
|
|
||||||
|
|
||||||
n = rand();
|
|
||||||
n = min+(n%(max-min+1));
|
|
||||||
|
|
||||||
return (int)n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
BOOL IntersectRect(RECT dst, RECT src1, RECT src2)
|
|
||||||
{
|
|
||||||
dst.left = max(src1.left, src2.left);
|
|
||||||
dst.right = min(src1.right, src2.right);
|
|
||||||
dst.top = max(src1.top, src2.top);
|
|
||||||
dst.bottom = min(src1.bottom, src2.bottom);
|
|
||||||
return IsRectEmpty(dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL IsRectEmpty(RECT rect)
|
|
||||||
{
|
|
||||||
return rect.left >= rect.right || rect.top >= rect.bottom;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
void GetCurrentDir(char *pName, int lg)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
strncpy(pName, _pgmptr, lg-1);
|
|
||||||
pName[lg-1] = 0;
|
|
||||||
|
|
||||||
lg = strlen(pName);
|
|
||||||
if ( lg == 0 ) return;
|
|
||||||
|
|
||||||
for ( i=0 ; i<lg ; i++ )
|
|
||||||
{
|
|
||||||
pName[i] = tolower(pName[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( lg > 0 )
|
|
||||||
{
|
|
||||||
lg --;
|
|
||||||
if ( pName[lg] == '\\' )
|
|
||||||
{
|
|
||||||
pName[lg+1] = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( lg > 6 && strcmp(pName+lg-6, "\\debug\\") == 0 )
|
|
||||||
{
|
|
||||||
pName[lg-5] = 0; // ignore le dossier \debug !
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int Speed(double speed, int max)
|
|
||||||
{
|
|
||||||
if (speed > 0.0)
|
|
||||||
{
|
|
||||||
return max((int)(speed * (double)max), 1);
|
|
||||||
}
|
|
||||||
if (speed < 0.0)
|
|
||||||
{
|
|
||||||
return min((int)(speed * (double)max), -1);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddCDPath(char *pFilename)
|
|
||||||
{
|
|
||||||
char temp[MAX_PATH];
|
|
||||||
int lg;
|
|
||||||
BOOL bDaniel = FALSE;
|
|
||||||
|
|
||||||
if ( g_CDPath[0] == 0 ) return;
|
|
||||||
|
|
||||||
lg = strlen(g_CDPath);
|
|
||||||
if ( lg > 14 && strstr(g_CDPath+lg-14, "\\daniel\\blupi\\") )
|
|
||||||
{
|
|
||||||
bDaniel = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if _DEMO
|
|
||||||
strcpy(temp, g_CDPath);
|
|
||||||
strcat(temp, pFilename);
|
|
||||||
#else
|
|
||||||
if ( !bDaniel &&
|
|
||||||
(strstr(pFilename, "image08\\") == pFilename ||
|
|
||||||
strstr(pFilename, "data\\") == pFilename ||
|
|
||||||
strstr(pFilename, "image16\\") == pFilename ||
|
|
||||||
strstr(pFilename, "sound\\")) )
|
|
||||||
{
|
|
||||||
strcpy(temp, g_CDPath);
|
|
||||||
strcat(temp, "..\\");
|
|
||||||
strcat(temp, pFilename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(temp, g_CDPath);
|
|
||||||
strcat(temp, pFilename);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
strcpy(pFilename, temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddUserPath(char *pFilename)
|
|
||||||
{
|
|
||||||
char temp[MAX_PATH];
|
|
||||||
char* pText;
|
|
||||||
int pos;
|
|
||||||
char last;
|
|
||||||
SECURITY_ATTRIBUTES att;
|
|
||||||
|
|
||||||
if ( g_CDPath[0] != 0 ) return;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
strcpy(temp, "c:\\Speedy_Blupi\\");
|
|
||||||
|
|
||||||
att.nLength = sizeof(SECURITY_ATTRIBUTES);
|
|
||||||
att.lpSecurityDescriptor = NULL;
|
|
||||||
att.bInheritHandle = FALSE;
|
|
||||||
CreateDirectoryA(temp, &att);
|
|
||||||
|
|
||||||
pText = strstr(pFilename, "\\");
|
|
||||||
if ( pText != NULL )
|
|
||||||
{
|
|
||||||
pos = strlen(temp)+(pText-pFilename)+1;
|
|
||||||
strcat(temp, pFilename);
|
|
||||||
last = temp[pos];
|
|
||||||
temp[pos] = 0;
|
|
||||||
CreateDirectoryA(temp, &att);
|
|
||||||
temp[pos] = last;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcat(temp, pFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(pFilename, temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TraceErrorDD(HRESULT hErr, const char *sFile, int nLine)
|
|
||||||
{
|
|
||||||
char dderr[256];
|
|
||||||
char err[1024];
|
|
||||||
|
|
||||||
switch (hErr)
|
|
||||||
{
|
|
||||||
case DD_OK : sprintf(dderr, "DD_OK"); break;
|
|
||||||
case DDERR_ALREADYINITIALIZED : sprintf(dderr, "DDERR_ALREADYINITIALIZED"); break;
|
|
||||||
case DDERR_CANNOTATTACHSURFACE : sprintf(dderr, "DDERR_CANNOTATTACHSURFACE"); break;
|
|
||||||
case DDERR_CANNOTDETACHSURFACE : sprintf(dderr, "DDERR_CANNOTDETACHSURFACE"); break;
|
|
||||||
case DDERR_CURRENTLYNOTAVAIL : sprintf(dderr, "DDERR_CURRENTLYNOTAVAIL"); break;
|
|
||||||
case DDERR_EXCEPTION : sprintf(dderr, "DDERR_EXCEPTION"); break;
|
|
||||||
case DDERR_GENERIC : sprintf(dderr, "DDERR_GENERIC"); break;
|
|
||||||
case DDERR_HEIGHTALIGN : sprintf(dderr, "DDERR_HEIGHTALIGN"); break;
|
|
||||||
case DDERR_INCOMPATIBLEPRIMARY : sprintf(dderr, "DDERR_INCOMPATIBLEPRIMARY"); break;
|
|
||||||
case DDERR_INVALIDCAPS : sprintf(dderr, "DDERR_INVALIDCAPS"); break;
|
|
||||||
case DDERR_INVALIDCLIPLIST : sprintf(dderr, "DDERR_INVALIDCLIPLIST"); break;
|
|
||||||
case DDERR_INVALIDMODE : sprintf(dderr, "DDERR_INVALIDMODE"); break;
|
|
||||||
case DDERR_INVALIDOBJECT : sprintf(dderr, "DDERR_INVALIDOBJECT"); break;
|
|
||||||
case DDERR_INVALIDPARAMS : sprintf(dderr, "DDERR_INVALIDPARAMS"); break;
|
|
||||||
case DDERR_INVALIDPIXELFORMAT : sprintf(dderr, "DDERR_INVALIDPIXELFORMAT"); break;
|
|
||||||
case DDERR_INVALIDRECT : sprintf(dderr, "DDERR_INVALIDRECT"); break;
|
|
||||||
case DDERR_LOCKEDSURFACES : sprintf(dderr, "DDERR_LOCKEDSURFACES"); break;
|
|
||||||
case DDERR_NO3D : sprintf(dderr, "DDERR_NO3D"); break;
|
|
||||||
case DDERR_NOALPHAHW : sprintf(dderr, "DDERR_NOALPHAHW"); break;
|
|
||||||
case DDERR_NOCLIPLIST : sprintf(dderr, "DDERR_NOCLIPLIST"); break;
|
|
||||||
case DDERR_NOCOLORCONVHW : sprintf(dderr, "DDERR_NOCOLORCONVHW"); break;
|
|
||||||
case DDERR_NOCOOPERATIVELEVELSET : sprintf(dderr, "DDERR_NOCOOPERATIVELEVELSET"); break;
|
|
||||||
case DDERR_NOCOLORKEY : sprintf(dderr, "DDERR_NOCOLORKEY"); break;
|
|
||||||
case DDERR_NOCOLORKEYHW : sprintf(dderr, "DDERR_NOCOLORKEYHW"); break;
|
|
||||||
case DDERR_NODIRECTDRAWSUPPORT : sprintf(dderr, "DDERR_NODIRECTDRAWSUPPORT"); break;
|
|
||||||
case DDERR_NOEXCLUSIVEMODE : sprintf(dderr, "DDERR_NOEXCLUSIVEMODE"); break;
|
|
||||||
case DDERR_NOFLIPHW : sprintf(dderr, "DDERR_NOFLIPHW"); break;
|
|
||||||
case DDERR_NOGDI : sprintf(dderr, "DDERR_NOGDI"); break;
|
|
||||||
case DDERR_NOMIRRORHW : sprintf(dderr, "DDERR_NOMIRRORHW"); break;
|
|
||||||
case DDERR_NOTFOUND : sprintf(dderr, "DDERR_NOTFOUND"); break;
|
|
||||||
case DDERR_NOOVERLAYHW : sprintf(dderr, "DDERR_NOOVERLAYHW"); break;
|
|
||||||
case DDERR_NORASTEROPHW : sprintf(dderr, "DDERR_NORASTEROPHW"); break;
|
|
||||||
case DDERR_NOROTATIONHW : sprintf(dderr, "DDERR_NOROTATIONHW"); break;
|
|
||||||
case DDERR_NOSTRETCHHW : sprintf(dderr, "DDERR_NOSTRETCHHW"); break;
|
|
||||||
case DDERR_NOT4BITCOLOR : sprintf(dderr, "DDERR_NOT4BITCOLOR"); break;
|
|
||||||
case DDERR_NOT4BITCOLORINDEX : sprintf(dderr, "DDERR_NOT4BITCOLORINDEX"); break;
|
|
||||||
case DDERR_NOT8BITCOLOR : sprintf(dderr, "DDERR_NOT8BITCOLOR"); break;
|
|
||||||
case DDERR_NOTEXTUREHW : sprintf(dderr, "DDERR_NOTEXTUREHW"); break;
|
|
||||||
case DDERR_NOVSYNCHW : sprintf(dderr, "DDERR_NOVSYNCHW"); break;
|
|
||||||
case DDERR_NOZBUFFERHW : sprintf(dderr, "DDERR_NOZBUFFERHW"); break;
|
|
||||||
case DDERR_NOZOVERLAYHW : sprintf(dderr, "DDERR_NOZOVERLAYHW"); break;
|
|
||||||
case DDERR_OUTOFCAPS : sprintf(dderr, "DDERR_OUTOFCAPS"); break;
|
|
||||||
case DDERR_OUTOFMEMORY : sprintf(dderr, "DDERR_OUTOFMEMORY"); break;
|
|
||||||
case DDERR_OUTOFVIDEOMEMORY : sprintf(dderr, "DDERR_OUTOFVIDEOMEMORY"); break;
|
|
||||||
case DDERR_OVERLAYCANTCLIP : sprintf(dderr, "DDERR_OVERLAYCANTCLIP"); break;
|
|
||||||
case DDERR_OVERLAYCOLORKEYONLYONEACTIVE : sprintf(dderr, "DDERR_OVERLAYCOLORKEYONLYONEACTIVE"); break;
|
|
||||||
case DDERR_PALETTEBUSY : sprintf(dderr, "DDERR_PALETTEBUSY"); break;
|
|
||||||
case DDERR_COLORKEYNOTSET : sprintf(dderr, "DDERR_COLORKEYNOTSET"); break;
|
|
||||||
case DDERR_SURFACEALREADYATTACHED : sprintf(dderr, "DDERR_SURFACEALREADYATTACHED"); break;
|
|
||||||
case DDERR_SURFACEALREADYDEPENDENT : sprintf(dderr, "DDERR_SURFACEALREADYDEPENDENT"); break;
|
|
||||||
case DDERR_SURFACEBUSY : sprintf(dderr, "DDERR_SURFACEBUSY"); break;
|
|
||||||
case DDERR_CANTLOCKSURFACE : sprintf(dderr, "DDERR_CANTLOCKSURFACE"); break;
|
|
||||||
case DDERR_SURFACEISOBSCURED : sprintf(dderr, "DDERR_SURFACEISOBSCURED"); break;
|
|
||||||
case DDERR_SURFACELOST : sprintf(dderr, "DDERR_SURFACELOST"); break;
|
|
||||||
case DDERR_SURFACENOTATTACHED : sprintf(dderr, "DDERR_SURFACENOTATTACHED"); break;
|
|
||||||
case DDERR_TOOBIGHEIGHT : sprintf(dderr, "DDERR_TOOBIGHEIGHT"); break;
|
|
||||||
case DDERR_TOOBIGSIZE : sprintf(dderr, "DDERR_TOOBIGSIZE"); break;
|
|
||||||
case DDERR_TOOBIGWIDTH : sprintf(dderr, "DDERR_TOOBIGWIDTH"); break;
|
|
||||||
case DDERR_UNSUPPORTED : sprintf(dderr, "DDERR_UNSUPPORTED"); break;
|
|
||||||
case DDERR_UNSUPPORTEDFORMAT : sprintf(dderr, "DDERR_UNSUPPORTEDFORMAT"); break;
|
|
||||||
case DDERR_UNSUPPORTEDMASK : sprintf(dderr, "DDERR_UNSUPPORTEDMASK"); break;
|
|
||||||
case DDERR_VERTICALBLANKINPROGRESS : sprintf(dderr, "DDERR_VERTICALBLANKINPROGRESS"); break;
|
|
||||||
case DDERR_WASSTILLDRAWING : sprintf(dderr, "DDERR_WASSTILLDRAWING"); break;
|
|
||||||
case DDERR_XALIGN : sprintf(dderr, "DDERR_XALIGN"); break;
|
|
||||||
case DDERR_INVALIDDIRECTDRAWGUID : sprintf(dderr, "DDERR_INVALIDDIRECTDRAWGUID"); break;
|
|
||||||
case DDERR_DIRECTDRAWALREADYCREATED : sprintf(dderr, "DDERR_DIRECTDRAWALREADYCREATED"); break;
|
|
||||||
case DDERR_NODIRECTDRAWHW : sprintf(dderr, "DDERR_NODIRECTDRAWHW"); break;
|
|
||||||
case DDERR_PRIMARYSURFACEALREADYEXISTS : sprintf(dderr, "DDERR_PRIMARYSURFACEALREADYEXISTS"); break;
|
|
||||||
case DDERR_NOEMULATION : sprintf(dderr, "DDERR_NOEMULATION"); break;
|
|
||||||
case DDERR_REGIONTOOSMALL : sprintf(dderr, "DDERR_REGIONTOOSMALL"); break;
|
|
||||||
case DDERR_CLIPPERISUSINGHWND : sprintf(dderr, "DDERR_CLIPPERISUSINGHWND"); break;
|
|
||||||
case DDERR_NOCLIPPERATTACHED : sprintf(dderr, "DDERR_NOCLIPPERATTACHED"); break;
|
|
||||||
case DDERR_NOHWND : sprintf(dderr, "DDERR_NOHWND"); break;
|
|
||||||
case DDERR_HWNDSUBCLASSED : sprintf(dderr, "DDERR_HWNDSUBCLASSED"); break;
|
|
||||||
case DDERR_HWNDALREADYSET : sprintf(dderr, "DDERR_HWNDALREADYSET"); break;
|
|
||||||
case DDERR_NOPALETTEATTACHED : sprintf(dderr, "DDERR_NOPALETTEATTACHED"); break;
|
|
||||||
case DDERR_NOPALETTEHW : sprintf(dderr, "DDERR_NOPALETTEHW"); break;
|
|
||||||
case DDERR_BLTFASTCANTCLIP : sprintf(dderr, "DDERR_BLTFASTCANTCLIP"); break;
|
|
||||||
case DDERR_NOBLTHW : sprintf(dderr, "DDERR_NOBLTHW"); break;
|
|
||||||
case DDERR_NODDROPSHW : sprintf(dderr, "DDERR_NODDROPSHW"); break;
|
|
||||||
case DDERR_OVERLAYNOTVISIBLE : sprintf(dderr, "DDERR_OVERLAYNOTVISIBLE"); break;
|
|
||||||
case DDERR_NOOVERLAYDEST : sprintf(dderr, "DDERR_NOOVERLAYDEST"); break;
|
|
||||||
case DDERR_INVALIDPOSITION : sprintf(dderr, "DDERR_INVALIDPOSITION"); break;
|
|
||||||
case DDERR_NOTAOVERLAYSURFACE : sprintf(dderr, "DDERR_NOTAOVERLAYSURFACE"); break;
|
|
||||||
case DDERR_EXCLUSIVEMODEALREADYSET : sprintf(dderr, "DDERR_EXCLUSIVEMODEALREADYSET"); break;
|
|
||||||
case DDERR_NOTFLIPPABLE : sprintf(dderr, "DDERR_NOTFLIPPABLE"); break;
|
|
||||||
case DDERR_CANTDUPLICATE : sprintf(dderr, "DDERR_CANTDUPLICATE"); break;
|
|
||||||
case DDERR_NOTLOCKED : sprintf(dderr, "DDERR_NOTLOCKED"); break;
|
|
||||||
case DDERR_CANTCREATEDC : sprintf(dderr, "DDERR_CANTCREATEDC"); break;
|
|
||||||
case DDERR_NODC : sprintf(dderr, "DDERR_NODC"); break;
|
|
||||||
case DDERR_WRONGMODE : sprintf(dderr, "DDERR_WRONGMODE"); break;
|
|
||||||
case DDERR_IMPLICITLYCREATED : sprintf(dderr, "DDERR_IMPLICITLYCREATED"); break;
|
|
||||||
case DDERR_NOTPALETTIZED : sprintf(dderr, "DDERR_NOTPALETTIZED"); break;
|
|
||||||
case DDERR_UNSUPPORTEDMODE : sprintf(dderr, "DDERR_UNSUPPORTEDMODE"); break;
|
|
||||||
case DDERR_NOMIPMAPHW : sprintf(dderr, "DDERR_NOMIPMAPHW"); break;
|
|
||||||
case DDERR_INVALIDSURFACETYPE : sprintf(dderr, "DDERR_INVALIDSURFACETYPE"); break;
|
|
||||||
case DDERR_DCALREADYCREATED : sprintf(dderr, "DDERR_DCALREADYCREATED"); break;
|
|
||||||
case DDERR_CANTPAGELOCK : sprintf(dderr, "DDERR_CANTPAGELOCK"); break;
|
|
||||||
case DDERR_CANTPAGEUNLOCK : sprintf(dderr, "DDERR_CANTPAGEUNLOCK"); break;
|
|
||||||
case DDERR_NOTPAGELOCKED : sprintf(dderr, "DDERR_NOTPAGELOCKED"); break;
|
|
||||||
case DDERR_NOTINITIALIZED : sprintf(dderr, "DDERR_NOTINITIALIZED"); break;
|
|
||||||
|
|
||||||
default : sprintf(dderr, "Unknown Error"); break;
|
|
||||||
}
|
|
||||||
sprintf(err, "DirectDraw Error %s in file %s at line %d\n", dderr, sFile, nLine);
|
|
||||||
OutputDebug(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
//
|
|
||||||
// Function : TraceErrorDS()
|
|
||||||
//
|
|
||||||
// Purpose : Traces an error (DirectSound)
|
|
||||||
//
|
|
||||||
//----------------------------------------------------------------------
|
|
||||||
|
|
||||||
void TraceErrorDS(HRESULT hErr, const char *sFile, int nLine)
|
|
||||||
{
|
|
||||||
char dserr[256];
|
|
||||||
char err[1024];
|
|
||||||
|
|
||||||
switch (hErr)
|
|
||||||
{
|
|
||||||
case DS_OK : sprintf(dserr, "DD_OK"); break;
|
|
||||||
case DSERR_ALLOCATED : sprintf(dserr, "DSERR_ALLOCATED"); break;
|
|
||||||
case DSERR_CONTROLUNAVAIL : sprintf(dserr, "DSERR_CONTROLUNAVAIL"); break;
|
|
||||||
case DSERR_INVALIDPARAM : sprintf(dserr, "DSERR_INVALIDPARAM"); break;
|
|
||||||
case DSERR_INVALIDCALL : sprintf(dserr, "DSERR_INVALIDCALL"); break;
|
|
||||||
case DSERR_GENERIC : sprintf(dserr, "DSERR_GENERIC"); break;
|
|
||||||
case DSERR_PRIOLEVELNEEDED : sprintf(dserr, "DSERR_PRIOLEVELNEEDED"); break;
|
|
||||||
case DSERR_OUTOFMEMORY : sprintf(dserr, "DSERR_OUTOFMEMORY"); break;
|
|
||||||
case DSERR_BADFORMAT : sprintf(dserr, "DSERR_BADFORMAT"); break;
|
|
||||||
case DSERR_UNSUPPORTED : sprintf(dserr, "DSERR_UNSUPPORTED"); break;
|
|
||||||
case DSERR_NODRIVER : sprintf(dserr, "DSERR_NODRIVER"); break;
|
|
||||||
case DSERR_ALREADYINITIALIZED : sprintf(dserr, "DSERR_ALREADYINITIALIZED"); break;
|
|
||||||
case DSERR_NOAGGREGATION : sprintf(dserr, "DSERR_NOAGGREGATION"); break;
|
|
||||||
case DSERR_BUFFERLOST : sprintf(dserr, "DSERR_BUFFERLOST"); break;
|
|
||||||
case DSERR_OTHERAPPHASPRIO : sprintf(dserr, "DSERR_OTHERAPPHASPRIO"); break;
|
|
||||||
case DSERR_UNINITIALIZED : sprintf(dserr, "DSERR_UNINITIALIZED"); break;
|
|
||||||
|
|
||||||
default : sprintf(dserr, "Unknown Error"); break;
|
|
||||||
}
|
|
||||||
sprintf(err, "DirectSound Error %s in file %s at line %d\n", dserr, sFile, nLine);
|
|
||||||
OutputDebug(err);
|
|
||||||
}
|
|
||||||
|
|
25
misc.h
@ -1,25 +0,0 @@
|
|||||||
// misc.h
|
|
||||||
//
|
|
||||||
#pragma once
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <minwindef.h>
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
extern void InitHInstance(HINSTANCE hInstance);
|
|
||||||
extern void OutputDebug(const char *pMessage);
|
|
||||||
extern void LoadString(UINT nID, char *pBuffer, int lgBuffer);
|
|
||||||
extern void ChangeSprite(int sprite);
|
|
||||||
|
|
||||||
extern POINT ConvLongToPos(LPARAM lParam);
|
|
||||||
|
|
||||||
extern void InitRandom();
|
|
||||||
extern int Random(int min, int max);
|
|
||||||
extern BOOL IsRectEmpty(RECT rect);
|
|
||||||
|
|
||||||
extern int Speed(double speed, int max);
|
|
||||||
extern void GetCurrentDir(char *pName, int lg);
|
|
||||||
extern void AddCDPath(char *pFilename);
|
|
||||||
extern void AddUserPath(char *pFilename);
|
|
||||||
|
|
||||||
extern void TraceErrorDD(HRESULT hErr, const char *sFile, int nLine);
|
|
||||||
extern void TraceErrorDS(HRESULT hErr, const char *sFile, int nLine);
|
|
304
movie.cpp
@ -1,304 +0,0 @@
|
|||||||
// movie.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h>
|
|
||||||
#include <commdlg.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#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)
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#define AVI_VIDEO "avivideo"
|
|
||||||
|
|
||||||
#define IDM_PLAY 10
|
|
||||||
#define IDM_RPLAY 11
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// Initialize avi libraries.
|
|
||||||
|
|
||||||
BOOL CMovie::initAVI()
|
|
||||||
{
|
|
||||||
MCI_DGV_OPEN_PARMS mciOpen;
|
|
||||||
|
|
||||||
// set up the open parameters
|
|
||||||
mciOpen.dwCallback = 0L;
|
|
||||||
mciOpen.wDeviceID = 0;
|
|
||||||
mciOpen.lpstrDeviceType = (LPWSTR)AVI_VIDEO;
|
|
||||||
mciOpen.lpstrElementName = NULL;
|
|
||||||
mciOpen.lpstrAlias = NULL;
|
|
||||||
mciOpen.dwStyle = 0;
|
|
||||||
mciOpen.hWndParent = NULL;
|
|
||||||
|
|
||||||
// try to open the driver
|
|
||||||
return (mciSendCommand(0, MCI_OPEN, (DWORD)(MCI_OPEN_TYPE),
|
|
||||||
(DWORD)(LPMCI_DGV_OPEN_PARMS)&mciOpen) == 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Closes the opened AVI file and the opened device type. |
|
|
||||||
|
|
||||||
void CMovie::termAVI()
|
|
||||||
{
|
|
||||||
MCIDEVICEID mciID;
|
|
||||||
MCI_GENERIC_PARMS mciClose;
|
|
||||||
|
|
||||||
// Get the device ID for the opened device type and then close
|
|
||||||
// the device type.
|
|
||||||
mciID = mciGetDeviceIDA(AVI_VIDEO);
|
|
||||||
mciSendCommand(mciID, MCI_CLOSE, 0L,
|
|
||||||
(DWORD)(LPMCI_GENERIC_PARMS)&mciClose);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Sets the movie rectange <rcMovie> to be
|
|
||||||
// centered within the app's window.
|
|
||||||
|
|
||||||
void CMovie::positionMovie(HWND hWnd, RECT rect)
|
|
||||||
{
|
|
||||||
// reposition the playback (child) window
|
|
||||||
MoveWindow(m_hwndMovie,
|
|
||||||
rect.left, rect.top,
|
|
||||||
rect.right, rect.bottom, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the movie and anything associated with it. |
|
|
||||||
// This function clears the <m_fPlaying> and <m_fMovieOpen> flags |
|
|
||||||
|
|
||||||
void CMovie::fileCloseMovie(HWND hWnd)
|
|
||||||
{
|
|
||||||
MCI_GENERIC_PARMS mciGeneric;
|
|
||||||
|
|
||||||
mciSendCommand(m_wMCIDeviceID, MCI_CLOSE, 0L,
|
|
||||||
(DWORD)(LPMCI_GENERIC_PARMS)&mciGeneric);
|
|
||||||
|
|
||||||
m_fPlaying = FALSE; // can't be playing any longer
|
|
||||||
m_fMovieOpen = FALSE; // no more movies open
|
|
||||||
|
|
||||||
// cause a total repaint to occur
|
|
||||||
InvalidateRect(hWnd, NULL, TRUE);
|
|
||||||
UpdateWindow(hWnd);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Open an AVI movie. Use CommDlg open box to
|
|
||||||
// open and then handle the initialization to
|
|
||||||
// show the movie and position it properly. Keep
|
|
||||||
// the movie paused when opened.
|
|
||||||
// Sets <m_fMovieOpen> on success.
|
|
||||||
|
|
||||||
BOOL CMovie::fileOpenMovie(HWND hWnd, RECT rect, char *pFilename)
|
|
||||||
{
|
|
||||||
MCI_DGV_OPEN_PARMS mciOpen;
|
|
||||||
MCI_DGV_WINDOW_PARMS mciWindow;
|
|
||||||
MCI_DGV_STATUS_PARMS mciStatus;
|
|
||||||
char string[MAX_PATH];
|
|
||||||
|
|
||||||
if ( pFilename[1] == ':' ) // nom complet "D:\REP..." ?
|
|
||||||
{
|
|
||||||
strcpy(string, pFilename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GetCurrentDir(string, MAX_PATH-30);
|
|
||||||
strcat(string, pFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
// we got a filename, now close any old movie and open the new one. */
|
|
||||||
if ( m_fMovieOpen ) fileCloseMovie(hWnd);
|
|
||||||
|
|
||||||
// we have a .AVI movie to open, use MCI
|
|
||||||
// set up the open parameters
|
|
||||||
mciOpen.dwCallback = 0L;
|
|
||||||
mciOpen.wDeviceID = 0;
|
|
||||||
mciOpen.lpstrDeviceType = NULL;
|
|
||||||
mciOpen.lpstrElementName = (LPWSTR)string;
|
|
||||||
mciOpen.lpstrAlias = NULL;
|
|
||||||
mciOpen.dwStyle = WS_CHILD;
|
|
||||||
mciOpen.hWndParent = hWnd;
|
|
||||||
|
|
||||||
// try to open the file
|
|
||||||
if ( mciSendCommand(0, MCI_OPEN,
|
|
||||||
(DWORD)(MCI_OPEN_ELEMENT|MCI_DGV_OPEN_PARENT|MCI_DGV_OPEN_WS),
|
|
||||||
(DWORD)(LPMCI_DGV_OPEN_PARMS)&mciOpen) == 0 )
|
|
||||||
{
|
|
||||||
// we opened the file o.k., now set up to play it.
|
|
||||||
m_wMCIDeviceID = mciOpen.wDeviceID; // save ID
|
|
||||||
m_fMovieOpen = TRUE; // a movie was opened
|
|
||||||
|
|
||||||
// show the playback window
|
|
||||||
mciWindow.dwCallback = 0L;
|
|
||||||
mciWindow.hWnd = NULL;
|
|
||||||
mciWindow.nCmdShow = SW_SHOW;
|
|
||||||
mciWindow.lpstrText = (LPWSTR)NULL;
|
|
||||||
// mciSendCommand(m_wMCIDeviceID, MCI_WINDOW,
|
|
||||||
// MCI_DGV_WINDOW_STATE,
|
|
||||||
// (DWORD)(LPMCI_DGV_WINDOW_PARMS)&mciWindow);
|
|
||||||
|
|
||||||
// get the window handle
|
|
||||||
mciStatus.dwItem = MCI_DGV_STATUS_HWND;
|
|
||||||
mciSendCommand(m_wMCIDeviceID,
|
|
||||||
MCI_STATUS, MCI_STATUS_ITEM,
|
|
||||||
(DWORD)(LPMCI_STATUS_PARMS)&mciStatus);
|
|
||||||
m_hwndMovie = (HWND)mciStatus.dwReturn;
|
|
||||||
|
|
||||||
// now get the movie centered
|
|
||||||
positionMovie(hWnd, rect);
|
|
||||||
|
|
||||||
// cause an update to occur
|
|
||||||
InvalidateRect(hWnd, NULL, FALSE);
|
|
||||||
UpdateWindow(hWnd);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// generic error for open
|
|
||||||
m_fMovieOpen = FALSE;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Play/pause the movie depending on the state
|
|
||||||
// of the <m_fPlaying> flag. |
|
|
||||||
// This function sets the <m_fPlaying> flag appropriately when done|
|
|
||||||
|
|
||||||
void CMovie::playMovie(HWND hWnd, int nDirection)
|
|
||||||
{
|
|
||||||
m_fPlaying = !m_fPlaying; // swap the play flag
|
|
||||||
|
|
||||||
if( !nDirection )
|
|
||||||
m_fPlaying = FALSE; // wDirection == NULL means PAUSE
|
|
||||||
|
|
||||||
// play/pause the AVI movie
|
|
||||||
if ( m_fPlaying )
|
|
||||||
{
|
|
||||||
DWORD dwFlags;
|
|
||||||
MCI_DGV_PLAY_PARMS mciPlay;
|
|
||||||
|
|
||||||
// init to play all
|
|
||||||
mciPlay.dwCallback = MAKELONG(hWnd,0);
|
|
||||||
mciPlay.dwFrom = mciPlay.dwTo = 0;
|
|
||||||
dwFlags = MCI_NOTIFY;
|
|
||||||
if ( nDirection == IDM_RPLAY )
|
|
||||||
dwFlags |= MCI_DGV_PLAY_REVERSE;
|
|
||||||
|
|
||||||
mciSendCommand(m_wMCIDeviceID, MCI_PLAY, dwFlags,
|
|
||||||
(DWORD)(LPMCI_DGV_PLAY_PARMS)&mciPlay);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MCI_DGV_PAUSE_PARMS mciPause;
|
|
||||||
|
|
||||||
// tell it to pause
|
|
||||||
mciSendCommand(m_wMCIDeviceID,MCI_PAUSE,0L,
|
|
||||||
(DWORD)(LPMCI_DGV_PAUSE_PARMS)&mciPause);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
|
|
||||||
// Constructeur.
|
|
||||||
|
|
||||||
CMovie::CMovie()
|
|
||||||
{
|
|
||||||
m_bEnable = FALSE;
|
|
||||||
m_wMCIDeviceID = 0;
|
|
||||||
m_fPlaying = FALSE;
|
|
||||||
m_fMovieOpen = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructeur.
|
|
||||||
|
|
||||||
CMovie::~CMovie()
|
|
||||||
{
|
|
||||||
termAVI();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ouvre la librairie avi.
|
|
||||||
|
|
||||||
BOOL CMovie::Create()
|
|
||||||
{
|
|
||||||
#if _EGAMES
|
|
||||||
m_bEnable = FALSE;
|
|
||||||
return FALSE;
|
|
||||||
#else
|
|
||||||
if ( initAVI() )
|
|
||||||
{
|
|
||||||
m_bEnable = TRUE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_bEnable = FALSE;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retourne l'<27>tat de DirectMovie.
|
|
||||||
|
|
||||||
BOOL CMovie::GetEnable()
|
|
||||||
{
|
|
||||||
return m_bEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Indique si un film existe.
|
|
||||||
|
|
||||||
BOOL CMovie::IsExist(char *pFilename)
|
|
||||||
{
|
|
||||||
char string[MAX_PATH];
|
|
||||||
FILE* file;
|
|
||||||
|
|
||||||
if ( pFilename[1] == ':' ) // nom complet "D:\REP..." ?
|
|
||||||
{
|
|
||||||
strcpy(string, pFilename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GetCurrentDir(string, MAX_PATH-30);
|
|
||||||
strcat(string, pFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
file = fopen(string, "rb");
|
|
||||||
if ( file == NULL ) return FALSE;
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Montre un film avi.
|
|
||||||
|
|
||||||
BOOL CMovie::Play(HWND hWnd, RECT rect, char *pFilename)
|
|
||||||
{
|
|
||||||
if ( !m_bEnable ) return FALSE;
|
|
||||||
if ( !fileOpenMovie(hWnd, rect, pFilename) ) return FALSE;
|
|
||||||
playMovie(hWnd, IDM_PLAY);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stoppe le film avi.
|
|
||||||
|
|
||||||
void CMovie::Stop(HWND hWnd)
|
|
||||||
{
|
|
||||||
if ( !m_bEnable ) return;
|
|
||||||
fileCloseMovie(hWnd);
|
|
||||||
}
|
|
36
movie.h
@ -1,36 +0,0 @@
|
|||||||
// movie.h
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#include <mciapi.h>
|
|
||||||
|
|
||||||
class CMovie
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CMovie();
|
|
||||||
~CMovie();
|
|
||||||
|
|
||||||
BOOL Create();
|
|
||||||
BOOL GetEnable();
|
|
||||||
BOOL IsExist(char *pFilename);
|
|
||||||
BOOL Play(HWND hWnd, RECT rect, char *pFilename);
|
|
||||||
void Stop(HWND hWnd);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void playMovie(HWND hWnd, int nDirection);
|
|
||||||
BOOL fileOpenMovie(HWND hWnd, RECT rect, char *pFilename);
|
|
||||||
void fileCloseMovie(HWND hWnd);
|
|
||||||
void positionMovie(HWND hWnd, RECT rect);
|
|
||||||
void termAVI();
|
|
||||||
BOOL initAVI();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
BOOL m_bEnable;
|
|
||||||
MCIDEVICEID m_wMCIDeviceID;
|
|
||||||
HWND m_hwndMovie;
|
|
||||||
BOOL m_fPlaying;
|
|
||||||
BOOL m_fMovieOpen;
|
|
||||||
};
|
|
331
network.cpp
@ -1,331 +0,0 @@
|
|||||||
// Network.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <windows.h>
|
|
||||||
#include "dplay.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "network.h"
|
|
||||||
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS_GLOBALS
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#pragma warning(disable : 4996)
|
|
||||||
#pragma comment(lib, "dplayx.lib")
|
|
||||||
#pragma comment(lib, "dxguid.lib")
|
|
||||||
|
|
||||||
// a0f94abe-11c3-d111-be62-0040f6944838
|
|
||||||
#define APP_GUID { 0xbe4af9a0, 0xc311, 0x11d1, { 0xbe, 0x62, 0x00, 0x40, 0xf6, 0x94, 0x48, 0x38 } };
|
|
||||||
|
|
||||||
CNetwork::CNetwork()
|
|
||||||
{
|
|
||||||
m_pDP = NULL;
|
|
||||||
m_dpid = 0;
|
|
||||||
m_bHost = FALSE;
|
|
||||||
m_providers.nb = 0;
|
|
||||||
*m_providers.list = NULL;
|
|
||||||
m_sessions.nb = 0;
|
|
||||||
*m_sessions.list = NULL;
|
|
||||||
m_unknown.nb = 0;
|
|
||||||
*m_unknown.list = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
CNetwork::~CNetwork()
|
|
||||||
{
|
|
||||||
FreeProviderList();
|
|
||||||
FreeSessionList();
|
|
||||||
FreeUnknownList();
|
|
||||||
if (m_pDP) m_pDP->Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL EnumProvidersCallback(LPGUID lpguidSP, LPSTR lpSPName,
|
|
||||||
DWORD dwMajorVersion, DWORD dwMinorVersion, NamedGUIDList* lpContext)
|
|
||||||
{
|
|
||||||
if (lpContext->nb < MAXSESSION)
|
|
||||||
{
|
|
||||||
lpContext->list[lpContext->nb]->guid = *lpguidSP;
|
|
||||||
strcpy(lpContext->list[lpContext->nb]->name, lpSPName);
|
|
||||||
lpContext->nb++;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::EnumProviders()
|
|
||||||
{
|
|
||||||
FreeProviderList();
|
|
||||||
m_providers.nb = 0;
|
|
||||||
*m_providers.list = (NamedGUID*)malloc(MAXSESSION * sizeof(NamedGUID));
|
|
||||||
|
|
||||||
if (!m_providers.list) return FALSE;
|
|
||||||
|
|
||||||
if (DirectPlayEnumerate((LPDPENUMDPCALLBACK)EnumProvidersCallback, &m_providers) != DP_OK)
|
|
||||||
{
|
|
||||||
FreeProviderList();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CNetwork::GetNbProviders()
|
|
||||||
{
|
|
||||||
return m_providers.nb;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* CNetwork::GetProviderName(int index)
|
|
||||||
{
|
|
||||||
if (index >= m_providers.nb) return NULL;
|
|
||||||
return m_providers.list[index]->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::CreateProvider(int index)
|
|
||||||
{
|
|
||||||
LPDIRECTPLAY lpDP;
|
|
||||||
BOOL bOK = FALSE;
|
|
||||||
|
|
||||||
if (index >= m_providers.nb) return FALSE;
|
|
||||||
|
|
||||||
if (DirectPlayCreate(&m_providers.list[index]->guid, &lpDP, 0) == DP_OK)
|
|
||||||
{
|
|
||||||
if (lpDP->QueryInterface(IID_IDirectPlay2A, (LPVOID*)&m_pDP) == DP_OK)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lpDP != NULL) lpDP->Release();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNetwork::FreeProviderList()
|
|
||||||
{
|
|
||||||
if (m_providers.list) free(m_providers.list);
|
|
||||||
|
|
||||||
m_providers.nb = 0;
|
|
||||||
*m_providers.list = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static BOOL EnumSessionsCallback(LPDPSESSIONDESC2 lpThisSD,
|
|
||||||
LPDWORD lpdwTimeOut, DWORD dwFlags, NamedGUIDList* lpContext)
|
|
||||||
{
|
|
||||||
if (dwFlags & DPESC_TIMEDOUT) return FALSE;
|
|
||||||
|
|
||||||
if (lpContext->nb < MAXSESSION)
|
|
||||||
{
|
|
||||||
lpContext->list[lpContext->nb]->guid = lpThisSD->guidInstance;
|
|
||||||
strcpy(lpContext->list[lpContext->nb]->name, lpThisSD->lpszSessionNameA);
|
|
||||||
lpContext->nb++;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::EnumSessions()
|
|
||||||
{
|
|
||||||
DPSESSIONDESC2 desc;
|
|
||||||
|
|
||||||
FreeSessionList();
|
|
||||||
m_sessions.nb = 0;
|
|
||||||
*m_sessions.list = (NamedGUID*)malloc(MAXSESSION * sizeof(NamedGUID));
|
|
||||||
|
|
||||||
if (!m_sessions.list) return FALSE;
|
|
||||||
|
|
||||||
ZeroMemory(&desc, sizeof(desc));
|
|
||||||
|
|
||||||
desc.guidApplication = APP_GUID;
|
|
||||||
desc.dwSize = sizeof(desc);
|
|
||||||
|
|
||||||
if (m_pDP->EnumSessions(&desc, 0, (LPDPENUMSESSIONSCALLBACK2)EnumSessionsCallback, &m_sessions, DPENUMSESSIONS_AVAILABLE) != DP_OK)
|
|
||||||
{
|
|
||||||
FreeSessionList();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
char* CNetwork::GetSessionName(int index)
|
|
||||||
{
|
|
||||||
if (index >= m_sessions.nb) return NULL;
|
|
||||||
return m_sessions.list[index]->name;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::JoinSession(int index)
|
|
||||||
{
|
|
||||||
DPNAME name;
|
|
||||||
DPSESSIONDESC2 desc;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
if (index > m_sessions.nb) return FALSE;
|
|
||||||
|
|
||||||
ZeroMemory(&desc, sizeof(desc));
|
|
||||||
|
|
||||||
desc.guidInstance = m_sessions.list[index]->guid;
|
|
||||||
|
|
||||||
hr = m_pDP->Open(&desc, DPOPEN_OPENSESSION);
|
|
||||||
if (hr != DP_OK)
|
|
||||||
{
|
|
||||||
TraceErrorDP(hr);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
name.dwFlags = 0;
|
|
||||||
name.dwSize = sizeof(name);
|
|
||||||
name.lpszLongNameA = NULL;
|
|
||||||
|
|
||||||
hr = m_pDP->CreatePlayer(&m_dpid, &name, NULL, NULL, 0, 0);
|
|
||||||
if (hr != DP_OK)
|
|
||||||
{
|
|
||||||
TraceErrorDP(hr);
|
|
||||||
m_pDP->Close();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_bHost = FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNetwork::FreeSessionList()
|
|
||||||
{
|
|
||||||
if (m_sessions.list) free(m_sessions.list);
|
|
||||||
|
|
||||||
m_sessions.nb = 0;
|
|
||||||
*m_sessions.list = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::CreateSession(char* pName)
|
|
||||||
{
|
|
||||||
DPSESSIONDESC2 desc;
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
ZeroMemory(&desc, sizeof(desc));
|
|
||||||
|
|
||||||
desc.guidApplication = APP_GUID;
|
|
||||||
desc.lpszSessionNameA = pName;
|
|
||||||
desc.dwSize = sizeof(desc);
|
|
||||||
desc.dwFlags = DPSESSION_KEEPALIVE | DPSESSION_MIGRATEHOST;
|
|
||||||
desc.dwMaxPlayers = MAXPLAYERS;
|
|
||||||
|
|
||||||
hr = m_pDP->Open(&desc, DPOPEN_CREATE);
|
|
||||||
if (hr != DP_OK)
|
|
||||||
{
|
|
||||||
TraceErrorDP(hr);
|
|
||||||
m_pDP->Close();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_bHost = TRUE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::Send(LPVOID lpData, DWORD dwDataSize, DWORD dwFlags)
|
|
||||||
{
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
if (!m_pDP) return FALSE;
|
|
||||||
|
|
||||||
if (hr = m_pDP->Send(m_dpid, 0, !!dwFlags, lpData, dwDataSize), hr != DP_OK)
|
|
||||||
{
|
|
||||||
TraceErrorDP(hr);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::Receive(LPVOID pDest, DWORD dwDataSize, LPDWORD lpdwPlayer)
|
|
||||||
{
|
|
||||||
DPID from = 0, to = 0, dataSize = 500;
|
|
||||||
char dataBuffer[500];
|
|
||||||
HRESULT hr;
|
|
||||||
|
|
||||||
hr = m_pDP->Receive(&from, &to, DPRECEIVE_ALL, dataBuffer, &dataSize);
|
|
||||||
if (hr != DP_OK)
|
|
||||||
{
|
|
||||||
if (hr != DPERR_NOMESSAGES) TraceErrorDP(hr);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ZeroMemory(pDest, dwDataSize);
|
|
||||||
|
|
||||||
*lpdwPlayer = -1;
|
|
||||||
for (int i = 0; i < MAXPLAYERS; i++)
|
|
||||||
{
|
|
||||||
if (m_players[i].bIsPresent && from == i)
|
|
||||||
{
|
|
||||||
*lpdwPlayer = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::Close()
|
|
||||||
{
|
|
||||||
return m_pDP->Close() == DP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CNetwork::FreeUnknownList()
|
|
||||||
{
|
|
||||||
if (m_unknown.list) free(m_unknown.list);
|
|
||||||
|
|
||||||
m_unknown.nb = 0;
|
|
||||||
*m_unknown.list = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CNetwork::IsHost()
|
|
||||||
{
|
|
||||||
return m_bHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TraceErrorDP(HRESULT hErr)
|
|
||||||
{
|
|
||||||
char dperr[256];
|
|
||||||
char err[1024];
|
|
||||||
|
|
||||||
switch (hErr)
|
|
||||||
{
|
|
||||||
case DPERR_OUTOFMEMORY: sprintf(dperr, "DPERR_OUTOFMEMORY"); break;
|
|
||||||
case DPERR_UNSUPPORTED: sprintf(dperr, "DPERR_UNSUPPORTED"); break;
|
|
||||||
case DPERR_NOINTERFACE: sprintf(dperr, "DPERR_NOINTERFACE"); break;
|
|
||||||
case DPERR_GENERIC: sprintf(dperr, "DPERR_GENERIC"); break;
|
|
||||||
case DPERR_INVALIDPARAMS: sprintf(dperr, "DPERR_INVALIDPARAMS"); break;
|
|
||||||
case DPERR_ACTIVEPLAYERS: sprintf(dperr, "DPERR_ACTIVEPLAYERS"); break;
|
|
||||||
case DPERR_ACCESSDENIED: sprintf(dperr, "DPERR_ACCESSDENIED"); break;
|
|
||||||
case DPERR_CANTADDPLAYER: sprintf(dperr, "DPERR_CANTADDPLAYER"); break;
|
|
||||||
case DPERR_CANTCREATEPLAYER: sprintf(dperr, "DPERR_CANTCREATEPLAYER"); break;
|
|
||||||
case DPERR_CANTCREATEGROUP: sprintf(dperr, "DPERR_CANTCREATEGROUP"); break;
|
|
||||||
case DPERR_CANTCREATESESSION: sprintf(dperr, "DPERR_CANTCREATESESSION"); break;
|
|
||||||
case DPERR_CAPSNOTAVAILABLEYET: sprintf(dperr, "DPERR_CAPTSNOTAVAILABLEYET"); break;
|
|
||||||
case DPERR_ALREADYINITIALIZED: sprintf(dperr, "DPERR_ALREADYINITIALIZED"); break;
|
|
||||||
case DPERR_INVALIDFLAGS: sprintf(dperr, "DPERR_INVALIDFLAGS"); break;
|
|
||||||
case DPERR_EXCEPTION: sprintf(dperr, "DPERR_EXCEPTION"); break;
|
|
||||||
case DPERR_INVALIDPLAYER: sprintf(dperr, "DPERR_INVALIDPLAYER"); break;
|
|
||||||
case DPERR_INVALIDOBJECT: sprintf(dperr, "DPERR_INVALIDOBJECT"); break;
|
|
||||||
case DPERR_NOCONNECTION: sprintf(dperr, "DPERR_NOCONNECTION"); break;
|
|
||||||
case DPERR_NONAMESERVERFOUND: sprintf(dperr, "DPERR_NONAMESERVERFOUND"); break;
|
|
||||||
case DPERR_NOMESSAGES: sprintf(dperr, "DPERR_NOMESSAGES"); break;
|
|
||||||
case DPERR_NOSESSIONS: sprintf(dperr, "DPERR_NOSESSIONS"); break;
|
|
||||||
case DPERR_NOPLAYERS: sprintf(dperr, "DPERR_NOPLAYERS"); break;
|
|
||||||
case DPERR_TIMEOUT: sprintf(dperr, "DPERR_TIMEOUT"); break;
|
|
||||||
case DPERR_SENDTOOBIG: sprintf(dperr, "DPERR_SENDTOOBIG"); break;
|
|
||||||
case DPERR_BUSY: sprintf(dperr, "DPERR_BUSY"); break;
|
|
||||||
case DPERR_UNAVAILABLE: sprintf(dperr, "DPERR_UNAVAILABLE"); break;
|
|
||||||
case DPERR_PLAYERLOST: sprintf(dperr, "DPERR_PLAYERLOST"); break;
|
|
||||||
case DPERR_USERCANCEL: sprintf(dperr, "DPERR_USERCANCEL"); break;
|
|
||||||
case DPERR_BUFFERTOOLARGE: sprintf(dperr, "DPERR_BUFFERTOOLARGE"); break;
|
|
||||||
case DPERR_SESSIONLOST: sprintf(dperr, "DPERR_SESSIONLOST"); break;
|
|
||||||
case DPERR_APPNOTSTARTED: sprintf(dperr, "DPERR_APPNOTSTARTED"); break;
|
|
||||||
case DPERR_CANTCREATEPROCESS: sprintf(dperr, "DPERR_CANTCREATEPROCESS"); break;
|
|
||||||
case DPERR_UNKNOWNAPPLICATION: sprintf(dperr, "DPERR_UNKNOWNAPPLICATION"); break;
|
|
||||||
case DPERR_INVALIDINTERFACE: sprintf(dperr, "DPERR_INVALIDINTERFACE"); break;
|
|
||||||
case DPERR_NOTLOBBIED: sprintf(dperr, "DPERR_NOTLOBBIED"); break;
|
|
||||||
case DP_OK: sprintf(dperr, "DP_OK"); break;
|
|
||||||
|
|
||||||
default: sprintf(dperr, "Unknown Error"); break;
|
|
||||||
}
|
|
||||||
sprintf(err, "DirectPlay Error %s\n", dperr);
|
|
||||||
OutputDebug(err);
|
|
||||||
}
|
|
102
network.h
@ -1,102 +0,0 @@
|
|||||||
// Network.h
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "dplay.h"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define MAXSESSION 100
|
|
||||||
#define MAXPLAYERS 4
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS_GLOBALS
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char bIsPresent;
|
|
||||||
char ready;
|
|
||||||
char unk_2;
|
|
||||||
char unk_3;
|
|
||||||
DPID dpid;
|
|
||||||
short team;
|
|
||||||
char name[22];
|
|
||||||
}
|
|
||||||
NetPlayer;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GUID guid;
|
|
||||||
char name[100];
|
|
||||||
}
|
|
||||||
NamedGUID;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int nb;
|
|
||||||
NamedGUID* list[MAXSESSION];
|
|
||||||
}
|
|
||||||
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:
|
|
||||||
CNetwork();
|
|
||||||
~CNetwork();
|
|
||||||
|
|
||||||
BOOL EnumProviders();
|
|
||||||
BOOL GetNbProviders();
|
|
||||||
char* GetProviderName(int index);
|
|
||||||
BOOL CreateProvider(int index);
|
|
||||||
void FreeProviderList();
|
|
||||||
BOOL EnumSessions();
|
|
||||||
char* GetSessionName(int index);
|
|
||||||
BOOL JoinSession(int index);
|
|
||||||
void FreeSessionList();
|
|
||||||
BOOL CreateSession(char* pName);
|
|
||||||
BOOL Send(LPVOID lpData, DWORD dwDataSize, DWORD dwFlags);
|
|
||||||
BOOL Receive(LPVOID pDest, DWORD dwDataSize, LPDWORD lpdwPlayer);
|
|
||||||
BOOL Close();
|
|
||||||
void FreeUnknownList();
|
|
||||||
BOOL IsHost();
|
|
||||||
|
|
||||||
NetPlayer m_players[4];
|
|
||||||
DPID m_dpid;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
LPDIRECTPLAY2 m_pDP;
|
|
||||||
NamedGUIDList m_providers;
|
|
||||||
NamedGUIDList m_sessions;
|
|
||||||
NamedGUIDList m_unknown;
|
|
||||||
BOOL m_bHost;
|
|
||||||
|
|
||||||
// NetPlayer m_players[4];
|
|
||||||
};
|
|
||||||
|
|
||||||
static BOOL EnumProvidersCallback(LPGUID lpguidSP, LPSTR lpSTName,
|
|
||||||
DWORD dwMajorVersion, DWORD dwMinorVersion, NamedGUIDList* lpContext);
|
|
||||||
|
|
||||||
static BOOL EnumSessionsCallback(LPDPSESSIONDESC2 lpThisSD,
|
|
||||||
LPDWORD lpdwTimeOut, DWORD dwFlags, NamedGUIDList* lpContext);
|
|
||||||
|
|
||||||
void TraceErrorDP(HRESULT hErr);
|
|
1984
pixmap.cpp
128
pixmap.h
@ -1,128 +0,0 @@
|
|||||||
// CPixmap.h
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <ddraw.h>
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#define MAXIMAGE 100
|
|
||||||
#define DIRECTDRAW_VERSION 0x0500
|
|
||||||
|
|
||||||
class CPixmap
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CPixmap();
|
|
||||||
~CPixmap();
|
|
||||||
|
|
||||||
void SetDebug(BOOL bDebug);
|
|
||||||
|
|
||||||
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 Cache2(int channel, const 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 IsIconPixel(int channel, int rank, POINT pos);
|
|
||||||
|
|
||||||
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 DrawMap(int channel, RECT src, RECT dest);
|
|
||||||
|
|
||||||
BOOL BuildIconMask(int channelMask, int rankMask,
|
|
||||||
int channel, int rankSrc, int rankDst);
|
|
||||||
|
|
||||||
BOOL Display();
|
|
||||||
|
|
||||||
void SetMousePosSprite(POINT pos, int sprite, BOOL bDemoPlay);
|
|
||||||
void SetMousePos(POINT pos, BOOL bDemoPlay);
|
|
||||||
void SetMouseSprite(int sprite, BOOL bDemoPlay);
|
|
||||||
void MouseShow(BOOL bShow);
|
|
||||||
void MouseInvalidate();
|
|
||||||
void MouseBackClear();
|
|
||||||
void MouseBackDraw();
|
|
||||||
void SetBenchmarkSuccess(BOOL bSuccess);
|
|
||||||
void SetTrueColor(BOOL bTrueColor);
|
|
||||||
void SetTrueColorDecor(BOOL bTrueColorDecor);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
void MouseUpdate();
|
|
||||||
BOOL MouseQuickDraw(RECT rect);
|
|
||||||
void MouseBackSave();
|
|
||||||
void MouseBackRestore();
|
|
||||||
void MouseBackDebug();
|
|
||||||
RECT MouseRectSprite();
|
|
||||||
void MouseHotSpot();
|
|
||||||
BOOL GetTrueColor();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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;
|
|
||||||
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;
|
|
||||||
|
|
||||||
LPDIRECTDRAW m_lpDD;
|
|
||||||
LPDIRECTDRAWSURFACE m_lpDDSPrimary;
|
|
||||||
LPDIRECTDRAWSURFACE m_lpDDSBack;
|
|
||||||
LPDIRECTDRAWSURFACE m_lpDDSMouse;
|
|
||||||
IDirectDrawPalette* 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;
|
|
||||||
};
|
|
284
resource.h
@ -1,284 +0,0 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Visual C++ generated include file.
|
|
||||||
// Used by Eggbert 2.rc
|
|
||||||
//
|
|
||||||
#define TX_ACTION_GO 1
|
|
||||||
#define TX_ACTION_STOP 2
|
|
||||||
#define TX_ACTION_MANGE 3
|
|
||||||
#define TX_ACTION_CARRY 4
|
|
||||||
#define TX_ACTION_DEPOSE 5
|
|
||||||
#define TX_ACTION_ABAT 6
|
|
||||||
#define TX_ACTION_ROC 7
|
|
||||||
#define TX_ACTION_CULTIVE 8
|
|
||||||
#define TX_ACTION_BUILD1 9
|
|
||||||
#define TX_ACTION_BUILD2 10
|
|
||||||
#define TX_ACTION_BUILD3 11
|
|
||||||
#define TX_ACTION_BUILD4 12
|
|
||||||
#define TX_ACTION_BUILD5 13
|
|
||||||
#define TX_ACTION_BUILD6 14
|
|
||||||
#define TX_ACTION_MUR 15
|
|
||||||
#define TX_ACTION_PALIS 16
|
|
||||||
#define TX_ACTION_ABATn 17
|
|
||||||
#define TX_ACTION_ROCn 18
|
|
||||||
#define TX_ACTION_PONT 19
|
|
||||||
#define TX_ACTION_TOUR 20
|
|
||||||
#define TX_ACTION_BOIT 21
|
|
||||||
#define TX_ACTION_LABO 22
|
|
||||||
#define TX_ACTION_FLEUR 23
|
|
||||||
#define TX_ACTION_FLEURn 24
|
|
||||||
#define TX_ACTION_DYNAMITE 25
|
|
||||||
#define TX_ACTION_BATEAU 26
|
|
||||||
#define TX_ACTION_DJEEP 27
|
|
||||||
#define TX_ACTION_DRAPEAU 28
|
|
||||||
#define TX_ACTION_EXTRAIT 29
|
|
||||||
#define TX_ACTION_FABJEEP 30
|
|
||||||
#define TX_ACTION_FABMINE 31
|
|
||||||
#define TX_ACTION_FABDISC 32
|
|
||||||
#define TX_ACTION_REPEAT 33
|
|
||||||
#define TX_ACTION_QARMURE 34
|
|
||||||
#define TX_ACTION_FABARMURE 35
|
|
||||||
#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_TINY 126
|
|
||||||
#define TX_CLEARPLAYER 127
|
|
||||||
#define TX_SETTINGS 128
|
|
||||||
#define TX_CHOOSEMUSIC 129
|
|
||||||
#define TX_BUTTON_SETUP1 130
|
|
||||||
#define TX_BUTTON_SETUP2 131
|
|
||||||
#define TX_BUTTON_SETUP3 132
|
|
||||||
#define TX_BUTTON_SETUP4 133
|
|
||||||
#define TX_NOMUSIC 134
|
|
||||||
#define TX_MUSIC1 135
|
|
||||||
#define TX_MUSIC2 136
|
|
||||||
#define TX_MUSIC3 137
|
|
||||||
#define TX_MUSIC4 138
|
|
||||||
#define TX_MUSIC5 139
|
|
||||||
#define TX_MUSIC6 140
|
|
||||||
#define TX_MUSIC7 141
|
|
||||||
#define TX_MUSIC8 142
|
|
||||||
#define TX_MUSIC9 143
|
|
||||||
#define TX_BUTTON_REGION 144
|
|
||||||
#define TX_DISCARDGAME 145
|
|
||||||
#define TX_EGGBERT 146
|
|
||||||
#define TX_DESIGNMISSION 147
|
|
||||||
#define TX_CHOOSEGAMER 148
|
|
||||||
#define TX_MUSIC 149
|
|
||||||
#define TX_TRAININGNUM 150
|
|
||||||
#define TX_MISSIONNUM 151
|
|
||||||
#define TX_MISSIONTIME 152
|
|
||||||
#define TX_SIZE 153
|
|
||||||
#define TX_BUTTON_SETUP5 154
|
|
||||||
#define TX_BUTTON_SETUP6 155
|
|
||||||
#define TX_BUTTON_SETUP7 156
|
|
||||||
#define TX_BUTTON_SETUP8 157
|
|
||||||
#define TX_CONFYES 158
|
|
||||||
#define TX_CONFNO 159
|
|
||||||
#define TX_SETTING 160
|
|
||||||
#define TX_SAVECURRENTMISS 161
|
|
||||||
#define TX_SOUNDVOL 162
|
|
||||||
#define TX_MUSICVOL 163
|
|
||||||
#define TX_COLORDEP 164
|
|
||||||
#define TX_INPUT 165
|
|
||||||
#define TX_OPENMISS 166
|
|
||||||
#define TX_READINFO 167
|
|
||||||
#define TX_PLAYERFREE 168
|
|
||||||
#define TX_NUMDOOROPEN 169
|
|
||||||
#define TX_NUMDOORSOPEN 170
|
|
||||||
#define TX_MUSIC10 171
|
|
||||||
#define TX_WRITENAME 172
|
|
||||||
#define TX_NONE 173
|
|
||||||
#define TX_CONFIRM 174
|
|
||||||
#define TX_CANCEL 175
|
|
||||||
#define TX_YES 176
|
|
||||||
#define TX_NO 177
|
|
||||||
#define TX_REGION 178
|
|
||||||
#define TX_SUS 179
|
|
||||||
#define TX_BUTTON_SETUP 180
|
|
||||||
#define TX_SAVES 181
|
|
||||||
#define TX_INSERT 182
|
|
||||||
#define TX_DELETEMISS 183
|
|
||||||
#define TX_DELETEMISSION 184
|
|
||||||
#define TX_NAMEOFMISS 185
|
|
||||||
#define TX_NAMEOFMISSION 186
|
|
||||||
#define TX_NONAME 187
|
|
||||||
#define TX_DESIGN 188
|
|
||||||
#define TX_MISSNUM 189
|
|
||||||
#define TX_MISSTIME 190
|
|
||||||
#define TX_MISSION2D 191
|
|
||||||
#define TX_SHOWNEXT 192
|
|
||||||
#define TX_SHOWPREV 193
|
|
||||||
#define TX_CONTENT 194
|
|
||||||
#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_SHOWCONNECTION 242
|
|
||||||
#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_HELP 268
|
|
||||||
#define TX_LOAD_CGAME 269
|
|
||||||
#define TX_SAVE_CGAME 270
|
|
||||||
#define TX_MISSIONFREE 272
|
|
||||||
#define TX_GAMESAVED 288
|
|
||||||
#define TX_NOTINDEMO 289
|
|
||||||
#define TX_REPEAT_CULTIVE 500
|
|
||||||
#define TX_REPEAT_FLEUR 501
|
|
||||||
#define TX_REPEAT_FLEURQ 502
|
|
||||||
#define TX_REPEAT_FABMINE 503
|
|
||||||
#define TX_REPEAT_FABJEEP 504
|
|
||||||
#define TX_REPEAT_PALIS 505
|
|
||||||
#define TX_REPEAT_PALISQ 506
|
|
||||||
#define TX_REPEAT_PONT 507
|
|
||||||
#define TX_REPEAT_PONTQ 508
|
|
||||||
#define TX_REPEAT_BATEAU 509
|
|
||||||
#define TX_REPEAT_BATEAUQ 510
|
|
||||||
#define TX_REPEAT_FABARMURE 511
|
|
||||||
#define TX_DIRECT_N 512
|
|
||||||
#define TX_DIRECT_S 513
|
|
||||||
#define TX_DIRECT_E 514
|
|
||||||
#define TX_DIRECT_O 515
|
|
||||||
#define IDR_WAVE_BOING 1000
|
|
||||||
#define TX_ERROR_MISC 1000
|
|
||||||
#define IDR_WAVE_BLOW 1001
|
|
||||||
#define TX_ERROR_GROUND 1001
|
|
||||||
#define TX_ERROR_FREE 1002
|
|
||||||
#define TX_ERROR_PONTOP 1003
|
|
||||||
#define TX_ERROR_PONTTERM 1004
|
|
||||||
#define TX_ERROR_TOURISOL 1005
|
|
||||||
#define TX_ERROR_TOUREAU 1006
|
|
||||||
#define TX_ERROR_TELE2 1007
|
|
||||||
#define TX_OBJ_BLUPIm 2000
|
|
||||||
#define TX_OBJ_BLUPIf 2001
|
|
||||||
#define TX_OBJ_BLUPI 2002
|
|
||||||
#define TX_OBJ_BATEAU 2003
|
|
||||||
#define TX_OBJ_JEEP 2004
|
|
||||||
#define TX_OBJ_PIEGE 2005
|
|
||||||
#define TX_OBJ_POISON 2006
|
|
||||||
#define TX_OBJ_DYNAMITE 2007
|
|
||||||
#define TX_OBJ_MINE 2008
|
|
||||||
#define TX_OBJ_TOMATE 2009
|
|
||||||
#define TX_OBJ_POTION 2010
|
|
||||||
#define TX_OBJ_PLANCHE 2011
|
|
||||||
#define TX_OBJ_PIERRE 2012
|
|
||||||
#define TX_OBJ_DRAPEAU 2013
|
|
||||||
#define TX_OBJ_FER 2014
|
|
||||||
#define TX_OBJ_FLEUR1 2015
|
|
||||||
#define TX_OBJ_FLEUR2 2016
|
|
||||||
#define TX_OBJ_FLEUR3 2017
|
|
||||||
#define TX_OBJ_CABANE 2018
|
|
||||||
#define TX_OBJ_LABO 2019
|
|
||||||
#define TX_OBJ_MINEFER 2020
|
|
||||||
#define TX_OBJ_USINE 2021
|
|
||||||
#define TX_OBJ_TOUR 2022
|
|
||||||
#define TX_OBJ_FEU 2023
|
|
||||||
#define TX_OBJ_ROBOT 2024
|
|
||||||
#define TX_OBJ_TRACKS 2025
|
|
||||||
#define TX_OBJ_BOMBE 2026
|
|
||||||
#define TX_OBJ_ARAIGNEE 2027
|
|
||||||
#define TX_OBJ_VIRUS 2028
|
|
||||||
#define TX_OBJ_ELECTRO 2029
|
|
||||||
#define TX_OBJ_ARBRE 2030
|
|
||||||
#define TX_OBJ_MUR 2031
|
|
||||||
#define TX_OBJ_ARBREb 2032
|
|
||||||
#define TX_OBJ_ROC 2033
|
|
||||||
#define TX_OBJ_OEUF 2034
|
|
||||||
#define TX_OBJ_PALISSADE 2035
|
|
||||||
#define TX_OBJ_ENNEMIp 2036
|
|
||||||
#define TX_OBJ_ENNEMI 2037
|
|
||||||
#define TX_OBJ_HERBE 2038
|
|
||||||
#define TX_OBJ_MOUSSE 2039
|
|
||||||
#define TX_OBJ_TERRE 2040
|
|
||||||
#define TX_OBJ_EAU 2041
|
|
||||||
#define TX_OBJ_RIVE 2042
|
|
||||||
#define TX_OBJ_MIXTE 2043
|
|
||||||
#define TX_OBJ_PONT 2044
|
|
||||||
#define TX_OBJ_COUVEUSE 2045
|
|
||||||
#define TX_OBJ_GLACE 2046
|
|
||||||
#define TX_OBJ_MAISON 2047
|
|
||||||
#define TX_OBJ_HACHURE 2048
|
|
||||||
#define TX_OBJ_MOUSSEb 2049
|
|
||||||
#define TX_OBJ_BOUQUET1 2050
|
|
||||||
#define TX_OBJ_BOUQUET2 2051
|
|
||||||
#define TX_OBJ_BOUQUET3 2052
|
|
||||||
#define TX_OBJ_DALLE 2053
|
|
||||||
#define TX_OBJ_ENNEMIs 2054
|
|
||||||
#define TX_OBJ_DISCIPLE 2055
|
|
||||||
#define TX_OBJ_METAL 2056
|
|
||||||
#define TX_OBJ_FUSEE 2057
|
|
||||||
#define TX_OBJ_TELEPORTE 2058
|
|
||||||
#define TX_OBJ_ARMURE 2059
|
|
||||||
#define TX_OBJ_DALLESPEC 2060
|
|
||||||
#define TX_OBJ_COUVTELE 2061
|
|
||||||
#define TX_OBJ_BATIMENT 2062
|
|
||||||
#define TX_OBJ_BATENNEMIS 2063
|
|
||||||
#define TX_OBJ_MURPAL 2064
|
|
||||||
#define TX_OBJ_OBJET 2065
|
|
||||||
#define TX_OBJ_ARME 2066
|
|
||||||
#define TX_OBJ_VEHICULE 2067
|
|
||||||
#define TX_OBJ_STARTFEU 2068
|
|
||||||
#define TX_OBJ_DELOBJ 2069
|
|
||||||
#define TX_OBJ_DELPERSO 2070
|
|
||||||
#define TX_OBJ_DELFEU 2071
|
|
||||||
#define TX_OBJ_PLANTE 2072
|
|
||||||
#define TX_OBJ_BARENNEMIS 2073
|
|
||||||
#define TX_WIN1 3000
|
|
||||||
#define TX_WIN2 3001
|
|
||||||
#define TX_WIN3 3002
|
|
||||||
#define TX_WIN4 3003
|
|
||||||
#define TX_WIN5 3004
|
|
||||||
#define TX_LOST1 3100
|
|
||||||
#define TX_LOST2 3101
|
|
||||||
#define TX_LOST3 3102
|
|
||||||
#define TX_LOST4 3103
|
|
||||||
#define TX_LOST5 3104
|
|
||||||
#define TX_LASTWIN1 3200
|
|
||||||
#define TX_LASTWIN2 3201
|
|
||||||
#define TX_LASTWIN3 3202
|
|
||||||
#define TX_BUTTON_CREATE 6900
|
|
||||||
#define IDM_EXIT 40001
|
|
||||||
|
|
||||||
// Next default values for new objects
|
|
||||||
//
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 194
|
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
|
||||||
#endif
|
|
||||||
#endif
|
|
87
resource1.h
@ -1,87 +0,0 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Visual C++ generated include file.
|
|
||||||
// Used by Eggbert2.rc
|
|
||||||
//
|
|
||||||
#define IDS_STRING101 101
|
|
||||||
#define IDS_STRING102 102
|
|
||||||
#define IDC_CURSOR1 102
|
|
||||||
#define IDS_STRING103 103
|
|
||||||
#define IDC_CURSOR2 103
|
|
||||||
#define IDS_STRING104 104
|
|
||||||
#define IDC_CURSOR3 104
|
|
||||||
#define IDS_STRING105 105
|
|
||||||
#define IDC_CURSOR4 105
|
|
||||||
#define IDS_STRING106 106
|
|
||||||
#define IDC_CURSOR5 106
|
|
||||||
#define IDS_STRING107 107
|
|
||||||
#define IDC_CURSOR6 107
|
|
||||||
#define IDS_STRING108 108
|
|
||||||
#define IDC_CURSOR7 108
|
|
||||||
#define IDS_STRING109 109
|
|
||||||
#define IDC_CURSOR8 109
|
|
||||||
#define IDS_STRING110 110
|
|
||||||
#define IDC_CURSOR9 110
|
|
||||||
#define IDS_STRING111 111
|
|
||||||
#define IDC_CURSOR10 111
|
|
||||||
#define IDS_STRING112 112
|
|
||||||
#define IDC_CURSOR11 112
|
|
||||||
#define IDS_STRING113 113
|
|
||||||
#define IDC_CURSOR12 113
|
|
||||||
#define IDS_STRING114 114
|
|
||||||
#define IDC_CURSOR13 114
|
|
||||||
#define IDS_STRING115 115
|
|
||||||
#define IDC_CURSOR14 115
|
|
||||||
#define IDS_STRING116 116
|
|
||||||
#define IDC_CURSOR15 116
|
|
||||||
#define IDS_STRING117 117
|
|
||||||
#define IDI_ICON1 117
|
|
||||||
#define IDS_STRING118 118
|
|
||||||
#define IDD_DIALOG1 118
|
|
||||||
#define IDS_STRING119 119
|
|
||||||
#define IDS_STRING120 120
|
|
||||||
#define IDS_STRING121 121
|
|
||||||
#define IDS_STRING122 122
|
|
||||||
#define IDS_STRING123 123
|
|
||||||
#define IDS_STRING124 124
|
|
||||||
#define IDS_STRING125 125
|
|
||||||
#define IDS_STRING126 126
|
|
||||||
#define IDS_STRING127 127
|
|
||||||
#define IDS_STRING128 128
|
|
||||||
#define IDS_STRING129 129
|
|
||||||
#define IDS_STRING130 130
|
|
||||||
#define IDS_STRING131 131
|
|
||||||
#define IDS_STRING132 132
|
|
||||||
#define IDS_STRING133 133
|
|
||||||
#define IDS_STRING134 134
|
|
||||||
#define IDS_STRING135 135
|
|
||||||
#define IDS_STRING136 136
|
|
||||||
#define IDS_STRING137 137
|
|
||||||
#define IDS_STRING198 149
|
|
||||||
#define IDS_STRING150 178
|
|
||||||
#define IDS_STRING197 197
|
|
||||||
#define IDS_STRING213 213
|
|
||||||
#define IDS_STRING214 214
|
|
||||||
#define IDS_STRING250 250
|
|
||||||
#define IDS_STRING3005 269
|
|
||||||
#define IDS_STRING270 270
|
|
||||||
#define IDS_STRING3105 3000
|
|
||||||
#define IDS_STRING3001 3001
|
|
||||||
#define IDS_STRING3002 3002
|
|
||||||
#define IDS_STRING3003 3003
|
|
||||||
#define IDS_STRING3004 3004
|
|
||||||
#define IDS_STRING138 3100
|
|
||||||
#define IDS_STRING3101 3101
|
|
||||||
#define IDS_STRING3102 3102
|
|
||||||
#define IDS_STRING3103 3103
|
|
||||||
#define IDS_STRING3104 3104
|
|
||||||
|
|
||||||
// Next default values for new objects
|
|
||||||
//
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 120
|
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
|
||||||
#endif
|
|
||||||
#endif
|
|
108
resource2.h
@ -1,108 +0,0 @@
|
|||||||
//{{NO_DEPENDENCIES}}
|
|
||||||
// Microsoft Visual C++ generated include file.
|
|
||||||
// Used by Resource.rc
|
|
||||||
//
|
|
||||||
#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_ONLYHSSCROLL 122
|
|
||||||
#define TX_BUTTON_ONLYVSCROLL 123
|
|
||||||
#define TX_BUTTON_TESTMISSION 124
|
|
||||||
#define TX_PAUSE 125
|
|
||||||
#define TX_TINY 126
|
|
||||||
#define TX_CLEARPLAYER 127
|
|
||||||
#define TX_SETTINGS 128
|
|
||||||
#define TX_CHOOSEMUSIC 129
|
|
||||||
#define TX_BUTTON_SETUP1 130
|
|
||||||
#define TX_BUTTON_SETUP2 131
|
|
||||||
#define TX_BUTTON_SETUP3 132
|
|
||||||
#define TX_BUTTON_SETUP4 133
|
|
||||||
#define TX_NOMUSIC 134
|
|
||||||
#define TX_MUSIC1 135
|
|
||||||
#define TX_MUSIC2 136
|
|
||||||
#define TX_MUSIC3 137
|
|
||||||
#define TX_MUSIC4 138
|
|
||||||
#define TX_MUSIC5 139
|
|
||||||
#define TX_MUSIC6 140
|
|
||||||
#define TX_MUSIC7 141
|
|
||||||
#define TX_MUSIC8 142
|
|
||||||
#define TX_MUSIC9 143
|
|
||||||
#define TX_BUTTON_REGION 144
|
|
||||||
#define TX_DISCARDGAME 145
|
|
||||||
#define TX_EGGBERT 146
|
|
||||||
#define TX_DESIGNMISSION 147
|
|
||||||
#define TX_CHOOSEGAMER 148
|
|
||||||
#define TX_MUSIC 149
|
|
||||||
#define TX_TRAININGNUM 150
|
|
||||||
#define TX_MISSIONNUM 151
|
|
||||||
#define TX_MISSIONTIME 152
|
|
||||||
#define TX_SIZE 153
|
|
||||||
#define TX_BUTTON_SETUP5 154
|
|
||||||
#define TX_BUTTON_SETUP6 155
|
|
||||||
#define TX_BUTTON_SETUP7 156
|
|
||||||
#define TX_BUTTON_SETUP8 157
|
|
||||||
#define TX_CONFYES 158
|
|
||||||
#define TX_CONFNO 159
|
|
||||||
#define TX_SETTING 160
|
|
||||||
#define TX_SAVECURRENTMISS 161
|
|
||||||
#define TX_SOUNDVOL 162
|
|
||||||
#define TX_MUSICVOL 163
|
|
||||||
#define TX_COLORDEP 164
|
|
||||||
#define TX_INPUT 165
|
|
||||||
#define TX_OPENMISS 166
|
|
||||||
#define TX_READINFO 167
|
|
||||||
#define TX_PLAYERFREE 168
|
|
||||||
#define TX_NUMDOOROPEN 169
|
|
||||||
#define TX_NUMDOORSOPEN 170
|
|
||||||
#define TX_MUSIC10 171
|
|
||||||
#define TX_WRITENAME 172
|
|
||||||
#define TX_NONE 173
|
|
||||||
#define TX_CONFIRM 174
|
|
||||||
#define TX_CANCEL 175
|
|
||||||
#define TX_YES 176
|
|
||||||
#define TX_NO 177
|
|
||||||
#define TX_REGION 178
|
|
||||||
#define TX_SUS 179
|
|
||||||
#define TX_BUTTON_SETUP 180
|
|
||||||
#define TX_SAVES 181
|
|
||||||
#define TX_INSERT 182
|
|
||||||
#define TX_DELETEMISS 183
|
|
||||||
#define TX_DELETEMISSION 184
|
|
||||||
#define TX_NAMEOFMISS 185
|
|
||||||
#define TX_NAMEOFMISSION 186
|
|
||||||
#define TX_NONAME 187
|
|
||||||
#define TX_DESIGN 188
|
|
||||||
#define TX_MISSNUM 189
|
|
||||||
#define TX_MISSTIME 190
|
|
||||||
#define IDI_ICON1 190
|
|
||||||
#define TX_MISSION2D 191
|
|
||||||
|
|
||||||
// Next default values for new objects
|
|
||||||
//
|
|
||||||
#ifdef APSTUDIO_INVOKED
|
|
||||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
|
||||||
#define _APS_NEXT_RESOURCE_VALUE 191
|
|
||||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
|
||||||
#define _APS_NEXT_CONTROL_VALUE 1001
|
|
||||||
#define _APS_NEXT_SYMED_VALUE 101
|
|
||||||
#endif
|
|
||||||
#endif
|
|
685
sound.cpp
@ -1,685 +0,0 @@
|
|||||||
// sound.cpp
|
|
||||||
//
|
|
||||||
|
|
||||||
#include <dsound.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <mciapi.h>
|
|
||||||
#include "sound.h"
|
|
||||||
#include "misc.h"
|
|
||||||
#include "def.h"
|
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
#pragma warning (disable : 4996)
|
|
||||||
#pragma comment(lib, "dsound.lib")
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// The following macro are used for proper error handling for DirectSound.
|
|
||||||
#define TRY_DS(exp) { { HRESULT rval = exp; if (rval != DS_OK) { TraceErrorDS(rval, __FILE__, __LINE__); return FALSE; } } }
|
|
||||||
|
|
||||||
|
|
||||||
struct WaveHeader
|
|
||||||
{
|
|
||||||
BYTE RIFF[4]; // "RIFF"
|
|
||||||
DWORD dwSize; // Size of data to follow
|
|
||||||
BYTE WAVE[4]; // "WAVE"
|
|
||||||
BYTE fmt_[4]; // "fmt "
|
|
||||||
DWORD dw16; // 16
|
|
||||||
WORD wOne_0; // 1
|
|
||||||
WORD wChnls; // Number of Channels
|
|
||||||
DWORD dwSRate; // Sample Rate
|
|
||||||
DWORD BytesPerSec; // Sample Rate
|
|
||||||
WORD wBlkAlign; // 1
|
|
||||||
WORD BitsPerSample; // Sample size
|
|
||||||
BYTE DATA[4]; // "DATA"
|
|
||||||
DWORD dwDSize; // Number of Samples
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Creates a DirectSound buffer.
|
|
||||||
|
|
||||||
BOOL CSound::CreateSoundBuffer(int dwBuf, DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample, DWORD dwBlkAlign, BOOL bStereo)
|
|
||||||
{
|
|
||||||
PCMWAVEFORMAT pcmwf;
|
|
||||||
DSBUFFERDESC dsbdesc;
|
|
||||||
|
|
||||||
// Set up wave format structure.
|
|
||||||
memset( &pcmwf, 0, sizeof(PCMWAVEFORMAT) );
|
|
||||||
pcmwf.wf.wFormatTag = WAVE_FORMAT_PCM;
|
|
||||||
pcmwf.wf.nChannels = bStereo ? 2 : 1;
|
|
||||||
pcmwf.wf.nSamplesPerSec = dwFreq;
|
|
||||||
pcmwf.wf.nBlockAlign = (WORD)dwBlkAlign;
|
|
||||||
pcmwf.wf.nAvgBytesPerSec = pcmwf.wf.nSamplesPerSec * pcmwf.wf.nBlockAlign;
|
|
||||||
pcmwf.wBitsPerSample = (WORD)dwBitsPerSample;
|
|
||||||
|
|
||||||
// Set up DSBUFFERDESC structure.
|
|
||||||
memset(&dsbdesc, 0, sizeof(DSBUFFERDESC)); // Zero it out.
|
|
||||||
dsbdesc.dwSize = sizeof(DSBUFFERDESC);
|
|
||||||
dsbdesc.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;
|
|
||||||
dsbdesc.dwBufferBytes = dwBufSize;
|
|
||||||
dsbdesc.lpwfxFormat = (LPWAVEFORMATEX)&pcmwf;
|
|
||||||
|
|
||||||
TRY_DS(m_lpDS->CreateSoundBuffer(&dsbdesc, &m_lpDSB[dwBuf], NULL), 63)
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// I dunno what the fuck this does.
|
|
||||||
/*
|
|
||||||
BOOL CSound::ErrorSomething()
|
|
||||||
{
|
|
||||||
if (m_lpDS ||
|
|
||||||
m_lpDSB != 0)
|
|
||||||
{
|
|
||||||
m_lpDS, m_lpDSB->TraceErrorDS;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// Reads in data from a wave file.
|
|
||||||
|
|
||||||
BOOL CSound::ReadData(LPDIRECTSOUNDBUFFER lpDSB, FILE* pFile, DWORD dwSize, DWORD dwPos)
|
|
||||||
{
|
|
||||||
// Seek to correct position in file (if necessary)
|
|
||||||
if ( dwPos != 0xffffffff )
|
|
||||||
{
|
|
||||||
if ( fseek(pFile, dwPos, SEEK_SET) != 0 )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Lock data in buffer for writing
|
|
||||||
LPVOID pData1;
|
|
||||||
DWORD dwData1Size;
|
|
||||||
LPVOID pData2;
|
|
||||||
DWORD dwData2Size;
|
|
||||||
HRESULT rval;
|
|
||||||
|
|
||||||
rval = lpDSB->Lock(0, dwSize, &pData1, &dwData1Size, &pData2, &dwData2Size, DSBLOCK_FROMWRITECURSOR);
|
|
||||||
if ( rval != DS_OK )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read in first chunk of data
|
|
||||||
if ( dwData1Size > 0 )
|
|
||||||
{
|
|
||||||
if ( fread(pData1, dwData1Size, 1, pFile) != 1 )
|
|
||||||
{
|
|
||||||
char holder[256];
|
|
||||||
wsprintfA(holder,"Data1 : %d, dwdata: %d, pFile: %d",pData1,dwData1Size,pFile);
|
|
||||||
OutputDebug(holder);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// read in second chunk if necessary
|
|
||||||
if ( dwData2Size > 0 )
|
|
||||||
{
|
|
||||||
if ( fread(pData2, dwData2Size, 1, pFile) != 1 )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unlock data in buffer
|
|
||||||
rval = lpDSB->Unlock(pData1, dwData1Size, pData2, dwData2Size);
|
|
||||||
if ( rval != DS_OK )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Creates a DirectSound buffer from a wave file.
|
|
||||||
|
|
||||||
BOOL CSound::CreateBufferFromWaveFile(int dwBuf, char *pFileName)
|
|
||||||
{
|
|
||||||
// Open the wave file
|
|
||||||
FILE* pFile = fopen(pFileName, "rb");
|
|
||||||
if ( pFile == NULL ) return FALSE;
|
|
||||||
|
|
||||||
// Read in the wave header
|
|
||||||
WaveHeader wavHdr;
|
|
||||||
if ( fread(&wavHdr, sizeof(wavHdr), 1, pFile) != 1 )
|
|
||||||
{
|
|
||||||
fclose(pFile);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Figure out the size of the data region
|
|
||||||
DWORD dwSize = wavHdr.dwDSize;
|
|
||||||
|
|
||||||
// Is this a stereo or mono file?
|
|
||||||
BOOL bStereo = wavHdr.wChnls > 1 ? TRUE : FALSE;
|
|
||||||
|
|
||||||
// Create the sound buffer for the wave file
|
|
||||||
if ( !CreateSoundBuffer(dwBuf, dwSize, wavHdr.dwSRate,
|
|
||||||
wavHdr.BitsPerSample, wavHdr.wBlkAlign, bStereo) )
|
|
||||||
{
|
|
||||||
// Close the file
|
|
||||||
fclose(pFile);
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read the data for the wave file into the sound buffer
|
|
||||||
if ( !ReadData(m_lpDSB[dwBuf], pFile, dwSize, sizeof(wavHdr)) )
|
|
||||||
{
|
|
||||||
fclose(pFile);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close out the wave file
|
|
||||||
fclose(pFile);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stops all sounds.
|
|
||||||
|
|
||||||
BOOL CSound::StopAllSounds()
|
|
||||||
{
|
|
||||||
// Make sure we have a valid sound buffer
|
|
||||||
for (int i = 0; i < MAXSOUND; i ++)
|
|
||||||
{
|
|
||||||
if ( m_lpDSB[i] )
|
|
||||||
{
|
|
||||||
DWORD dwStatus;
|
|
||||||
TRY_DS(m_lpDSB[i]->GetStatus(&dwStatus));
|
|
||||||
|
|
||||||
if ( (dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING )
|
|
||||||
{
|
|
||||||
TRY_DS(m_lpDSB[i]->Stop())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Plays a sound using direct sound.
|
|
||||||
|
|
||||||
BOOL CSound::PlaySoundDS(DWORD dwSound, DWORD dwFlags)
|
|
||||||
{
|
|
||||||
// Make sure the sound is valid
|
|
||||||
if ( dwSound >= MAXSOUND ) return FALSE;
|
|
||||||
|
|
||||||
// Make sure we have a valid sound buffer
|
|
||||||
if ( m_lpDSB[dwSound] )
|
|
||||||
{
|
|
||||||
DWORD dwStatus;
|
|
||||||
TRY_DS(m_lpDSB[dwSound]->GetStatus(&dwStatus));
|
|
||||||
|
|
||||||
if ( (dwStatus & DSBSTATUS_PLAYING) != DSBSTATUS_PLAYING )
|
|
||||||
{
|
|
||||||
// Play the sound
|
|
||||||
TRY_DS(m_lpDSB[dwSound]->Play(0, 0, dwFlags));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
// Modifie le volume midi.
|
|
||||||
// Le volume est compris entre 0 et 20 !
|
|
||||||
|
|
||||||
void InitMidiVolume(int volume)
|
|
||||||
{
|
|
||||||
int nb, i, n;
|
|
||||||
MMRESULT result;
|
|
||||||
HMIDIOUT hmo = 0;
|
|
||||||
|
|
||||||
static int table[21] =
|
|
||||||
{
|
|
||||||
0x00000000,
|
|
||||||
0x11111111,
|
|
||||||
0x22222222,
|
|
||||||
0x33333333,
|
|
||||||
0x44444444,
|
|
||||||
0x55555555,
|
|
||||||
0x66666666,
|
|
||||||
0x77777777,
|
|
||||||
0x88888888,
|
|
||||||
0x99999999,
|
|
||||||
0xAAAAAAAA,
|
|
||||||
0xBBBBBBBB,
|
|
||||||
0xCCCCCCCC,
|
|
||||||
0xDDDDDDDD,
|
|
||||||
0xEEEEEEEE,
|
|
||||||
0xF222F222,
|
|
||||||
0xF555F555,
|
|
||||||
0xF777F777,
|
|
||||||
0xFAAAFAAA,
|
|
||||||
0xFDDDFDDD,
|
|
||||||
0xFFFFFFFF,
|
|
||||||
};
|
|
||||||
|
|
||||||
if ( volume < 0 ) volume = 0;
|
|
||||||
if ( volume > MAXVOLUME ) volume = MAXVOLUME;
|
|
||||||
|
|
||||||
nb = midiOutGetNumDevs();
|
|
||||||
for ( i=0 ; i<nb ; i++ )
|
|
||||||
{
|
|
||||||
result = midiOutOpen((LPHMIDIOUT)&hmo, i, 0L, 0L, 0L);
|
|
||||||
if ( result != MMSYSERR_NOERROR )
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
result = midiOutSetVolume(hmo, table[volume]);
|
|
||||||
if ( result != MMSYSERR_NOERROR )
|
|
||||||
{
|
|
||||||
n = 1;
|
|
||||||
}
|
|
||||||
midiOutClose(hmo);
|
|
||||||
hmo = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
// Constructeur.
|
|
||||||
|
|
||||||
CSound::CSound()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
m_bEnable = FALSE;
|
|
||||||
m_bState = FALSE;
|
|
||||||
m_MidiDeviceID = 0;
|
|
||||||
m_MIDIFilename[0] = 0;
|
|
||||||
m_audioVolume = 20;
|
|
||||||
m_midiVolume = 15;
|
|
||||||
m_lastMidiVolume = 0;
|
|
||||||
m_nbSuspendSkip = 0;
|
|
||||||
|
|
||||||
m_lpDS = NULL;
|
|
||||||
|
|
||||||
for ( i=0 ; i<MAXSOUND ; i++ )
|
|
||||||
{
|
|
||||||
m_lpDSB[i] = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( i=0 ; i<MAXBLUPI ; i++ )
|
|
||||||
{
|
|
||||||
m_channelBlupi[i] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Destructeur.
|
|
||||||
|
|
||||||
CSound::~CSound()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if ( m_bEnable )
|
|
||||||
{
|
|
||||||
InitMidiVolume(15); // remet un volume moyen !
|
|
||||||
}
|
|
||||||
|
|
||||||
for ( i=0 ; i<MAXSOUND ; i++ )
|
|
||||||
{
|
|
||||||
if ( m_lpDSB[i] != NULL )
|
|
||||||
{
|
|
||||||
//? m_lpDSB[i]->Release();
|
|
||||||
m_lpDSB[i]= NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_lpDS != NULL )
|
|
||||||
{
|
|
||||||
m_lpDS->Release();
|
|
||||||
m_lpDS = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Initialisation de DirectSound.
|
|
||||||
|
|
||||||
BOOL CSound::Create(HWND hWnd)
|
|
||||||
{
|
|
||||||
if ( !DirectSoundCreate(NULL, &m_lpDS, NULL) == DS_OK )
|
|
||||||
{
|
|
||||||
OutputDebug("Fatal error: DirectSoundCreate\n");
|
|
||||||
m_bEnable = FALSE;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_lpDS->SetCooperativeLevel(hWnd, DSSCL_NORMAL);
|
|
||||||
m_bEnable = TRUE;
|
|
||||||
m_hWnd = hWnd;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Retourne l'<27>tat de DirectSound.
|
|
||||||
|
|
||||||
BOOL CSound::GetEnable()
|
|
||||||
{
|
|
||||||
return m_bEnable;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Enclenche ou d<>clenche le son.
|
|
||||||
|
|
||||||
void CSound::SetState(BOOL bState)
|
|
||||||
{
|
|
||||||
m_bState = bState;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Gestion des volumes audio (.wav) et midi (.mid).
|
|
||||||
|
|
||||||
void CSound::SetAudioVolume(int volume)
|
|
||||||
{
|
|
||||||
m_audioVolume = volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CSound::GetAudioVolume()
|
|
||||||
{
|
|
||||||
if ( !m_bEnable ) return 0;
|
|
||||||
return m_audioVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSound::SetMidiVolume(int volume)
|
|
||||||
{
|
|
||||||
m_midiVolume = volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
int CSound::GetMidiVolume()
|
|
||||||
{
|
|
||||||
if ( !m_bEnable ) return 0;
|
|
||||||
return m_midiVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Cache tous les ficheirs son (.wav).
|
|
||||||
|
|
||||||
void CSound::CacheAll()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char name[50];
|
|
||||||
|
|
||||||
if ( !m_bEnable ) return;
|
|
||||||
|
|
||||||
for ( i=0 ; i<MAXSOUND ; i++ )
|
|
||||||
{
|
|
||||||
sprintf(name, "sound\\sound%.3d.blp", i);
|
|
||||||
if ( !Cache(i, name) ) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Charge un fichier son (.wav).
|
|
||||||
|
|
||||||
BOOL CSound::Cache(int channel, char *pFilename)
|
|
||||||
{
|
|
||||||
if ( !m_bEnable ) return FALSE;
|
|
||||||
if ( channel < 0 || channel >= MAXSOUND ) return FALSE;
|
|
||||||
|
|
||||||
if ( m_lpDSB[channel] != NULL )
|
|
||||||
{
|
|
||||||
Flush(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
return CreateBufferFromWaveFile(channel, pFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
// D<>charge un son.
|
|
||||||
|
|
||||||
void CSound::Flush(int channel)
|
|
||||||
{
|
|
||||||
if ( !m_bEnable ) return;
|
|
||||||
if ( channel < 0 || channel >= MAXSOUND ) return;
|
|
||||||
|
|
||||||
if ( m_lpDSB[channel] != NULL )
|
|
||||||
{
|
|
||||||
m_lpDSB[channel]->Release();
|
|
||||||
m_lpDSB[channel]= NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fait entendre un son.
|
|
||||||
// Le volume est compris entre 0 (max) et -10000 (silence).
|
|
||||||
// Le panoramique est compris entre -10000 (gauche), 0 (centre)
|
|
||||||
// et +10000 (droite).
|
|
||||||
|
|
||||||
BOOL CSound::Play(int channel, int volume, int pan)
|
|
||||||
{
|
|
||||||
if ( !m_bEnable ) return TRUE;
|
|
||||||
if ( !m_bState || m_audioVolume == 0 ) return TRUE;
|
|
||||||
|
|
||||||
volume -= (MAXVOLUME-m_audioVolume)*((10000/4)/MAXVOLUME);
|
|
||||||
|
|
||||||
//? if ( volume == -10000 ) return TRUE;
|
|
||||||
if ( volume <= -10000/4 ) return TRUE;
|
|
||||||
|
|
||||||
if ( channel < 0 || channel >= MAXSOUND ) return FALSE;
|
|
||||||
if ( m_lpDSB[channel] == NULL ) return FALSE;
|
|
||||||
|
|
||||||
m_lpDSB[channel]->SetVolume(volume);
|
|
||||||
m_lpDSB[channel]->SetPan(pan);
|
|
||||||
m_lpDSB[channel]->Play(0, 0, 0);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL CSound::StopSound(Sound channel)
|
|
||||||
{
|
|
||||||
if (m_bEnable) return FALSE;
|
|
||||||
if (m_bState || m_audioVolume == 0) return FALSE;
|
|
||||||
|
|
||||||
if (0 < channel || channel < MAXSOUND)
|
|
||||||
{
|
|
||||||
if (m_lpDSB[channel] == NULL)
|
|
||||||
return (BOOL)m_lpDSB[channel];
|
|
||||||
m_lpDSB[channel]->Stop();
|
|
||||||
m_lpDSB[channel]->SetCurrentPosition(0);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fait entendre un son dans une image.
|
|
||||||
// Si rank != -1, il indique le rang du blupi dont il faudra
|
|
||||||
// <20>ventuellement stopper le dernier son en cours !
|
|
||||||
|
|
||||||
BOOL CSound::PlayImage(int channel, POINT pos, int rank)
|
|
||||||
{
|
|
||||||
int stopCh, volumex, volumey, volume, pan;
|
|
||||||
|
|
||||||
if ( rank >= 0 && rank < MAXBLUPI )
|
|
||||||
{
|
|
||||||
stopCh = m_channelBlupi[rank];
|
|
||||||
if ( stopCh >= 0 && m_lpDSB[stopCh] != NULL )
|
|
||||||
{
|
|
||||||
m_lpDSB[stopCh]->Stop(); // stoppe le son pr<70>c<EFBFBD>dent
|
|
||||||
m_lpDSB[stopCh]->SetCurrentPosition(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_channelBlupi[rank] = channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
//? pan = (int)(((long)pos.x*20000L)/LXIMAGE)-10000L;
|
|
||||||
//? pan = (int)(((long)pos.x*10000L)/LXIMAGE)-5000L;
|
|
||||||
pan = (int)(((long)pos.x*5000L)/LXIMAGE)-2500L;
|
|
||||||
|
|
||||||
volumex = 0; // volume maximum
|
|
||||||
if ( pos.x < 0 )
|
|
||||||
{
|
|
||||||
volumex = (pos.x*2500)/LXIMAGE;
|
|
||||||
}
|
|
||||||
if ( pos.x > LXIMAGE )
|
|
||||||
{
|
|
||||||
pos.x -= LXIMAGE;
|
|
||||||
volumex = (-pos.x*2500)/LXIMAGE;
|
|
||||||
}
|
|
||||||
if ( volumex < -10000 ) volumex = -10000;
|
|
||||||
|
|
||||||
volumey = 0; // volume maximum
|
|
||||||
if ( pos.y < 0 )
|
|
||||||
{
|
|
||||||
volumey = (pos.y*2500)/LYIMAGE;
|
|
||||||
}
|
|
||||||
if ( pos.y > LYIMAGE )
|
|
||||||
{
|
|
||||||
pos.y -= LYIMAGE;
|
|
||||||
volumey = (-pos.y*2500)/LYIMAGE;
|
|
||||||
}
|
|
||||||
if ( volumey < -10000 ) volumey = -10000;
|
|
||||||
|
|
||||||
if ( volumex < volumey ) volume = volumex;
|
|
||||||
else volume = volumey;
|
|
||||||
|
|
||||||
return Play(channel, volume, pan);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Uses MCI to play a MIDI file. The window procedure
|
|
||||||
// is notified when playback is complete.
|
|
||||||
|
|
||||||
BOOL CSound::PlayMusic(HWND hWnd, LPSTR lpszMIDIFilename)
|
|
||||||
{
|
|
||||||
MCI_OPEN_PARMS mciOpenParms;
|
|
||||||
MCI_PLAY_PARMS mciPlayParms;
|
|
||||||
DWORD dwReturn;
|
|
||||||
char string[MAX_PATH];
|
|
||||||
|
|
||||||
if ( !m_bEnable ) return TRUE;
|
|
||||||
if ( m_midiVolume == 0 ) return TRUE;
|
|
||||||
InitMidiVolume(m_midiVolume);
|
|
||||||
m_lastMidiVolume = m_midiVolume;
|
|
||||||
|
|
||||||
if ( lpszMIDIFilename[1] == ':' ) // nom complet "D:\REP..." ?
|
|
||||||
{
|
|
||||||
strcpy(string, lpszMIDIFilename);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GetCurrentDir(string, MAX_PATH-30);
|
|
||||||
strcat(string, lpszMIDIFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open the device by specifying the device and filename.
|
|
||||||
// MCI will attempt to choose the MIDI mapper as the output port.
|
|
||||||
mciOpenParms.lpstrDeviceType = (LPCWSTR)"sequencer";
|
|
||||||
mciOpenParms.lpstrElementName = (LPCWSTR)string;
|
|
||||||
dwReturn = mciSendCommand(NULL,
|
|
||||||
MCI_OPEN,
|
|
||||||
MCI_OPEN_TYPE|MCI_OPEN_ELEMENT,
|
|
||||||
(DWORD)(LPVOID)&mciOpenParms);
|
|
||||||
if ( dwReturn != 0 )
|
|
||||||
{
|
|
||||||
OutputDebug("PlayMusic-1\n");
|
|
||||||
mciGetErrorStringA(dwReturn, string, 128);
|
|
||||||
OutputDebug(string);
|
|
||||||
// Failed to open device. Don't close it; just return error.
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The device opened successfully; get the device ID.
|
|
||||||
m_MidiDeviceID = mciOpenParms.wDeviceID;
|
|
||||||
|
|
||||||
// Begin playback.
|
|
||||||
mciPlayParms.dwCallback = (DWORD)hWnd;
|
|
||||||
dwReturn = mciSendCommand(m_MidiDeviceID,
|
|
||||||
MCI_PLAY,
|
|
||||||
MCI_NOTIFY,
|
|
||||||
(DWORD)(LPVOID)&mciPlayParms);
|
|
||||||
if ( dwReturn != 0 )
|
|
||||||
{
|
|
||||||
OutputDebug("PlayMusic-2\n");
|
|
||||||
mciGetErrorStringA(dwReturn, string, 128);
|
|
||||||
OutputDebug(string);
|
|
||||||
StopMusic();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(m_MIDIFilename, lpszMIDIFilename);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restart the MIDI player.
|
|
||||||
|
|
||||||
BOOL CSound::RestartMusic()
|
|
||||||
{
|
|
||||||
OutputDebug("RestartMusic\n");
|
|
||||||
if ( !m_bEnable ) return TRUE;
|
|
||||||
if ( m_midiVolume == 0 ) return TRUE;
|
|
||||||
if ( m_MIDIFilename[0] == 0 ) return FALSE;
|
|
||||||
|
|
||||||
return PlayMusic(m_hWnd, m_MIDIFilename);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shuts down the MIDI player.
|
|
||||||
|
|
||||||
void CSound::SuspendMusic()
|
|
||||||
{
|
|
||||||
if ( !m_bEnable ) return;
|
|
||||||
|
|
||||||
if ( m_nbSuspendSkip != 0 )
|
|
||||||
{
|
|
||||||
m_nbSuspendSkip --;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_MidiDeviceID && m_midiVolume != 0 )
|
|
||||||
{
|
|
||||||
mciSendCommand(m_MidiDeviceID, MCI_CLOSE, 0, NULL);
|
|
||||||
}
|
|
||||||
m_MidiDeviceID = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shuts down the MIDI player.
|
|
||||||
|
|
||||||
void CSound::StopMusic()
|
|
||||||
{
|
|
||||||
SuspendMusic();
|
|
||||||
m_MIDIFilename[0] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retourne TRUE si une musique est en cours.
|
|
||||||
|
|
||||||
BOOL CSound::IsPlayingMusic()
|
|
||||||
{
|
|
||||||
return (m_MIDIFilename[0] != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Adapte le volume de la musique en cours, si n<>cessaire.
|
|
||||||
|
|
||||||
void CSound::AdaptVolumeMusic()
|
|
||||||
{
|
|
||||||
if ( m_midiVolume != m_lastMidiVolume )
|
|
||||||
{
|
|
||||||
InitMidiVolume(m_midiVolume);
|
|
||||||
m_lastMidiVolume = m_midiVolume;
|
|
||||||
RestartMusic();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Indique le nombre de suspend <20> sauter.
|
|
||||||
|
|
||||||
void CSound::SetSuspendSkip(int nb)
|
|
||||||
{
|
|
||||||
m_nbSuspendSkip = nb;
|
|
||||||
}
|
|
||||||
|
|
103
sound.h
@ -1,103 +0,0 @@
|
|||||||
// sound.h
|
|
||||||
//
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <windef.h>
|
|
||||||
#include <minwindef.h>
|
|
||||||
#include "dsound.h"
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SOUND_1_CLICK,
|
|
||||||
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
|
|
||||||
#define MAXVOLUME 20
|
|
||||||
#define MAXBLUPI 100
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
class CSound
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CSound();
|
|
||||||
~CSound();
|
|
||||||
|
|
||||||
BOOL Create(HWND hWnd);
|
|
||||||
void SetState(BOOL bState);
|
|
||||||
BOOL GetEnable();
|
|
||||||
|
|
||||||
void SetAudioVolume(int volume);
|
|
||||||
int GetAudioVolume();
|
|
||||||
void SetMidiVolume(int volume);
|
|
||||||
int GetMidiVolume();
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
BOOL CreateSoundBuffer(int dwBuf, DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample, DWORD dwBlkAlign, BOOL bStereo);
|
|
||||||
BOOL ReadData(LPDIRECTSOUNDBUFFER lpDSB, FILE* pFile, DWORD dwSize, DWORD dwPos);
|
|
||||||
BOOL CreateBufferFromWaveFile(int dwBuf, char *pFileName);
|
|
||||||
BOOL StopAllSounds();
|
|
||||||
BOOL PlaySoundDS(DWORD dwSound, DWORD dwFlags);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
HWND m_hWnd;
|
|
||||||
BOOL m_bEnable;
|
|
||||||
BOOL m_bState;
|
|
||||||
BOOL m_bCDAudio;
|
|
||||||
LPDIRECTSOUND m_lpDS;
|
|
||||||
LPDIRECTSOUNDBUFFER m_lpDSB[MAXSOUND];
|
|
||||||
short m_channelBlupi[MAXBLUPI];
|
|
||||||
UINT m_MidiDeviceID;
|
|
||||||
char m_MIDIFilename[50];
|
|
||||||
int m_audioVolume;
|
|
||||||
int m_midiVolume;
|
|
||||||
int m_lastMidiVolume;
|
|
||||||
int m_nbSuspendSkip;
|
|
||||||
};
|
|
378
text.cpp
@ -1,378 +0,0 @@
|
|||||||
// Text.cpp
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <ddraw.h>
|
|
||||||
#include "def.h"
|
|
||||||
#include "pixmap.h"
|
|
||||||
#include "text.h"
|
|
||||||
#include "texttables.h"
|
|
||||||
|
|
||||||
#pragma warning (disable: 4996)
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
// Retourne l'offset pour un caract<63>re donn<6E>.
|
|
||||||
|
|
||||||
int GetOffset(char c)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
static unsigned char table_accents[15] =
|
|
||||||
{
|
|
||||||
0xFC, 0xE0, 0xE2, 0xE9, 0xE8, 0xEB, 0xEA, 0xEF,
|
|
||||||
0xEE, 0xF4, 0xF9, 0xFB, 0xE4, 0xF6, 0xE7
|
|
||||||
};
|
|
||||||
|
|
||||||
for ( i=0 ; i<15 ; i++ )
|
|
||||||
{
|
|
||||||
if ( (unsigned char)c == table_accents[i] )
|
|
||||||
{
|
|
||||||
return 15+i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( c<0 || c>128 ) return 1; // carr<72>
|
|
||||||
|
|
||||||
return c;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retourne la longueur d'un caract<63>re.
|
|
||||||
|
|
||||||
int GetCharWidth(char c, int font)
|
|
||||||
{
|
|
||||||
static unsigned char table_width[128] =
|
|
||||||
{
|
|
||||||
9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,8,
|
|
||||||
9,9,8,8,8,8,5,5,8,8,8,9,8,8,10,10,
|
|
||||||
5,6,9,13,11,12,12,6,6,6,12,12,5,9,6,9,
|
|
||||||
8,8,9,9,8,9,8,8,9,9,6,6,8,9,10,11,
|
|
||||||
12,8,9,9,9,8,8,8,9,4,8,9,8,10,9,9,
|
|
||||||
8,9,8,9,10,8,9,11,9,8,10,7,10,7,13,13,
|
|
||||||
9,9,8,8,8,8,6,8,8,4,6,8,4,12,8,8,
|
|
||||||
8,8,7,6,7,8,8,10,8,8,7,6,6,6,10,0,
|
|
||||||
};
|
|
||||||
|
|
||||||
static unsigned char table_width_little[128] =
|
|
||||||
{
|
|
||||||
6,6,6,6,6,6,6,6,6,6,6,6,5,6,6,7,
|
|
||||||
6,6,6,6,6,6,3,3,6,6,6,6,6,6,5,5,
|
|
||||||
3,3,5,8,5,11,9,3,4,4,6,6,3,4,3,6,
|
|
||||||
5,5,5,5,5,5,5,5,5,5,3,3,7,6,7,6,
|
|
||||||
9,8,6,7,7,5,5,8,7,2,4,7,5,10,7,8,
|
|
||||||
6,8,7,6,6,6,8,12,7,6,6,3,5,3,6,8,
|
|
||||||
4,6,6,6,6,6,4,6,6,2,3,5,2,10,6,6,
|
|
||||||
6,6,3,5,3,6,6,8,6,6,5,4,6,4,7,0,
|
|
||||||
};
|
|
||||||
|
|
||||||
if ( font == FONTLITTLE )
|
|
||||||
{
|
|
||||||
return table_width_little[GetOffset(c)];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return table_width[GetOffset(c)]-1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Affiche un texte.
|
|
||||||
|
|
||||||
void DrawTextB(CPixmap *pPixmap, POINT pos, char *pText, int font)
|
|
||||||
{
|
|
||||||
int rank;
|
|
||||||
|
|
||||||
if ( font == FONTLITTLE )
|
|
||||||
{
|
|
||||||
while ( *pText != 0 )
|
|
||||||
{
|
|
||||||
rank = GetOffset(*pText);
|
|
||||||
pPixmap->DrawIcon(-1, CHLITTLE, rank, pos);
|
|
||||||
|
|
||||||
pos.x += GetCharWidth(*pText++, font);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while ( *pText != 0 )
|
|
||||||
{
|
|
||||||
rank = GetOffset(*pText);
|
|
||||||
rank += 128*font;
|
|
||||||
pPixmap->DrawIcon(-1, CHTEXT, rank, pos);
|
|
||||||
|
|
||||||
pos.x += GetCharWidth(*pText++, font);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawTextLeft(CPixmap* pPixmap, POINT pos, char *text, int font)
|
|
||||||
{
|
|
||||||
DrawTextB(pPixmap, pos, text, font);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//Implement later
|
|
||||||
|
|
||||||
void DrawChar(CPixmap* pPixmap, POINT* pos, char c, int font)
|
|
||||||
{
|
|
||||||
POINT pos1;
|
|
||||||
int width;
|
|
||||||
UINT index;
|
|
||||||
|
|
||||||
index = (UINT)(BYTE)c;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawCharSingle(CPixmap pPixmap, POINT pos, char* pText, int font)
|
|
||||||
{
|
|
||||||
if (font == FONTLITTLE)
|
|
||||||
{
|
|
||||||
pPixmap.DrawIcon(-1, CHLITTLE, (int)pText, pos, 0, FALSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
pPixmap.DrawIcon(-1, CHTEXT, (int)(pText + font * 128), pos, 0, FALSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Affiche un texte pench<63>.
|
|
||||||
|
|
||||||
void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText,
|
|
||||||
int pente, int font)
|
|
||||||
{
|
|
||||||
int rank, lg, rel, start;
|
|
||||||
|
|
||||||
start = pos.y;
|
|
||||||
rel = 0;
|
|
||||||
while ( *pText != 0 )
|
|
||||||
{
|
|
||||||
rank = GetOffset(*pText);
|
|
||||||
rank += 128*font;
|
|
||||||
pPixmap->DrawIcon(-1, CHTEXT, rank, pos);
|
|
||||||
|
|
||||||
lg = GetCharWidth(*pText++, font);
|
|
||||||
rel += lg;
|
|
||||||
pos.x += lg;
|
|
||||||
pos.y = start + rel/pente;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Affiche un pav<61> de texte.
|
|
||||||
// Une ligne vide est affich<63>e avec un demi interligne !
|
|
||||||
// Si part != -1, n'affiche que les lignes qui commencent
|
|
||||||
// par "n|", avec n=part.
|
|
||||||
|
|
||||||
void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
|
|
||||||
int pente, int font, int part)
|
|
||||||
{
|
|
||||||
char text[100];
|
|
||||||
char* pDest;
|
|
||||||
int itl;
|
|
||||||
|
|
||||||
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
|
|
||||||
else itl = DIMTEXTY;
|
|
||||||
|
|
||||||
while ( *pText != 0 )
|
|
||||||
{
|
|
||||||
pDest = text;
|
|
||||||
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
|
|
||||||
{
|
|
||||||
*pDest++ = *pText++;
|
|
||||||
}
|
|
||||||
*pDest = 0;
|
|
||||||
if ( *pText == '\r' ) pText ++; // saute '\r'
|
|
||||||
if ( *pText == '\n' ) pText ++; // saute '\n'
|
|
||||||
|
|
||||||
pDest = text;
|
|
||||||
if ( text[0] != 0 && text[1] == '|' ) // commence par "n|" ?
|
|
||||||
{
|
|
||||||
if ( part != -1 && part != text[0]-'0' ) continue;
|
|
||||||
pDest += 2; // saute "n|"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( part != -1 ) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pente == 0 )
|
|
||||||
{
|
|
||||||
DrawTextB(pPixmap, pos, pDest, font);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DrawTextPente(pPixmap, pos, pDest, pente, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pDest[0] == 0 ) // ligne vide ?
|
|
||||||
{
|
|
||||||
pos.y += itl/2; // descend de 1/2 ligne
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pos.y += itl; // passe <20> la ligne suivante
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Affiche un texte centr<74> pouvant <20>ventuellement
|
|
||||||
// contenir plusieurs lignes s<>par<61>es par des '\n'.
|
|
||||||
|
|
||||||
void DrawTextCenter(CPixmap *pPixmap, POINT pos, char *pText, int font)
|
|
||||||
{
|
|
||||||
char text[100];
|
|
||||||
char* pDest;
|
|
||||||
int itl;
|
|
||||||
POINT start;
|
|
||||||
|
|
||||||
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
|
|
||||||
else itl = DIMTEXTY;
|
|
||||||
|
|
||||||
while ( *pText != 0 )
|
|
||||||
{
|
|
||||||
pDest = text;
|
|
||||||
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
|
|
||||||
{
|
|
||||||
*pDest++ = *pText++;
|
|
||||||
}
|
|
||||||
*pDest = 0;
|
|
||||||
if ( *pText == '\r' ) pText ++; // saute '\r'
|
|
||||||
if ( *pText == '\n' ) pText ++; // saute '\n'
|
|
||||||
|
|
||||||
pDest = text;
|
|
||||||
start.x = pos.x - GetTextWidth(pDest)/2;
|
|
||||||
start.y = pos.y;
|
|
||||||
DrawTextB(pPixmap, start, pDest, font);
|
|
||||||
|
|
||||||
if ( pDest[0] == 0 ) // ligne vide ?
|
|
||||||
{
|
|
||||||
pos.y += itl/2; // descend de 1/2 ligne
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pos.y += itl; // passe <20> la ligne suivante
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retourne la hauteur d'un texte.
|
|
||||||
|
|
||||||
int GetTextHeight(char *pText, int font, int part)
|
|
||||||
{
|
|
||||||
char text[100];
|
|
||||||
char* pDest;
|
|
||||||
int itl;
|
|
||||||
int h=0;
|
|
||||||
|
|
||||||
if ( font == FONTLITTLE ) itl = DIMLITTLEY;
|
|
||||||
else itl = DIMTEXTY;
|
|
||||||
|
|
||||||
while ( *pText != 0 )
|
|
||||||
{
|
|
||||||
pDest = text;
|
|
||||||
while ( *pText != 0 && *pText != '\r' && *pText != '\n' )
|
|
||||||
{
|
|
||||||
*pDest++ = *pText++;
|
|
||||||
}
|
|
||||||
*pDest = 0;
|
|
||||||
if ( *pText == '\r' ) pText ++; // saute '\r'
|
|
||||||
if ( *pText == '\n' ) pText ++; // saute '\n'
|
|
||||||
|
|
||||||
pDest = text;
|
|
||||||
if ( text[0] != 0 && text[1] == '|' ) // commence par "n|" ?
|
|
||||||
{
|
|
||||||
if ( part != -1 && part != text[0]-'0' ) continue;
|
|
||||||
pDest += 2; // saute "n|"
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( part != -1 ) continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pDest[0] == 0 ) // ligne vide ?
|
|
||||||
{
|
|
||||||
h += itl/2; // descend de 1/2 ligne
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
h += itl; // passe <20> la ligne suivante
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retourne la longueur d'un texte.
|
|
||||||
|
|
||||||
int GetTextWidth(char *pText, int font)
|
|
||||||
{
|
|
||||||
int width = 0;
|
|
||||||
|
|
||||||
while ( *pText != 0 )
|
|
||||||
{
|
|
||||||
width += GetCharWidth(*pText++, font);
|
|
||||||
}
|
|
||||||
|
|
||||||
return width;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
61
text.h
@ -1,61 +0,0 @@
|
|||||||
// Text.h
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define FONTWHITE 0
|
|
||||||
#define FONTRED 1
|
|
||||||
#define FONTSLIM 2
|
|
||||||
#define FONTLITTLE 10
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
char charIcon;
|
|
||||||
char charOffsetX;
|
|
||||||
char charOffsetY;
|
|
||||||
char accentIcon;
|
|
||||||
char accentOffsetX;
|
|
||||||
char accentOffsetY;
|
|
||||||
}
|
|
||||||
CharOffset;
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawTextB(CPixmap *pPixmap, POINT pos, char *pText, int font);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawTextLeft(CPixmap* pPixmap, POINT pos, char *text, int font);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawTextNew(CPixmap *pPixmap, POINT pos, char* pText, int font);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawChar(CPixmap* pPixmap, POINT pos, char* pText, double size);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawCharSingle(CPixmap* pPixmap, POINT pos, int rank, double size);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawTextNew(CPixmap* pPixmap, POINT pos, char* pText, int font);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawTextPente(CPixmap *pPixmap, POINT pos, char *pText,
|
|
||||||
int pente, int font=0);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawTextRect(CPixmap *pPixmap, POINT pos, char *pText,
|
|
||||||
int pente, int font=0, int part=-1);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawTextCenter(CPixmap *pPixmap, POINT pos, char *pText, int font=0);
|
|
||||||
|
|
||||||
extern
|
|
||||||
int GetTextHeight(char *pText, int font=0, int part=-1);
|
|
||||||
|
|
||||||
extern
|
|
||||||
int GetTextWidth(char *pText, int font=0);
|
|
||||||
|
|
||||||
extern
|
|
||||||
void DrawBignum(CPixmap *pPixmap, POINT pos, int num);
|
|
||||||
|
|
||||||
extern
|
|
||||||
int GetBignumWidth(int num);
|
|
||||||
|
|
1673
texttables.h
270
wave.cpp
@ -1,270 +0,0 @@
|
|||||||
|
|
||||||
/*****************************************************************
|
|
||||||
*
|
|
||||||
* Copyright (c) 1996 Microsoft Corporation
|
|
||||||
*
|
|
||||||
* File: wave.cpp
|
|
||||||
* Content: Routines for getting waves from resources
|
|
||||||
* Author: Dave Edson; modified by Peter Donnelly
|
|
||||||
*
|
|
||||||
******************************************************************/
|
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include "wave.h"
|
|
||||||
|
|
||||||
typedef struct tagWAVEFILE
|
|
||||||
{
|
|
||||||
DWORD cbSize; // Size of file
|
|
||||||
LPWAVEFORMATEX pwfxInfo; // Wave Header
|
|
||||||
LPBYTE pbData; // Wave Bits
|
|
||||||
}
|
|
||||||
WAVEFILE, *LPWAVEFILE;
|
|
||||||
|
|
||||||
|
|
||||||
// Function Prototypes
|
|
||||||
BOOL wave_ParseWaveMemory(void *pvRes,
|
|
||||||
WAVEFORMATEX **ppWaveHeader,
|
|
||||||
BYTE **ppbWaveData,
|
|
||||||
DWORD *pcbWaveSize);
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// WAVE_LoadResource: Gets a wave file into the memory pointed
|
|
||||||
// to by pWaveFile from a resource.
|
|
||||||
//
|
|
||||||
/////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
LPVOID WAVE_LoadResource
|
|
||||||
(int ID, // ID of resource
|
|
||||||
HMODULE hModule, // hInst of app with WAVE
|
|
||||||
LPWAVEFILE pWaveFile) // Points to the struct to fill
|
|
||||||
{
|
|
||||||
HRSRC hResInfo;
|
|
||||||
HGLOBAL hResData;
|
|
||||||
void *pvRes;
|
|
||||||
DWORD dwSize;
|
|
||||||
LPVOID lpMemory;
|
|
||||||
|
|
||||||
// Find the resource and load into memory
|
|
||||||
if (((hResInfo = FindResourceA(hModule, MAKEINTRESOURCEA(ID), "WAVE")) != NULL) &&
|
|
||||||
((hResData = LoadResource(hModule, hResInfo)) != NULL) &&
|
|
||||||
((pvRes = LockResource(hResData)) != NULL))
|
|
||||||
{
|
|
||||||
// If we found it, copy the bits from the resource into
|
|
||||||
// our own chunk of memory
|
|
||||||
dwSize = SizeofResource(hModule, hResInfo);
|
|
||||||
lpMemory = malloc (dwSize);
|
|
||||||
memcpy (lpMemory, pvRes, dwSize);
|
|
||||||
UnlockResource(hResData);
|
|
||||||
FreeResource(hResData);
|
|
||||||
|
|
||||||
// Parse it out
|
|
||||||
if (wave_ParseWaveMemory(lpMemory,
|
|
||||||
&(pWaveFile->pwfxInfo),
|
|
||||||
&(pWaveFile->pbData),
|
|
||||||
&(pWaveFile->cbSize)))
|
|
||||||
{
|
|
||||||
return lpMemory; // OK
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// wave_ParseWaveMemory
|
|
||||||
// Parses a chunk of memory into the header and samples.
|
|
||||||
// This is done by looking for the "fmt " and "data"
|
|
||||||
// fields in the memory.
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
BOOL wave_ParseWaveMemory
|
|
||||||
|
|
||||||
(LPVOID lpChunkOfMemory, // Points to raw ram
|
|
||||||
LPWAVEFORMATEX *lplpWaveHeader, // Points to pointer to header
|
|
||||||
LPBYTE *lplpWaveSamples,// Points to pointer to samples
|
|
||||||
LPDWORD lpcbWaveSize) // Points to size
|
|
||||||
{
|
|
||||||
LPDWORD pdw;
|
|
||||||
LPDWORD pdwEnd;
|
|
||||||
DWORD dwRiff;
|
|
||||||
DWORD dwType;
|
|
||||||
DWORD dwLength;
|
|
||||||
|
|
||||||
// Set defaults to NULL or zero
|
|
||||||
if (lplpWaveHeader)
|
|
||||||
*lplpWaveHeader = NULL;
|
|
||||||
|
|
||||||
if (lplpWaveSamples)
|
|
||||||
*lplpWaveSamples = NULL;
|
|
||||||
|
|
||||||
if (lpcbWaveSize)
|
|
||||||
*lpcbWaveSize = 0;
|
|
||||||
|
|
||||||
// Set up DWORD pointers to the start of the chunk
|
|
||||||
// of memory.
|
|
||||||
pdw = (DWORD *)lpChunkOfMemory;
|
|
||||||
|
|
||||||
// Get the type and length of the chunk of memory
|
|
||||||
dwRiff = *pdw++;
|
|
||||||
dwLength = *pdw++;
|
|
||||||
dwType = *pdw++;
|
|
||||||
|
|
||||||
// Using the mmioFOURCC macro (part of Windows SDK), ensure
|
|
||||||
// that this is a RIFF WAVE chunk of memory
|
|
||||||
if (dwRiff != mmioFOURCC('R', 'I', 'F', 'F'))
|
|
||||||
return FALSE; // not even RIFF
|
|
||||||
|
|
||||||
if (dwType != mmioFOURCC('W', 'A', 'V', 'E'))
|
|
||||||
return FALSE; // not a WAV
|
|
||||||
|
|
||||||
// Find the pointer to the end of the chunk of memory
|
|
||||||
pdwEnd = (DWORD *)((BYTE *)pdw + dwLength-4);
|
|
||||||
|
|
||||||
// Run through the bytes looking for the tags
|
|
||||||
while (pdw < pdwEnd)
|
|
||||||
{
|
|
||||||
dwType = *pdw++;
|
|
||||||
dwLength = *pdw++;
|
|
||||||
|
|
||||||
switch (dwType)
|
|
||||||
{
|
|
||||||
// Found the format part
|
|
||||||
case mmioFOURCC('f', 'm', 't', ' '):
|
|
||||||
|
|
||||||
if (lplpWaveHeader && !*lplpWaveHeader)
|
|
||||||
{
|
|
||||||
if (dwLength < sizeof(WAVEFORMAT))
|
|
||||||
return FALSE; // something's wrong! Not a WAV
|
|
||||||
|
|
||||||
// Set the lplpWaveHeader to point to this part of
|
|
||||||
// the memory chunk
|
|
||||||
*lplpWaveHeader = (LPWAVEFORMATEX)pdw;
|
|
||||||
|
|
||||||
// Check to see if the other two items have been
|
|
||||||
// filled out yet (the bits and the size of the
|
|
||||||
// bits). If so, then this chunk of memory has
|
|
||||||
// been parsed out and we can exit
|
|
||||||
if ((!lplpWaveSamples || *lplpWaveSamples) &&
|
|
||||||
(!lpcbWaveSize || *lpcbWaveSize))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Found the samples
|
|
||||||
case mmioFOURCC('d', 'a', 't', 'a'):
|
|
||||||
|
|
||||||
if ((lplpWaveSamples && !*lplpWaveSamples) ||
|
|
||||||
(lpcbWaveSize && !*lpcbWaveSize))
|
|
||||||
{
|
|
||||||
// Point the samples pointer to this part of the
|
|
||||||
// chunk of memory.
|
|
||||||
if (lplpWaveSamples) *lplpWaveSamples = (LPBYTE)pdw;
|
|
||||||
|
|
||||||
// Set the size of the wave
|
|
||||||
if (lpcbWaveSize) *lpcbWaveSize = dwLength;
|
|
||||||
|
|
||||||
// Make sure we have our header pointer set up.
|
|
||||||
// If we do, we can exit
|
|
||||||
if (!lplpWaveHeader || *lplpWaveHeader)
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
} // End case
|
|
||||||
|
|
||||||
// Move the pointer through the chunk of memory
|
|
||||||
pdw = (DWORD *)((BYTE *)pdw + ((dwLength+1)&~1));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Failed! If we made it here, we did not get all the pieces
|
|
||||||
// of the wave
|
|
||||||
return FALSE;
|
|
||||||
} // wave_ParseWaveMemory
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// LoadWave
|
|
||||||
// Gets the sound data and loads it into a DirectSound
|
|
||||||
// secondary buffer.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void LoadWave(HINSTANCE hinst, int ResourceID,
|
|
||||||
LPDIRECTSOUND lpds,
|
|
||||||
LPDIRECTSOUNDBUFFER &lpDSB)
|
|
||||||
{
|
|
||||||
// These variables are used in Steps 1 and 2
|
|
||||||
LPVOID lpWaveData;
|
|
||||||
WAVEFILE WaveFile;
|
|
||||||
DSBUFFERDESC dsbd;
|
|
||||||
|
|
||||||
// These variables are used in step 3, further down below
|
|
||||||
LPVOID pbData = NULL;
|
|
||||||
LPVOID pbData2 = NULL;
|
|
||||||
DWORD dwLength;
|
|
||||||
DWORD dwLength2;
|
|
||||||
|
|
||||||
|
|
||||||
lpWaveData = WAVE_LoadResource (ResourceID, hinst, &WaveFile );
|
|
||||||
|
|
||||||
// Step 1: Set up the direct sound buffer.
|
|
||||||
memset(&dsbd, 0, sizeof(DSBUFFERDESC));
|
|
||||||
|
|
||||||
dsbd.dwSize = sizeof(DSBUFFERDESC);
|
|
||||||
// We want a buffer that lives on the sound card's memory
|
|
||||||
// (DSBCAPS_STATIC) and can have the pan, volume, and
|
|
||||||
// frequency adjusted (DSBCAPS_CTRLDEFAULT)
|
|
||||||
dsbd.dwFlags = DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME | DSBCAPS_STATIC ;
|
|
||||||
|
|
||||||
// Set up the size and format
|
|
||||||
dsbd.dwBufferBytes = WaveFile.cbSize;
|
|
||||||
dsbd.lpwfxFormat = WaveFile.pwfxInfo; // Must be a PCM format!
|
|
||||||
|
|
||||||
// Step 2: Create the buffer
|
|
||||||
if (DS_OK != lpds->CreateSoundBuffer(&dsbd, &lpDSB, NULL))
|
|
||||||
{
|
|
||||||
OutputDebugStringA("Failed to create sound buffer\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Once this code succeeds, lpDSB will point to a DirectSoundBuffer.
|
|
||||||
// At this point, you can copy blocks of sound data into the buffer,
|
|
||||||
// using the Lock and Unlock interfaces on the DirectSoundBuffer:
|
|
||||||
|
|
||||||
// Lock down the DirectSound buffer
|
|
||||||
if (DS_OK == lpDSB->Lock
|
|
||||||
(0, // Offset into buffer to start writing
|
|
||||||
WaveFile.cbSize, // Size of wave file to copy in
|
|
||||||
&pbData, // Points to first block of sound data
|
|
||||||
&dwLength, // Length of first block of data
|
|
||||||
&pbData2, // Points to second block of sound data
|
|
||||||
&dwLength2, // Length of second block of data
|
|
||||||
0L)) // Flags
|
|
||||||
{
|
|
||||||
// Copy first chunk
|
|
||||||
memcpy(pbData, WaveFile.pbData, dwLength);
|
|
||||||
|
|
||||||
// Copy second chunk
|
|
||||||
if (dwLength2)
|
|
||||||
memcpy(pbData2, WaveFile.pbData+dwLength , dwLength2);
|
|
||||||
|
|
||||||
// Free up the memory allocated in the WAVE_LoadFile function, since we
|
|
||||||
// have copied it to the buffer
|
|
||||||
free (lpWaveData);
|
|
||||||
|
|
||||||
// Unlock the buffer
|
|
||||||
if (DS_OK != lpDSB->Unlock(pbData, dwLength, pbData2, dwLength2))
|
|
||||||
OutputDebugStringA("Unlock failed");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OutputDebugStringA("Lock failed");
|
|
||||||
}
|
|
||||||
} // LoadWave
|
|