diff --git a/3rdParty/Storm/Source/storm.cpp b/3rdParty/Storm/Source/storm.cpp index 67bf57fb3..d3968164d 100644 --- a/3rdParty/Storm/Source/storm.cpp +++ b/3rdParty/Storm/Source/storm.cpp @@ -248,3 +248,4 @@ BOOL __stdcall SDlgKillTimer(int a1, int a2) rBool; BOOL __stdcall SDlgDrawBitmap(HWND hWnd, int a2, int a3, int a4, int a5, int a6, int a7) rBool; BOOL __stdcall SDlgDialogBoxParam(HINSTANCE hInst, char *szDialog, int a3, WNDPROC func, int a5) rBool; BOOL __stdcall SGdiTextOut(void *pBuffer, int x, int y, int mask, char *str, int len) rBool; +BOOL __stdcall SFileEnableDirectAccess(BOOL enable) rBool; diff --git a/3rdParty/Storm/Source/storm.def b/3rdParty/Storm/Source/storm.def index 180910df6..6631907cf 100644 --- a/3rdParty/Storm/Source/storm.def +++ b/3rdParty/Storm/Source/storm.def @@ -88,7 +88,7 @@ EXPORTS SFileDdaInitialize @260 NONAME SFileDdaSetVolume @261 NONAME SFileDestroy @262 NONAME - ;SFileEnableDirectAccess @263 NONAME + SFileEnableDirectAccess @263 NONAME SFileGetFileArchive @264 NONAME SFileGetFileSize @265 NONAME SFileOpenArchive @266 NONAME diff --git a/3rdParty/Storm/Source/storm.h b/3rdParty/Storm/Source/storm.h index b3f674285..562a258fc 100644 --- a/3rdParty/Storm/Source/storm.h +++ b/3rdParty/Storm/Source/storm.h @@ -1310,6 +1310,7 @@ BOOL __stdcall SDlgKillTimer(int a1, int a2); BOOL __stdcall SDlgDrawBitmap(HWND hWnd, int a2, int a3, int a4, int a5, int a6, int a7); BOOL __stdcall SDlgDialogBoxParam(HINSTANCE hInst, char *szDialog, int a3, WNDPROC func, int a5); BOOL __stdcall SGdiTextOut(void *pBuffer, int x, int y, int mask, char *str, int len); +BOOL __stdcall SFileEnableDirectAccess(BOOL enable); #ifdef __GNUC__ } diff --git a/3rdParty/Storm/Source/storm_gcc.def b/3rdParty/Storm/Source/storm_gcc.def index 7ea69c10b..387477a99 100644 --- a/3rdParty/Storm/Source/storm_gcc.def +++ b/3rdParty/Storm/Source/storm_gcc.def @@ -127,7 +127,8 @@ EXPORTS SFileDdaSetVolume @261 NONAME SFileDdaSetVolume@12 @261 NONAME SFileDestroy @262 NONAME - ;SFileEnableDirectAccess @263 NONAME + SFileEnableDirectAccess @263 NONAME + SFileEnableDirectAccess@4 @263 NONAME SFileGetFileArchive @264 NONAME SFileGetFileArchive@8 @264 NONAME SFileGetFileSize @265 NONAME diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 941d95959..f691aca13 100644 --- a/Source/diablo.cpp +++ b/Source/diablo.cpp @@ -254,71 +254,81 @@ void __cdecl free_game() FreeGameMem(); } -bool __cdecl diablo_get_not_running() +BOOL __cdecl diablo_get_not_running() { SetLastError(0); CreateEvent(NULL, FALSE, FALSE, "DiabloEvent"); return GetLastError() != ERROR_ALREADY_EXISTS; } -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - HINSTANCE v4; // esi - char Filename[260]; // [esp+8h] [ebp-10Ch] - char value_name[8]; // [esp+10Ch] [ebp-8h] + HINSTANCE hInst; + int nData; + char szFileName[MAX_PATH]; - v4 = hInstance; + hInst = hInstance; #ifndef DEBUGGER diablo_reload_process(hInstance); #endif - ghInst = v4; - if (RestrictedTest()) + ghInst = hInst; + + if(RestrictedTest()) ErrOkDlg(IDD_DIALOG10, 0, "C:\\Src\\Diablo\\Source\\DIABLO.CPP", 877); - if (ReadOnlyTest()) { - if (!GetModuleFileName(ghInst, Filename, 0x104u)) - *Filename = '\0'; - DirErrorDlg(Filename); + if(ReadOnlyTest()) { + if(!GetModuleFileName(ghInst, szFileName, sizeof(szFileName))) + szFileName[0] = '\0'; + DirErrorDlg(szFileName); } + ShowCursor(FALSE); srand(GetTickCount()); InitHash(); exception_get_filter(); - if (!diablo_find_window("DIABLO") && diablo_get_not_running()) { + + BOOL bNoEvent = diablo_get_not_running(); + if(!diablo_find_window("DIABLO") && bNoEvent) { +#ifdef _DEBUG + SFileEnableDirectAccess(TRUE); +#endif diablo_init_screen(); diablo_parse_flags(lpCmdLine); init_create_window(nCmdShow); sound_init(); UiInitialize(); + #ifdef _DEBUG - if (showintrodebug) - play_movie("gendata\\logo.smk", 1); -#else - play_movie("gendata\\logo.smk", 1); + if(showintrodebug) #endif - strcpy(value_name, "Intro"); - if (!SRegLoadValue("Diablo", value_name, 0, (int *)&hInstance)) - hInstance = (HINSTANCE)1; - if (hInstance) - play_movie("gendata\\diablo1.smk", 1); - SRegSaveValue("Diablo", value_name, 0, 0); + play_movie("gendata\\logo.smk", TRUE); + + char szValueName[] = "Intro"; + if(!SRegLoadValue("Diablo", szValueName, 0, &nData)) + nData = 1; + if(nData) + play_movie("gendata\\diablo1.smk", TRUE); + SRegSaveValue("Diablo", szValueName, 0, 0); + #ifdef _DEBUG - if (showintrodebug) { + if(showintrodebug) { +#endif UiTitleDialog(7); BlackPalette(); +#ifdef _DEBUG } -#else - UiTitleDialog(7); - BlackPalette(); #endif + mainmenu_loop(); UiDestroy(); SaveGamma(); - if (ghMainWnd) { + + if(ghMainWnd) { Sleep(300); DestroyWindow(ghMainWnd); } } - return 0; + + return FALSE; } void __fastcall diablo_parse_flags(char *args) diff --git a/Source/diablo.h b/Source/diablo.h index 44f97f438..08790fe99 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -41,8 +41,8 @@ int __fastcall diablo_init_menu(int a1, int bSinglePlayer); void __fastcall run_game_loop(int uMsg); void __fastcall start_game(int uMsg); void __cdecl free_game(); -bool __cdecl diablo_get_not_running(); -int __stdcall WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd); +BOOL __cdecl diablo_get_not_running(); +int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); void __fastcall diablo_parse_flags(char *args); void __cdecl diablo_init_screen(); BOOL __fastcall diablo_find_window(LPCSTR lpClassName); diff --git a/Source/effects.cpp b/Source/effects.cpp index 849f55afc..06fd2541a 100644 --- a/Source/effects.cpp +++ b/Source/effects.cpp @@ -1042,12 +1042,21 @@ void __fastcall PlaySFX_priv(TSFX *pSFX, BOOL loc, int x, int y) void __fastcall stream_play(TSFX *pSFX, int lVolume, int lPan) { + /// ASSERT: assert(pSFX); + /// ASSERT: assert(pSFX->bFlags & sfx_STREAM); sfx_stop(); lVolume += sound_get_or_set_sound_volume(1); if (lVolume >= VOLUME_MIN) { if (lVolume > VOLUME_MAX) lVolume = VOLUME_MAX; - if (!SFileOpenFile(pSFX->pszName, &sfx_stream)) { +#ifdef _DEBUG + SFileEnableDirectAccess(FALSE); +#endif + BOOL success = SFileOpenFile(pSFX->pszName, &sfx_stream); +#ifdef _DEBUG + SFileEnableDirectAccess(TRUE); +#endif + if (!success) { sfx_stream = 0; } else { if (!SFileDdaBeginEx(sfx_stream, 0x40000, 0, 0, lVolume, lPan, 0)) diff --git a/Source/sound.cpp b/Source/sound.cpp index 64ec9c4fc..787274785 100644 --- a/Source/sound.cpp +++ b/Source/sound.cpp @@ -367,9 +367,16 @@ void __cdecl music_stop() void __fastcall music_start(int nTrack) { + /// ASSERT: assert((DWORD) nTrack < NUM_MUSIC); music_stop(); if (sglpDS && gbMusicOn) { +#ifdef _DEBUG + SFileEnableDirectAccess(FALSE); +#endif BOOL success = SFileOpenFile(sgszMusicTracks[nTrack], &sgpMusicTrack); +#ifdef _DEBUG + SFileEnableDirectAccess(TRUE); +#endif sound_create_primary_buffer(sgpMusicTrack); if (!success) { sgpMusicTrack = 0;