Disable cd check by default, add support for SP/Carma game modes (#41)
This commit is contained in:
parent
dd05afea6e
commit
62d000b861
|
@ -129,7 +129,7 @@ void PlaySmackerFile(char* pSmack_name) {
|
||||||
void DoOpeningAnimation() {
|
void DoOpeningAnimation() {
|
||||||
LOG_TRACE("()");
|
LOG_TRACE("()");
|
||||||
PlaySmackerFile("LOGO.SMK");
|
PlaySmackerFile("LOGO.SMK");
|
||||||
PlaySmackerFile("MIX_INTR.SMK");
|
PlaySmackerFile(harness_game_mode.intro_smk_file);
|
||||||
return WaitForNoKeys();
|
return WaitForNoKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1410,7 +1410,14 @@ void ShadowMode() {
|
||||||
// IDA: int __cdecl SwitchToRealResolution()
|
// IDA: int __cdecl SwitchToRealResolution()
|
||||||
int SwitchToRealResolution() {
|
int SwitchToRealResolution() {
|
||||||
LOG_TRACE("()");
|
LOG_TRACE("()");
|
||||||
NOT_IMPLEMENTED();
|
|
||||||
|
if (gGraf_data_index == gReal_graf_data_index) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
gGraf_data_index = gReal_graf_data_index;
|
||||||
|
gGraf_spec_index = gReal_graf_data_index;
|
||||||
|
gCurrent_graf_data = &gGraf_data[gReal_graf_data_index];
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDA: int __cdecl SwitchToLoresMode()
|
// IDA: int __cdecl SwitchToLoresMode()
|
||||||
|
|
|
@ -1445,7 +1445,7 @@ void GetAString(FILE* pF, char* pString) {
|
||||||
// IDA: void __cdecl AboutToLoadFirstCar()
|
// IDA: void __cdecl AboutToLoadFirstCar()
|
||||||
void AboutToLoadFirstCar() {
|
void AboutToLoadFirstCar() {
|
||||||
LOG_TRACE("()");
|
LOG_TRACE("()");
|
||||||
NOT_IMPLEMENTED();
|
memset(gFunk_groove_flags, 0, sizeof(gFunk_groove_flags));
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDA: void __usercall LoadOpponentsCars(tRace_info *pRace_info@<EAX>)
|
// IDA: void __usercall LoadOpponentsCars(tRace_info *pRace_info@<EAX>)
|
||||||
|
@ -1663,6 +1663,11 @@ int TestForOriginalCarmaCDinDrive() {
|
||||||
tPath_name paths_txt;
|
tPath_name paths_txt;
|
||||||
int paths_txt_first_char;
|
int paths_txt_first_char;
|
||||||
|
|
||||||
|
// JeffH: Added to optionally bypass this check
|
||||||
|
if (!harness_enable_cd_check) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
paths_txt[0] = 0;
|
paths_txt[0] = 0;
|
||||||
strcat(paths_txt, gApplication_path);
|
strcat(paths_txt, gApplication_path);
|
||||||
strcat(paths_txt, gDir_separator);
|
strcat(paths_txt, gDir_separator);
|
||||||
|
@ -1703,15 +1708,9 @@ int TestForOriginalCarmaCDinDrive() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Harness_GameMode() == eGame_mode_SplatPack) {
|
if (!PDCheckDriveExists2(cutscene_pathname, harness_game_mode.intro_smk_file, 2000000)) {
|
||||||
if (!PDCheckDriveExists2(cutscene_pathname, "SPLINTRO.SMK", 2000000)) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!PDCheckDriveExists2(cutscene_pathname, "MIX_INTR.SMK", 2000000)) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (paths_txt_first_char != '@') {
|
if (paths_txt_first_char != '@') {
|
||||||
EncodeFile(paths_txt);
|
EncodeFile(paths_txt);
|
||||||
|
|
|
@ -76,7 +76,6 @@ void GameMain(int pArgc, char** pArgv) {
|
||||||
strcat(gApplication_path, "DATA");
|
strcat(gApplication_path, "DATA");
|
||||||
|
|
||||||
UsePathFileToDetermineIfFullInstallation();
|
UsePathFileToDetermineIfFullInstallation();
|
||||||
|
|
||||||
if (!gCD_fully_installed && GetCDPathFromPathsTxtFile(CD_dir) && !PDCheckDriveExists(CD_dir)) {
|
if (!gCD_fully_installed && GetCDPathFromPathsTxtFile(CD_dir) && !PDCheckDriveExists(CD_dir)) {
|
||||||
PDInitialiseSystem();
|
PDInitialiseSystem();
|
||||||
fprintf(stderr, "Can't find the Carmageddon CD\n");
|
fprintf(stderr, "Can't find the Carmageddon CD\n");
|
||||||
|
|
|
@ -46,11 +46,10 @@ void UsePathFileToDetermineIfFullInstallation() {
|
||||||
strcat(path_file, gDir_separator);
|
strcat(path_file, gDir_separator);
|
||||||
strcat(path_file, "PATHS.TXT");
|
strcat(path_file, "PATHS.TXT");
|
||||||
|
|
||||||
if (PDCheckDriveExists(path_file) == 0) {
|
if (PDCheckDriveExists(path_file)) {
|
||||||
fp = fopen(path_file, "rt");
|
fp = fopen(path_file, "rt");
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
if (GetALineWithNoPossibleService(fp, line2) && GetALineWithNoPossibleService(fp, line2) && GetALineWithNoPossibleService(fp, line3) && strcmp(line3, "Full") == 0) {
|
if (GetALineWithNoPossibleService(fp, line2) && GetALineWithNoPossibleService(fp, line2) && GetALineWithNoPossibleService(fp, line3) && strcmp(line3, "Full") == 0) {
|
||||||
|
|
||||||
gCD_fully_installed = 1;
|
gCD_fully_installed = 1;
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
|
@ -9,8 +9,6 @@ extern int original_main(int pArgc, char* pArgv[]);
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
Harness_Init(argv[0], &OpenGLRenderer);
|
|
||||||
|
|
||||||
char* root_dir = getenv("DETHRACE_ROOT_DIR");
|
char* root_dir = getenv("DETHRACE_ROOT_DIR");
|
||||||
if (!root_dir) {
|
if (!root_dir) {
|
||||||
LOG_PANIC("DETHRACE_ROOT_DIR is not set");
|
LOG_PANIC("DETHRACE_ROOT_DIR is not set");
|
||||||
|
@ -21,5 +19,7 @@ int main(int argc, char* argv[]) {
|
||||||
LOG_PANIC("Failed to chdir. Returned %d", result);
|
LOG_PANIC("Failed to chdir. Returned %d", result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Harness_Init(argv[0], &OpenGLRenderer);
|
||||||
|
|
||||||
return original_main(argc, argv);
|
return original_main(argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -611,6 +611,11 @@ int original_main(int pArgc, char** pArgv) {
|
||||||
float f;
|
float f;
|
||||||
|
|
||||||
for (i = 1; i < pArgc; i++) {
|
for (i = 1; i < pArgc; i++) {
|
||||||
|
|
||||||
|
if (Harness_Hook_HandleCommandLineArg(pArgv[i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (strcasecmp(pArgv[i], "-hires") == 0) {
|
if (strcasecmp(pArgv[i], "-hires") == 0) {
|
||||||
gGraf_spec_index = 1;
|
gGraf_spec_index = 1;
|
||||||
} else if (strcasecmp(pArgv[i], "-yon") == 0 && i < pArgc - 1) {
|
} else if (strcasecmp(pArgv[i], "-yon") == 0 && i < pArgc - 1) {
|
||||||
|
|
|
@ -2,25 +2,44 @@
|
||||||
#include "harness.h"
|
#include "harness.h"
|
||||||
#include "input/keyboard.h"
|
#include "input/keyboard.h"
|
||||||
#include "stack_trace_handler.h"
|
#include "stack_trace_handler.h"
|
||||||
|
#include "unistd.h"
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
SDL_Window* window;
|
SDL_Window* window;
|
||||||
renderer* current_renderer;
|
renderer* current_renderer;
|
||||||
br_pixelmap* palette;
|
br_pixelmap* palette;
|
||||||
uint32_t* screen_buffer;
|
uint32_t* screen_buffer;
|
||||||
eGame_mode game_mode;
|
|
||||||
|
|
||||||
br_pixelmap* last_dst = NULL;
|
br_pixelmap* last_dst = NULL;
|
||||||
br_pixelmap* last_src = NULL;
|
br_pixelmap* last_src = NULL;
|
||||||
|
|
||||||
|
// if not 0, enable the original CD check code, otherwise just skip
|
||||||
|
int harness_enable_cd_check;
|
||||||
|
|
||||||
|
// SplatPack or Carmageddon. This is where we represent the code differences between the two. For example, the intro smack file.
|
||||||
|
tHarness_GameMode harness_game_mode;
|
||||||
|
|
||||||
|
void Harness_DetectGameMode() {
|
||||||
|
if (access("DATA/CUTSCENE/SPLINTRO.SMK", F_OK) != -1) {
|
||||||
|
harness_game_mode.name = "Splat Pack";
|
||||||
|
harness_game_mode.intro_smk_file = "SPLINTRO.SMK";
|
||||||
|
} else {
|
||||||
|
harness_game_mode.name = "Carmageddon";
|
||||||
|
harness_game_mode.intro_smk_file = "MIX_INTR.SMK";
|
||||||
|
}
|
||||||
|
LOG_INFO("\"%s\"", harness_game_mode.name);
|
||||||
|
}
|
||||||
|
|
||||||
void Harness_Init(char* name, renderer* renderer) {
|
void Harness_Init(char* name, renderer* renderer) {
|
||||||
install_signal_handler(name);
|
install_signal_handler(name);
|
||||||
current_renderer = renderer;
|
current_renderer = renderer;
|
||||||
screen_buffer = NULL;
|
screen_buffer = NULL;
|
||||||
game_mode = eGame_mode_Carmageddon;
|
|
||||||
|
|
||||||
if (SDL_Init(SDL_INIT_TIMER) != 0) {
|
if (SDL_Init(SDL_INIT_TIMER) != 0) {
|
||||||
LOG_PANIC("SDL_INIT_TIMER error: %s", SDL_GetError());
|
LOG_PANIC("SDL_INIT_TIMER error: %s", SDL_GetError());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Harness_DetectGameMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harness_PumpEvents() {
|
void Harness_PumpEvents() {
|
||||||
|
@ -41,8 +60,12 @@ void Harness_PumpEvents() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
eGame_mode Harness_GameMode() {
|
int Harness_Hook_HandleCommandLineArg(char* arg) {
|
||||||
return game_mode;
|
if (strcasecmp(arg, "-cdcheck") == 0) {
|
||||||
|
harness_enable_cd_check = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Harness_Hook_DOSGfxBegin() {
|
void Harness_Hook_DOSGfxBegin() {
|
||||||
|
|
|
@ -5,25 +5,24 @@
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
typedef int harness_game_func(void*);
|
|
||||||
|
|
||||||
typedef struct renderer {
|
typedef struct renderer {
|
||||||
int (*get_window_flags)();
|
int (*get_window_flags)();
|
||||||
void (*init)(SDL_Window* window);
|
void (*init)(SDL_Window* window);
|
||||||
void (*doubleBuffer)(uint32_t* src, SDL_Window* window);
|
void (*doubleBuffer)(uint32_t* src, SDL_Window* window);
|
||||||
} renderer;
|
} renderer;
|
||||||
|
|
||||||
typedef enum eGame_mode {
|
typedef struct tHarness_GameMode {
|
||||||
eGame_mode_Carmageddon,
|
char* name;
|
||||||
eGame_mode_SplatPack
|
char* intro_smk_file;
|
||||||
} eGame_mode;
|
} tHarness_GameMode;
|
||||||
|
|
||||||
|
extern tHarness_GameMode harness_game_mode;
|
||||||
|
extern int harness_enable_cd_check;
|
||||||
|
|
||||||
void Harness_Init(char* name, renderer* renderer);
|
void Harness_Init(char* name, renderer* renderer);
|
||||||
void Harness_RunWindowLoop(harness_game_func* game_func, void* arg);
|
|
||||||
|
|
||||||
eGame_mode Harness_GameMode();
|
|
||||||
|
|
||||||
// Hooks are called from original game code.
|
// Hooks are called from original game code.
|
||||||
|
int Harness_Hook_HandleCommandLineArg(char* arg);
|
||||||
void Harness_Hook_DOSGfxBegin();
|
void Harness_Hook_DOSGfxBegin();
|
||||||
void Harness_Hook_BrDevPaletteSetOld(br_pixelmap* pm);
|
void Harness_Hook_BrDevPaletteSetOld(br_pixelmap* pm);
|
||||||
void Harness_Hook_BrDevPaletteSetEntryOld(int i, br_colour colour);
|
void Harness_Hook_BrDevPaletteSetEntryOld(int i, br_colour colour);
|
||||||
|
|
Loading…
Reference in New Issue