More Android stub-outs and bug fixes. Fix broken SDL fiber sync.

This commit is contained in:
elasota
2020-10-10 02:42:06 -04:00
parent a2f19f5ccb
commit 5c98783bbb
63 changed files with 1445 additions and 635 deletions

View File

@@ -28,7 +28,7 @@ namespace GpFiberStarter_Win32
}
}
IGpFiber *GpFiberStarter::StartFiber(ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
IGpFiber *GpFiberStarter::StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
{
ULONG_PTR lowLimit;
ULONG_PTR highLimit;

View File

@@ -8,9 +8,9 @@ void GpThreadEvent_Win32::Wait()
WaitForSingleObject(m_event, INFINITE);
}
void GpThreadEvent_Win32::WaitTimed(uint32_t msec)
bool GpThreadEvent_Win32::WaitTimed(uint32_t msec)
{
WaitForSingleObject(m_event, static_cast<DWORD>(msec));
return WaitForSingleObject(m_event, static_cast<DWORD>(msec)) == WAIT_OBJECT_0;
}
void GpThreadEvent_Win32::Signal()

View File

@@ -8,7 +8,7 @@ class GpThreadEvent_Win32 final : public PortabilityLayer::HostThreadEvent
{
public:
void Wait() override;
void WaitTimed(uint32_t msec) override;
bool WaitTimed(uint32_t msec) override;
void Signal() override;
void Destroy() override;

View File

@@ -1 +1,13 @@
AerofoilSDL
Common
FreeType
GpApp
GpCommon
GpFontHandler_FreeType2
GpShell
MacRomanConversion
PortabilityLayer
rapidjson
SDL2
stb
zlib

View File

@@ -2,7 +2,7 @@
# Uncomment this if you're using STL in your project
# You can find more information here:
# https://developer.android.com/ndk/guides/cpp-support
# APP_STL := c++_shared
APP_STL := c++_shared
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64

View File

@@ -6,13 +6,25 @@ LOCAL_MODULE := main
SDL_PATH := ../SDL
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(SDL_PATH)/include \
$(LOCAL_PATH)/../GpShell \
$(LOCAL_PATH)/../GpCommon \
$(LOCAL_PATH)/../AerofoilSDL \
$(LOCAL_PATH)/../Common \
$(LOCAL_PATH)/../PortabilityLayer
LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
# Add your application source files here...
LOCAL_SRC_FILES := YourSourceHere.c
LOCAL_SRC_FILES := \
GpMain_SDL_Android.cpp \
GpSystemServices_Android.cpp \
GpFileSystem_Android.cpp
LOCAL_SHARED_LIBRARIES := SDL2
LOCAL_STATIC_LIBRARIES := GpShell GpFontHandler_FreeType2 AerofoilSDL GpApp
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog
include $(BUILD_SHARED_LIBRARY)

View File

@@ -0,0 +1,5 @@
#pragma once
struct GpAndroidGlobals
{
};

View File

@@ -0,0 +1,84 @@
#include "GpFileSystem_Android.h"
GpFileSystem_Android::GpFileSystem_Android()
{
}
bool GpFileSystem_Android::FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path)
{
return false;
}
bool GpFileSystem_Android::FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists)
{
return false;
}
GpIOStream *GpFileSystem_Android::OpenFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, GpFileCreationDisposition_t createDisposition)
{
return nullptr;
}
bool GpFileSystem_Android::DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed)
{
existed = false;
return false;
}
PortabilityLayer::HostDirectoryCursor *GpFileSystem_Android::ScanDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory)
{
return nullptr;
}
bool GpFileSystem_Android::ValidateFilePath(const char *path, size_t length) const
{
for (size_t i = 0; i < length; i++)
{
const char c = path[i];
if (c >= '0' && c <= '9')
continue;
if (c == '_' || c == '.' || c == '\'')
continue;
if (c == ' ' && i != 0 && i != length - 1)
continue;
if (c >= 'a' && c <= 'z')
continue;
if (c >= 'A' && c <= 'Z')
continue;
return false;
}
return true;
}
bool GpFileSystem_Android::ValidateFilePathUnicodeChar(uint32_t c) const
{
if (c >= '0' && c <= '9')
return true;
if (c == '_' || c == '\'')
return true;
if (c == ' ')
return true;
if (c >= 'a' && c <= 'z')
return true;
if (c >= 'A' && c <= 'Z')
return true;
return false;
}
GpFileSystem_Android *GpFileSystem_Android::GetInstance()
{
return &ms_instance;
}
GpFileSystem_Android GpFileSystem_Android::ms_instance;

View File

@@ -0,0 +1,27 @@
#pragma once
#include "HostFileSystem.h"
#include "GpCoreDefs.h"
class GpFileSystem_Android final : public PortabilityLayer::HostFileSystem
{
public:
GpFileSystem_Android();
bool FileExists(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path) override;
bool FileLocked(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool *exists) override;
GpIOStream *OpenFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool writeAccess, GpFileCreationDisposition_t createDisposition) override;
bool DeleteFile(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, bool &existed) override;
PortabilityLayer::HostDirectoryCursor *ScanDirectory(PortabilityLayer::VirtualDirectory_t virtualDirectory) override;
bool ValidateFilePath(const char *path, size_t sz) const override;
bool ValidateFilePathUnicodeChar(uint32_t ch) const override;
static GpFileSystem_Android *GetInstance();
private:
bool ResolvePath(PortabilityLayer::VirtualDirectory_t virtualDirectory, const char *path, wchar_t *outPath);
static GpFileSystem_Android ms_instance;
};

View File

@@ -4,7 +4,6 @@
#include "GpAudioDriverFactory.h"
#include "GpDisplayDriverFactory.h"
#include "GpGlobalConfig.h"
#include "GpFiber_Win32.h"
#include "GpFiber_SDL.h"
#include "GpFileSystem_Android.h"
#include "GpFontHandlerFactory.h"
@@ -19,8 +18,6 @@
#include "GpAndroid.h"
#include "resource.h"
GpAndroidGlobals g_gpAndroidGlobals;
extern "C" IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
@@ -29,17 +26,19 @@ IGpDisplayDriver *GpDriver_CreateDisplayDriver_SDL_GL2(const GpDisplayDriverProp
IGpAudioDriver *GpDriver_CreateAudioDriver_SDL(const GpAudioDriverProperties &properties);
int main(int argc, const char **argv)
int main(int argc, char* argv[])
{
if (SDL_Init(SDL_INIT_VIDEO) < 0)
return -1;
SDL_GL_LoadLibrary("libGLESv2.so");
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Android::GetInstance());
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Android::GetInstance());
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2;
g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_SDL2;
g_gpGlobalConfig.m_audioDriverType = EGpAudioDriverType_None;
g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_FreeType2;
@@ -54,13 +53,7 @@ int main(int argc, const char **argv)
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL);
GpFontHandlerFactory::RegisterFontHandlerFactory(EGpFontHandlerType_FreeType2, GpDriver_CreateFontHandler_FreeType2);
if (logger)
logger->Printf(IGpLogDriver::Category_Information, "SDL environment configured, starting up");
int returnCode = GpMain::Run();
if (logger)
logger->Printf(IGpLogDriver::Category_Information, "SDL environment exited with code %i, cleaning up", returnCode);
return returnCode;
}

View File

@@ -0,0 +1,174 @@
#include "GpSystemServices_Android.h"
#include "HostMutex.h"
#include "HostThreadEvent.h"
#include <time.h>
#include <mutex>
#include <condition_variable>
template<class TMutex>
class GpMutex_Cpp11 final : public PortabilityLayer::HostMutex
{
public:
GpMutex_Cpp11();
~GpMutex_Cpp11();
void Destroy() override;
void Lock() override;
void Unlock() override;
private:
TMutex m_mutex;
};
template<class TMutex>
GpMutex_Cpp11<TMutex>::GpMutex_Cpp11()
{
}
template<class TMutex>
GpMutex_Cpp11<TMutex>::~GpMutex_Cpp11()
{
}
template<class TMutex>
void GpMutex_Cpp11<TMutex>::Destroy()
{
this->~GpMutex_Cpp11();
free(this);
}
template<class TMutex>
void GpMutex_Cpp11<TMutex>::Lock()
{
m_mutex.lock();
}
template<class TMutex>
void GpMutex_Cpp11<TMutex>::Unlock()
{
m_mutex.unlock();
}
typedef GpMutex_Cpp11<std::mutex> GpMutex_Cpp11_Vanilla;
typedef GpMutex_Cpp11<std::recursive_mutex> GpMutex_Cpp11_Recursive;
class GpThreadEvent_Cpp11 final : public PortabilityLayer::HostThreadEvent
{
public:
GpThreadEvent_Cpp11();
~GpThreadEvent_Cpp11();
void Wait() override;
bool WaitTimed(uint32_t msec) override;
void Signal() override;
void Destroy() override;
private:
std::mutex m_mutex;
std::condition_variable m_cvar;
bool m_flag;
};
GpThreadEvent_Cpp11::GpThreadEvent_Cpp11()
: m_flag(false)
{
}
GpThreadEvent_Cpp11::~GpThreadEvent_Cpp11()
{
}
void GpThreadEvent_Cpp11::Wait()
{
std::unique_lock<std::mutex> lock(m_mutex);
m_cvar.wait(lock,[&]()->bool{ return m_flag; });
}
bool GpThreadEvent_Cpp11::WaitTimed(uint32_t msec)
{
std::unique_lock<std::mutex> lock(m_mutex);
if (!m_cvar.wait_for(lock, std::chrono::milliseconds(msec), [&]()->bool{ return m_flag; }))
return false;
return true;
}
void GpThreadEvent_Cpp11::Signal()
{
m_mutex.lock();
m_flag = true;
m_mutex.unlock();
m_cvar.notify_all();
}
void GpThreadEvent_Cpp11::Destroy()
{
this->~GpThreadEvent_Cpp11();
free(this);
}
GpSystemServices_Android::GpSystemServices_Android()
{
}
int64_t GpSystemServices_Android::GetTime() const
{
time_t t = time(nullptr);
return static_cast<int64_t>(t) - 2082844800;
}
void GpSystemServices_Android::GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const
{
time_t t = time(nullptr);
tm *tmObject = localtime(&t);
year = static_cast<unsigned int>(tmObject->tm_year);
month = static_cast<unsigned int>(tmObject->tm_mon);
hour = static_cast<unsigned int>(tmObject->tm_hour);
minute = static_cast<unsigned int>(tmObject->tm_min);
second = static_cast<unsigned int>(tmObject->tm_sec);
}
PortabilityLayer::HostMutex *GpSystemServices_Android::CreateMutex()
{
GpMutex_Cpp11_Vanilla *mutex = static_cast<GpMutex_Cpp11_Vanilla*>(malloc(sizeof(GpMutex_Cpp11_Vanilla)));
if (!mutex)
return nullptr;
return new (mutex) GpMutex_Cpp11_Vanilla();
}
PortabilityLayer::HostMutex *GpSystemServices_Android::CreateRecursiveMutex()
{
GpMutex_Cpp11_Recursive *mutex = static_cast<GpMutex_Cpp11_Recursive*>(malloc(sizeof(GpMutex_Cpp11_Recursive)));
if (!mutex)
return nullptr;
return new (mutex) GpMutex_Cpp11_Recursive();
}
PortabilityLayer::HostThreadEvent *GpSystemServices_Android::CreateThreadEvent(bool autoReset, bool startSignaled)
{
GpThreadEvent_Cpp11 *evt = static_cast<GpThreadEvent_Cpp11*>(malloc(sizeof(GpThreadEvent_Cpp11)));
if (!evt)
return nullptr;
return new (evt) GpThreadEvent_Cpp11();
}
uint64_t GpSystemServices_Android::GetFreeMemoryCosmetic() const
{
return 0;
}
void GpSystemServices_Android::Beep() const
{
}
GpSystemServices_Android *GpSystemServices_Android::GetInstance()
{
return &ms_instance;
}
GpSystemServices_Android GpSystemServices_Android::ms_instance;

View File

@@ -0,0 +1,23 @@
#pragma once
#include "HostSystemServices.h"
#include "GpCoreDefs.h"
class GpSystemServices_Android final : public PortabilityLayer::HostSystemServices
{
public:
GpSystemServices_Android();
int64_t GetTime() const override;
void GetLocalDateTime(unsigned int &year, unsigned int &month, unsigned int &day, unsigned int &hour, unsigned int &minute, unsigned int &second) const override;
PortabilityLayer::HostMutex *CreateMutex() override;
PortabilityLayer::HostMutex *CreateRecursiveMutex() override;
PortabilityLayer::HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) override;
uint64_t GetFreeMemoryCosmetic() const override;
void Beep() const override;
static GpSystemServices_Android *GetInstance();
private:
static GpSystemServices_Android ms_instance;
};

View File

@@ -0,0 +1 @@
assets

View File

@@ -3,6 +3,20 @@
call remove_symlinks.bat
mklink /D app\jni\AerofoilSDL ..\..\..\AerofoilSDL
mklink /D app\jni\Common ..\..\..\Common
mklink /D app\jni\SDL2 ..\..\..\SDL2-2.0.12
mklink /D app\jni\GpApp ..\..\..\GpApp
mklink /D app\jni\GpShell ..\..\..\GpShell
mklink /D app\jni\GpCommon ..\..\..\GpCommon
mklink /D app\jni\GpFontHandler_FreeType2 ..\..\..\GpFontHandler_FreeType2
mklink /D app\jni\PortabilityLayer ..\..\..\PortabilityLayer
mklink /D app\jni\FreeType ..\..\..\FreeType
mklink /D app\jni\zlib ..\..\..\zlib
mklink /D app\jni\rapidjson ..\..\..\rapidjson
mklink /D app\jni\MacRomanConversion ..\..\..\MacRomanConversion
mklink /D app\jni\stb ..\..\..\stb
mklink /D app\src\main\assets ..\..\..\..\Packaged
pause

View File

@@ -1,4 +1,17 @@
@setlocal enableextensions
@cd /d "%~dp0"
rmdir app\jni\AerofoilSDL
rmdir app\jni\Common
rmdir app\jni\SDL2
rmdir app\jni\GpShell
rmdir app\jni\GpCommon
rmdir app\jni\GpApp
rmdir app\jni\GpFontHandler_FreeType2
rmdir app\jni\PortabilityLayer
rmdir app\jni\FreeType
rmdir app\jni\zlib
rmdir app\jni\rapidjson
rmdir app\jni\MacRomanConversion
rmdir app\jni\stb
rmdir app\src\main\assets

View File

@@ -87,6 +87,7 @@
<ClCompile Include="..\Aerofoil\GpColorCursor_Win32.cpp" />
<ClCompile Include="..\Aerofoil\GpFileStream_Win32.cpp" />
<ClCompile Include="..\Aerofoil\GpFileSystem_Win32.cpp" />
<ClCompile Include="..\Aerofoil\GpLogDriver_Win32.cpp" />
<ClCompile Include="..\Aerofoil\GpMutex_Win32.cpp" />
<ClCompile Include="..\Aerofoil\GpSystemServices_Win32.cpp" />
<ClCompile Include="..\Aerofoil\GpThreadEvent_Win32.cpp" />

View File

@@ -60,6 +60,9 @@
<ClCompile Include="GpAudioDriver_SDL2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\Aerofoil\GpLogDriver_Win32.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="ShaderCode\Functions.h">

28
AerofoilSDL/Android.mk Normal file
View File

@@ -0,0 +1,28 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := AerofoilSDL
SDL_PATH := ../SDL2
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../GpCommon \
$(LOCAL_PATH)/../GpShell \
$(LOCAL_PATH)/../Common \
$(LOCAL_PATH)/../PortabilityLayer \
$(LOCAL_PATH)/$(SDL_PATH)/include
LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
# Add your application source files here...
LOCAL_SRC_FILES := \
GpAudioDriver_SDL2.cpp \
GpDisplayDriver_SDL_GL2.cpp \
GpFiber_SDL.cpp \
GpFiberStarter_SDL.cpp \
ShaderCode/DrawQuadPaletteP.cpp \
ShaderCode/DrawQuadV.cpp \
ShaderCode/ScaleQuadP.cpp
include $(BUILD_STATIC_LIBRARY)

View File

@@ -62,7 +62,7 @@ struct GpAudioChannelBufferChain_SDL2 final
bool m_hasTrigger;
};
GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) class GpAudioChannel_SDL2 final : public IGpAudioChannel
class GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) GpAudioChannel_SDL2 final : public IGpAudioChannel
{
public:
enum ChannelState
@@ -104,7 +104,7 @@ private:
ChannelState m_channelState;
};
GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) class GpAudioDriver_SDL2 final : public IGpAudioDriver, public IGpPrefsHandler
class GP_ALIGNED(GP_SYSTEM_MEMORY_ALIGNMENT) GpAudioDriver_SDL2 final : public IGpAudioDriver, public IGpPrefsHandler
{
public:
friend class GpAudioChannel_SDL2;

View File

@@ -4,10 +4,11 @@
#include "GpComPtr.h"
#include "GpFiber_SDL.h"
#include "GpDisplayDriverProperties.h"
#include "GpSystemServices_Win32.h"
#include "GpWindows.h" // TODO: Remove
//#include "GpSystemServices_Win32.h"
//#include "GpWindows.h" // TODO: Remove
#include "GpVOSEvent.h"
#include "GpRingBuffer.h"
#include "HostSystemServices.h"
#include "IGpCursor.h"
#include "IGpDisplayDriverSurface.h"
#include "IGpLogDriver.h"
@@ -152,7 +153,6 @@ struct GpGLFunctions
PFNGLGENBUFFERSPROC GenBuffers;
PFNGLBUFFERDATAPROC BufferData;
PFNGLMAPBUFFERPROC MapBuffer;
PFNGLBINDBUFFERPROC BindBuffer;
PFNGLDELETEBUFFERSPROC DeleteBuffers;
@@ -823,8 +823,6 @@ private:
SDL_Cursor *m_arrowCursor;
bool m_cursorIsHidden;
UINT m_expectedSyncDelta;
bool m_isResettingSwapChain;
bool m_isFullScreen;
@@ -854,7 +852,6 @@ private:
IGpFiber *m_vosFiber;
PortabilityLayer::HostThreadEvent *m_vosEvent;
GpWindowsGlobals *m_osGlobals;
float m_bgColor[4];
bool m_bgIsDark;
@@ -896,6 +893,9 @@ GpDisplayDriverSurface_GL2::GpDisplayDriverSurface_GL2(GpDisplayDriver_SDL_GL2 *
assert(pitch % 4 == 0);
paddingPixels = pitch / 4 - width;
break;
default:
assert(false);
paddingPixels = 0;
}
m_paddedTextureWidth = width + paddingPixels;
@@ -1082,7 +1082,6 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
, m_lastFullScreenToggleTimeStamp(0)
, m_bgIsDark(false)
, m_useICCProfile(false)
, m_osGlobals(static_cast<GpWindowsGlobals*>(properties.m_osGlobals))
, m_properties(properties)
, m_syncTimeBase(std::chrono::time_point<std::chrono::high_resolution_clock>::duration::zero())
, m_waitCursor(nullptr)
@@ -1112,7 +1111,7 @@ static bool LookupOpenGLFunction(T &target, const char *name)
void *proc = SDL_GL_GetProcAddress(name);
if (proc)
{
target = static_cast<T>(proc);
target = reinterpret_cast<T>(proc);
return true;
}
else
@@ -1139,12 +1138,6 @@ bool GpGLFunctions::LookUpFunctions()
LOOKUP_FUNC(CheckFramebufferStatus);
LOOKUP_FUNC(DeleteFramebuffers);
LOOKUP_FUNC(GenBuffers);
LOOKUP_FUNC(BufferData);
LOOKUP_FUNC(MapBuffer);
LOOKUP_FUNC(BindBuffer);
LOOKUP_FUNC(DeleteBuffers);
LOOKUP_FUNC(CreateProgram);
LOOKUP_FUNC(DeleteProgram);
LOOKUP_FUNC(LinkProgram);
@@ -1152,6 +1145,11 @@ bool GpGLFunctions::LookUpFunctions()
LOOKUP_FUNC(GetProgramiv);
LOOKUP_FUNC(GetProgramInfoLog);
LOOKUP_FUNC(GenBuffers);
LOOKUP_FUNC(BufferData);
LOOKUP_FUNC(BindBuffer);
LOOKUP_FUNC(DeleteBuffers);
LOOKUP_FUNC(GetUniformLocation);
LOOKUP_FUNC(GetAttribLocation);
LOOKUP_FUNC(Uniform4fv);
@@ -1671,7 +1669,7 @@ void GpDisplayDriver_SDL_GL2::Run()
IGpLogDriver *logger = m_properties.m_logger;
m_vosEvent = GpSystemServices_Win32::GetInstance()->CreateThreadEvent(true, false);
m_vosEvent = m_properties.m_systemServices->CreateThreadEvent(true, false);
m_vosFiber = new GpFiber_SDL(nullptr, m_vosEvent);
m_window = SDL_CreateWindow(GP_APPLICATION_NAME, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, m_windowWidthPhysical, m_windowHeightPhysical, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
@@ -1685,10 +1683,6 @@ void GpDisplayDriver_SDL_GL2::Run()
InitResources(m_windowWidthVirtual, m_windowHeightVirtual);
LARGE_INTEGER lastTimestamp;
memset(&lastTimestamp, 0, sizeof(lastTimestamp));
MSG msg;
for (;;)
{
SDL_Event msg;
@@ -2320,13 +2314,13 @@ bool GpDisplayDriver_SDL_GL2::ResizeOpenGLWindow(uint32_t &windowWidth, uint32_t
if (desiredWidth < 640)
desiredWidth = 640;
else if (desiredWidth > MAXDWORD)
desiredWidth = MAXDWORD;
else if (desiredWidth > 32768)
desiredWidth = 32768;
if (desiredHeight < 480)
desiredHeight = 480;
else if (desiredHeight > MAXDWORD)
desiredHeight = MAXDWORD;
else if (desiredHeight > 32768)
desiredHeight = 32768;
if (logger)
logger->Printf(IGpLogDriver::Category_Information, "ResizeOpenGLWindow: Adjusted dimensions: %i x %i", static_cast<int>(desiredWidth), static_cast<int>(desiredHeight));
@@ -2432,8 +2426,8 @@ void GpDisplayDriver_SDL_GL2::ScaleVirtualScreen()
{
static_cast<float>(static_cast<double>(m_windowWidthVirtual) / static_cast<double>(m_windowWidthPhysical)),
static_cast<float>(static_cast<double>(m_windowHeightVirtual) / static_cast<double>(m_windowHeightPhysical)),
m_windowWidthVirtual,
m_windowHeightVirtual
static_cast<float>(m_windowWidthVirtual),
static_cast<float>(m_windowHeightVirtual)
};
m_gl.Uniform4fv(m_scaleQuadProgram.m_pixelDXDYDimensionsLocation, 1, reinterpret_cast<const GLfloat*>(dxdy_dimensions));

View File

@@ -1,7 +1,7 @@
#include "GpFiberStarter.h"
#include "GpFiber_SDL.h"
#include "GpSystemServices_Win32.h"
#include "HostSystemServices.h"
#include "HostThreadEvent.h"
#include "SDL_thread.h"
@@ -14,6 +14,7 @@ namespace GpFiberStarter_SDL
{
GpFiberStarter::ThreadFunc_t m_threadFunc;
PortabilityLayer::HostThreadEvent *m_creatingReturnEvent;
PortabilityLayer::HostThreadEvent *m_creatingWakeEvent;
void *m_context;
};
@@ -23,29 +24,47 @@ namespace GpFiberStarter_SDL
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
PortabilityLayer::HostThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
PortabilityLayer::HostThreadEvent *wakeEvent = tss->m_creatingWakeEvent;
void *context = tss->m_context;
creatingReturnEvent->Signal();
wakeEvent->Wait();
threadFunc(context);
return 0;
}
}
IGpFiber *GpFiberStarter::StartFiber(ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
IGpFiber *GpFiberStarter::StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber)
{
PortabilityLayer::HostThreadEvent *returnEvent = GpSystemServices_Win32::GetInstance()->CreateThreadEvent(true, false);
PortabilityLayer::HostThreadEvent *returnEvent = systemServices->CreateThreadEvent(true, false);
if (!returnEvent)
return nullptr;
PortabilityLayer::HostThreadEvent *wakeEvent = systemServices->CreateThreadEvent(true, false);
if (!wakeEvent)
{
returnEvent->Destroy();
return nullptr;
}
GpFiberStarter_SDL::FiberStartState startState;
startState.m_context = context;
startState.m_creatingReturnEvent = returnEvent;
startState.m_creatingWakeEvent = wakeEvent;
startState.m_threadFunc = threadFunc;
SDL_Thread *thread = SDL_CreateThread(GpFiberStarter_SDL::FiberStartRoutine, "Fiber", &startState);
if (!thread)
{
returnEvent->Destroy();
wakeEvent->Destroy();
return nullptr;
}
returnEvent->Wait();
returnEvent->Destroy();
return new GpFiber_SDL(thread, returnEvent);
return new GpFiber_SDL(thread, wakeEvent);
}

View File

@@ -2,8 +2,6 @@
#include "HostSystemServices.h"
#include "HostThreadEvent.h"
#include "GpSystemServices_Win32.h"
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent)
: m_event(threadEvent)
, m_thread(thread)

View File

@@ -1,7 +1,9 @@
#include "Functions.h"
#include "DrawQuadPixelConstants.h"
#define GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL "varying vec4 texCoord;\n"\
#define GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL \
"\n"\
"varying vec4 texCoord;\n"\
"uniform sampler2D surfaceTexture;\n"\
"uniform sampler2D paletteTexture;\n"\
"\n"\
@@ -23,6 +25,6 @@
namespace GpBinarizedShaders
{
const char *g_drawQuadPaletteP_GL2 = GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL;
const char *g_drawQuadPaletteICCP_GL2 = "#define USE_ICC_PROFILE\n" GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL;
const char *g_drawQuadPaletteP_GL2 = GP_GL_SHADER_CODE_PRECISION_PREFIX GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL;
const char *g_drawQuadPaletteICCP_GL2 = "#define USE_ICC_PROFILE\n" GP_GL_SHADER_CODE_PRECISION_PREFIX GP_GL_SHADER_CODE_DRAWQUADPIXELCONSTANTS_H GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_DRAWQUADPALETTEP_GLSL;
}

View File

@@ -1,3 +1,5 @@
#define GP_GL_SHADER_CODE_PRECISION_PREFIX "precision mediump float;\n"\
#define GP_GL_SHADER_CODE_FUNCTIONS_H "vec3 pow3(vec3 v, float ex)\n"\
"{\n"\
" return vec3(pow(v.x, ex), pow(v.y, ex), pow(v.z, ex));\n"\

View File

@@ -39,7 +39,7 @@
namespace GpBinarizedShaders
{
const char *g_scaleQuadP_GL2 = GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_SCALEQUADP_GLSL;
const char *g_scaleQuadP_GL2 = GP_GL_SHADER_CODE_PRECISION_PREFIX GP_GL_SHADER_CODE_FUNCTIONS_H GP_GL_SHADER_CODE_SCALEQUADP_GLSL;
extern const char *g_drawQuadRGBP_GL2;
extern const char *g_drawQuad15BitP_GL2;

View File

@@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
#if __cplusplus >= 199711L
#define GP_IS_CPP11 1
#else

38
FreeType/Android.mk Normal file
View File

@@ -0,0 +1,38 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := FreeType
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/freetype/include
# Add your application source files here...
LOCAL_SRC_FILES := \
$(LOCAL_PATH)/freetype/src/base/ftbase.c \
$(LOCAL_PATH)/freetype/src/base/ftbitmap.c \
$(LOCAL_PATH)/freetype/src/base/ftdebug.c \
$(LOCAL_PATH)/freetype/src/base/ftinit.c \
$(LOCAL_PATH)/freetype/src/base/ftsystem.c \
$(LOCAL_PATH)/freetype/src/winfonts/winfnt.c \
$(LOCAL_PATH)/freetype/src/autofit/autofit.c \
$(LOCAL_PATH)/freetype/src/bdf/bdf.c \
$(LOCAL_PATH)/freetype/src/cff/cff.c \
$(LOCAL_PATH)/freetype/src/gzip/ftgzip.c \
$(LOCAL_PATH)/freetype/src/lzw/ftlzw.c \
$(LOCAL_PATH)/freetype/src/pcf/pcf.c \
$(LOCAL_PATH)/freetype/src/pfr/pfr.c \
$(LOCAL_PATH)/freetype/src/psaux/psaux.c \
$(LOCAL_PATH)/freetype/src/pshinter/pshinter.c \
$(LOCAL_PATH)/freetype/src/psnames/psnames.c \
$(LOCAL_PATH)/freetype/src/raster/raster.c \
$(LOCAL_PATH)/freetype/src/sfnt/sfnt.c \
$(LOCAL_PATH)/freetype/src/smooth/smooth.c \
$(LOCAL_PATH)/freetype/src/truetype/truetype.c \
$(LOCAL_PATH)/freetype/src/type1/type1.c \
$(LOCAL_PATH)/freetype/src/cid/type1cid.c \
$(LOCAL_PATH)/freetype/src/type42/type42.c
LOCAL_CFLAGS := -DFT2_BUILD_LIBRARY
include $(BUILD_SHARED_LIBRARY)

View File

@@ -19,9 +19,6 @@
<Filter Include="Source Files\base">
<UniqueIdentifier>{3fb0e907-a078-4943-ab94-631783b69f75}</UniqueIdentifier>
</Filter>
<Filter Include="Source Files\autofit">
<UniqueIdentifier>{61b2d9d3-2578-438e-bbf2-52b3a0f60001}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="freetype\src\winfonts\fnterrs.h">

88
GpApp/Android.mk Normal file
View File

@@ -0,0 +1,88 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := GpApp
SDL_PATH := ../SDL2
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../GpCommon \
$(LOCAL_PATH)/../Common \
$(LOCAL_PATH)/../PortabilityLayer
LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
# Add your application source files here...
LOCAL_SRC_FILES := \
About.cpp \
AnimCursor.cpp \
AppleEvents.cpp \
Banner.cpp \
ColorUtils.cpp \
Coordinates.cpp \
DialogUtils.cpp \
DynamicMaps.cpp \
Dynamics.cpp \
Dynamics2.cpp \
Dynamics3.cpp \
Environ.cpp \
Events.cpp \
FileError.cpp \
GameOver.cpp \
GpAppInterface.cpp \
Grease.cpp \
HighScores.cpp \
House.cpp \
HouseInfo.cpp \
HouseIO.cpp \
HouseLegal.cpp \
Input.cpp \
Interactions.cpp \
InterfaceInit.cpp \
Link.cpp \
Main.cpp \
MainWindow.cpp \
Map.cpp \
Marquee.cpp \
Menu.cpp \
Modes.cpp \
Music.cpp \
ObjectAdd.cpp \
ObjectDraw.cpp \
ObjectDraw2.cpp \
ObjectDrawAll.cpp \
ObjectEdit.cpp \
ObjectInfo.cpp \
ObjectRects.cpp \
Objects.cpp \
Play.cpp \
Player.cpp \
Prefs.cpp \
RectUtils.cpp \
Render.cpp \
Room.cpp \
RoomGraphics.cpp \
RoomInfo.cpp \
RubberBands.cpp \
SavedGames.cpp \
Scoreboard.cpp \
Scrap.cpp \
SelectHouse.cpp \
Settings.cpp \
Sound.cpp \
SoundSync_Cpp11.cpp \
StringUtils.cpp \
StructuresInit.cpp \
StructuresInit2.cpp \
Tools.cpp \
Transit.cpp \
Transitions.cpp \
Triggers.cpp \
Trip.cpp \
Utilities.cpp \
WindowUtils.cpp
LOCAL_STATIC_LIBRARIES := PortabilityLayer
include $(BUILD_SHARED_LIBRARY)

View File

@@ -288,7 +288,7 @@ void InitAnimatedCursor (acurHandle ballCursH)
//-------------------------------------------------------------- LoadCursors
// Just calls the above function. Other code could be added here thoughÉ
// Just calls the above function. Other code could be added here though?
// to add additional cursors.
void LoadCursors (void)
@@ -302,7 +302,7 @@ void LoadCursors (void)
void DisposCursors (void)
{
register short i, j;
short i, j;
if (compiledAnimCursorH != nil)
{

View File

@@ -161,11 +161,11 @@ Boolean DoWeHaveSystem605 (void)
haveIt = false;
return (haveIt);
}
/
*/
//-------------------------------------------------------------- DoWeHaveSystem7
// Determines if the System version is at least 7.0.0 or more recent.
/*
Boolean DoWeHaveSystem7 (void)
{
SysEnvRec thisWorld;
@@ -178,7 +178,7 @@ Boolean DoWeHaveSystem7 (void)
haveIt = false;
return (haveIt);
}
*/
//-------------------------------------------------------------- DoWeHaveSoundManager3
// Determines if the Sound Manager version is at least 3.0.0 or more recent.
/*
@@ -279,7 +279,7 @@ void FlushResolutionChange(void)
}
//-------------------------------------------------------------- CheckOurEnvirons
// Calls all the above functions in order to fill out a sort of "spec sheet"É
// Calls all the above functions in order to fill out a sort of "spec sheet"<EFBFBD>
// for the current Mac.
void CheckOurEnvirons (void)
@@ -418,8 +418,8 @@ void HandleDepthSwitching (void)
//-------------------------------------------------------------- CheckMemorySize
// Tests for a specific amount of memory available. If the required memoryÉ
// is not available, attempts to turn off various game features (music, etc.)É
// Tests for a specific amount of memory available. If the required memory<EFBFBD>
// is not available, attempts to turn off various game features (music, etc.)<EFBFBD>
// in order to accomodate the constrained memory available.
void CheckMemorySize (void)

View File

@@ -180,7 +180,7 @@ typedef struct
objectType objects[kMaxRoomObs]; // 24 * 12
} roomType, *roomPtr; // total = 348
typedef struct
struct houseType
{
int16_t version; // 2
int16_t unusedShort; // 2
@@ -198,9 +198,12 @@ typedef struct
int16_t padding;
roomType rooms[1]; // 348 * nRooms
// total = 866 +
static const size_t kBinaryDataSize = 866;
} houseType, *housePtr; // total = 866 +
};
typedef houseType *housePtr;
typedef THandle<houseType> houseHand;

30
GpApp/SoundSync_Cpp11.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "SoundSync.h"
#include <atomic>
static std::atomic<uint64_t> gs_prioritiesBlob(0);
SoundSyncState SoundSync_ReadAll()
{
const uint64_t priorities = gs_prioritiesBlob.load(std::memory_order_relaxed);
SoundSyncState state;
state.priority0 = static_cast<uint16_t>((priorities >> 0) & 0xffff);
state.priority1 = static_cast<uint16_t>((priorities >> 16) & 0xffff);
state.priority2 = static_cast<uint16_t>((priorities >> 32) & 0xffff);
state.priority3 = static_cast<uint16_t>((priorities >> 48) & 0xffff);
return state;
}
void SoundSync_ClearPriority(int index)
{
const uint64_t clearMask = ~(static_cast<int64_t>(0xffff) << (index * 16));
gs_prioritiesBlob &= clearMask;
}
void SoundSync_PutPriority(int index, int16_t priority)
{
const uint64_t insertMask = static_cast<int64_t>(priority) << (index * 16);
gs_prioritiesBlob |= insertMask;
}

View File

@@ -2,6 +2,8 @@
enum EGpAudioDriverType
{
EGpAudioDriverType_None,
EGpAudioDriverType_XAudio2,
EGpAudioDriverType_SDL2,

View File

@@ -5,7 +5,7 @@ class GpComPtr final
{
public:
GpComPtr();
const GpComPtr(const GpComPtr<T> &other);
GpComPtr(const GpComPtr<T> &other);
explicit GpComPtr(T *ptr);
~GpComPtr();

View File

@@ -10,6 +10,11 @@ struct IGpFiber;
struct IGpVOSEventQueue;
struct IGpLogDriver;
namespace PortabilityLayer
{
class HostSystemServices;
}
struct GpDisplayDriverProperties
{
typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber);
@@ -41,4 +46,5 @@ struct GpDisplayDriverProperties
IGpVOSEventQueue *m_eventQueue;
IGpLogDriver *m_logger;
PortabilityLayer::HostSystemServices *m_systemServices;
};

View File

@@ -0,0 +1,20 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := GpFontHandler_FreeType2
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../Common \
$(LOCAL_PATH)/../GpCommon \
$(LOCAL_PATH)/../FreeType/freetype/include
LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
# Add your application source files here...
LOCAL_SRC_FILES := \
GpFontHandler_FreeType2.cpp
LOCAL_SHARED_LIBRARIES := FreeType
include $(BUILD_STATIC_LIBRARY)

View File

@@ -425,7 +425,11 @@ bool GpFontHandler_FreeType2::Init()
return true;
}
extern "C" __declspec(dllexport) IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties)
extern "C"
#ifdef _MSC_VER
__declspec(dllexport)
#endif
IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties)
{
return GpFontHandler_FreeType2::Create();
}

26
GpShell/Android.mk Normal file
View File

@@ -0,0 +1,26 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := GpShell
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../Common \
$(LOCAL_PATH)/../GpCommon \
$(LOCAL_PATH)/../PortabilityLayer
LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
# Add your application source files here...
LOCAL_SRC_FILES := \
GpAppEnvironment.cpp \
GpAudioDriverFactory.cpp \
GpDisplayDriverFactory.cpp \
GpFontHandlerFactory.cpp \
GpGlobalConfig.cpp \
GpInputDriverFactory.cpp \
GpMain.cpp \
GpMemoryBuffer.cpp \
GpVOSEventQueue.cpp
include $(BUILD_STATIC_LIBRARY)

View File

@@ -18,6 +18,7 @@ GpAppEnvironment::GpAppEnvironment()
, m_numInputDrivers(0)
, m_fontHandler(nullptr)
, m_vosEventQueue(nullptr)
, m_systemServices(nullptr)
, m_applicationFiber(nullptr)
, m_vosFiber(nullptr)
, m_suspendCallID(PortabilityLayer::HostSuspendCallID_Unknown)
@@ -50,7 +51,7 @@ GpDisplayDriverTickStatus_t GpAppEnvironment::Tick(IGpFiber *vosFiber)
{
case ApplicationState_NotStarted:
InitializeApplicationState();
m_applicationFiber = GpFiberStarter::StartFiber(GpAppEnvironment::StaticAppThreadFunc, this, vosFiber);
m_applicationFiber = GpFiberStarter::StartFiber(m_systemServices, GpAppEnvironment::StaticAppThreadFunc, this, vosFiber);
m_applicationState = ApplicationState_Running;
break;
case ApplicationState_WaitingForEvents:
@@ -125,6 +126,11 @@ void GpAppEnvironment::SetVOSEventQueue(GpVOSEventQueue *eventQueue)
m_vosEventQueue = eventQueue;
}
void GpAppEnvironment::SetSystemServices(PortabilityLayer::HostSystemServices *systemServices)
{
m_systemServices = systemServices;
}
void GpAppEnvironment::StaticAppThreadFunc(void *context)
{
static_cast<GpAppEnvironment*>(context)->AppThreadFunc();

View File

@@ -10,6 +10,7 @@ namespace PortabilityLayer
{
union HostSuspendCallArgument;
class HostVOSEventQueue;
class HostSystemServices;
}
struct IGpDisplayDriver;
@@ -35,6 +36,7 @@ public:
void SetInputDrivers(IGpInputDriver *const* inputDrivers, size_t numDrivers);
void SetFontHandler(IGpFontHandler *fontHandler);
void SetVOSEventQueue(GpVOSEventQueue *eventQueue);
void SetSystemServices(PortabilityLayer::HostSystemServices *systemServices);
private:
enum ApplicationState
@@ -61,6 +63,7 @@ private:
IGpInputDriver *const* m_inputDrivers;
IGpFontHandler *m_fontHandler;
GpVOSEventQueue *m_vosEventQueue;
PortabilityLayer::HostSystemServices *m_systemServices;
IGpFiber *m_applicationFiber;
IGpFiber *m_vosFiber;

View File

@@ -2,10 +2,15 @@
struct IGpFiber;
namespace PortabilityLayer
{
class HostSystemServices;
}
class GpFiberStarter
{
public:
typedef void(*ThreadFunc_t)(void *context);
static IGpFiber *StartFiber(ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber);
static IGpFiber *StartFiber(PortabilityLayer::HostSystemServices *systemServices, ThreadFunc_t threadFunc, void *context, IGpFiber *creatingFiber);
};

View File

@@ -5,6 +5,8 @@
#include "EGpFontHandlerType.h"
#include "EGpInputDriverType.h"
#include <stdint.h>
struct IGpLogDriver;
namespace PortabilityLayer

View File

@@ -66,6 +66,7 @@ int GpMain::Run()
ddProps.m_osGlobals = g_gpGlobalConfig.m_osGlobals;
ddProps.m_eventQueue = eventQueue;
ddProps.m_logger = g_gpGlobalConfig.m_logger;
ddProps.m_systemServices = g_gpGlobalConfig.m_systemServices;
GpAudioDriverProperties adProps;
memset(&adProps, 0, sizeof(adProps));
@@ -116,6 +117,7 @@ int GpMain::Run()
appEnvironment->SetInputDrivers(inputDrivers, numCreatedInputDrivers);
appEnvironment->SetFontHandler(fontHandler);
appEnvironment->SetVOSEventQueue(eventQueue);
appEnvironment->SetSystemServices(g_gpGlobalConfig.m_systemServices);
// Start the display loop
displayDriver->Run();
@@ -129,7 +131,5 @@ int GpMain::Run()
free(inputDrivers);
}
// GP TODO: Cleanup
return 0;
}

View File

@@ -0,0 +1,12 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MacRomanConversion
# Add your application source files here...
LOCAL_SRC_FILES := \
MacRomanConversion.cpp
include $(BUILD_STATIC_LIBRARY)

112
PortabilityLayer/Android.mk Normal file
View File

@@ -0,0 +1,112 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := PortabilityLayer
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/../GpCommon \
$(LOCAL_PATH)/../Common \
$(LOCAL_PATH)/../rapidjson/include \
$(LOCAL_PATH)/../MacRomanConversion \
$(LOCAL_PATH)/../stb
LOCAL_CFLAGS := -DGP_DEBUG_CONFIG=0
# Add your application source files here...
LOCAL_SRC_FILES := \
AntiAliasTable.cpp \
AppEventHandler.cpp \
BinHex4.cpp \
BitmapImage.cpp \
ByteSwap.cpp \
CFileStream.cpp \
DeflateCodec.cpp \
DialogManager.cpp \
DisplayDeviceManager.cpp \
EllipsePlotter.cpp \
FileBrowserUI.cpp \
FileManager.cpp \
FontFamily.cpp \
FontManager.cpp \
FontRenderer.cpp \
GPArchive.cpp \
HostAudioDriver.cpp \
HostDisplayDriver.cpp \
HostFileSystem.cpp \
HostFontHandler.cpp \
HostInputDriver.cpp \
HostLogDriver.cpp \
HostSuspendHook.cpp \
HostSystemServices.cpp \
HostVOSEventQueue.cpp \
IconLoader.cpp \
InputManager.cpp \
LinePlotter.cpp \
MacBinary2.cpp \
MacFileInfo.cpp \
MacFileMem.cpp \
MemoryManager.cpp \
MemReaderStream.cpp \
MenuManager.cpp \
MMBlock.cpp \
MMHandleBlock.cpp \
PLApplication.cpp \
PLButtonWidget.cpp \
PLControlDefinitions.cpp \
PLCore.cpp \
PLCTabReducer.cpp \
PLDialogs.cpp \
PLEditboxWidget.cpp \
PLEventQueue.cpp \
PLHacks.cpp \
PLHandle.cpp \
PLIconWidget.cpp \
PLImageWidget.cpp \
PLInvisibleWidget.cpp \
PLKeyEncoding.cpp \
PLLabelWidget.cpp \
PLMenus.cpp \
PLMovies.cpp \
PLNumberFormatting.cpp \
PLPopupMenuWidget.cpp \
PLQDOffscreen.cpp \
PLQDraw.cpp \
PLResourceManager.cpp \
PLResources.cpp \
PLScrollBarWidget.cpp \
PLSound.cpp \
PLStandardColors.cpp \
PLStringCompare.cpp \
PLSysCalls.cpp \
PLTimeTaggedVOSEvent.cpp \
PLWidgets.cpp \
QDGraf.cpp \
QDManager.cpp \
QDPictDecoder.cpp \
QDPictEmitContext.cpp \
QDPictHeader.cpp \
QDPixMap.cpp \
QDPort.cpp \
QDStandardPalette.cpp \
RandomNumberGenerator.cpp \
ResolveCachingColor.cpp \
ResourceCompiledRef.cpp \
ResourceFile.cpp \
ScanlineMask.cpp \
ScanlineMaskBuilder.cpp \
ScanlineMaskConverter.cpp \
ScanlineMaskIterator.cpp \
SimpleGraphic.cpp \
TextPlacer.cpp \
UTF8.cpp \
UTF16.cpp \
WindowDef.cpp \
WindowManager.cpp \
XModemCRC.cpp \
ZipFileProxy.cpp
LOCAL_STATIC_LIBRARIES := zlib MacRomanConversion stb
include $(BUILD_SHARED_LIBRARY)

View File

@@ -292,10 +292,10 @@ namespace PortabilityLayer
const uint16_t expectedResCRC = ByteUnpack::BigUInt16(&decodedBytes[resourceForkCRCLoc]);
if (expectedDataCRC != BinHexCRC(&decodedBytes[dataForkStart], mfi.m_dataForkSize))
return false;
return nullptr;
if (expectedResCRC != BinHexCRC(&decodedBytes[resourceForkStart], mfi.m_resourceForkSize))
return false;
return nullptr;
return new MacFileMem(&decodedBytes[dataForkStart], &decodedBytes[resourceForkStart], nullptr, mfi);
}

View File

@@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
#include "VirtualDirectory.h"
class PLPasStr;

View File

@@ -1,5 +1,7 @@
#pragma once
#include <stdint.h>
struct IGpInputDriver;
namespace PortabilityLayer

View File

@@ -21,7 +21,7 @@ namespace PortabilityLayer
virtual HostMutex *CreateMutex() = 0;
virtual HostMutex *CreateRecursiveMutex() = 0;
virtual HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 0;
virtual size_t GetFreeMemoryCosmetic() const = 0; // Returns free memory in bytes, does not have to be accurate
virtual uint64_t GetFreeMemoryCosmetic() const = 0; // Returns free memory in bytes, does not have to be accurate
virtual void Beep() const = 0;
static void SetInstance(HostSystemServices *instance);

View File

@@ -8,7 +8,7 @@ namespace PortabilityLayer
{
public:
virtual void Wait() = 0;
virtual void WaitTimed(uint32_t msec) = 0;
virtual bool WaitTimed(uint32_t msec) = 0;
virtual void Signal() = 0;
virtual void Destroy() = 0;
};

View File

@@ -158,8 +158,8 @@ namespace PortabilityLayer
if (fileInfo.m_resourceForkSize != 0)
rsrcBuffer = new uint8_t[fileInfo.m_resourceForkSize];
ScopedArray<uint8_t> dataContents = dataBuffer;
ScopedArray<uint8_t> rsrcContents = rsrcBuffer;
ScopedArray<uint8_t> dataContents(dataBuffer);
ScopedArray<uint8_t> rsrcContents(rsrcBuffer);
uint8_t *padding = mb2Header;

View File

@@ -706,6 +706,8 @@ namespace PortabilityLayer
if (evt.m_vosEvent.m_event.m_mouseInputEvent.m_button == GpMouseButtons::kLeft)
canDismiss = true;
break;
default:
break;
}
}
}
@@ -764,6 +766,8 @@ namespace PortabilityLayer
if (evt.m_vosEvent.m_event.m_mouseInputEvent.m_button == GpMouseButtons::kLeft)
canDismiss = true;
break;
default:
break;
}
}
}

View File

@@ -298,7 +298,7 @@ void NumToString(long number, unsigned char *str)
number /= 10;
*outChar = '0' + digit;
*outChar++;
outChar++;
}
const ptrdiff_t strLength = outChar - firstChar;
@@ -753,7 +753,7 @@ bool Window::ReplaceWidget(PortabilityLayer::Widget *oldWidget, PortabilityLayer
oldWidget->Destroy();
m_widgets[i] = newWidget;
newWidget->m_window = this;
newWidget->SetWindow(this);
newWidget->DrawControl(&m_surface);
m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);

View File

@@ -29,7 +29,7 @@ namespace PortabilityLayer
Rect GetExpandedRect() const override;
bool HandlesTickEvents() const;
bool HandlesTickEvents() const override;
void SetSelection(size_t startChar, size_t endChar);

View File

@@ -14,8 +14,8 @@ namespace PortabilityLayer
bool Init(const WidgetBasicState &state, const void *additionalData) override;
WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt);
int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback);
WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) override;
int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) override;
void DrawControl(DrawSurface *surface) override;
void OnStateChanged() override;

View File

@@ -1783,6 +1783,7 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap8,
{
case GpPixelFormats::k8BitCustom:
case GpPixelFormats::k8BitStandard:
case GpPixelFormats::kBW1:
pixelSizeBytes = 1;
break;
case GpPixelFormats::kRGB555:
@@ -1794,6 +1795,8 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap8,
case GpPixelFormats::kRGB32:
pixelSizeBytes = 4;
break;
default:
return;
};
const uint8_t *srcBytes = static_cast<const uint8_t*>(srcBitmap->m_data);
@@ -2029,8 +2032,8 @@ void DebugPixMap(PixMap **pixMapH, const char *outName)
{
PixMap *pixMap = *pixMapH;
char outPath[1024];
strcpy_s(outPath, outName);
strcat_s(outPath, ".png");
strcpy(outPath, outName);
strcat(outPath, ".png");
stbi_write_png(outPath, pixMap->m_rect.right - pixMap->m_rect.left, pixMap->m_rect.bottom - pixMap->m_rect.top, 1, pixMap->m_data, pixMap->m_pitch);
}

View File

@@ -179,7 +179,7 @@ namespace PortabilityLayer
{
AudioCommand cmd;
cmd.m_commandType = AudioCommandTypes::kCallback;
cmd.m_param.m_ptr = callback;
cmd.m_param.m_ptr = reinterpret_cast<void*>(callback);
return this->PushCommand(cmd, blocking);
}

View File

@@ -71,7 +71,7 @@ static void TranslateKeyboardInputEvent(const GpVOSEvent &vosEventBase, uint32_t
inputManager->ApplyKeyboardEvent(vosEvent);
// Special handling of alt-enter, redirect to display driver
if (vosEventBase.m_eventType == GpKeyboardInputEventTypes::kDown &&
if (vosEventBase.m_event.m_keyboardInputEvent.m_eventType == GpKeyboardInputEventTypes::kDown &&
vosEventBase.m_event.m_keyboardInputEvent.m_keyIDSubset == GpKeyIDSubsets::kSpecial &&
vosEventBase.m_event.m_keyboardInputEvent.m_key.m_specialKey == GpKeySpecials::kEnter)
{

View File

@@ -139,6 +139,11 @@ namespace PortabilityLayer
return m_rect;
}
void Widget::SetWindow(Window *window)
{
m_window = window;
}
Window *Widget::GetWindow() const
{
return m_window;

View File

@@ -80,21 +80,23 @@ namespace PortabilityLayer
virtual int ResolvePart(const Point &point) const;
const Rect &GetRect() const;
Window *GetWindow() const;
protected:
friend struct Window;
void SetWindow(Window *window);
Window *GetWindow() const;
virtual void GainFocus();
virtual void LoseFocus();
explicit Widget(const WidgetBasicState &state);
virtual ~Widget();
virtual void OnEnabledChanged();
virtual void OnStateChanged();
virtual void OnTick();
protected:
friend struct Window;
explicit Widget(const WidgetBasicState &state);
virtual ~Widget();
static void BaseRelease(void *storage);
static void *BaseAlloc(size_t sz);

12
stb/Android.mk Normal file
View File

@@ -0,0 +1,12 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := stb
# Add your application source files here...
LOCAL_SRC_FILES := \
stb_image_write.c
include $(BUILD_STATIC_LIBRARY)

19
zlib/Android.mk Normal file
View File

@@ -0,0 +1,19 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := zlib
# Add your application source files here...
LOCAL_SRC_FILES := \
adler32.c \
crc32.c \
deflate.c \
inffast.c \
inflate.c \
inftrees.c \
trees.c \
zutil.c
include $(BUILD_STATIC_LIBRARY)