Fixed the playback of additional movies defined in the MovieXX options (#330)

Added the keyboard buffer cleanup function to metarule3.
This commit is contained in:
NovaRain
2020-08-13 15:22:20 +08:00
parent 63b2025468
commit 12070f5e3d
4 changed files with 36 additions and 6 deletions
+4 -4
View File
@@ -250,11 +250,11 @@
if (get_flags(obj2) bwand FLAG_MULTIHEX) then distance--
/* sfall metalure3 function macros */
#define SET_HORRIGAN_ENCOUNTER (200)
/* sfall metarule3 function macros */
// sets the number of days (range 1...127) for the Frank Horrigan encounter, or disable the encounter if days is set to 0
#define set_horrigan_days(day) metarule3(SET_HORRIGAN_ENCOUNTER, day, 0, 0)
#define set_horrigan_days(day) metarule3(200, day, 0, 0)
// clears the keyboard input buffer, use it in the HOOK_KEYPRESS hook to clear keyboard events before calling script functions that accept key input
#define clear_keyboard_buffer metarule3(201, 0, 0, 0)
/* sfall_funcX macros */
+4
View File
@@ -28,6 +28,7 @@ static bool HorriganEncounterDisabled = false;
enum MetaruleFunction : long {
SET_HORRIGAN_ENCOUNTER = 200, // sets the number of days for the Frank Horrigan encounter or disable encounter
CLEAR_KEYBOARD_BUFFER = 201, // clears the keyboard input buffer, should be used in the HOOK_KEYPRESS hook to clear keyboard events in some cases
};
/*
@@ -51,6 +52,9 @@ static long __fastcall op_metarule3_ext(long metafunc, long* args) {
}
break;
}
case CLEAR_KEYBOARD_BUFFER:
__asm call kb_clear_;
break;
default:
DebugPrintf("\nOPCODE ERROR: metarule3(%d, ...) - metarule function number does not exist.\n > Script: %s, procedure %s.",
metafunc, (*ptr_currentProgram)->fileName, FindCurrentProc(*ptr_currentProgram));
+27 -2
View File
@@ -106,7 +106,9 @@ private:
//}
if (d3d9Device->CreateTexture(lpAllocInfo->dwWidth, lpAllocInfo->dwHeight, 1, 0, lpAllocInfo->Format, D3DPOOL_DEFAULT, &mTex, nullptr) != D3D_OK) {
dlog(" Failed to create movie texture!", DL_INIT);
dlogr(" Failed to create movie texture!", DL_INIT);
} else {
dlogr(" OK!", DL_INIT);
}
return S_OK;
}
@@ -470,6 +472,8 @@ skip:
///////////////////////////////////////////////////////////////////////////////
#define DEFAULT_MOVIES 17 // max vanilla movies
char MoviePaths[MaxMovies * 65];
static DWORD Artimer1DaysCheckTimer;
@@ -485,6 +489,25 @@ less:
}
}
static void __declspec(naked) gmovie_play_hack_subpal() {
__asm {
xor eax, eax;
lea edx, [ebp * 4];
cmp ebp, DEFAULT_MOVIES;
cmovb eax, edx;
retn;
}
}
static void __declspec(naked) op_play_gmovie_hack() {
__asm {
mov edx, 0xB; // default play mode flags
cmp ecx, DEFAULT_MOVIES;
cmovb edx, eax;
retn;
}
}
void SkipOpeningMoviesPatch() {
int skipOpening = GetConfigInt("Misc", "SkipOpeningMovies", 0);
if (skipOpening) {
@@ -509,7 +532,7 @@ void MoviesInit() {
MoviePaths[index + 64] = '\0';
_itoa_s(i + 1, &optName[5], 3, 10);
if (i < 17) {
if (i < DEFAULT_MOVIES) {
GetConfigString("Misc", optName, ptr_movie_list[i], &MoviePaths[index], 65);
} else {
GetConfigString("Misc", optName, "", &MoviePaths[index], 65);
@@ -518,6 +541,8 @@ void MoviesInit() {
dlog(".", DL_INIT);
const DWORD movieListAddr[] = {0x44E6AE, 0x44E721, 0x44E75E, 0x44E78A}; // gmovie_play_
SafeWriteBatch<DWORD>((DWORD)MoviePtrs, movieListAddr);
MakeCall(0x44E896, gmovie_play_hack_subpal, 2);
MakeCall(0x45A1C9, op_play_gmovie_hack);
dlog(".", DL_INIT);
/*
+1
View File
@@ -348,6 +348,7 @@ static const wchar_t *SoundExtensions[] = { L"wav", L"mp3", L"wma" };
/*
TODO: For sfx sounds in wav format, playback must be performed using the game functions (DirectSound)
because there is a small delay (~50-100ms) when using DirectShow
sfx - environment effects must set their volume relative to the location from the player (see gsound_compute_relative_volume_)
*/
static bool __fastcall SoundFileLoad(PlayType playType, const char* path) {
if (!path) return false;