mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-03 16:09:32 +00:00
WINTERMUTE: Remove the rest of the WIN32-specifics
This commit is contained in:
parent
01d6ff2121
commit
99ed2b2ae1
@ -3736,15 +3736,11 @@ bool CBGame::handleKeypress(Common::Event *event, bool printable) {
|
|||||||
stopVideo();
|
stopVideo();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#ifdef __WIN32__
|
|
||||||
// TODO: Do we really need to handle this in-engine?
|
if (event->type == Common::EVENT_QUIT) {
|
||||||
// handle Alt+F4 on windows
|
|
||||||
if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_F4 && (event->kbd.flags == Common::KBD_ALT)) {
|
|
||||||
onWindowClose();
|
onWindowClose();
|
||||||
return true;
|
return true;
|
||||||
//TODO
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) {
|
if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) {
|
||||||
// TODO: Handle alt-enter as well as alt-return.
|
// TODO: Handle alt-enter as well as alt-return.
|
||||||
|
@ -59,15 +59,6 @@ CBRegistry::~CBRegistry() {
|
|||||||
AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) {
|
AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) {
|
||||||
AnsiString ret = "";
|
AnsiString ret = "";
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
// check ini file first (so what we can use project files on windows)
|
|
||||||
char buffer[32768];
|
|
||||||
GetPrivateProfileString(subKey.c_str(), key.c_str(), init.c_str(), buffer, 32768, _iniName);
|
|
||||||
ret = AnsiString(buffer);
|
|
||||||
|
|
||||||
if (buffer != init) return ret;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
ret = getValue(_localValues, subKey, key, found);
|
ret = getValue(_localValues, subKey, key, found);
|
||||||
if (!found) ret = getValue(_values, subKey, key, found);
|
if (!found) ret = getValue(_values, subKey, key, found);
|
||||||
@ -86,11 +77,6 @@ bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, co
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) {
|
int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) {
|
||||||
#ifdef __WIN32__
|
|
||||||
int ret = GetPrivateProfileInt(subKey.c_str(), key.c_str(), init, _iniName);
|
|
||||||
if (ret != init) return ret;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
AnsiString val = readString(subKey, key, "");
|
AnsiString val = readString(subKey, key, "");
|
||||||
if (val.empty()) return init;
|
if (val.empty()) return init;
|
||||||
else return atoi(val.c_str());
|
else return atoi(val.c_str());
|
||||||
|
@ -1339,201 +1339,12 @@ CScScript::TExternalFunction *CScScript::getExternal(char *name) {
|
|||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
ERRORCODE CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) {
|
ERRORCODE CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) {
|
||||||
|
|
||||||
#ifndef __WIN32__
|
|
||||||
|
|
||||||
Game->LOG(0, "External functions are not supported on this platform.");
|
Game->LOG(0, "External functions are not supported on this platform.");
|
||||||
stack->correctParams(0);
|
stack->correctParams(0);
|
||||||
stack->pushNULL();
|
stack->pushNULL();
|
||||||
return STATUS_FAILED;
|
return STATUS_FAILED;
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
bool Success = false;
|
|
||||||
HMODULE hDll = LoadLibrary(Function->dll_name);
|
|
||||||
|
|
||||||
if (hDll) {
|
|
||||||
FARPROC pFunc = GetProcAddress(hDll, Function->name);
|
|
||||||
if (pFunc) {
|
|
||||||
int i;
|
|
||||||
Success = true;
|
|
||||||
stack->correctParams(Function->nu_params);
|
|
||||||
CBDynBuffer *Buffer = new CBDynBuffer(Game, 20 * sizeof(uint32));
|
|
||||||
|
|
||||||
for (i = 0; i < Function->nu_params; i++) {
|
|
||||||
CScValue *Val = stack->pop();
|
|
||||||
switch (Function->params[i]) {
|
|
||||||
case TYPE_BOOL:
|
|
||||||
buffer->PutDWORD((uint32)Val->getBool());
|
|
||||||
break;
|
|
||||||
case TYPE_LONG:
|
|
||||||
buffer->PutDWORD(Val->getInt());
|
|
||||||
break;
|
|
||||||
case TYPE_BYTE:
|
|
||||||
buffer->PutDWORD((byte)Val->getInt());
|
|
||||||
break;
|
|
||||||
case TYPE_STRING:
|
|
||||||
if (Val->isNULL()) buffer->PutDWORD(0);
|
|
||||||
else buffer->PutDWORD((uint32)Val->getString());
|
|
||||||
break;
|
|
||||||
case TYPE_MEMBUFFER:
|
|
||||||
if (Val->isNULL()) buffer->PutDWORD(0);
|
|
||||||
else buffer->PutDWORD((uint32)Val->getMemBuffer());
|
|
||||||
break;
|
|
||||||
case TYPE_FLOAT: {
|
|
||||||
float f = Val->getFloat();
|
|
||||||
buffer->PutDWORD(*((uint32 *)&f));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TYPE_DOUBLE: {
|
|
||||||
double d = Val->getFloat();
|
|
||||||
uint32 *pd = (uint32 *)&d;
|
|
||||||
|
|
||||||
buffer->PutDWORD(pd[0]);
|
|
||||||
buffer->PutDWORD(pd[1]);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// call
|
|
||||||
uint32 ret;
|
|
||||||
bool StackCorrupted = false;
|
|
||||||
switch (Function->call_type) {
|
|
||||||
case CALL_CDECL:
|
|
||||||
ret = Call_cdecl(buffer->_buffer, buffer->GetSize(), (uint32)pFunc, &StackCorrupted);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ret = Call_stdcall(buffer->_buffer, buffer->GetSize(), (uint32)pFunc, &StackCorrupted);
|
|
||||||
}
|
|
||||||
delete Buffer;
|
|
||||||
|
|
||||||
// return
|
|
||||||
switch (Function->returns) {
|
|
||||||
case TYPE_BOOL:
|
|
||||||
stack->pushBool((byte)ret != 0);
|
|
||||||
break;
|
|
||||||
case TYPE_LONG:
|
|
||||||
stack->pushInt(ret);
|
|
||||||
break;
|
|
||||||
case TYPE_BYTE:
|
|
||||||
stack->pushInt((byte)ret);
|
|
||||||
break;
|
|
||||||
break;
|
|
||||||
case TYPE_STRING:
|
|
||||||
stack->pushString((char *)ret);
|
|
||||||
break;
|
|
||||||
case TYPE_MEMBUFFER: {
|
|
||||||
CSXMemBuffer *Buf = new CSXMemBuffer(Game, (void *)ret);
|
|
||||||
stack->pushNative(Buf, false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case TYPE_FLOAT: {
|
|
||||||
uint32 dw = GetST0();
|
|
||||||
stack->pushFloat(*((float *)&dw));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TYPE_DOUBLE:
|
|
||||||
stack->pushFloat(GetST0Double());
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
stack->pushNULL();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StackCorrupted) RuntimeError("Warning: Stack corrupted after calling '%s' in '%s'\n Check parameters and/or calling convention.", Function->name, Function->dll_name);
|
|
||||||
} else RuntimeError("Exported function '%s' not found in '%s'", Function->name, Function->dll_name);
|
|
||||||
} else RuntimeError("Error loading DLL '%s'", Function->dll_name);
|
|
||||||
|
|
||||||
if (!Success) {
|
|
||||||
stack->correctParams(0);
|
|
||||||
stack->pushNULL();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hDll) FreeLibrary(hDll);
|
|
||||||
|
|
||||||
return Success ? STATUS_OK : STATUS_FAILED;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
uint32 CScScript::Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt) {
|
|
||||||
uint32 rc; // here's our return value...
|
|
||||||
uint32 OrigESP;
|
|
||||||
bool StkCorrupt = false;
|
|
||||||
__asm {
|
|
||||||
mov OrigESP, esp
|
|
||||||
mov ecx, sz // get size of buffer
|
|
||||||
mov esi, args // get buffer
|
|
||||||
sub esp, ecx // allocate stack space
|
|
||||||
mov edi, esp // start of destination stack frame
|
|
||||||
shr ecx, 2 // make it dwords
|
|
||||||
rep movsd // copy params to real stack
|
|
||||||
call [func] // call the function
|
|
||||||
mov rc, eax // save the return value
|
|
||||||
add esp, sz // restore the stack pointer
|
|
||||||
cmp esp, OrigESP
|
|
||||||
jz finish
|
|
||||||
mov esp, OrigESP
|
|
||||||
mov StkCorrupt, 1
|
|
||||||
finish:
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StackCorrupt) *StackCorrupt = StkCorrupt;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
uint32 CScScript::Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt) {
|
|
||||||
uint32 rc; // here's our return value...
|
|
||||||
uint32 OrigESP;
|
|
||||||
bool StkCorrupt = false;
|
|
||||||
|
|
||||||
__asm {
|
|
||||||
mov OrigESP, esp
|
|
||||||
mov ecx, sz // get size of buffer
|
|
||||||
mov esi, args // get buffer
|
|
||||||
sub esp, ecx // allocate stack space
|
|
||||||
mov edi, esp // start of destination stack frame
|
|
||||||
shr ecx, 2 // make it dwords
|
|
||||||
rep movsd // copy it
|
|
||||||
call [func] // call the function
|
|
||||||
mov rc, eax // save the return value
|
|
||||||
cmp esp, OrigESP
|
|
||||||
jz finish
|
|
||||||
mov esp, OrigESP
|
|
||||||
mov StkCorrupt, 1
|
|
||||||
finish:
|
|
||||||
}
|
|
||||||
|
|
||||||
if (StackCorrupt) *StackCorrupt = StkCorrupt;
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
__declspec(naked) uint32 CScScript::GetST0(void) {
|
|
||||||
uint32 f; // temp var
|
|
||||||
__asm {
|
|
||||||
fstp uint32 ptr [f] // pop ST0 into f
|
|
||||||
mov eax, uint32 ptr [f] // copy into eax
|
|
||||||
ret // done
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
double CScScript::GetST0Double(void) {
|
|
||||||
double d; // temp var
|
|
||||||
__asm {
|
|
||||||
fstp qword ptr [d] // get ST0 into d
|
|
||||||
}
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
ERRORCODE CScScript::copyParameters(CScStack *stack) {
|
ERRORCODE CScScript::copyParameters(CScStack *stack) {
|
||||||
|
@ -56,13 +56,6 @@ public:
|
|||||||
|
|
||||||
void afterLoad();
|
void afterLoad();
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
static uint32 Call_cdecl(const void *args, size_t sz, uint32 func, bool *StackCorrupt);
|
|
||||||
static uint32 Call_stdcall(const void *args, size_t sz, uint32 func, bool *StackCorrupt);
|
|
||||||
static uint32 GetST0(void);
|
|
||||||
static double GetST0Double(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CScValue *_operand;
|
CScValue *_operand;
|
||||||
CScValue *_reg1;
|
CScValue *_reg1;
|
||||||
bool _freezable;
|
bool _freezable;
|
||||||
|
@ -337,17 +337,17 @@ bool CBPlatform::equalRect(Common::Rect *rect1, Common::Rect *rect2) {
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
AnsiString CBPlatform::getSystemFontPath() {
|
AnsiString CBPlatform::getSystemFontPath() {
|
||||||
#ifdef __WIN32__
|
/*#ifdef __WIN32__
|
||||||
// we're looking for something like "c:\windows\fonts\";
|
// we're looking for something like "c:\windows\fonts\";
|
||||||
char winDir[MAX_PATH_LENGTH + 1];
|
char winDir[MAX_PATH_LENGTH + 1];
|
||||||
winDir[MAX_PATH_LENGTH] = '\0';
|
winDir[MAX_PATH_LENGTH] = '\0';
|
||||||
::GetWindowsDirectory(winDir, MAX_PATH_LENGTH);
|
::GetWindowsDirectory(winDir, MAX_PATH_LENGTH);
|
||||||
return PathUtil::Combine(AnsiString(winDir), "fonts");
|
return PathUtil::Combine(AnsiString(winDir), "fonts");
|
||||||
#else
|
#else*/
|
||||||
// !PORTME
|
// !PORTME
|
||||||
//return "/Library/Fonts/";
|
//return "/Library/Fonts/";
|
||||||
return "";
|
return "";
|
||||||
#endif
|
//#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -64,11 +64,8 @@ CUIEdit::CUIEdit(CBGame *inGame): CUIObject(inGame) {
|
|||||||
_cursorChar = NULL;
|
_cursorChar = NULL;
|
||||||
setCursorChar("|");
|
setCursorChar("|");
|
||||||
|
|
||||||
#ifdef __WIN32__
|
|
||||||
_cursorBlinkRate = GetCaretBlinkTime();
|
|
||||||
#else
|
|
||||||
_cursorBlinkRate = 600;
|
_cursorBlinkRate = 600;
|
||||||
#endif
|
|
||||||
_frameWidth = 0;
|
_frameWidth = 0;
|
||||||
|
|
||||||
setText("");
|
setText("");
|
||||||
|
@ -115,7 +115,7 @@ AnsiString PathUtil::getExtension(const AnsiString &path) {
|
|||||||
AnsiString PathUtil::getSafeLogFileName() {
|
AnsiString PathUtil::getSafeLogFileName() {
|
||||||
AnsiString logFileName = getUserDirectory();
|
AnsiString logFileName = getUserDirectory();
|
||||||
|
|
||||||
#ifdef __WIN32__
|
/*#ifdef __WIN32__
|
||||||
char moduleName[MAX_PATH_LENGTH];
|
char moduleName[MAX_PATH_LENGTH];
|
||||||
::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH);
|
::GetModuleFileName(NULL, moduleName, MAX_PATH_LENGTH);
|
||||||
|
|
||||||
@ -123,10 +123,10 @@ AnsiString PathUtil::getSafeLogFileName() {
|
|||||||
fileName = Combine("/Wintermute Engine/Logs/", fileName);
|
fileName = Combine("/Wintermute Engine/Logs/", fileName);
|
||||||
logFileName = Combine(logFileName, fileName);
|
logFileName = Combine(logFileName, fileName);
|
||||||
|
|
||||||
#else
|
#else*/
|
||||||
// !PORTME
|
// !PORTME
|
||||||
logFileName = combine(logFileName, "/Wintermute Engine/wme.log");
|
logFileName = combine(logFileName, "/Wintermute Engine/wme.log");
|
||||||
#endif
|
//#endif
|
||||||
|
|
||||||
createDirectory(getDirectoryName(logFileName));
|
createDirectory(getDirectoryName(logFileName));
|
||||||
return logFileName;
|
return logFileName;
|
||||||
|
Loading…
Reference in New Issue
Block a user