Merge 5d8cd0ebdf
into 6929e054a9
This commit is contained in:
commit
69e29fe622
|
@ -261,3 +261,4 @@ target_include_directories(${EXECUTABLE_NAME} PRIVATE ${ZLIB_INCLUDE_DIRS})
|
|||
add_subdirectory("third_party/sdl2")
|
||||
target_link_libraries(${EXECUTABLE_NAME} ${SDL2_LIBRARIES})
|
||||
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${SDL2_INCLUDE_DIRS})
|
||||
add_definitions(-DSDL_MAIN_HANDLED)
|
|
@ -246,6 +246,10 @@ bool characterSelectorWindowInit()
|
|||
|
||||
int characterSelectorWindowX = (screenGetWidth() - CS_WINDOW_WIDTH) / 2;
|
||||
int characterSelectorWindowY = (screenGetHeight() - CS_WINDOW_HEIGHT) / 2;
|
||||
CacheEntry* backgroundFrmHandle;
|
||||
int backgroundFid;
|
||||
unsigned char* backgroundFrmData;
|
||||
|
||||
gCharacterSelectorWindow = windowCreate(characterSelectorWindowX, characterSelectorWindowY, CS_WINDOW_WIDTH, CS_WINDOW_HEIGHT, _colorTable[0], 0);
|
||||
if (gCharacterSelectorWindow == -1) {
|
||||
goto err;
|
||||
|
@ -256,9 +260,8 @@ bool characterSelectorWindowInit()
|
|||
goto err;
|
||||
}
|
||||
|
||||
CacheEntry* backgroundFrmHandle;
|
||||
int backgroundFid = buildFid(6, 174, 0, 0, 0);
|
||||
unsigned char* backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle);
|
||||
backgroundFid = buildFid(6, 174, 0, 0, 0);
|
||||
backgroundFrmData = artLockFrameData(backgroundFid, 0, 0, &backgroundFrmHandle);
|
||||
if (backgroundFrmData == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
|
|
@ -354,7 +354,7 @@ void _setMixTableColor(int a1)
|
|||
}
|
||||
|
||||
// 0x4C78E4
|
||||
bool colorPaletteLoad(char* path)
|
||||
bool colorPaletteLoad(const char* path)
|
||||
{
|
||||
if (gColorFileNameMangler != NULL) {
|
||||
path = gColorFileNameMangler(path);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef char*(ColorFileNameManger)(char*);
|
||||
typedef const char*(ColorFileNameManger)(const char*);
|
||||
typedef void(ColorTransitionCallback)();
|
||||
|
||||
typedef int(ColorPaletteFileOpenProc)(const char* path, int mode);
|
||||
|
@ -54,7 +54,7 @@ void _setSystemPaletteEntries(unsigned char* a1, int a2, int a3);
|
|||
void _setIntensityTableColor(int a1);
|
||||
void _setIntensityTables();
|
||||
void _setMixTableColor(int a1);
|
||||
bool colorPaletteLoad(char* path);
|
||||
bool colorPaletteLoad(const char* path);
|
||||
char* _colorError();
|
||||
void _buildBlendTable(unsigned char* ptr, unsigned char ch);
|
||||
void _rebuildColorBlendTables();
|
||||
|
|
13
src/db.cc
13
src/db.cc
|
@ -599,6 +599,19 @@ int fileWriteUInt32List(File* stream, unsigned int* arr, int count)
|
|||
return fileWriteInt32List(stream, (int*)arr, count);
|
||||
}
|
||||
|
||||
std::vector<fs::path> fileNameList(const fs::path& path, const std::regex& pattern)
|
||||
{
|
||||
std::vector<fs::path> result;
|
||||
fs::directory_iterator di(path);
|
||||
|
||||
std::for_each(begin(di), end(di), [&](const fs::directory_entry& de) {
|
||||
const fs::path& p(de.path());
|
||||
if (std::regex_match(p.string(), pattern))
|
||||
result.push_back(p);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
// 0x4C6628
|
||||
int fileNameListInit(const char* pattern, char*** fileNameListPtr, int a3, int a4)
|
||||
{
|
||||
|
|
6
src/db.h
6
src/db.h
|
@ -4,8 +4,13 @@
|
|||
#include "memory_defs.h"
|
||||
#include "xfile.h"
|
||||
|
||||
#include <vector>
|
||||
#include <filesystem>
|
||||
#include <regex>
|
||||
#include <stddef.h>
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
typedef XFile File;
|
||||
typedef void FileReadProgressHandler();
|
||||
typedef char* StrdupProc(const char* string);
|
||||
|
@ -69,6 +74,7 @@ int fileWriteUInt16List(File* stream, unsigned short* arr, int count);
|
|||
int fileWriteInt32List(File* stream, int* arr, int count);
|
||||
int _db_fwriteLongCount(File* stream, int* arr, int count);
|
||||
int fileWriteUInt32List(File* stream, unsigned int* arr, int count);
|
||||
std::vector<fs::path> fileNameList(const fs::path& path, const std::regex& pattern);
|
||||
int fileNameListInit(const char* pattern, char*** fileNames, int a3, int a4);
|
||||
void fileNameListFree(char*** fileNames, int a2);
|
||||
void _db_register_mem(MallocProc* mallocProc, StrdupProc* strdupProc, FreeProc* freeProc);
|
||||
|
|
|
@ -47,7 +47,7 @@ bool fileFindNext(DirectoryFileFindData* findData)
|
|||
// 0x4E63CC
|
||||
bool findFindClose(DirectoryFileFindData* findData)
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
FindClose(findData->hFind);
|
||||
#else
|
||||
if (closedir(findData->dir) != 0) {
|
||||
|
|
|
@ -1539,6 +1539,11 @@ int gameDialogSetReviewOptionText(const char* string)
|
|||
// 0x446288
|
||||
int _gdProcessInit()
|
||||
{
|
||||
int upBtn;
|
||||
int downBtn;
|
||||
int optionsWindowX;
|
||||
int optionsWindowY;
|
||||
|
||||
int fid;
|
||||
|
||||
int replyWindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2 + GAME_DIALOG_REPLY_WINDOW_X;
|
||||
|
@ -1549,7 +1554,7 @@ int _gdProcessInit()
|
|||
}
|
||||
|
||||
// Top part of the reply window - scroll up.
|
||||
int upBtn = buttonCreate(gGameDialogReplyWindow, 1, 1, 377, 28, -1, -1, KEY_ARROW_UP, -1, NULL, NULL, NULL, 32);
|
||||
upBtn = buttonCreate(gGameDialogReplyWindow, 1, 1, 377, 28, -1, -1, KEY_ARROW_UP, -1, NULL, NULL, NULL, 32);
|
||||
if (upBtn == -1) {
|
||||
goto err_1;
|
||||
}
|
||||
|
@ -1558,7 +1563,7 @@ int _gdProcessInit()
|
|||
buttonSetMouseCallbacks(upBtn, _reply_arrow_up, _reply_arrow_restore, 0, 0);
|
||||
|
||||
// Bottom part of the reply window - scroll down.
|
||||
int downBtn = buttonCreate(gGameDialogReplyWindow, 1, 29, 377, 28, -1, -1, KEY_ARROW_DOWN, -1, NULL, NULL, NULL, 32);
|
||||
downBtn = buttonCreate(gGameDialogReplyWindow, 1, 29, 377, 28, -1, -1, KEY_ARROW_DOWN, -1, NULL, NULL, NULL, 32);
|
||||
if (downBtn == -1) {
|
||||
goto err_1;
|
||||
}
|
||||
|
@ -1566,8 +1571,8 @@ int _gdProcessInit()
|
|||
buttonSetCallbacks(downBtn, _gsound_red_butt_press, _gsound_red_butt_release);
|
||||
buttonSetMouseCallbacks(downBtn, _reply_arrow_down, _reply_arrow_restore, 0, 0);
|
||||
|
||||
int optionsWindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2 + GAME_DIALOG_OPTIONS_WINDOW_X;
|
||||
int optionsWindowY = (screenGetHeight() - GAME_DIALOG_WINDOW_HEIGHT) / 2 + GAME_DIALOG_OPTIONS_WINDOW_Y;
|
||||
optionsWindowX = (screenGetWidth() - GAME_DIALOG_WINDOW_WIDTH) / 2 + GAME_DIALOG_OPTIONS_WINDOW_X;
|
||||
optionsWindowY = (screenGetHeight() - GAME_DIALOG_WINDOW_HEIGHT) / 2 + GAME_DIALOG_OPTIONS_WINDOW_Y;
|
||||
gGameDialogOptionsWindow = windowCreate(optionsWindowX, optionsWindowY, GAME_DIALOG_OPTIONS_WINDOW_WIDTH, GAME_DIALOG_OPTIONS_WINDOW_HEIGHT, 256, WINDOW_FLAG_0x04);
|
||||
if (gGameDialogOptionsWindow == -1) {
|
||||
goto err_2;
|
||||
|
|
|
@ -46,7 +46,7 @@ const char* gMovieFileNames[MOVIE_COUNT] = {
|
|||
};
|
||||
|
||||
// 0x518DE4
|
||||
char* gMoviePaletteFilePaths[MOVIE_COUNT] = {
|
||||
const char* gMoviePaletteFilePaths[MOVIE_COUNT] = {
|
||||
NULL,
|
||||
"art\\cuts\\introsub.pal",
|
||||
"art\\cuts\\eldersub.pal",
|
||||
|
@ -209,7 +209,7 @@ int gameMoviePlay(int movie, int flags)
|
|||
int oldTextColor;
|
||||
int oldFont;
|
||||
if (subtitlesEnabled) {
|
||||
char* subtitlesPaletteFilePath;
|
||||
const char* subtitlesPaletteFilePath;
|
||||
if (gMoviePaletteFilePaths[movie] != NULL) {
|
||||
subtitlesPaletteFilePath = gMoviePaletteFilePaths[movie];
|
||||
} else {
|
||||
|
|
|
@ -35,7 +35,7 @@ typedef enum GameMovie {
|
|||
extern const float flt_50352A;
|
||||
|
||||
extern const char* gMovieFileNames[MOVIE_COUNT];
|
||||
extern char* gMoviePaletteFilePaths[MOVIE_COUNT];
|
||||
extern const char* gMoviePaletteFilePaths[MOVIE_COUNT];
|
||||
extern bool gGameMovieIsPlaying;
|
||||
extern bool gGameMovieFaded;
|
||||
|
||||
|
|
|
@ -40,12 +40,15 @@
|
|||
#include "word_wrap.h"
|
||||
#include "world_map.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <vector>
|
||||
#include <assert.h>
|
||||
#include <direct.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <algorithm>
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
#define LS_WINDOW_WIDTH 640
|
||||
#define LS_WINDOW_HEIGHT 480
|
||||
|
@ -2632,36 +2635,21 @@ int _EraseSave()
|
|||
{
|
||||
debugPrint("\nLOADSAVE: Erasing save(bad) slot...\n");
|
||||
|
||||
sprintf(_gmpath, "%s\\%s\\%s%.2d\\", _patches, "SAVEGAME", "SLOT", _slot_cursor + 1);
|
||||
strcpy(_str0, _gmpath);
|
||||
strcat(_str0, "SAVE.DAT");
|
||||
remove(_str0);
|
||||
std::stringstream slot;
|
||||
slot << "SLOT" << std::setw(2) << std::setfill( '0') << _slot_cursor + 1;
|
||||
|
||||
sprintf(_gmpath, "%s\\%s%.2d\\", "SAVEGAME", "SLOT", _slot_cursor + 1);
|
||||
sprintf(_str0, "%s*.%s", _gmpath, "SAV");
|
||||
// TODO: What's _patches value? Needs to be optimized.
|
||||
fs::path savePath(fs::path(_patches) / fs::path("SAVEGAME") / fs::path(slot.str()));
|
||||
|
||||
char** fileList;
|
||||
int fileListLength = fileNameListInit(_str0, &fileList, 0, 0);
|
||||
if (fileListLength == -1) {
|
||||
fs::remove(fs::path(savePath).append("SAVE.DAT"));
|
||||
|
||||
std::vector<fs::path> fileList = fileNameList(savePath, std::regex("^.+\\.SAV$"));
|
||||
if (fileList.empty())
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprintf(_gmpath, "%s\\%s\\%s%.2d\\", _patches, "SAVEGAME", "SLOT", _slot_cursor + 1);
|
||||
for (int index = fileListLength - 1; index >= 0; index--) {
|
||||
strcpy(_str0, _gmpath);
|
||||
strcat(_str0, fileList[index]);
|
||||
remove(_str0);
|
||||
}
|
||||
|
||||
fileNameListFree(&fileList, 0);
|
||||
|
||||
sprintf(_gmpath, "%s\\%s\\%s%.2d\\", _patches, "SAVEGAME", "SLOT", _slot_cursor + 1);
|
||||
|
||||
char* v1 = _strmfe(_str1, "AUTOMAP.DB", "SAV");
|
||||
strcpy(_str0, _gmpath);
|
||||
strcat(_str0, v1);
|
||||
|
||||
remove(_str0);
|
||||
std::for_each(fileList.begin(), fileList.end(), [] (const fs::path& p) {
|
||||
fs::remove(p);
|
||||
});
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
// 0x4E08A0
|
||||
bool mmxIsSupported()
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
return false;
|
||||
#else
|
||||
int v1;
|
||||
|
||||
// TODO: There are other ways to determine MMX using FLAGS register.
|
||||
|
@ -22,6 +25,7 @@ bool mmxIsSupported()
|
|||
}
|
||||
|
||||
return v1 != 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
// 0x4E0DB0
|
||||
|
|
|
@ -260,6 +260,9 @@ char _obj_seen[5001];
|
|||
// 0x488780
|
||||
int objectsInit(unsigned char* buf, int width, int height, int pitch)
|
||||
{
|
||||
int dudeFid;
|
||||
int eggFid;
|
||||
|
||||
memset(_obj_seen, 0, 5001);
|
||||
dword_639D98 = width + 320;
|
||||
_updateAreaPixelBounds = -320;
|
||||
|
@ -308,7 +311,7 @@ int objectsInit(unsigned char* buf, int width, int height, int pitch)
|
|||
gObjectsWindowBufferSize = height * width;
|
||||
gObjectsWindowPitch = pitch;
|
||||
|
||||
int dudeFid = buildFid(1, _art_vault_guy_num, 0, 0, 0);
|
||||
dudeFid = buildFid(1, _art_vault_guy_num, 0, 0, 0);
|
||||
objectCreateWithFidPid(&gDude, dudeFid, 0x1000000);
|
||||
|
||||
gDude->flags |= OBJECT_FLAG_0x400;
|
||||
|
@ -322,7 +325,7 @@ int objectsInit(unsigned char* buf, int width, int height, int pitch)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
int eggFid = buildFid(6, 2, 0, 0, 0);
|
||||
eggFid = buildFid(6, 2, 0, 0, 0);
|
||||
objectCreateWithFidPid(&gEgg, eggFid, -1);
|
||||
gEgg->flags |= OBJECT_FLAG_0x400;
|
||||
gEgg->flags |= OBJECT_TEMPORARY;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <windows.h>
|
||||
|
||||
#include <mmreg.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
#define DIRECTSOUND_VERSION 0x0300
|
||||
#include <dsound.h>
|
||||
|
|
Loading…
Reference in New Issue