mirror of
https://github.com/1dot13/source.git
synced 2026-07-22 13:40:22 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
133f346cdb | ||
|
|
f46e3f1004 | ||
|
|
bba7528c76 | ||
|
|
eed4156d48 | ||
|
|
23bf32e4ad | ||
|
|
3bfebf6c8d |
@@ -1442,7 +1442,6 @@ UINT32 InitializeJA2(void)
|
|||||||
HandleLaserLockResult( PrepareLaserLockSystem() );
|
HandleLaserLockResult( PrepareLaserLockSystem() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HandleJA2CDCheck( );
|
|
||||||
|
|
||||||
gfWorldLoaded = FALSE;
|
gfWorldLoaded = FALSE;
|
||||||
|
|
||||||
@@ -1472,9 +1471,6 @@ UINT32 InitializeJA2(void)
|
|||||||
//gsRenderCenterX = 805;
|
//gsRenderCenterX = 805;
|
||||||
//gsRenderCenterY = 805;
|
//gsRenderCenterY = 805;
|
||||||
|
|
||||||
// Init data
|
|
||||||
InitializeSystemVideoObjects( );
|
|
||||||
|
|
||||||
// Init animation system
|
// Init animation system
|
||||||
if ( !InitAnimationSystem( ) )
|
if ( !InitAnimationSystem( ) )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -670,13 +670,6 @@ void AddCustomEmail(INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender,
|
|||||||
// add message to list
|
// add message to list
|
||||||
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_E_NONE );
|
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_E_NONE );
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
|
|
||||||
if( fCurrentlyInLaptop )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//--
|
//--
|
||||||
@@ -721,14 +714,6 @@ void AddEmailWithSpecialData(INT32 iMessageOffset, INT32 iMessageLength, UINT8 u
|
|||||||
// add message to list
|
// add message to list
|
||||||
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, iFirstData, uiSecondData, -1 , -1, EmailType, EmailAIM );
|
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, iFirstData, uiSecondData, -1 , -1, EmailType, EmailAIM );
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
|
|
||||||
if( fCurrentlyInLaptop == TRUE )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -761,14 +746,6 @@ void AddEmailWithSpecialDataXML(INT32 iMessageOffset, INT32 iMessageLength, UINT
|
|||||||
// add message to list
|
// add message to list
|
||||||
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, iFirstData, uiSecondData, -1 , -1, EmailType, EmailAIM);
|
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, iFirstData, uiSecondData, -1 , -1, EmailType, EmailAIM);
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
|
|
||||||
if( fCurrentlyInLaptop == TRUE )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,13 +769,6 @@ void AddPreReadEmailTypeXML( INT32 iMessageOffset, INT32 iMessageLength, UINT8 u
|
|||||||
// add message to list
|
// add message to list
|
||||||
AddEmailMessage( iMessageOffset,iMessageLength, pSubject, iDate, ubSender, TRUE, 0, 0, -1, -1 , EmailType, TYPE_E_NONE );
|
AddEmailMessage( iMessageOffset,iMessageLength, pSubject, iDate, ubSender, TRUE, 0, 0, -1, -1 , EmailType, TYPE_E_NONE );
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
|
|
||||||
if( fCurrentlyInLaptop )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddEmailTypeXML( INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender, INT32 iDate, INT32 iCurrentIMPPosition, UINT8 EmailType )
|
void AddEmailTypeXML( INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender, INT32 iDate, INT32 iCurrentIMPPosition, UINT8 EmailType )
|
||||||
@@ -830,13 +800,6 @@ void AddEmailTypeXML( INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender
|
|||||||
}
|
}
|
||||||
|
|
||||||
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, -1, EmailType, TYPE_E_NONE);
|
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, -1, EmailType, TYPE_E_NONE);
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
if( fCurrentlyInLaptop )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef JA2UB
|
#ifdef JA2UB
|
||||||
@@ -853,14 +816,6 @@ void AddBobbyREmailJA2(INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSende
|
|||||||
// add message to list
|
// add message to list
|
||||||
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_EMAIL_BOBBY_R_L1);
|
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_EMAIL_BOBBY_R_L1);
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
|
|
||||||
if( fCurrentlyInLaptop == TRUE )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -884,14 +839,6 @@ void AddEmailWFMercAvailable(INT32 iMessageOffset, INT32 iMessageLength, UINT8 u
|
|||||||
|
|
||||||
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, -1 , EmailType, TYPE_E_NONE);
|
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, -1 , EmailType, TYPE_E_NONE);
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
|
|
||||||
if( fCurrentlyInLaptop == TRUE )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -931,14 +878,6 @@ void AddEmail(INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender, INT32
|
|||||||
// add message to list
|
// add message to list
|
||||||
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_E_NONE);
|
AddEmailMessage(iMessageOffset,iMessageLength, pSubject, iDate, ubSender, FALSE, 0, 0, iCurrentIMPPosition, iCurrentShipmentDestinationID, EmailType, TYPE_E_NONE);
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
|
|
||||||
if( fCurrentlyInLaptop == TRUE )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -968,13 +907,6 @@ void AddPreReadEmail(INT32 iMessageOffset, INT32 iMessageLength, UINT8 ubSender,
|
|||||||
// add message to list
|
// add message to list
|
||||||
AddEmailMessage( iMessageOffset,iMessageLength, pSubject, iDate, ubSender, TRUE, 0, 0, -1, -1 , EmailType, TYPE_E_NONE );
|
AddEmailMessage( iMessageOffset,iMessageLength, pSubject, iDate, ubSender, TRUE, 0, 0, -1, -1 , EmailType, TYPE_E_NONE );
|
||||||
|
|
||||||
// if we are in fact int he laptop, redraw icons, might be change in mail status
|
|
||||||
|
|
||||||
if( fCurrentlyInLaptop == TRUE )
|
|
||||||
{
|
|
||||||
// redraw icons, might be new mail
|
|
||||||
DrawLapTopIcons();
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1956,9 +1888,6 @@ void BtnMessageXCallback(GUI_BUTTON *btn,INT32 reason)
|
|||||||
// reset page being displayed
|
// reset page being displayed
|
||||||
giMessagePage = 0;
|
giMessagePage = 0;
|
||||||
|
|
||||||
// redraw icons
|
|
||||||
DrawLapTopIcons();
|
|
||||||
|
|
||||||
// force update of entire screen
|
// force update of entire screen
|
||||||
fPausedReDrawScreenFlag=TRUE;
|
fPausedReDrawScreenFlag=TRUE;
|
||||||
|
|
||||||
@@ -2421,7 +2350,6 @@ BOOLEAN DisplayNewMailBox( void )
|
|||||||
|
|
||||||
// printf warning string
|
// printf warning string
|
||||||
mprintf(EMAIL_WARNING_X + 60, EMAIL_WARNING_Y + 63, pNewMailStrings[0] );
|
mprintf(EMAIL_WARNING_X + 60, EMAIL_WARNING_Y + 63, pNewMailStrings[0] );
|
||||||
DrawLapTopIcons( );
|
|
||||||
|
|
||||||
// invalidate region
|
// invalidate region
|
||||||
InvalidateRegion( EMAIL_WARNING_X, EMAIL_WARNING_Y, EMAIL_WARNING_X + 270, EMAIL_WARNING_Y + 200 );
|
InvalidateRegion( EMAIL_WARNING_X, EMAIL_WARNING_Y, EMAIL_WARNING_X + 270, EMAIL_WARNING_Y + 200 );
|
||||||
@@ -2883,9 +2811,6 @@ void DeleteEmail()
|
|||||||
// upadte list
|
// upadte list
|
||||||
PlaceMessagesinPages();
|
PlaceMessagesinPages();
|
||||||
|
|
||||||
// redraw icons (if deleted message was last unread, remove checkmark)
|
|
||||||
DrawLapTopIcons();
|
|
||||||
|
|
||||||
// if all of a sudden we are beyond last page, move back one
|
// if all of a sudden we are beyond last page, move back one
|
||||||
if(iCurrentPage > iLastPage)
|
if(iCurrentPage > iLastPage)
|
||||||
iCurrentPage=iLastPage;
|
iCurrentPage=iLastPage;
|
||||||
@@ -3037,9 +2962,6 @@ void ViewMessageRegionCallBack( MOUSE_REGION * pRegion, INT32 iReason )
|
|||||||
// reset page being displayed
|
// reset page being displayed
|
||||||
giMessagePage = 0;
|
giMessagePage = 0;
|
||||||
|
|
||||||
// redraw icons
|
|
||||||
DrawLapTopIcons();
|
|
||||||
|
|
||||||
// force update of entire screen
|
// force update of entire screen
|
||||||
fPausedReDrawScreenFlag=TRUE;
|
fPausedReDrawScreenFlag=TRUE;
|
||||||
|
|
||||||
|
|||||||
@@ -837,13 +837,6 @@ BOOLEAN InitLaptopAndLaptopScreens()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
UINT32
|
|
||||||
DrawLapTopIcons()
|
|
||||||
{
|
|
||||||
|
|
||||||
return (TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
UINT32
|
UINT32
|
||||||
DrawLapTopText()
|
DrawLapTopText()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ void ExitLaptop();
|
|||||||
void RenderLaptop();
|
void RenderLaptop();
|
||||||
UINT32 ExitLaptopMode(UINT32 uiMode);
|
UINT32 ExitLaptopMode(UINT32 uiMode);
|
||||||
void EnterNewLaptopMode();
|
void EnterNewLaptopMode();
|
||||||
UINT32 DrawLapTopIcons();
|
|
||||||
UINT32 DrawLapTopText();
|
UINT32 DrawLapTopText();
|
||||||
void ReDrawHighLight();
|
void ReDrawHighLight();
|
||||||
void DrawButtonText();
|
void DrawButtonText();
|
||||||
@@ -26,7 +25,6 @@ BOOLEAN IsBookMarkSet( INT32 iBookId );
|
|||||||
BOOLEAN LeaveLapTopScreen( );
|
BOOLEAN LeaveLapTopScreen( );
|
||||||
void SetLaptopExitScreen( UINT32 uiExitScreen );
|
void SetLaptopExitScreen( UINT32 uiExitScreen );
|
||||||
void SetLaptopNewGameFlag( );
|
void SetLaptopNewGameFlag( );
|
||||||
UINT32 DrawLapTopIcons( );
|
|
||||||
void LapTopScreenCallBack(MOUSE_REGION * pRegion, INT32 iReason );
|
void LapTopScreenCallBack(MOUSE_REGION * pRegion, INT32 iReason );
|
||||||
void HandleRightButtonUpEvent( void );
|
void HandleRightButtonUpEvent( void );
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,6 @@ UINT32 guiEXTRABUFFER = 0;
|
|||||||
|
|
||||||
BOOLEAN gfExtraBuffer = FALSE;
|
BOOLEAN gfExtraBuffer = FALSE;
|
||||||
|
|
||||||
BOOLEAN InitializeSystemVideoObjects( )
|
|
||||||
{
|
|
||||||
|
|
||||||
return( TRUE );
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN InitializeGameVideoObjects( )
|
BOOLEAN InitializeGameVideoObjects( )
|
||||||
{
|
{
|
||||||
VSURFACE_DESC vs_desc;
|
VSURFACE_DESC vs_desc;
|
||||||
|
|||||||
@@ -14,8 +14,7 @@ extern UINT32 guiEXTRABUFFER;
|
|||||||
|
|
||||||
extern BOOLEAN gfExtraBuffer;
|
extern BOOLEAN gfExtraBuffer;
|
||||||
|
|
||||||
BOOLEAN InitializeSystemVideoObjects( );
|
|
||||||
BOOLEAN InitializeGameVideoObjects( );
|
BOOLEAN InitializeGameVideoObjects( );
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ set(UtilsSrc
|
|||||||
"${CMAKE_CURRENT_SOURCE_DIR}/Cinematics.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/Cinematics.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/Cursors.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/Cursors.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/Debug Control.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/Debug Control.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/dsutil.cpp"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/Encrypted File.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/Encrypted File.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/Event Pump.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/Event Pump.cpp"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/ExportStrings.cpp"
|
"${CMAKE_CURRENT_SOURCE_DIR}/ExportStrings.cpp"
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ extern BOOLEAN GetCDromDriveLetter( STR8 pString );
|
|||||||
|
|
||||||
#define DATA_8_BIT_DIR "8-Bit\\"
|
#define DATA_8_BIT_DIR "8-Bit\\"
|
||||||
|
|
||||||
BOOLEAN PerformTimeLimitedCheck();
|
|
||||||
|
|
||||||
// WANNE: Given a string, replaces all instances of "oldpiece" with "newpiece"
|
// WANNE: Given a string, replaces all instances of "oldpiece" with "newpiece"
|
||||||
/*
|
/*
|
||||||
@@ -295,64 +294,6 @@ BOOLEAN IfWin95(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void HandleLimitedNumExecutions( )
|
|
||||||
{
|
|
||||||
// Get system directory
|
|
||||||
HWFILE hFileHandle;
|
|
||||||
CHAR8 ubSysDir[ 512 ];
|
|
||||||
INT8 bNumRuns;
|
|
||||||
|
|
||||||
GetSystemDirectory( (LPSTR) ubSysDir, sizeof( ubSysDir ) );
|
|
||||||
|
|
||||||
// Append filename
|
|
||||||
strcat( ubSysDir, "\\winaese.dll" );
|
|
||||||
|
|
||||||
// Open file and check # runs...
|
|
||||||
if ( FileExists( (STR)ubSysDir ) )
|
|
||||||
{
|
|
||||||
// Open and read
|
|
||||||
if ( ( hFileHandle = FileOpen( (STR)ubSysDir, FILE_ACCESS_READ, FALSE)) == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read value
|
|
||||||
FileRead( hFileHandle, &bNumRuns, sizeof( bNumRuns ) , NULL);
|
|
||||||
|
|
||||||
// Close file
|
|
||||||
FileClose( hFileHandle );
|
|
||||||
|
|
||||||
if ( bNumRuns <= 0 )
|
|
||||||
{
|
|
||||||
// Fail!
|
|
||||||
SET_ERROR( "Error 1054: Cannot execute - contact Sir-Tech Software." );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bNumRuns = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
// OK, decrement # runs...
|
|
||||||
bNumRuns--;
|
|
||||||
|
|
||||||
// Open and write
|
|
||||||
if ( ( hFileHandle = FileOpen( (STR)ubSysDir, FILE_ACCESS_WRITE, FALSE)) == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write value
|
|
||||||
FileWrite( hFileHandle, &bNumRuns, sizeof( bNumRuns ) , NULL);
|
|
||||||
|
|
||||||
// Close file
|
|
||||||
FileClose( hFileHandle );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
SGPFILENAME gCheckFilenames[] =
|
SGPFILENAME gCheckFilenames[] =
|
||||||
{
|
{
|
||||||
"DATA\\INTRO.SLF",
|
"DATA\\INTRO.SLF",
|
||||||
@@ -371,65 +312,7 @@ UINT32 gCheckFileMinSizes[] =
|
|||||||
187000000,
|
187000000,
|
||||||
236000000
|
236000000
|
||||||
};
|
};
|
||||||
#define NOCDCHECK
|
|
||||||
|
|
||||||
#if defined( JA2TESTVERSION ) || defined( _DEBUG )
|
|
||||||
#define NOCDCHECK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined( RUSSIANGOLD )
|
|
||||||
// CD check enabled
|
|
||||||
#else
|
|
||||||
#define NOCDCHECK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOLEAN HandleJA2CDCheck( )
|
|
||||||
{
|
|
||||||
#ifdef TIME_LIMITED_VERSION
|
|
||||||
if( !PerformTimeLimitedCheck() )
|
|
||||||
{
|
|
||||||
return( FALSE );
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return( TRUE );
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN HandleJA2CDCheckTwo( )
|
|
||||||
{
|
|
||||||
|
|
||||||
return( TRUE );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN PerformTimeLimitedCheck()
|
|
||||||
{
|
|
||||||
#ifndef TIME_LIMITED_VERSION
|
|
||||||
return( TRUE );
|
|
||||||
|
|
||||||
#else
|
|
||||||
SYSTEMTIME sSystemTime;
|
|
||||||
|
|
||||||
GetSystemTime( &sSystemTime );
|
|
||||||
|
|
||||||
|
|
||||||
//if according to the system clock, we are past july 1999, quit the game
|
|
||||||
if( sSystemTime.wYear > 1999 || sSystemTime.wMonth > 7 )
|
|
||||||
{
|
|
||||||
//spit out an error message
|
|
||||||
MessageBox( NULL, "This time limited version of Jagged Alliance 2 v1.13 has expired.", "Ja2 Error!", MB_OK );
|
|
||||||
return( FALSE );
|
|
||||||
}
|
|
||||||
|
|
||||||
return( TRUE );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN DoJA2FilesExistsOnDrive( CHAR8 *zCdLocation )
|
BOOLEAN DoJA2FilesExistsOnDrive( CHAR8 *zCdLocation )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ BOOLEAN WrapString( STR16 pStr, STR16 pStr2, UINT16 usWidth, INT32 uiFont );
|
|||||||
BOOLEAN IfWinNT(void);
|
BOOLEAN IfWinNT(void);
|
||||||
BOOLEAN IfWin95(void);
|
BOOLEAN IfWin95(void);
|
||||||
|
|
||||||
void HandleLimitedNumExecutions( );
|
|
||||||
|
|
||||||
BOOLEAN HandleJA2CDCheck( );
|
|
||||||
BOOLEAN HandleJA2CDCheckTwo( );
|
|
||||||
|
|
||||||
// WANNE: This method replaces characters in a given text with new characters
|
// WANNE: This method replaces characters in a given text with new characters
|
||||||
STR8 Replace(STR8 string, STR8 oldpiece, STR8 newpiece);
|
STR8 Replace(STR8 string, STR8 oldpiece, STR8 newpiece);
|
||||||
|
|||||||
@@ -1,344 +0,0 @@
|
|||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
#include <windows.h>
|
|
||||||
#include <windowsx.h>
|
|
||||||
#include <mmsystem.h>
|
|
||||||
#include <dsound.h>
|
|
||||||
#include "dsutil.h"
|
|
||||||
#include "debug.h"
|
|
||||||
|
|
||||||
#include "sgp.h"
|
|
||||||
|
|
||||||
#include "Sound Control.h"
|
|
||||||
|
|
||||||
// THIS MODULE IS TEMPORARY - USED FOR OUR SOUND SYSTEM INTIL IT IS IMPLEMENTED FOR THE SGP
|
|
||||||
extern HWND ghWindow;
|
|
||||||
typedef UINT32 EFFECT;
|
|
||||||
|
|
||||||
BOOL DSEnable( HWND hwnd );
|
|
||||||
BOOL DSDisable( void );
|
|
||||||
BOOL SoundLoadEffect( EFFECT sfx );
|
|
||||||
BOOL SoundDestroyEffect( EFFECT sfx );
|
|
||||||
BOOL InitSound( HWND hwndOwner );
|
|
||||||
BOOL SoundPlayEffect( EFFECT sfx );
|
|
||||||
|
|
||||||
|
|
||||||
void EnableQuickSound( )
|
|
||||||
{
|
|
||||||
DSEnable( ghWindow );
|
|
||||||
InitSound( ghWindow );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DisableQuickSound( )
|
|
||||||
{
|
|
||||||
DSDisable( );
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlayQuickSound( INT16 sSound )
|
|
||||||
{
|
|
||||||
SoundPlayEffect( (EFFECT)sSound );
|
|
||||||
}
|
|
||||||
|
|
||||||
#define NUM_SOUND_EFFECTS NUM_SAMPLES
|
|
||||||
|
|
||||||
LPDIRECTSOUND lpDS = NULL;
|
|
||||||
LPDIRECTSOUNDBUFFER lpSoundEffects[NUM_SOUND_EFFECTS];
|
|
||||||
|
|
||||||
|
|
||||||
extern char szSoundEffects[MAX_SAMPLES][255];
|
|
||||||
//char szSoundEffects[NUM_SOUND_EFFECTS][255] =
|
|
||||||
//char szSoundEffects[MAX_SAMPLES][255] =
|
|
||||||
//{
|
|
||||||
// "SHOOT1",
|
|
||||||
// "MISS1",
|
|
||||||
// "FALL1",
|
|
||||||
// "HIT1",
|
|
||||||
// "HIT2",
|
|
||||||
// "DOOROPEN1",
|
|
||||||
// "DOORCLOSE1",
|
|
||||||
// "BURST1",
|
|
||||||
// "ENDTURN"
|
|
||||||
//};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DSEnable
|
|
||||||
*
|
|
||||||
* Figures out whether or not to use DirectSound, based on an entry
|
|
||||||
* in WIN.INI. Sets a module-level flag and goes about creating the
|
|
||||||
* DirectSound object if necessary. Returns TRUE if successful.
|
|
||||||
*/
|
|
||||||
BOOL DSEnable( HWND hwnd )
|
|
||||||
{
|
|
||||||
HRESULT dsrval;
|
|
||||||
//BOOL bUseDSound;
|
|
||||||
|
|
||||||
if (lpDS != NULL)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
dsrval = DirectSoundCreate(NULL, &lpDS, NULL);
|
|
||||||
|
|
||||||
switch( dsrval )
|
|
||||||
{
|
|
||||||
case DSERR_ALLOCATED:
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DSERR_NOAGGREGATION:
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DSERR_OUTOFMEMORY:
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DSERR_INVALIDPARAM:
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case DSERR_NODRIVER:
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dsrval != DS_OK)
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
dsrval = IDirectSound_SetCooperativeLevel(lpDS, hwnd, DSSCL_NORMAL);
|
|
||||||
|
|
||||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "Sound INIT OK");
|
|
||||||
|
|
||||||
if (dsrval != DS_OK)
|
|
||||||
{
|
|
||||||
DSDisable();
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
} /* DSEnable */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DSDisable
|
|
||||||
*
|
|
||||||
* Turn off DirectSound
|
|
||||||
*/
|
|
||||||
BOOL DSDisable( void )
|
|
||||||
{
|
|
||||||
if (lpDS == NULL)
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
IDirectSound_Release(lpDS);
|
|
||||||
lpDS = NULL;
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
} /* DSDisable */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* InitSound
|
|
||||||
*
|
|
||||||
* Sets up the DirectSound object and loads all sounds into secondary
|
|
||||||
* DirectSound buffers. Returns FALSE on error, or TRUE if successful
|
|
||||||
*/
|
|
||||||
BOOL InitSound( HWND hwndOwner )
|
|
||||||
{
|
|
||||||
int idx;
|
|
||||||
DSBUFFERDESC dsBD;
|
|
||||||
IDirectSoundBuffer *lpPrimary;
|
|
||||||
|
|
||||||
DSEnable(hwndOwner);
|
|
||||||
|
|
||||||
if (lpDS == NULL)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Load all sounds -- any that can't load for some reason will have NULL
|
|
||||||
* pointers instead of valid SOUNDEFFECT data, and we will know not to
|
|
||||||
* play them later on.
|
|
||||||
*/
|
|
||||||
for( idx = 0; idx < NUM_SOUND_EFFECTS; idx++ )
|
|
||||||
{
|
|
||||||
if (SoundLoadEffect((EFFECT)idx))
|
|
||||||
{
|
|
||||||
DSBCAPS caps;
|
|
||||||
|
|
||||||
caps.dwSize = sizeof(caps);
|
|
||||||
IDirectSoundBuffer_GetCaps(lpSoundEffects[idx], &caps);
|
|
||||||
|
|
||||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("_______SOUND(%d) OK", idx));
|
|
||||||
|
|
||||||
//if (caps.dwFlags & DSBCAPS_LOCHARDWARE)
|
|
||||||
//Msg( "Sound effect %s in hardware", szSoundEffects[idx]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("_______SOUND(%d) BAD", idx));
|
|
||||||
|
|
||||||
//Msg( "cant load sound effect %s", szSoundEffects[idx]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* get the primary buffer and start it playing
|
|
||||||
*
|
|
||||||
* by playing the primary buffer, DirectSound knows to keep the
|
|
||||||
* mixer active, even though we are not making any noise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ZeroMemory( &dsBD, sizeof(DSBUFFERDESC) );
|
|
||||||
dsBD.dwSize = sizeof(dsBD);
|
|
||||||
dsBD.dwFlags = DSBCAPS_PRIMARYBUFFER;
|
|
||||||
|
|
||||||
if (SUCCEEDED(IDirectSound_CreateSoundBuffer(lpDS, &dsBD, &lpPrimary, NULL)))
|
|
||||||
{
|
|
||||||
if (!SUCCEEDED(IDirectSoundBuffer_Play(lpPrimary, 0, 0, DSBPLAY_LOOPING)))
|
|
||||||
{
|
|
||||||
//Msg("Unable to play Primary sound buffer");
|
|
||||||
}
|
|
||||||
|
|
||||||
IDirectSoundBuffer_Release(lpPrimary);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//Msg("Unable to create Primary sound buffer");
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
} /* InitSound */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* DestroySound
|
|
||||||
*
|
|
||||||
* Undoes everything that was done in a InitSound call
|
|
||||||
*/
|
|
||||||
BOOL DestroySound( void )
|
|
||||||
{
|
|
||||||
DWORD idxKill;
|
|
||||||
|
|
||||||
for( idxKill = 0; idxKill < NUM_SOUND_EFFECTS; idxKill++ )
|
|
||||||
{
|
|
||||||
SoundDestroyEffect( (EFFECT)idxKill );
|
|
||||||
}
|
|
||||||
|
|
||||||
DSDisable();
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
} /* DestroySound */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SoundDestroyEffect
|
|
||||||
*
|
|
||||||
* Frees up resources associated with a sound effect
|
|
||||||
*/
|
|
||||||
BOOL SoundDestroyEffect( EFFECT sfx )
|
|
||||||
{
|
|
||||||
if(lpSoundEffects[sfx])
|
|
||||||
{
|
|
||||||
IDirectSoundBuffer_Release(lpSoundEffects[sfx]);
|
|
||||||
lpSoundEffects[sfx] = NULL;
|
|
||||||
}
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
} /* SoundDestryEffect */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SoundLoadEffect
|
|
||||||
*
|
|
||||||
* Initializes a sound effect by loading the WAV file from a resource
|
|
||||||
*/
|
|
||||||
BOOL SoundLoadEffect( EFFECT sfx )
|
|
||||||
{
|
|
||||||
if (lpDS && lpSoundEffects[sfx] == NULL && *szSoundEffects[sfx])
|
|
||||||
{
|
|
||||||
//
|
|
||||||
// use DSLoadSoundBuffer (in ..\misc\dsutil.c) to load
|
|
||||||
// a sound from a resource.
|
|
||||||
//
|
|
||||||
lpSoundEffects[sfx] = DSLoadSoundBuffer(lpDS, szSoundEffects[sfx]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return lpSoundEffects[sfx] != NULL;
|
|
||||||
|
|
||||||
} /* SoundLoadEffect */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SoundPlayEffect
|
|
||||||
*
|
|
||||||
* Plays the sound effect specified.
|
|
||||||
* Returns TRUE if succeeded.
|
|
||||||
*/
|
|
||||||
BOOL SoundPlayEffect( EFFECT sfx )
|
|
||||||
{
|
|
||||||
HRESULT dsrval;
|
|
||||||
IDirectSoundBuffer *pdsb = lpSoundEffects[sfx];
|
|
||||||
|
|
||||||
if( !lpDS || !pdsb )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Rewind the play cursor to the start of the effect, and play
|
|
||||||
*/
|
|
||||||
IDirectSoundBuffer_SetCurrentPosition(pdsb, 0);
|
|
||||||
dsrval = IDirectSoundBuffer_Play(pdsb, 0, 0, 0);
|
|
||||||
|
|
||||||
if( dsrval == DS_OK )
|
|
||||||
|
|
||||||
if (dsrval == DSERR_BUFFERLOST)
|
|
||||||
{
|
|
||||||
//Msg("** %s needs restored", szSoundEffects[sfx]);
|
|
||||||
|
|
||||||
dsrval = IDirectSoundBuffer_Restore(pdsb);
|
|
||||||
|
|
||||||
if (dsrval == DS_OK)
|
|
||||||
{
|
|
||||||
if (DSReloadSoundBuffer(pdsb, szSoundEffects[sfx]))
|
|
||||||
{
|
|
||||||
//Msg("** %s has been restored", szSoundEffects[sfx]);
|
|
||||||
IDirectSoundBuffer_SetCurrentPosition(pdsb, 0);
|
|
||||||
dsrval = IDirectSoundBuffer_Play(pdsb, 0, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dsrval = E_FAIL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (dsrval == DS_OK);
|
|
||||||
|
|
||||||
} /* SoundPlayEffect */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* SoundStopEffect
|
|
||||||
*
|
|
||||||
* Stops the sound effect specified.
|
|
||||||
* Returns TRUE if succeeded.
|
|
||||||
*/
|
|
||||||
BOOL SoundStopEffect( EFFECT sfx )
|
|
||||||
{
|
|
||||||
HRESULT dsrval;
|
|
||||||
|
|
||||||
if( !lpDS || !lpSoundEffects[sfx] )
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
dsrval = IDirectSoundBuffer_Stop(lpSoundEffects[sfx]);
|
|
||||||
|
|
||||||
return SUCCEEDED(dsrval);
|
|
||||||
|
|
||||||
} /* SoundStopEffect */
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef __WIN_UTIL_H
|
|
||||||
#define __WIN_UTIL_H
|
|
||||||
|
|
||||||
|
|
||||||
void SetThreadToHighestPriority( );
|
|
||||||
|
|
||||||
void EnableQuickSound( );
|
|
||||||
void DisableQuickSound( );
|
|
||||||
void PlayQuickSound( INT16 sSound );
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
@@ -1,372 +0,0 @@
|
|||||||
// THIS MODULE IS TEMPORARY - USED FOR OUR SOUND SYSTEM INTIL IT IS IMPLEMENTED FOR THE SGP
|
|
||||||
// TAKEN FROM MS SAMPLES FOR DirectSound
|
|
||||||
|
|
||||||
#include "types.h"
|
|
||||||
#include <windows.h>
|
|
||||||
#include <mmsystem.h>
|
|
||||||
#include <dsound.h>
|
|
||||||
|
|
||||||
#define WIN32_LEAN_AND_MEAN
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
BYTE *pbWaveData; // pointer into wave resource (for restore)
|
|
||||||
DWORD cbWaveSize; // size of wave data (for restore)
|
|
||||||
int iAlloc; // number of buffers.
|
|
||||||
int iCurrent; // current buffer
|
|
||||||
IDirectSoundBuffer* Buffers[1]; // list of buffers
|
|
||||||
|
|
||||||
} SNDOBJ, *HSNDOBJ;
|
|
||||||
|
|
||||||
#define _HSNDOBJ_DEFINED
|
|
||||||
#include "dsutil.h"
|
|
||||||
|
|
||||||
static const char c_szWAV[] = "WAVE";
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// DSLoadSoundBuffer
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
IDirectSoundBuffer *DSLoadSoundBuffer(IDirectSound *pDS, LPCTSTR lpName)
|
|
||||||
{
|
|
||||||
IDirectSoundBuffer *pDSB = NULL;
|
|
||||||
DSBUFFERDESC dsBD = {0};
|
|
||||||
BYTE *pbWaveData;
|
|
||||||
|
|
||||||
if (DSGetWaveResource(NULL, lpName, &dsBD.lpwfxFormat, &pbWaveData, &dsBD.dwBufferBytes))
|
|
||||||
{
|
|
||||||
dsBD.dwSize = sizeof(dsBD);
|
|
||||||
dsBD.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRLDEFAULT; // | DSBCAPS_GETCURRENTPOSITION2;
|
|
||||||
|
|
||||||
if (SUCCEEDED(IDirectSound_CreateSoundBuffer(pDS, &dsBD, &pDSB, NULL)))
|
|
||||||
{
|
|
||||||
if (!DSFillSoundBuffer(pDSB, pbWaveData, dsBD.dwBufferBytes))
|
|
||||||
{
|
|
||||||
IDirectSoundBuffer_Release(pDSB);
|
|
||||||
pDSB = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pDSB = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pDSB;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// DSReloadSoundBuffer
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
BOOL DSReloadSoundBuffer(IDirectSoundBuffer *pDSB, LPCTSTR lpName)
|
|
||||||
{
|
|
||||||
BOOL result=FALSE;
|
|
||||||
BYTE *pbWaveData;
|
|
||||||
DWORD cbWaveSize;
|
|
||||||
|
|
||||||
if (DSGetWaveResource(NULL, lpName, NULL, &pbWaveData, &cbWaveSize))
|
|
||||||
{
|
|
||||||
if (SUCCEEDED(IDirectSoundBuffer_Restore(pDSB)) &&
|
|
||||||
DSFillSoundBuffer(pDSB, pbWaveData, cbWaveSize))
|
|
||||||
{
|
|
||||||
result = TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// DSGetWaveResource
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
BOOL DSGetWaveResource(HMODULE hModule, LPCTSTR lpName,
|
|
||||||
WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pcbWaveSize)
|
|
||||||
{
|
|
||||||
HRSRC hResInfo;
|
|
||||||
HGLOBAL hResData;
|
|
||||||
void *pvRes;
|
|
||||||
|
|
||||||
if (((hResInfo = FindResource(hModule, lpName, c_szWAV)) != NULL) &&
|
|
||||||
((hResData = LoadResource(hModule, hResInfo)) != NULL) &&
|
|
||||||
((pvRes = LockResource(hResData)) != NULL) &&
|
|
||||||
DSParseWaveResource(pvRes, ppWaveHeader, ppbWaveData, pcbWaveSize))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
// SndObj fns
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
SNDOBJ *SndObjCreate(IDirectSound *pDS, LPCTSTR lpName, int iConcurrent)
|
|
||||||
{
|
|
||||||
SNDOBJ *pSO = NULL;
|
|
||||||
LPWAVEFORMATEX pWaveHeader;
|
|
||||||
BYTE *pbData;
|
|
||||||
UINT cbData;
|
|
||||||
|
|
||||||
if (DSGetWaveResource(NULL, lpName, &pWaveHeader, &pbData, (DWORD *)&cbData))
|
|
||||||
{
|
|
||||||
if (iConcurrent < 1)
|
|
||||||
iConcurrent = 1;
|
|
||||||
|
|
||||||
if ((pSO = (SNDOBJ *)LocalAlloc(LPTR, sizeof(SNDOBJ) +
|
|
||||||
(iConcurrent-1) * sizeof(IDirectSoundBuffer *))) != NULL)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
pSO->iAlloc = iConcurrent;
|
|
||||||
pSO->pbWaveData = pbData;
|
|
||||||
pSO->cbWaveSize = cbData;
|
|
||||||
pSO->Buffers[0] = DSLoadSoundBuffer(pDS, lpName);
|
|
||||||
|
|
||||||
for (i=1; i<pSO->iAlloc; i++)
|
|
||||||
{
|
|
||||||
if (FAILED(IDirectSound_DuplicateSoundBuffer(pDS,
|
|
||||||
pSO->Buffers[0], &pSO->Buffers[i])))
|
|
||||||
{
|
|
||||||
pSO->Buffers[i] = DSLoadSoundBuffer(pDS, lpName);
|
|
||||||
if (!pSO->Buffers[i]) {
|
|
||||||
SndObjDestroy(pSO);
|
|
||||||
pSO = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pSO;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void SndObjDestroy(SNDOBJ *pSO)
|
|
||||||
{
|
|
||||||
if (pSO)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i=0; i<pSO->iAlloc; i++)
|
|
||||||
{
|
|
||||||
if (pSO->Buffers[i])
|
|
||||||
{
|
|
||||||
IDirectSoundBuffer_Release(pSO->Buffers[i]);
|
|
||||||
pSO->Buffers[i] = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LocalFree((HANDLE)pSO);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
IDirectSoundBuffer *SndObjGetFreeBuffer(SNDOBJ *pSO)
|
|
||||||
{
|
|
||||||
IDirectSoundBuffer *pDSB;
|
|
||||||
|
|
||||||
if (pSO == NULL)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (pDSB = pSO->Buffers[pSO->iCurrent])
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
DWORD dwStatus;
|
|
||||||
|
|
||||||
hres = IDirectSoundBuffer_GetStatus(pDSB, &dwStatus);
|
|
||||||
|
|
||||||
if (FAILED(hres))
|
|
||||||
dwStatus = 0;
|
|
||||||
|
|
||||||
if ((dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
|
|
||||||
{
|
|
||||||
if (pSO->iAlloc > 1)
|
|
||||||
{
|
|
||||||
if (++pSO->iCurrent >= pSO->iAlloc)
|
|
||||||
pSO->iCurrent = 0;
|
|
||||||
|
|
||||||
pDSB = pSO->Buffers[pSO->iCurrent];
|
|
||||||
hres = IDirectSoundBuffer_GetStatus(pDSB, &dwStatus);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hres) && (dwStatus & DSBSTATUS_PLAYING) == DSBSTATUS_PLAYING)
|
|
||||||
{
|
|
||||||
IDirectSoundBuffer_Stop(pDSB);
|
|
||||||
IDirectSoundBuffer_SetCurrentPosition(pDSB, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pDSB = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pDSB && (dwStatus & DSBSTATUS_BUFFERLOST))
|
|
||||||
{
|
|
||||||
if (FAILED(IDirectSoundBuffer_Restore(pDSB)) ||
|
|
||||||
!DSFillSoundBuffer(pDSB, pSO->pbWaveData, pSO->cbWaveSize))
|
|
||||||
{
|
|
||||||
pDSB = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pDSB;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
BOOL SndObjPlay(SNDOBJ *pSO, DWORD dwPlayFlags)
|
|
||||||
{
|
|
||||||
BOOL result = FALSE;
|
|
||||||
|
|
||||||
if (pSO == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if ((!(dwPlayFlags & DSBPLAY_LOOPING) || (pSO->iAlloc == 1)))
|
|
||||||
{
|
|
||||||
IDirectSoundBuffer *pDSB = SndObjGetFreeBuffer(pSO);
|
|
||||||
if (pDSB != NULL) {
|
|
||||||
result = SUCCEEDED(IDirectSoundBuffer_Play(pDSB, 0, 0, dwPlayFlags));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
BOOL SndObjStop(SNDOBJ *pSO)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (pSO == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
for (i=0; i<pSO->iAlloc; i++)
|
|
||||||
{
|
|
||||||
IDirectSoundBuffer_Stop(pSO->Buffers[i]);
|
|
||||||
IDirectSoundBuffer_SetCurrentPosition(pSO->Buffers[i], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
BOOL DSFillSoundBuffer(IDirectSoundBuffer *pDSB, BYTE *pbWaveData, DWORD cbWaveSize)
|
|
||||||
{
|
|
||||||
if (pDSB && pbWaveData && cbWaveSize)
|
|
||||||
{
|
|
||||||
LPVOID pMem1, pMem2;
|
|
||||||
DWORD dwSize1, dwSize2;
|
|
||||||
|
|
||||||
if (SUCCEEDED(IDirectSoundBuffer_Lock(pDSB, 0, cbWaveSize,
|
|
||||||
&pMem1, &dwSize1, &pMem2, &dwSize2, 0)))
|
|
||||||
{
|
|
||||||
CopyMemory(pMem1, pbWaveData, dwSize1);
|
|
||||||
|
|
||||||
if ( 0 != dwSize2 )
|
|
||||||
CopyMemory(pMem2, pbWaveData+dwSize1, dwSize2);
|
|
||||||
|
|
||||||
IDirectSoundBuffer_Unlock(pDSB, pMem1, dwSize1, pMem2, dwSize2);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
BOOL DSParseWaveResource(void *pvRes, WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData,DWORD *pcbWaveSize)
|
|
||||||
{
|
|
||||||
DWORD *pdw;
|
|
||||||
DWORD *pdwEnd;
|
|
||||||
DWORD dwRiff;
|
|
||||||
DWORD dwType;
|
|
||||||
DWORD dwLength;
|
|
||||||
|
|
||||||
if (ppWaveHeader)
|
|
||||||
*ppWaveHeader = NULL;
|
|
||||||
|
|
||||||
if (ppbWaveData)
|
|
||||||
*ppbWaveData = NULL;
|
|
||||||
|
|
||||||
if (pcbWaveSize)
|
|
||||||
*pcbWaveSize = 0;
|
|
||||||
|
|
||||||
pdw = (DWORD *)pvRes;
|
|
||||||
dwRiff = *pdw++;
|
|
||||||
dwLength = *pdw++;
|
|
||||||
dwType = *pdw++;
|
|
||||||
|
|
||||||
if (dwRiff != mmioFOURCC('R', 'I', 'F', 'F'))
|
|
||||||
goto exit; // not even RIFF
|
|
||||||
|
|
||||||
if (dwType != mmioFOURCC('W', 'A', 'V', 'E'))
|
|
||||||
goto exit; // not a WAV
|
|
||||||
|
|
||||||
pdwEnd = (DWORD *)((BYTE *)pdw + dwLength-4);
|
|
||||||
|
|
||||||
while (pdw < pdwEnd)
|
|
||||||
{
|
|
||||||
dwType = *pdw++;
|
|
||||||
dwLength = *pdw++;
|
|
||||||
|
|
||||||
switch (dwType)
|
|
||||||
{
|
|
||||||
case mmioFOURCC('f', 'm', 't', ' '):
|
|
||||||
if (ppWaveHeader && !*ppWaveHeader)
|
|
||||||
{
|
|
||||||
if (dwLength < sizeof(WAVEFORMAT))
|
|
||||||
goto exit; // not a WAV
|
|
||||||
|
|
||||||
*ppWaveHeader = (WAVEFORMATEX *)pdw;
|
|
||||||
|
|
||||||
if ((!ppbWaveData || *ppbWaveData) &&
|
|
||||||
(!pcbWaveSize || *pcbWaveSize))
|
|
||||||
{
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case mmioFOURCC('d', 'a', 't', 'a'):
|
|
||||||
if ((ppbWaveData && !*ppbWaveData) ||
|
|
||||||
(pcbWaveSize && !*pcbWaveSize))
|
|
||||||
{
|
|
||||||
if (ppbWaveData)
|
|
||||||
*ppbWaveData = (LPBYTE)pdw;
|
|
||||||
|
|
||||||
if (pcbWaveSize)
|
|
||||||
*pcbWaveSize = dwLength;
|
|
||||||
|
|
||||||
if (!ppWaveHeader || *ppWaveHeader)
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
pdw = (DWORD *)((BYTE *)pdw + ((dwLength+1)&~1));
|
|
||||||
}
|
|
||||||
|
|
||||||
exit:
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
-215
@@ -1,215 +0,0 @@
|
|||||||
/*==========================================================================
|
|
||||||
*
|
|
||||||
* Copyright (C) 1995 Microsoft Corporation. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* File: dsutil.cpp
|
|
||||||
* Content: Routines for dealing with sounds from resources
|
|
||||||
*
|
|
||||||
*
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// DSLoadSoundBuffer Loads an IDirectSoundBuffer from a Win32 resource in
|
|
||||||
// the current application.
|
|
||||||
//
|
|
||||||
// Params:
|
|
||||||
// pDS -- Pointer to an IDirectSound that will be used to create
|
|
||||||
// the buffer.
|
|
||||||
//
|
|
||||||
// lpName -- Name of WAV resource to load the data from. Can be a
|
|
||||||
// resource id specified using the MAKEINTRESOURCE macro.
|
|
||||||
//
|
|
||||||
// Returns an IDirectSoundBuffer containing the wave data or NULL on error.
|
|
||||||
//
|
|
||||||
// example:
|
|
||||||
// in the application's resource script (.RC file)
|
|
||||||
// Turtle WAV turtle.wav
|
|
||||||
//
|
|
||||||
// some code in the application:
|
|
||||||
// IDirectSoundBuffer *pDSB = DSLoadSoundBuffer(pDS, "Turtle");
|
|
||||||
//
|
|
||||||
// if (pDSB)
|
|
||||||
// {
|
|
||||||
// IDirectSoundBuffer_Play(pDSB, 0, 0, DSBPLAY_TOEND);
|
|
||||||
// /* ... */
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
IDirectSoundBuffer *DSLoadSoundBuffer(IDirectSound *pDS, LPCTSTR lpName);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// DSReloadSoundBuffer Reloads an IDirectSoundBuffer from a Win32 resource in
|
|
||||||
// the current application. normally used to handle
|
|
||||||
// a DSERR_BUFFERLOST error.
|
|
||||||
// Params:
|
|
||||||
// pDSB -- Pointer to an IDirectSoundBuffer to be reloaded.
|
|
||||||
//
|
|
||||||
// lpName -- Name of WAV resource to load the data from. Can be a
|
|
||||||
// resource id specified using the MAKEINTRESOURCE macro.
|
|
||||||
//
|
|
||||||
// Returns a BOOL indicating whether the buffer was successfully reloaded.
|
|
||||||
//
|
|
||||||
// example:
|
|
||||||
// in the application's resource script (.RC file)
|
|
||||||
// Turtle WAV turtle.wav
|
|
||||||
//
|
|
||||||
// some code in the application:
|
|
||||||
// TryAgain:
|
|
||||||
// HRESULT hres = IDirectSoundBuffer_Play(pDSB, 0, 0, DSBPLAY_TOEND);
|
|
||||||
//
|
|
||||||
// if (FAILED(hres))
|
|
||||||
// {
|
|
||||||
// if ((hres == DSERR_BUFFERLOST) &&
|
|
||||||
// DSReloadSoundBuffer(pDSB, "Turtle"))
|
|
||||||
// {
|
|
||||||
// goto TryAgain;
|
|
||||||
// }
|
|
||||||
// /* deal with other errors... */
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
BOOL DSReloadSoundBuffer(IDirectSoundBuffer *pDSB, LPCTSTR lpName);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// DSGetWaveResource Finds a WAV resource in a Win32 module.
|
|
||||||
//
|
|
||||||
// Params:
|
|
||||||
// hModule -- Win32 module handle of module containing WAV resource.
|
|
||||||
// Pass NULL to indicate current application.
|
|
||||||
//
|
|
||||||
// lpName -- Name of WAV resource to load the data from. Can be a
|
|
||||||
// resource id specified using the MAKEINTRESOURCE macro.
|
|
||||||
//
|
|
||||||
// ppWaveHeader-- Optional pointer to WAVEFORMATEX * to receive a pointer to
|
|
||||||
// the WAVEFORMATEX header in the specified WAV resource.
|
|
||||||
// Pass NULL if not required.
|
|
||||||
//
|
|
||||||
// ppbWaveData -- Optional pointer to BYTE * to receive a pointer to the
|
|
||||||
// waveform data in the specified WAV resource. Pass NULL if
|
|
||||||
// not required.
|
|
||||||
//
|
|
||||||
// pdwWaveSize -- Optional pointer to DWORD to receive the size of the
|
|
||||||
// waveform data in the specified WAV resource. Pass NULL if
|
|
||||||
// not required.
|
|
||||||
//
|
|
||||||
// Returns a BOOL indicating whether a valid WAV resource was found.
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
BOOL DSGetWaveResource(HMODULE hModule, LPCTSTR lpName,
|
|
||||||
WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pdwWaveSize);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// HSNDOBJ Handle to a SNDOBJ object.
|
|
||||||
//
|
|
||||||
// SNDOBJs are implemented in dsutil as an example layer built on top
|
|
||||||
// of DirectSound.
|
|
||||||
//
|
|
||||||
// A SNDOBJ is generally used to manage individual
|
|
||||||
// sounds which need to be played multiple times concurrently. A
|
|
||||||
// SNDOBJ represents a queue of IDirectSoundBuffer objects which
|
|
||||||
// all refer to the same buffer memory.
|
|
||||||
//
|
|
||||||
// A SNDOBJ also automatically reloads the sound resource when
|
|
||||||
// DirectSound returns a DSERR_BUFFERLOST
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
#ifndef _HSNDOBJ_DEFINED
|
|
||||||
DECLARE_HANDLE32(HSNDOBJ);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SndObjCreate Loads a SNDOBJ from a Win32 resource in
|
|
||||||
// the current application.
|
|
||||||
//
|
|
||||||
// Params:
|
|
||||||
// pDS -- Pointer to an IDirectSound that will be used to create
|
|
||||||
// the SNDOBJ.
|
|
||||||
//
|
|
||||||
// lpName -- Name of WAV resource to load the data from. Can be a
|
|
||||||
// resource id specified using the MAKEINTRESOURCE macro.
|
|
||||||
//
|
|
||||||
// iConcurrent -- Integer representing the number of concurrent playbacks of
|
|
||||||
// to plan for. Attempts to play more than this number will
|
|
||||||
// succeed but will restart the least recently played buffer
|
|
||||||
// even if it is not finished playing yet.
|
|
||||||
//
|
|
||||||
// Returns an HSNDOBJ or NULL on error.
|
|
||||||
//
|
|
||||||
// NOTES:
|
|
||||||
// SNDOBJs automatically restore and reload themselves as required.
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
HSNDOBJ SndObjCreate(IDirectSound *pDS, LPCTSTR lpName, int iConcurrent);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SndObjDestroy Frees a SNDOBJ and releases all of its buffers.
|
|
||||||
//
|
|
||||||
// Params:
|
|
||||||
// hSO -- Handle to a SNDOBJ to free.
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
void SndObjDestroy(HSNDOBJ hSO);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SndObjPlay Plays a buffer in a SNDOBJ.
|
|
||||||
//
|
|
||||||
// Params:
|
|
||||||
// hSO -- Handle to a SNDOBJ to play a buffer from.
|
|
||||||
//
|
|
||||||
// dwPlayFlags -- Flags to pass to IDirectSoundBuffer::Play. It is not
|
|
||||||
// legal to play an SndObj which has more than one buffer
|
|
||||||
// with the DSBPLAY_LOOPING flag. Pass 0 to stop playback.
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
BOOL SndObjPlay(HSNDOBJ hSO, DWORD dwPlayFlags);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SndObjStop Stops one or more buffers in a SNDOBJ.
|
|
||||||
//
|
|
||||||
// Params:
|
|
||||||
// hSO -- Handle to a SNDOBJ to play a buffer from.
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
BOOL SndObjStop(HSNDOBJ hSO);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// SndObjGetFreeBuffer returns one of the cloned buffers that is
|
|
||||||
// not currently playing
|
|
||||||
//
|
|
||||||
// Params:
|
|
||||||
// hSO -- Handle to a SNDOBJ
|
|
||||||
//
|
|
||||||
// NOTES:
|
|
||||||
// This function is provided so that callers can set things like pan etc
|
|
||||||
// before playing the buffer.
|
|
||||||
//
|
|
||||||
// EXAMPLE:
|
|
||||||
// ...
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
IDirectSoundBuffer *SndObjGetFreeBuffer(HSNDOBJ hSO);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
|
||||||
// helper routines
|
|
||||||
//
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
BOOL DSFillSoundBuffer(IDirectSoundBuffer *pDSB, BYTE *pbWaveData, DWORD dwWaveSize);
|
|
||||||
BOOL DSParseWaveResource(void *pvRes, WAVEFORMATEX **ppWaveHeader, BYTE **ppbWaveData, DWORD *pdwWaveSize);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -856,11 +856,6 @@ int PASCAL HandledWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pC
|
|||||||
//Process the command line BEFORE initialization
|
//Process the command line BEFORE initialization
|
||||||
ProcessJa2CommandLineBeforeInitialization( pCommandLine );
|
ProcessJa2CommandLineBeforeInitialization( pCommandLine );
|
||||||
|
|
||||||
// Handle Check for CD
|
|
||||||
if ( !HandleJA2CDCheck( ) )
|
|
||||||
{
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// ShowCursor(FALSE);
|
// ShowCursor(FALSE);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user