Skip to content

Commit

Permalink
Split no_videos into no_fmvs and no_intros so that people can skip in…
Browse files Browse the repository at this point in the history
…tros and still have in-game FMVs
  • Loading branch information
krystalgamer committed Nov 8, 2023
1 parent 6c093f8 commit b7c7330
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 16 deletions.
20 changes: 14 additions & 6 deletions texture_loader/new_ep.c
Expand Up @@ -5,13 +5,14 @@
#include "patches.h"
#include "console.h"

#define CTL_VERSION "0.7.1"
#define CTL_VERSION "0.8"

typedef int (*OriginalEntryPoint_t)(void);
OriginalEntryPoint_t OriginalEntryPoint = (OriginalEntryPoint_t)0x0052B46F;

typedef struct{
bool no_videos;
bool no_intros;
bool no_fmvs;
bool texture_loader;
bool file_loader;
bool console;
Expand Down Expand Up @@ -102,10 +103,14 @@ static BOOL ApplyMyPatches(const Settings *settings){
DO_OR_QUIT(LowRes());
}

if (settings->no_videos) {
if (settings->no_intros) {
DO_OR_QUIT(DisableIntros());
}

if (settings->no_fmvs) {
DO_OR_QUIT(DisableFmvs());
}

if (settings->file_loader) {
DO_OR_QUIT(FileLoader());
}
Expand Down Expand Up @@ -197,7 +202,8 @@ static void WriteSettingsToDisk(const Settings *settings) {
}

cJSON* json = cJSON_CreateObject();
AddSettingToJsonObject(json, "no_videos", settings->no_videos);
AddSettingToJsonObject(json, "no_intros", settings->no_intros);
AddSettingToJsonObject(json, "no_fmvs", settings->no_fmvs);
AddSettingToJsonObject(json, "psx_graphics", settings->psx_graphics);
AddSettingToJsonObject(json, "console", settings->console);
AddSettingToJsonObject(json, "texture_loader", settings->texture_loader);
Expand Down Expand Up @@ -248,7 +254,8 @@ static void ReadSettings(Settings* settings) {
exit(420);
}

GetJsonBool(json, "no_videos", &settings->no_videos);
GetJsonBool(json, "no_intros", &settings->no_intros);
GetJsonBool(json, "no_fmvs", &settings->no_fmvs);
GetJsonBool(json, "psx_graphics", &settings->psx_graphics);
GetJsonBool(json, "console", &settings->console);
GetJsonBool(json, "texture_loader", &settings->texture_loader);
Expand All @@ -268,7 +275,8 @@ static int NewEntryPoint() {
.console = true,
.file_loader = true,
.texture_loader = true,
.no_videos = false,
.no_intros = true,
.no_fmvs = false,
.psx_graphics = false,
.frame_counter = false,
.frame_limiter = false,
Expand Down
68 changes: 66 additions & 2 deletions texture_loader/patches.c
Expand Up @@ -17,12 +17,76 @@ BOOL FreadHook();
BOOL OpenFileFromDisk();
DWORD MyGetFileSize(FILE *fp);

BOOL DisableIntros(){
/************************************************
NO VIDEOS
************************************************/

static int videoPlayerPatched = 0;
static int playFmvs = 1;
static int playIntros = 1;

typedef int (*VideoPlayer_t)(const char* fileName, int a2);
static VideoPlayer_t VideoPlayer = (VideoPlayer_t)0x0050B160;

static int MyVideoPlayer(const char* fileName, int a2) {

if (!playFmvs && fileName[0] == 'L') {
return 1;

}

if (!playIntros) {

Nop(0x004707BE, 0x004707C3 - 0x004707BE, "Disable wrapper for Bink functions.")
if (!strcmp(fileName, "ATVILOGO.bik")) {
return 1;
}

if (!strcmp(fileName, "NEVERSOFT.bik")) {
return 1;
}

if (!strcmp(fileName, "TREYARCH.bik")) {
return 1;
}

if (!strcmp(fileName, "GRAYMATT.bik")) {
return 1;
}
}

return VideoPlayer(fileName, a2);
}

static BOOL PatchVideoPlayer(void) {

if (videoPlayerPatched) {
return TRUE;
}


HookFunc(0x004707BE, (DWORD)&MyVideoPlayer, "Patching video player with my own");

videoPlayerPatched = 1;
return TRUE;
}

BOOL DisableIntros(void){

playIntros = 0;
puts("Disabled intros");
return PatchVideoPlayer();
}

BOOL DisableFmvs(void){

playFmvs = 0;
puts("Disabled FMVs");
return PatchVideoPlayer();
}


/************************************************
FILE LOADER
Expand Down
1 change: 1 addition & 0 deletions texture_loader/patches.h
Expand Up @@ -6,6 +6,7 @@ BOOL FrameLimiter();
BOOL FrameCounter();
BOOL LowRes();
BOOL DisableIntros();
BOOL DisableFmvs();
BOOL FileLoader();
BOOL TextureLoader();
BOOL ModOptions();
Expand Down
17 changes: 9 additions & 8 deletions texture_loader/sm2000.json
@@ -1,9 +1,10 @@
{
"no_videos": true,
"texture_loader": true,
"file_loader": true,
"console": false,
"psx_graphics": true,
"frame_counter": false,
"frame_limiter": false
}
"no_intros": true,
"no_fmvs": false,
"psx_graphics": false,
"console": true,
"texture_loader": true,
"file_loader": true,
"frame_counter": false,
"frame_limiter": false
}

0 comments on commit b7c7330

Please sign in to comment.