mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-13 19:49:36 +00:00
More Android stub-outs and bug fixes. Fix broken SDL fiber sync.
This commit is contained in:
@@ -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 lowLimit;
|
||||||
ULONG_PTR highLimit;
|
ULONG_PTR highLimit;
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ void GpThreadEvent_Win32::Wait()
|
|||||||
WaitForSingleObject(m_event, INFINITE);
|
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()
|
void GpThreadEvent_Win32::Signal()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class GpThreadEvent_Win32 final : public PortabilityLayer::HostThreadEvent
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Wait() override;
|
void Wait() override;
|
||||||
void WaitTimed(uint32_t msec) override;
|
bool WaitTimed(uint32_t msec) override;
|
||||||
void Signal() override;
|
void Signal() override;
|
||||||
void Destroy() override;
|
void Destroy() override;
|
||||||
|
|
||||||
|
|||||||
12
AerofoilAndroid/app/jni/.gitignore
vendored
12
AerofoilAndroid/app/jni/.gitignore
vendored
@@ -1 +1,13 @@
|
|||||||
|
AerofoilSDL
|
||||||
|
Common
|
||||||
|
FreeType
|
||||||
|
GpApp
|
||||||
|
GpCommon
|
||||||
|
GpFontHandler_FreeType2
|
||||||
|
GpShell
|
||||||
|
MacRomanConversion
|
||||||
|
PortabilityLayer
|
||||||
|
rapidjson
|
||||||
SDL2
|
SDL2
|
||||||
|
stb
|
||||||
|
zlib
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
# Uncomment this if you're using STL in your project
|
# Uncomment this if you're using STL in your project
|
||||||
# You can find more information here:
|
# You can find more information here:
|
||||||
# https://developer.android.com/ndk/guides/cpp-support
|
# 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
|
APP_ABI := armeabi-v7a arm64-v8a x86 x86_64
|
||||||
|
|
||||||
|
|||||||
@@ -6,13 +6,25 @@ LOCAL_MODULE := main
|
|||||||
|
|
||||||
SDL_PATH := ../SDL
|
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...
|
# 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_SHARED_LIBRARIES := SDL2
|
||||||
|
|
||||||
|
LOCAL_STATIC_LIBRARIES := GpShell GpFontHandler_FreeType2 AerofoilSDL GpApp
|
||||||
|
|
||||||
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog
|
LOCAL_LDLIBS := -lGLESv1_CM -lGLESv2 -llog
|
||||||
|
|
||||||
include $(BUILD_SHARED_LIBRARY)
|
include $(BUILD_SHARED_LIBRARY)
|
||||||
|
|||||||
5
AerofoilAndroid/app/jni/main/GpAndroid.h
Normal file
5
AerofoilAndroid/app/jni/main/GpAndroid.h
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
struct GpAndroidGlobals
|
||||||
|
{
|
||||||
|
};
|
||||||
84
AerofoilAndroid/app/jni/main/GpFileSystem_Android.cpp
Normal file
84
AerofoilAndroid/app/jni/main/GpFileSystem_Android.cpp
Normal 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;
|
||||||
27
AerofoilAndroid/app/jni/main/GpFileSystem_Android.h
Normal file
27
AerofoilAndroid/app/jni/main/GpFileSystem_Android.h
Normal 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;
|
||||||
|
};
|
||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "GpAudioDriverFactory.h"
|
#include "GpAudioDriverFactory.h"
|
||||||
#include "GpDisplayDriverFactory.h"
|
#include "GpDisplayDriverFactory.h"
|
||||||
#include "GpGlobalConfig.h"
|
#include "GpGlobalConfig.h"
|
||||||
#include "GpFiber_Win32.h"
|
|
||||||
#include "GpFiber_SDL.h"
|
#include "GpFiber_SDL.h"
|
||||||
#include "GpFileSystem_Android.h"
|
#include "GpFileSystem_Android.h"
|
||||||
#include "GpFontHandlerFactory.h"
|
#include "GpFontHandlerFactory.h"
|
||||||
@@ -19,8 +18,6 @@
|
|||||||
|
|
||||||
#include "GpAndroid.h"
|
#include "GpAndroid.h"
|
||||||
|
|
||||||
#include "resource.h"
|
|
||||||
|
|
||||||
GpAndroidGlobals g_gpAndroidGlobals;
|
GpAndroidGlobals g_gpAndroidGlobals;
|
||||||
|
|
||||||
extern "C" IGpFontHandler *GpDriver_CreateFontHandler_FreeType2(const GpFontHandlerProperties &properties);
|
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);
|
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)
|
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
SDL_GL_LoadLibrary("libGLESv2.so");
|
||||||
|
|
||||||
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Android::GetInstance());
|
GpAppInterface_Get()->PL_HostFileSystem_SetInstance(GpFileSystem_Android::GetInstance());
|
||||||
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Android::GetInstance());
|
GpAppInterface_Get()->PL_HostSystemServices_SetInstance(GpSystemServices_Android::GetInstance());
|
||||||
|
|
||||||
g_gpGlobalConfig.m_displayDriverType = EGpDisplayDriverType_SDL_GL2;
|
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;
|
g_gpGlobalConfig.m_fontHandlerType = EGpFontHandlerType_FreeType2;
|
||||||
|
|
||||||
@@ -54,13 +53,7 @@ int main(int argc, const char **argv)
|
|||||||
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL);
|
GpAudioDriverFactory::RegisterAudioDriverFactory(EGpAudioDriverType_SDL2, GpDriver_CreateAudioDriver_SDL);
|
||||||
GpFontHandlerFactory::RegisterFontHandlerFactory(EGpFontHandlerType_FreeType2, GpDriver_CreateFontHandler_FreeType2);
|
GpFontHandlerFactory::RegisterFontHandlerFactory(EGpFontHandlerType_FreeType2, GpDriver_CreateFontHandler_FreeType2);
|
||||||
|
|
||||||
if (logger)
|
|
||||||
logger->Printf(IGpLogDriver::Category_Information, "SDL environment configured, starting up");
|
|
||||||
|
|
||||||
int returnCode = GpMain::Run();
|
int returnCode = GpMain::Run();
|
||||||
|
|
||||||
if (logger)
|
|
||||||
logger->Printf(IGpLogDriver::Category_Information, "SDL environment exited with code %i, cleaning up", returnCode);
|
|
||||||
|
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|||||||
174
AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp
Normal file
174
AerofoilAndroid/app/jni/main/GpSystemServices_Android.cpp
Normal 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;
|
||||||
23
AerofoilAndroid/app/jni/main/GpSystemServices_Android.h
Normal file
23
AerofoilAndroid/app/jni/main/GpSystemServices_Android.h
Normal 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;
|
||||||
|
};
|
||||||
1
AerofoilAndroid/app/src/main/.gitignore
vendored
Normal file
1
AerofoilAndroid/app/src/main/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
assets
|
||||||
@@ -3,6 +3,20 @@
|
|||||||
|
|
||||||
call remove_symlinks.bat
|
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\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
|
pause
|
||||||
|
|||||||
@@ -1,4 +1,17 @@
|
|||||||
@setlocal enableextensions
|
@setlocal enableextensions
|
||||||
@cd /d "%~dp0"
|
@cd /d "%~dp0"
|
||||||
|
|
||||||
|
rmdir app\jni\AerofoilSDL
|
||||||
|
rmdir app\jni\Common
|
||||||
rmdir app\jni\SDL2
|
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
|
||||||
@@ -87,6 +87,7 @@
|
|||||||
<ClCompile Include="..\Aerofoil\GpColorCursor_Win32.cpp" />
|
<ClCompile Include="..\Aerofoil\GpColorCursor_Win32.cpp" />
|
||||||
<ClCompile Include="..\Aerofoil\GpFileStream_Win32.cpp" />
|
<ClCompile Include="..\Aerofoil\GpFileStream_Win32.cpp" />
|
||||||
<ClCompile Include="..\Aerofoil\GpFileSystem_Win32.cpp" />
|
<ClCompile Include="..\Aerofoil\GpFileSystem_Win32.cpp" />
|
||||||
|
<ClCompile Include="..\Aerofoil\GpLogDriver_Win32.cpp" />
|
||||||
<ClCompile Include="..\Aerofoil\GpMutex_Win32.cpp" />
|
<ClCompile Include="..\Aerofoil\GpMutex_Win32.cpp" />
|
||||||
<ClCompile Include="..\Aerofoil\GpSystemServices_Win32.cpp" />
|
<ClCompile Include="..\Aerofoil\GpSystemServices_Win32.cpp" />
|
||||||
<ClCompile Include="..\Aerofoil\GpThreadEvent_Win32.cpp" />
|
<ClCompile Include="..\Aerofoil\GpThreadEvent_Win32.cpp" />
|
||||||
|
|||||||
@@ -60,6 +60,9 @@
|
|||||||
<ClCompile Include="GpAudioDriver_SDL2.cpp">
|
<ClCompile Include="GpAudioDriver_SDL2.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\Aerofoil\GpLogDriver_Win32.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="ShaderCode\Functions.h">
|
<ClInclude Include="ShaderCode\Functions.h">
|
||||||
|
|||||||
28
AerofoilSDL/Android.mk
Normal file
28
AerofoilSDL/Android.mk
Normal 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)
|
||||||
@@ -62,7 +62,7 @@ struct GpAudioChannelBufferChain_SDL2 final
|
|||||||
bool m_hasTrigger;
|
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:
|
public:
|
||||||
enum ChannelState
|
enum ChannelState
|
||||||
@@ -104,7 +104,7 @@ private:
|
|||||||
ChannelState m_channelState;
|
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:
|
public:
|
||||||
friend class GpAudioChannel_SDL2;
|
friend class GpAudioChannel_SDL2;
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
#include "GpComPtr.h"
|
#include "GpComPtr.h"
|
||||||
#include "GpFiber_SDL.h"
|
#include "GpFiber_SDL.h"
|
||||||
#include "GpDisplayDriverProperties.h"
|
#include "GpDisplayDriverProperties.h"
|
||||||
#include "GpSystemServices_Win32.h"
|
//#include "GpSystemServices_Win32.h"
|
||||||
#include "GpWindows.h" // TODO: Remove
|
//#include "GpWindows.h" // TODO: Remove
|
||||||
#include "GpVOSEvent.h"
|
#include "GpVOSEvent.h"
|
||||||
#include "GpRingBuffer.h"
|
#include "GpRingBuffer.h"
|
||||||
|
#include "HostSystemServices.h"
|
||||||
#include "IGpCursor.h"
|
#include "IGpCursor.h"
|
||||||
#include "IGpDisplayDriverSurface.h"
|
#include "IGpDisplayDriverSurface.h"
|
||||||
#include "IGpLogDriver.h"
|
#include "IGpLogDriver.h"
|
||||||
@@ -152,7 +153,6 @@ struct GpGLFunctions
|
|||||||
|
|
||||||
PFNGLGENBUFFERSPROC GenBuffers;
|
PFNGLGENBUFFERSPROC GenBuffers;
|
||||||
PFNGLBUFFERDATAPROC BufferData;
|
PFNGLBUFFERDATAPROC BufferData;
|
||||||
PFNGLMAPBUFFERPROC MapBuffer;
|
|
||||||
PFNGLBINDBUFFERPROC BindBuffer;
|
PFNGLBINDBUFFERPROC BindBuffer;
|
||||||
PFNGLDELETEBUFFERSPROC DeleteBuffers;
|
PFNGLDELETEBUFFERSPROC DeleteBuffers;
|
||||||
|
|
||||||
@@ -823,8 +823,6 @@ private:
|
|||||||
SDL_Cursor *m_arrowCursor;
|
SDL_Cursor *m_arrowCursor;
|
||||||
bool m_cursorIsHidden;
|
bool m_cursorIsHidden;
|
||||||
|
|
||||||
|
|
||||||
UINT m_expectedSyncDelta;
|
|
||||||
bool m_isResettingSwapChain;
|
bool m_isResettingSwapChain;
|
||||||
|
|
||||||
bool m_isFullScreen;
|
bool m_isFullScreen;
|
||||||
@@ -854,7 +852,6 @@ private:
|
|||||||
|
|
||||||
IGpFiber *m_vosFiber;
|
IGpFiber *m_vosFiber;
|
||||||
PortabilityLayer::HostThreadEvent *m_vosEvent;
|
PortabilityLayer::HostThreadEvent *m_vosEvent;
|
||||||
GpWindowsGlobals *m_osGlobals;
|
|
||||||
|
|
||||||
float m_bgColor[4];
|
float m_bgColor[4];
|
||||||
bool m_bgIsDark;
|
bool m_bgIsDark;
|
||||||
@@ -896,6 +893,9 @@ GpDisplayDriverSurface_GL2::GpDisplayDriverSurface_GL2(GpDisplayDriver_SDL_GL2 *
|
|||||||
assert(pitch % 4 == 0);
|
assert(pitch % 4 == 0);
|
||||||
paddingPixels = pitch / 4 - width;
|
paddingPixels = pitch / 4 - width;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
paddingPixels = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_paddedTextureWidth = width + paddingPixels;
|
m_paddedTextureWidth = width + paddingPixels;
|
||||||
@@ -1082,7 +1082,6 @@ GpDisplayDriver_SDL_GL2::GpDisplayDriver_SDL_GL2(const GpDisplayDriverProperties
|
|||||||
, m_lastFullScreenToggleTimeStamp(0)
|
, m_lastFullScreenToggleTimeStamp(0)
|
||||||
, m_bgIsDark(false)
|
, m_bgIsDark(false)
|
||||||
, m_useICCProfile(false)
|
, m_useICCProfile(false)
|
||||||
, m_osGlobals(static_cast<GpWindowsGlobals*>(properties.m_osGlobals))
|
|
||||||
, m_properties(properties)
|
, m_properties(properties)
|
||||||
, m_syncTimeBase(std::chrono::time_point<std::chrono::high_resolution_clock>::duration::zero())
|
, m_syncTimeBase(std::chrono::time_point<std::chrono::high_resolution_clock>::duration::zero())
|
||||||
, m_waitCursor(nullptr)
|
, m_waitCursor(nullptr)
|
||||||
@@ -1112,7 +1111,7 @@ static bool LookupOpenGLFunction(T &target, const char *name)
|
|||||||
void *proc = SDL_GL_GetProcAddress(name);
|
void *proc = SDL_GL_GetProcAddress(name);
|
||||||
if (proc)
|
if (proc)
|
||||||
{
|
{
|
||||||
target = static_cast<T>(proc);
|
target = reinterpret_cast<T>(proc);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1120,7 +1119,7 @@ static bool LookupOpenGLFunction(T &target, const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define LOOKUP_FUNC(func) do { if (!LookupOpenGLFunction(this->func, "gl" #func)) return false; } while(false)
|
#define LOOKUP_FUNC(func) do { if (!LookupOpenGLFunction(this->func, "gl" #func)) return false; } while(false)
|
||||||
|
|
||||||
|
|
||||||
bool GpGLFunctions::LookUpFunctions()
|
bool GpGLFunctions::LookUpFunctions()
|
||||||
{
|
{
|
||||||
@@ -1139,12 +1138,6 @@ bool GpGLFunctions::LookUpFunctions()
|
|||||||
LOOKUP_FUNC(CheckFramebufferStatus);
|
LOOKUP_FUNC(CheckFramebufferStatus);
|
||||||
LOOKUP_FUNC(DeleteFramebuffers);
|
LOOKUP_FUNC(DeleteFramebuffers);
|
||||||
|
|
||||||
LOOKUP_FUNC(GenBuffers);
|
|
||||||
LOOKUP_FUNC(BufferData);
|
|
||||||
LOOKUP_FUNC(MapBuffer);
|
|
||||||
LOOKUP_FUNC(BindBuffer);
|
|
||||||
LOOKUP_FUNC(DeleteBuffers);
|
|
||||||
|
|
||||||
LOOKUP_FUNC(CreateProgram);
|
LOOKUP_FUNC(CreateProgram);
|
||||||
LOOKUP_FUNC(DeleteProgram);
|
LOOKUP_FUNC(DeleteProgram);
|
||||||
LOOKUP_FUNC(LinkProgram);
|
LOOKUP_FUNC(LinkProgram);
|
||||||
@@ -1152,6 +1145,11 @@ bool GpGLFunctions::LookUpFunctions()
|
|||||||
LOOKUP_FUNC(GetProgramiv);
|
LOOKUP_FUNC(GetProgramiv);
|
||||||
LOOKUP_FUNC(GetProgramInfoLog);
|
LOOKUP_FUNC(GetProgramInfoLog);
|
||||||
|
|
||||||
|
LOOKUP_FUNC(GenBuffers);
|
||||||
|
LOOKUP_FUNC(BufferData);
|
||||||
|
LOOKUP_FUNC(BindBuffer);
|
||||||
|
LOOKUP_FUNC(DeleteBuffers);
|
||||||
|
|
||||||
LOOKUP_FUNC(GetUniformLocation);
|
LOOKUP_FUNC(GetUniformLocation);
|
||||||
LOOKUP_FUNC(GetAttribLocation);
|
LOOKUP_FUNC(GetAttribLocation);
|
||||||
LOOKUP_FUNC(Uniform4fv);
|
LOOKUP_FUNC(Uniform4fv);
|
||||||
@@ -1671,7 +1669,7 @@ void GpDisplayDriver_SDL_GL2::Run()
|
|||||||
|
|
||||||
IGpLogDriver *logger = m_properties.m_logger;
|
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_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);
|
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);
|
InitResources(m_windowWidthVirtual, m_windowHeightVirtual);
|
||||||
|
|
||||||
LARGE_INTEGER lastTimestamp;
|
|
||||||
memset(&lastTimestamp, 0, sizeof(lastTimestamp));
|
|
||||||
|
|
||||||
MSG msg;
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
SDL_Event msg;
|
SDL_Event msg;
|
||||||
@@ -2320,13 +2314,13 @@ bool GpDisplayDriver_SDL_GL2::ResizeOpenGLWindow(uint32_t &windowWidth, uint32_t
|
|||||||
|
|
||||||
if (desiredWidth < 640)
|
if (desiredWidth < 640)
|
||||||
desiredWidth = 640;
|
desiredWidth = 640;
|
||||||
else if (desiredWidth > MAXDWORD)
|
else if (desiredWidth > 32768)
|
||||||
desiredWidth = MAXDWORD;
|
desiredWidth = 32768;
|
||||||
|
|
||||||
if (desiredHeight < 480)
|
if (desiredHeight < 480)
|
||||||
desiredHeight = 480;
|
desiredHeight = 480;
|
||||||
else if (desiredHeight > MAXDWORD)
|
else if (desiredHeight > 32768)
|
||||||
desiredHeight = MAXDWORD;
|
desiredHeight = 32768;
|
||||||
|
|
||||||
if (logger)
|
if (logger)
|
||||||
logger->Printf(IGpLogDriver::Category_Information, "ResizeOpenGLWindow: Adjusted dimensions: %i x %i", static_cast<int>(desiredWidth), static_cast<int>(desiredHeight));
|
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_windowWidthVirtual) / static_cast<double>(m_windowWidthPhysical)),
|
||||||
static_cast<float>(static_cast<double>(m_windowHeightVirtual) / static_cast<double>(m_windowHeightPhysical)),
|
static_cast<float>(static_cast<double>(m_windowHeightVirtual) / static_cast<double>(m_windowHeightPhysical)),
|
||||||
m_windowWidthVirtual,
|
static_cast<float>(m_windowWidthVirtual),
|
||||||
m_windowHeightVirtual
|
static_cast<float>(m_windowHeightVirtual)
|
||||||
};
|
};
|
||||||
|
|
||||||
m_gl.Uniform4fv(m_scaleQuadProgram.m_pixelDXDYDimensionsLocation, 1, reinterpret_cast<const GLfloat*>(dxdy_dimensions));
|
m_gl.Uniform4fv(m_scaleQuadProgram.m_pixelDXDYDimensionsLocation, 1, reinterpret_cast<const GLfloat*>(dxdy_dimensions));
|
||||||
@@ -2526,7 +2520,7 @@ bool GpDisplayDriver_SDL_GL2::ScaleQuadProgram::Link(GpDisplayDriver_SDL_GL2 *dr
|
|||||||
std::vector<char> errorMsgBuffer;
|
std::vector<char> errorMsgBuffer;
|
||||||
errorMsgBuffer.resize(static_cast<size_t>(logLength) + 1);
|
errorMsgBuffer.resize(static_cast<size_t>(logLength) + 1);
|
||||||
errorMsgBuffer[logLength] = '\0';
|
errorMsgBuffer[logLength] = '\0';
|
||||||
|
|
||||||
gl->GetProgramInfoLog(m_program->GetID(), static_cast<size_t>(logLength), nullptr, reinterpret_cast<GLchar*>(&errorMsgBuffer[0]));
|
gl->GetProgramInfoLog(m_program->GetID(), static_cast<size_t>(logLength), nullptr, reinterpret_cast<GLchar*>(&errorMsgBuffer[0]));
|
||||||
const char *errorMsg = &errorMsgBuffer[0];
|
const char *errorMsg = &errorMsgBuffer[0];
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include "GpFiberStarter.h"
|
#include "GpFiberStarter.h"
|
||||||
#include "GpFiber_SDL.h"
|
#include "GpFiber_SDL.h"
|
||||||
#include "GpSystemServices_Win32.h"
|
|
||||||
|
|
||||||
|
#include "HostSystemServices.h"
|
||||||
#include "HostThreadEvent.h"
|
#include "HostThreadEvent.h"
|
||||||
|
|
||||||
#include "SDL_thread.h"
|
#include "SDL_thread.h"
|
||||||
@@ -14,6 +14,7 @@ namespace GpFiberStarter_SDL
|
|||||||
{
|
{
|
||||||
GpFiberStarter::ThreadFunc_t m_threadFunc;
|
GpFiberStarter::ThreadFunc_t m_threadFunc;
|
||||||
PortabilityLayer::HostThreadEvent *m_creatingReturnEvent;
|
PortabilityLayer::HostThreadEvent *m_creatingReturnEvent;
|
||||||
|
PortabilityLayer::HostThreadEvent *m_creatingWakeEvent;
|
||||||
void *m_context;
|
void *m_context;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -23,29 +24,47 @@ namespace GpFiberStarter_SDL
|
|||||||
|
|
||||||
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
|
GpFiberStarter::ThreadFunc_t threadFunc = tss->m_threadFunc;
|
||||||
PortabilityLayer::HostThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
|
PortabilityLayer::HostThreadEvent *creatingReturnEvent = tss->m_creatingReturnEvent;
|
||||||
|
PortabilityLayer::HostThreadEvent *wakeEvent = tss->m_creatingWakeEvent;
|
||||||
void *context = tss->m_context;
|
void *context = tss->m_context;
|
||||||
creatingReturnEvent->Signal();
|
creatingReturnEvent->Signal();
|
||||||
|
|
||||||
|
wakeEvent->Wait();
|
||||||
|
|
||||||
threadFunc(context);
|
threadFunc(context);
|
||||||
|
|
||||||
return 0;
|
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;
|
GpFiberStarter_SDL::FiberStartState startState;
|
||||||
startState.m_context = context;
|
startState.m_context = context;
|
||||||
startState.m_creatingReturnEvent = returnEvent;
|
startState.m_creatingReturnEvent = returnEvent;
|
||||||
|
startState.m_creatingWakeEvent = wakeEvent;
|
||||||
startState.m_threadFunc = threadFunc;
|
startState.m_threadFunc = threadFunc;
|
||||||
|
|
||||||
SDL_Thread *thread = SDL_CreateThread(GpFiberStarter_SDL::FiberStartRoutine, "Fiber", &startState);
|
SDL_Thread *thread = SDL_CreateThread(GpFiberStarter_SDL::FiberStartRoutine, "Fiber", &startState);
|
||||||
if (!thread)
|
if (!thread)
|
||||||
|
{
|
||||||
|
returnEvent->Destroy();
|
||||||
|
wakeEvent->Destroy();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
returnEvent->Wait();
|
returnEvent->Wait();
|
||||||
|
returnEvent->Destroy();
|
||||||
|
|
||||||
return new GpFiber_SDL(thread, returnEvent);
|
return new GpFiber_SDL(thread, wakeEvent);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
#include "HostSystemServices.h"
|
#include "HostSystemServices.h"
|
||||||
#include "HostThreadEvent.h"
|
#include "HostThreadEvent.h"
|
||||||
|
|
||||||
#include "GpSystemServices_Win32.h"
|
|
||||||
|
|
||||||
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent)
|
GpFiber_SDL::GpFiber_SDL(SDL_Thread *thread, PortabilityLayer::HostThreadEvent *threadEvent)
|
||||||
: m_event(threadEvent)
|
: m_event(threadEvent)
|
||||||
, m_thread(thread)
|
, m_thread(thread)
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#include "Functions.h"
|
#include "Functions.h"
|
||||||
#include "DrawQuadPixelConstants.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 surfaceTexture;\n"\
|
||||||
"uniform sampler2D paletteTexture;\n"\
|
"uniform sampler2D paletteTexture;\n"\
|
||||||
"\n"\
|
"\n"\
|
||||||
@@ -23,6 +25,6 @@
|
|||||||
|
|
||||||
namespace GpBinarizedShaders
|
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_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_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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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"\
|
#define GP_GL_SHADER_CODE_FUNCTIONS_H "vec3 pow3(vec3 v, float ex)\n"\
|
||||||
"{\n"\
|
"{\n"\
|
||||||
" return vec3(pow(v.x, ex), pow(v.y, ex), pow(v.z, ex));\n"\
|
" return vec3(pow(v.x, ex), pow(v.y, ex), pow(v.z, ex));\n"\
|
||||||
|
|||||||
@@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
namespace GpBinarizedShaders
|
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_drawQuadRGBP_GL2;
|
||||||
extern const char *g_drawQuad15BitP_GL2;
|
extern const char *g_drawQuad15BitP_GL2;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#if __cplusplus >= 199711L
|
#if __cplusplus >= 199711L
|
||||||
#define GP_IS_CPP11 1
|
#define GP_IS_CPP11 1
|
||||||
#else
|
#else
|
||||||
|
|||||||
38
FreeType/Android.mk
Normal file
38
FreeType/Android.mk
Normal 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)
|
||||||
@@ -19,9 +19,6 @@
|
|||||||
<Filter Include="Source Files\base">
|
<Filter Include="Source Files\base">
|
||||||
<UniqueIdentifier>{3fb0e907-a078-4943-ab94-631783b69f75}</UniqueIdentifier>
|
<UniqueIdentifier>{3fb0e907-a078-4943-ab94-631783b69f75}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
<Filter Include="Source Files\autofit">
|
|
||||||
<UniqueIdentifier>{61b2d9d3-2578-438e-bbf2-52b3a0f60001}</UniqueIdentifier>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="freetype\src\winfonts\fnterrs.h">
|
<ClInclude Include="freetype\src\winfonts\fnterrs.h">
|
||||||
|
|||||||
88
GpApp/Android.mk
Normal file
88
GpApp/Android.mk
Normal 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)
|
||||||
@@ -233,7 +233,7 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
|
|||||||
short i, j;
|
short i, j;
|
||||||
IGpCursor *hwCursor;
|
IGpCursor *hwCursor;
|
||||||
Boolean result = true;
|
Boolean result = true;
|
||||||
|
|
||||||
if (ballCursH)
|
if (ballCursH)
|
||||||
{
|
{
|
||||||
j = (*ballCursH)->n; // Get the number of cursors
|
j = (*ballCursH)->n; // Get the number of cursors
|
||||||
@@ -266,8 +266,8 @@ Boolean GetColorCursors (acurHandle ballCursH, compiledAcurHandle compiledBallCu
|
|||||||
void InitAnimatedCursor (acurHandle ballCursH)
|
void InitAnimatedCursor (acurHandle ballCursH)
|
||||||
{
|
{
|
||||||
compiledAcurHandle compiledBallCursorH;
|
compiledAcurHandle compiledBallCursorH;
|
||||||
|
|
||||||
if (ballCursH == nil)
|
if (ballCursH == nil)
|
||||||
ballCursH = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('acur', 128).StaticCast<acurRec>();
|
ballCursH = PortabilityLayer::ResourceManager::GetInstance()->GetAppResource('acur', 128).StaticCast<acurRec>();
|
||||||
if (ballCursH && ballCursH != animCursorH)
|
if (ballCursH && ballCursH != animCursorH)
|
||||||
{
|
{
|
||||||
@@ -288,7 +288,7 @@ void InitAnimatedCursor (acurHandle ballCursH)
|
|||||||
|
|
||||||
//-------------------------------------------------------------- LoadCursors
|
//-------------------------------------------------------------- LoadCursors
|
||||||
|
|
||||||
// Just calls the above function. Other code could be added here though<EFBFBD>
|
// Just calls the above function. Other code could be added here though?
|
||||||
// to add additional cursors.
|
// to add additional cursors.
|
||||||
|
|
||||||
void LoadCursors (void)
|
void LoadCursors (void)
|
||||||
@@ -302,8 +302,8 @@ void LoadCursors (void)
|
|||||||
|
|
||||||
void DisposCursors (void)
|
void DisposCursors (void)
|
||||||
{
|
{
|
||||||
register short i, j;
|
short i, j;
|
||||||
|
|
||||||
if (compiledAnimCursorH != nil)
|
if (compiledAnimCursorH != nil)
|
||||||
{
|
{
|
||||||
j = (*animCursorH)->n;
|
j = (*animCursorH)->n;
|
||||||
@@ -372,7 +372,7 @@ void SpinCursor (short incrementIndex)
|
|||||||
{
|
{
|
||||||
UInt32 dummyLong;
|
UInt32 dummyLong;
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
for (i = 0; i < incrementIndex; i++)
|
for (i = 0; i < incrementIndex; i++)
|
||||||
{
|
{
|
||||||
IncrementCursor();
|
IncrementCursor();
|
||||||
@@ -388,7 +388,7 @@ void BackSpinCursor (short decrementIndex)
|
|||||||
{
|
{
|
||||||
UInt32 dummyLong;
|
UInt32 dummyLong;
|
||||||
short i;
|
short i;
|
||||||
|
|
||||||
for (i = 0; i < decrementIndex; i++)
|
for (i = 0; i < decrementIndex; i++)
|
||||||
{
|
{
|
||||||
DecrementCursor();
|
DecrementCursor();
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ short GetThisVolumeRefNum (void)
|
|||||||
{
|
{
|
||||||
PLError_t theErr;
|
PLError_t theErr;
|
||||||
short vRef;
|
short vRef;
|
||||||
|
|
||||||
theErr = GetVol(nil, &vRef);
|
theErr = GetVol(nil, &vRef);
|
||||||
return (vRef);
|
return (vRef);
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ short GetThisVolumeRefNum (void)
|
|||||||
long GetThisCurrentDirectoryID (void)
|
long GetThisCurrentDirectoryID (void)
|
||||||
{
|
{
|
||||||
long dirID;
|
long dirID;
|
||||||
|
|
||||||
dirID = LMGetCurDirStore();
|
dirID = LMGetCurDirStore();
|
||||||
return (dirID);
|
return (dirID);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ Boolean DoWeHaveGestalt (void)
|
|||||||
return (TrapExists(kGestaltTrap));
|
return (TrapExists(kGestaltTrap));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------- DoWeHaveWNE
|
//-------------------------------------------------------------- DoWeHaveWNE
|
||||||
|
|
||||||
// Specifically tests for the availablity of the WaitNextEvent() trap.
|
// Specifically tests for the availablity of the WaitNextEvent() trap.
|
||||||
/*
|
/*
|
||||||
@@ -119,25 +119,25 @@ Boolean DoWeHaveWNE (void)
|
|||||||
return (TrapExists(kWNETrap));
|
return (TrapExists(kWNETrap));
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------- DoWeHaveColor
|
//-------------------------------------------------------------- DoWeHaveColor
|
||||||
// Determines if ROMs support Color QuickDraw (monitor not neccessarily color).
|
// Determines if ROMs support Color QuickDraw (monitor not neccessarily color).
|
||||||
/*
|
/*
|
||||||
Boolean DoWeHaveColor (void)
|
Boolean DoWeHaveColor (void)
|
||||||
{
|
{
|
||||||
SysEnvRec thisWorld;
|
SysEnvRec thisWorld;
|
||||||
|
|
||||||
SysEnvirons(2, &thisWorld);
|
SysEnvirons(2, &thisWorld);
|
||||||
return (thisWorld.hasColorQD);
|
return (thisWorld.hasColorQD);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------- DoWeHaveSystem602
|
//-------------------------------------------------------------- DoWeHaveSystem602
|
||||||
// Determines if the System version is at least 6.0.2 or more recent.
|
// Determines if the System version is at least 6.0.2 or more recent.
|
||||||
/*
|
/*
|
||||||
Boolean DoWeHaveSystem602 (void)
|
Boolean DoWeHaveSystem602 (void)
|
||||||
{
|
{
|
||||||
SysEnvRec thisWorld;
|
SysEnvRec thisWorld;
|
||||||
Boolean haveIt;
|
Boolean haveIt;
|
||||||
|
|
||||||
SysEnvirons(2, &thisWorld);
|
SysEnvirons(2, &thisWorld);
|
||||||
if (thisWorld.systemVersion >= 0x0602)
|
if (thisWorld.systemVersion >= 0x0602)
|
||||||
haveIt = true;
|
haveIt = true;
|
||||||
@@ -146,14 +146,14 @@ Boolean DoWeHaveSystem602 (void)
|
|||||||
return (haveIt);
|
return (haveIt);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------- DoWeHaveSystem605
|
//-------------------------------------------------------------- DoWeHaveSystem605
|
||||||
// Determines if the System version is at least 6.0.5 or more recent.
|
// Determines if the System version is at least 6.0.5 or more recent.
|
||||||
/*
|
/*
|
||||||
Boolean DoWeHaveSystem605 (void)
|
Boolean DoWeHaveSystem605 (void)
|
||||||
{
|
{
|
||||||
SysEnvRec thisWorld;
|
SysEnvRec thisWorld;
|
||||||
Boolean haveIt;
|
Boolean haveIt;
|
||||||
|
|
||||||
SysEnvirons(2, &thisWorld);
|
SysEnvirons(2, &thisWorld);
|
||||||
if (thisWorld.systemVersion >= 0x0605)
|
if (thisWorld.systemVersion >= 0x0605)
|
||||||
haveIt = true;
|
haveIt = true;
|
||||||
@@ -161,16 +161,16 @@ Boolean DoWeHaveSystem605 (void)
|
|||||||
haveIt = false;
|
haveIt = false;
|
||||||
return (haveIt);
|
return (haveIt);
|
||||||
}
|
}
|
||||||
/
|
*/
|
||||||
//-------------------------------------------------------------- DoWeHaveSystem7
|
//-------------------------------------------------------------- DoWeHaveSystem7
|
||||||
|
|
||||||
// Determines if the System version is at least 7.0.0 or more recent.
|
// Determines if the System version is at least 7.0.0 or more recent.
|
||||||
|
/*
|
||||||
Boolean DoWeHaveSystem7 (void)
|
Boolean DoWeHaveSystem7 (void)
|
||||||
{
|
{
|
||||||
SysEnvRec thisWorld;
|
SysEnvRec thisWorld;
|
||||||
Boolean haveIt;
|
Boolean haveIt;
|
||||||
|
|
||||||
SysEnvirons(2, &thisWorld);
|
SysEnvirons(2, &thisWorld);
|
||||||
if (thisWorld.systemVersion >= 0x0700)
|
if (thisWorld.systemVersion >= 0x0700)
|
||||||
haveIt = true;
|
haveIt = true;
|
||||||
@@ -178,7 +178,7 @@ Boolean DoWeHaveSystem7 (void)
|
|||||||
haveIt = false;
|
haveIt = false;
|
||||||
return (haveIt);
|
return (haveIt);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
//-------------------------------------------------------------- DoWeHaveSoundManager3
|
//-------------------------------------------------------------- DoWeHaveSoundManager3
|
||||||
// Determines if the Sound Manager version is at least 3.0.0 or more recent.
|
// Determines if the Sound Manager version is at least 3.0.0 or more recent.
|
||||||
/*
|
/*
|
||||||
@@ -186,12 +186,12 @@ Boolean DoWeHaveSoundManager3 (void)
|
|||||||
{
|
{
|
||||||
// NumVersion version;
|
// NumVersion version;
|
||||||
Boolean hasIt;
|
Boolean hasIt;
|
||||||
|
|
||||||
hasIt = true;
|
hasIt = true;
|
||||||
|
|
||||||
version = SndSoundManagerVersion();
|
version = SndSoundManagerVersion();
|
||||||
hasIt = (version.majorRev >= 3);
|
hasIt = (version.majorRev >= 3);
|
||||||
|
|
||||||
return hasIt;
|
return hasIt;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -213,35 +213,35 @@ void SwitchToDepth (short, Boolean)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- CanWeDisplay4Bit
|
//-------------------------------------------------------------- CanWeDisplay4Bit
|
||||||
// Determines if device (monitor) capable of supporting 4 bit (16 colors/grays).
|
// Determines if device (monitor) capable of supporting 4 bit (16 colors/grays).
|
||||||
/*
|
/*
|
||||||
Boolean CanWeDisplay4Bit (GDHandle theDevice)
|
Boolean CanWeDisplay4Bit (GDHandle theDevice)
|
||||||
{
|
{
|
||||||
short canDepth;
|
short canDepth;
|
||||||
Boolean canDo;
|
Boolean canDo;
|
||||||
|
|
||||||
canDo = false;
|
canDo = false;
|
||||||
canDepth = HasDepth(theDevice, 4, 1, 0);
|
canDepth = HasDepth(theDevice, 4, 1, 0);
|
||||||
if (canDepth != 0)
|
if (canDepth != 0)
|
||||||
canDo = true;
|
canDo = true;
|
||||||
|
|
||||||
return (canDo);
|
return (canDo);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
//-------------------------------------------------------------- CanWeDisplay1Bit
|
//-------------------------------------------------------------- CanWeDisplay1Bit
|
||||||
// Determines if device (monitor) capable of supporting 1 bit (black & white).
|
// Determines if device (monitor) capable of supporting 1 bit (black & white).
|
||||||
/*
|
/*
|
||||||
Boolean CanWeDisplay1Bit (GDHandle theDevice)
|
Boolean CanWeDisplay1Bit (GDHandle theDevice)
|
||||||
{
|
{
|
||||||
short canDepth;
|
short canDepth;
|
||||||
Boolean canDo;
|
Boolean canDo;
|
||||||
|
|
||||||
canDo = false;
|
canDo = false;
|
||||||
canDepth = HasDepth(theDevice, 1, 1, 0);
|
canDepth = HasDepth(theDevice, 1, 1, 0);
|
||||||
if (canDepth != 0)
|
if (canDepth != 0)
|
||||||
canDo = true;
|
canDo = true;
|
||||||
|
|
||||||
return (canDo);
|
return (canDo);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
@@ -278,12 +278,12 @@ void FlushResolutionChange(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------- CheckOurEnvirons
|
//-------------------------------------------------------------- CheckOurEnvirons
|
||||||
// Calls all the above functions in order to fill out a sort of "spec sheet"<22>
|
// Calls all the above functions in order to fill out a sort of "spec sheet"<22>
|
||||||
// for the current Mac.
|
// for the current Mac.
|
||||||
|
|
||||||
void CheckOurEnvirons (void)
|
void CheckOurEnvirons (void)
|
||||||
{
|
{
|
||||||
thisMac.vRefNum = 0; // TEMP
|
thisMac.vRefNum = 0; // TEMP
|
||||||
thisMac.dirID = 0; // TEMP
|
thisMac.dirID = 0; // TEMP
|
||||||
thisMac.hasGestalt = true; // TEMP
|
thisMac.hasGestalt = true; // TEMP
|
||||||
@@ -294,7 +294,7 @@ void CheckOurEnvirons (void)
|
|||||||
thisMac.hasSM3 = true; // TEMP
|
thisMac.hasSM3 = true; // TEMP
|
||||||
thisMac.hasQT = DoWeHaveQuickTime();
|
thisMac.hasQT = DoWeHaveQuickTime();
|
||||||
thisMac.hasDrag = DoWeHaveDragManager();
|
thisMac.hasDrag = DoWeHaveDragManager();
|
||||||
|
|
||||||
thisMac.can1Bit = true;
|
thisMac.can1Bit = true;
|
||||||
thisMac.can4Bit = true;
|
thisMac.can4Bit = true;
|
||||||
thisMac.can8Bit = true;
|
thisMac.can8Bit = true;
|
||||||
@@ -368,13 +368,13 @@ void InstallResolutionHandler(void)
|
|||||||
void ReflectSecondMonitorEnvirons (Boolean use1Bit, Boolean use4Bit, Boolean use8Bit)
|
void ReflectSecondMonitorEnvirons (Boolean use1Bit, Boolean use4Bit, Boolean use8Bit)
|
||||||
{
|
{
|
||||||
GDHandle tempGDevice;
|
GDHandle tempGDevice;
|
||||||
|
|
||||||
tempGDevice = GetDeviceList();
|
tempGDevice = GetDeviceList();
|
||||||
while (tempGDevice != nil)
|
while (tempGDevice != nil)
|
||||||
{
|
{
|
||||||
if (TestDeviceAttribute(tempGDevice, screenDevice))
|
if (TestDeviceAttribute(tempGDevice, screenDevice))
|
||||||
if ((use1Bit && CanWeDisplay1Bit(tempGDevice)) ||
|
if ((use1Bit && CanWeDisplay1Bit(tempGDevice)) ||
|
||||||
(use4Bit && CanWeDisplay4Bit(tempGDevice)) ||
|
(use4Bit && CanWeDisplay4Bit(tempGDevice)) ||
|
||||||
(use8Bit && CanWeDisplay8Bit(tempGDevice)))
|
(use8Bit && CanWeDisplay8Bit(tempGDevice)))
|
||||||
if (!TestDeviceAttribute(tempGDevice, mainScreen))
|
if (!TestDeviceAttribute(tempGDevice, mainScreen))
|
||||||
{
|
{
|
||||||
@@ -418,8 +418,8 @@ void HandleDepthSwitching (void)
|
|||||||
|
|
||||||
//-------------------------------------------------------------- CheckMemorySize
|
//-------------------------------------------------------------- CheckMemorySize
|
||||||
|
|
||||||
// Tests for a specific amount of memory available. If the required memory<72>
|
// Tests for a specific amount of memory available. If the required memory<72>
|
||||||
// is not available, attempts to turn off various game features (music, etc.)<29>
|
// is not available, attempts to turn off various game features (music, etc.)<29>
|
||||||
// in order to accomodate the constrained memory available.
|
// in order to accomodate the constrained memory available.
|
||||||
|
|
||||||
void CheckMemorySize (void)
|
void CheckMemorySize (void)
|
||||||
@@ -428,10 +428,10 @@ void CheckMemorySize (void)
|
|||||||
#define kPaddingBytes 204800L // 200K Padding
|
#define kPaddingBytes 204800L // 200K Padding
|
||||||
long bytesNeeded;
|
long bytesNeeded;
|
||||||
long soundBytes, musicBytes;
|
long soundBytes, musicBytes;
|
||||||
|
|
||||||
dontLoadMusic = false;
|
dontLoadMusic = false;
|
||||||
dontLoadSounds = false;
|
dontLoadSounds = false;
|
||||||
|
|
||||||
bytesNeeded = kBaseBytesNeeded; // base memory
|
bytesNeeded = kBaseBytesNeeded; // base memory
|
||||||
soundBytes = SoundBytesNeeded(); // sound memory
|
soundBytes = SoundBytesNeeded(); // sound memory
|
||||||
if (soundBytes <= 0L)
|
if (soundBytes <= 0L)
|
||||||
@@ -444,15 +444,15 @@ void CheckMemorySize (void)
|
|||||||
else
|
else
|
||||||
bytesNeeded += musicBytes;
|
bytesNeeded += musicBytes;
|
||||||
bytesNeeded += 4L * (long)thisMac.constrainedScreen.bottom; // main screen
|
bytesNeeded += 4L * (long)thisMac.constrainedScreen.bottom; // main screen
|
||||||
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) *
|
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) *
|
||||||
((long)houseRect.bottom + 1 - (long)houseRect.top) *
|
((long)houseRect.bottom + 1 - (long)houseRect.top) *
|
||||||
(long)thisMac.isDepth) / 8L; // work map
|
(long)thisMac.isDepth) / 8L; // work map
|
||||||
bytesNeeded += 4L * (long)houseRect.bottom;
|
bytesNeeded += 4L * (long)houseRect.bottom;
|
||||||
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) *
|
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) *
|
||||||
((long)houseRect.bottom + 1 - (long)houseRect.top) *
|
((long)houseRect.bottom + 1 - (long)houseRect.top) *
|
||||||
(long)thisMac.isDepth) / 8L; // back map
|
(long)thisMac.isDepth) / 8L; // back map
|
||||||
bytesNeeded += 4L * houseRect.bottom;
|
bytesNeeded += 4L * houseRect.bottom;
|
||||||
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) * 21 *
|
bytesNeeded += (((long)houseRect.right - (long)houseRect.left) * 21 *
|
||||||
(long)thisMac.isDepth) / 8L; // scoreboard map
|
(long)thisMac.isDepth) / 8L; // scoreboard map
|
||||||
bytesNeeded += (6396L * (long)thisMac.isDepth) / 8L; // more scoreboard
|
bytesNeeded += (6396L * (long)thisMac.isDepth) / 8L; // more scoreboard
|
||||||
bytesNeeded += (32112L * (long)thisMac.isDepth) / 8L; // glider map
|
bytesNeeded += (32112L * (long)thisMac.isDepth) / 8L; // glider map
|
||||||
@@ -516,7 +516,7 @@ void CheckMemorySize (void)
|
|||||||
bytesNeeded += sizeof(dynaType) * kMaxDynamicObs;
|
bytesNeeded += sizeof(dynaType) * kMaxDynamicObs;
|
||||||
bytesNeeded += sizeof(objDataType) * kMaxMasterObjects;
|
bytesNeeded += sizeof(objDataType) * kMaxMasterObjects;
|
||||||
bytesNeeded += kDemoLength; SpinCursor(1);
|
bytesNeeded += kDemoLength; SpinCursor(1);
|
||||||
|
|
||||||
SpinCursor(1);
|
SpinCursor(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ typedef struct
|
|||||||
objectType objects[kMaxRoomObs]; // 24 * 12
|
objectType objects[kMaxRoomObs]; // 24 * 12
|
||||||
} roomType, *roomPtr; // total = 348
|
} roomType, *roomPtr; // total = 348
|
||||||
|
|
||||||
typedef struct
|
struct houseType
|
||||||
{
|
{
|
||||||
int16_t version; // 2
|
int16_t version; // 2
|
||||||
int16_t unusedShort; // 2
|
int16_t unusedShort; // 2
|
||||||
@@ -198,9 +198,12 @@ typedef struct
|
|||||||
|
|
||||||
int16_t padding;
|
int16_t padding;
|
||||||
roomType rooms[1]; // 348 * nRooms
|
roomType rooms[1]; // 348 * nRooms
|
||||||
|
// total = 866 +
|
||||||
|
|
||||||
static const size_t kBinaryDataSize = 866;
|
static const size_t kBinaryDataSize = 866;
|
||||||
} houseType, *housePtr; // total = 866 +
|
};
|
||||||
|
|
||||||
|
typedef houseType *housePtr;
|
||||||
|
|
||||||
typedef THandle<houseType> houseHand;
|
typedef THandle<houseType> houseHand;
|
||||||
|
|
||||||
|
|||||||
30
GpApp/SoundSync_Cpp11.cpp
Normal file
30
GpApp/SoundSync_Cpp11.cpp
Normal 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;
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
enum EGpAudioDriverType
|
enum EGpAudioDriverType
|
||||||
{
|
{
|
||||||
|
EGpAudioDriverType_None,
|
||||||
|
|
||||||
EGpAudioDriverType_XAudio2,
|
EGpAudioDriverType_XAudio2,
|
||||||
EGpAudioDriverType_SDL2,
|
EGpAudioDriverType_SDL2,
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class GpComPtr final
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GpComPtr();
|
GpComPtr();
|
||||||
const GpComPtr(const GpComPtr<T> &other);
|
GpComPtr(const GpComPtr<T> &other);
|
||||||
explicit GpComPtr(T *ptr);
|
explicit GpComPtr(T *ptr);
|
||||||
~GpComPtr();
|
~GpComPtr();
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,11 @@ struct IGpFiber;
|
|||||||
struct IGpVOSEventQueue;
|
struct IGpVOSEventQueue;
|
||||||
struct IGpLogDriver;
|
struct IGpLogDriver;
|
||||||
|
|
||||||
|
namespace PortabilityLayer
|
||||||
|
{
|
||||||
|
class HostSystemServices;
|
||||||
|
}
|
||||||
|
|
||||||
struct GpDisplayDriverProperties
|
struct GpDisplayDriverProperties
|
||||||
{
|
{
|
||||||
typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber);
|
typedef GpDisplayDriverTickStatus_t (*TickFunc_t)(void *context, IGpFiber *vosFiber);
|
||||||
@@ -41,4 +46,5 @@ struct GpDisplayDriverProperties
|
|||||||
|
|
||||||
IGpVOSEventQueue *m_eventQueue;
|
IGpVOSEventQueue *m_eventQueue;
|
||||||
IGpLogDriver *m_logger;
|
IGpLogDriver *m_logger;
|
||||||
|
PortabilityLayer::HostSystemServices *m_systemServices;
|
||||||
};
|
};
|
||||||
|
|||||||
20
GpFontHandler_FreeType2/Android.mk
Normal file
20
GpFontHandler_FreeType2/Android.mk
Normal 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)
|
||||||
@@ -425,7 +425,11 @@ bool GpFontHandler_FreeType2::Init()
|
|||||||
return true;
|
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();
|
return GpFontHandler_FreeType2::Create();
|
||||||
}
|
}
|
||||||
|
|||||||
26
GpShell/Android.mk
Normal file
26
GpShell/Android.mk
Normal 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)
|
||||||
@@ -18,6 +18,7 @@ GpAppEnvironment::GpAppEnvironment()
|
|||||||
, m_numInputDrivers(0)
|
, m_numInputDrivers(0)
|
||||||
, m_fontHandler(nullptr)
|
, m_fontHandler(nullptr)
|
||||||
, m_vosEventQueue(nullptr)
|
, m_vosEventQueue(nullptr)
|
||||||
|
, m_systemServices(nullptr)
|
||||||
, m_applicationFiber(nullptr)
|
, m_applicationFiber(nullptr)
|
||||||
, m_vosFiber(nullptr)
|
, m_vosFiber(nullptr)
|
||||||
, m_suspendCallID(PortabilityLayer::HostSuspendCallID_Unknown)
|
, m_suspendCallID(PortabilityLayer::HostSuspendCallID_Unknown)
|
||||||
@@ -50,7 +51,7 @@ GpDisplayDriverTickStatus_t GpAppEnvironment::Tick(IGpFiber *vosFiber)
|
|||||||
{
|
{
|
||||||
case ApplicationState_NotStarted:
|
case ApplicationState_NotStarted:
|
||||||
InitializeApplicationState();
|
InitializeApplicationState();
|
||||||
m_applicationFiber = GpFiberStarter::StartFiber(GpAppEnvironment::StaticAppThreadFunc, this, vosFiber);
|
m_applicationFiber = GpFiberStarter::StartFiber(m_systemServices, GpAppEnvironment::StaticAppThreadFunc, this, vosFiber);
|
||||||
m_applicationState = ApplicationState_Running;
|
m_applicationState = ApplicationState_Running;
|
||||||
break;
|
break;
|
||||||
case ApplicationState_WaitingForEvents:
|
case ApplicationState_WaitingForEvents:
|
||||||
@@ -125,6 +126,11 @@ void GpAppEnvironment::SetVOSEventQueue(GpVOSEventQueue *eventQueue)
|
|||||||
m_vosEventQueue = eventQueue;
|
m_vosEventQueue = eventQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GpAppEnvironment::SetSystemServices(PortabilityLayer::HostSystemServices *systemServices)
|
||||||
|
{
|
||||||
|
m_systemServices = systemServices;
|
||||||
|
}
|
||||||
|
|
||||||
void GpAppEnvironment::StaticAppThreadFunc(void *context)
|
void GpAppEnvironment::StaticAppThreadFunc(void *context)
|
||||||
{
|
{
|
||||||
static_cast<GpAppEnvironment*>(context)->AppThreadFunc();
|
static_cast<GpAppEnvironment*>(context)->AppThreadFunc();
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
union HostSuspendCallArgument;
|
union HostSuspendCallArgument;
|
||||||
class HostVOSEventQueue;
|
class HostVOSEventQueue;
|
||||||
|
class HostSystemServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct IGpDisplayDriver;
|
struct IGpDisplayDriver;
|
||||||
@@ -35,6 +36,7 @@ public:
|
|||||||
void SetInputDrivers(IGpInputDriver *const* inputDrivers, size_t numDrivers);
|
void SetInputDrivers(IGpInputDriver *const* inputDrivers, size_t numDrivers);
|
||||||
void SetFontHandler(IGpFontHandler *fontHandler);
|
void SetFontHandler(IGpFontHandler *fontHandler);
|
||||||
void SetVOSEventQueue(GpVOSEventQueue *eventQueue);
|
void SetVOSEventQueue(GpVOSEventQueue *eventQueue);
|
||||||
|
void SetSystemServices(PortabilityLayer::HostSystemServices *systemServices);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum ApplicationState
|
enum ApplicationState
|
||||||
@@ -61,6 +63,7 @@ private:
|
|||||||
IGpInputDriver *const* m_inputDrivers;
|
IGpInputDriver *const* m_inputDrivers;
|
||||||
IGpFontHandler *m_fontHandler;
|
IGpFontHandler *m_fontHandler;
|
||||||
GpVOSEventQueue *m_vosEventQueue;
|
GpVOSEventQueue *m_vosEventQueue;
|
||||||
|
PortabilityLayer::HostSystemServices *m_systemServices;
|
||||||
IGpFiber *m_applicationFiber;
|
IGpFiber *m_applicationFiber;
|
||||||
IGpFiber *m_vosFiber;
|
IGpFiber *m_vosFiber;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct IGpFiber;
|
struct IGpFiber;
|
||||||
|
|
||||||
|
namespace PortabilityLayer
|
||||||
|
{
|
||||||
|
class HostSystemServices;
|
||||||
|
}
|
||||||
|
|
||||||
class GpFiberStarter
|
class GpFiberStarter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef void(*ThreadFunc_t)(void *context);
|
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);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,19 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "EGpDisplayDriverType.h"
|
#include "EGpDisplayDriverType.h"
|
||||||
#include "EGpAudioDriverType.h"
|
#include "EGpAudioDriverType.h"
|
||||||
#include "EGpFontHandlerType.h"
|
#include "EGpFontHandlerType.h"
|
||||||
#include "EGpInputDriverType.h"
|
#include "EGpInputDriverType.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
struct IGpLogDriver;
|
struct IGpLogDriver;
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
class HostSystemServices;
|
class HostSystemServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct GpGlobalConfig
|
struct GpGlobalConfig
|
||||||
{
|
{
|
||||||
EGpDisplayDriverType m_displayDriverType;
|
EGpDisplayDriverType m_displayDriverType;
|
||||||
EGpAudioDriverType m_audioDriverType;
|
EGpAudioDriverType m_audioDriverType;
|
||||||
EGpFontHandlerType m_fontHandlerType;
|
EGpFontHandlerType m_fontHandlerType;
|
||||||
@@ -23,7 +25,7 @@ struct GpGlobalConfig
|
|||||||
|
|
||||||
IGpLogDriver *m_logger;
|
IGpLogDriver *m_logger;
|
||||||
PortabilityLayer::HostSystemServices *m_systemServices;
|
PortabilityLayer::HostSystemServices *m_systemServices;
|
||||||
void *m_osGlobals;
|
void *m_osGlobals;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern GpGlobalConfig g_gpGlobalConfig;
|
extern GpGlobalConfig g_gpGlobalConfig;
|
||||||
|
|||||||
@@ -66,6 +66,7 @@ int GpMain::Run()
|
|||||||
ddProps.m_osGlobals = g_gpGlobalConfig.m_osGlobals;
|
ddProps.m_osGlobals = g_gpGlobalConfig.m_osGlobals;
|
||||||
ddProps.m_eventQueue = eventQueue;
|
ddProps.m_eventQueue = eventQueue;
|
||||||
ddProps.m_logger = g_gpGlobalConfig.m_logger;
|
ddProps.m_logger = g_gpGlobalConfig.m_logger;
|
||||||
|
ddProps.m_systemServices = g_gpGlobalConfig.m_systemServices;
|
||||||
|
|
||||||
GpAudioDriverProperties adProps;
|
GpAudioDriverProperties adProps;
|
||||||
memset(&adProps, 0, sizeof(adProps));
|
memset(&adProps, 0, sizeof(adProps));
|
||||||
@@ -116,6 +117,7 @@ int GpMain::Run()
|
|||||||
appEnvironment->SetInputDrivers(inputDrivers, numCreatedInputDrivers);
|
appEnvironment->SetInputDrivers(inputDrivers, numCreatedInputDrivers);
|
||||||
appEnvironment->SetFontHandler(fontHandler);
|
appEnvironment->SetFontHandler(fontHandler);
|
||||||
appEnvironment->SetVOSEventQueue(eventQueue);
|
appEnvironment->SetVOSEventQueue(eventQueue);
|
||||||
|
appEnvironment->SetSystemServices(g_gpGlobalConfig.m_systemServices);
|
||||||
|
|
||||||
// Start the display loop
|
// Start the display loop
|
||||||
displayDriver->Run();
|
displayDriver->Run();
|
||||||
@@ -129,7 +131,5 @@ int GpMain::Run()
|
|||||||
free(inputDrivers);
|
free(inputDrivers);
|
||||||
}
|
}
|
||||||
|
|
||||||
// GP TODO: Cleanup
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
12
MacRomanConversion/Android.mk
Normal file
12
MacRomanConversion/Android.mk
Normal 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
112
PortabilityLayer/Android.mk
Normal 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)
|
||||||
@@ -1,302 +1,302 @@
|
|||||||
#include "BinHex4.h"
|
#include "BinHex4.h"
|
||||||
#include "GpIOStream.h"
|
#include "GpIOStream.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
// See: https://files.stairways.com/other/binhex-40-specs-info.txt
|
// See: https://files.stairways.com/other/binhex-40-specs-info.txt
|
||||||
// Unfortunately, while the spec specifies that decoding is to be done high-to-low,
|
// Unfortunately, while the spec specifies that decoding is to be done high-to-low,
|
||||||
// it doesn't specify how the encoded 6-bit value is split.
|
// it doesn't specify how the encoded 6-bit value is split.
|
||||||
|
|
||||||
#include "MacFileInfo.h"
|
#include "MacFileInfo.h"
|
||||||
#include "ByteUnpack.h"
|
#include "ByteUnpack.h"
|
||||||
#include "XModemCRC.h"
|
#include "XModemCRC.h"
|
||||||
#include "MacFileMem.h"
|
#include "MacFileMem.h"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
static bool IsEOL(char c)
|
static bool IsEOL(char c)
|
||||||
{
|
{
|
||||||
return c == '\r' || c == '\n';
|
return c == '\r' || c == '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool IsWhitespaceChar(char c)
|
static bool IsWhitespaceChar(char c)
|
||||||
{
|
{
|
||||||
return c == '\r' || c == '\n' || c == ' ' || c == '\t';
|
return c == '\r' || c == '\n' || c == ' ' || c == '\t';
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t BinHexCRCNoPadding(const uint8_t *bytes, size_t size, int initialValue)
|
uint16_t BinHexCRCNoPadding(const uint8_t *bytes, size_t size, int initialValue)
|
||||||
{
|
{
|
||||||
uint16_t crc = initialValue;
|
uint16_t crc = initialValue;
|
||||||
for (size_t b = 0; b < size; b++)
|
for (size_t b = 0; b < size; b++)
|
||||||
{
|
{
|
||||||
uint8_t v = bytes[b];
|
uint8_t v = bytes[b];
|
||||||
|
|
||||||
for (int i = 0; i < 8; i++)
|
for (int i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
int temp = (crc & 0x8000);
|
int temp = (crc & 0x8000);
|
||||||
crc = (crc << 1) | (v >> 7);
|
crc = (crc << 1) | (v >> 7);
|
||||||
|
|
||||||
if (temp)
|
if (temp)
|
||||||
crc = crc ^ 0x1021;
|
crc = crc ^ 0x1021;
|
||||||
|
|
||||||
v = (v << 1) & 0xff;
|
v = (v << 1) & 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<uint16_t>(crc);
|
return static_cast<uint16_t>(crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t BinHexCRC(const uint8_t *bytes, size_t size)
|
uint16_t BinHexCRC(const uint8_t *bytes, size_t size)
|
||||||
{
|
{
|
||||||
const uint8_t zeroBytes[] = { 0, 0 };
|
const uint8_t zeroBytes[] = { 0, 0 };
|
||||||
|
|
||||||
uint16_t crc = BinHexCRCNoPadding(bytes, size, 0);
|
uint16_t crc = BinHexCRCNoPadding(bytes, size, 0);
|
||||||
return BinHexCRCNoPadding(zeroBytes, 2, crc);
|
return BinHexCRCNoPadding(zeroBytes, 2, crc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
MacFileMem *BinHex4::LoadHQX(GpIOStream *stream)
|
MacFileMem *BinHex4::LoadHQX(GpIOStream *stream)
|
||||||
{
|
{
|
||||||
const uint8_t errCodeChar = 64;
|
const uint8_t errCodeChar = 64;
|
||||||
|
|
||||||
uint8_t charMap[128];
|
uint8_t charMap[128];
|
||||||
for (int i = 0; i < 128; i++)
|
for (int i = 0; i < 128; i++)
|
||||||
charMap[i] = errCodeChar;
|
charMap[i] = errCodeChar;
|
||||||
|
|
||||||
const char binHexCharacters[] = "!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
|
const char binHexCharacters[] = "!\"#$%&'()*+,-012345689@ABCDEFGHIJKLMNPQRSTUVXYZ[`abcdefhijklmpqr";
|
||||||
|
|
||||||
for (int i = 0; i < 64; i++)
|
for (int i = 0; i < 64; i++)
|
||||||
charMap[binHexCharacters[i]] = static_cast<uint8_t>(i);
|
charMap[binHexCharacters[i]] = static_cast<uint8_t>(i);
|
||||||
|
|
||||||
const char expectedPrefix[] = "(This file must be converted with BinHex";
|
const char expectedPrefix[] = "(This file must be converted with BinHex";
|
||||||
const size_t prefixSizeChars = sizeof(expectedPrefix) - 1;
|
const size_t prefixSizeChars = sizeof(expectedPrefix) - 1;
|
||||||
char prefix[prefixSizeChars];
|
char prefix[prefixSizeChars];
|
||||||
|
|
||||||
if (stream->Read(prefix, prefixSizeChars) != prefixSizeChars)
|
if (stream->Read(prefix, prefixSizeChars) != prefixSizeChars)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (memcmp(prefix, expectedPrefix, prefixSizeChars))
|
if (memcmp(prefix, expectedPrefix, prefixSizeChars))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Find end char
|
// Find end char
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char nextChar;
|
char nextChar;
|
||||||
if (!stream->Read(&nextChar, 1))
|
if (!stream->Read(&nextChar, 1))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (IsEOL(nextChar))
|
if (IsEOL(nextChar))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find start colon
|
// Find start colon
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
char nextChar;
|
char nextChar;
|
||||||
if (!stream->Read(&nextChar, 1))
|
if (!stream->Read(&nextChar, 1))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (IsWhitespaceChar(nextChar))
|
if (IsWhitespaceChar(nextChar))
|
||||||
continue;
|
continue;
|
||||||
else if (nextChar == ':')
|
else if (nextChar == ':')
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> bytesAfter6To8;
|
std::vector<uint8_t> bytesAfter6To8;
|
||||||
|
|
||||||
if (stream->IsSeekable())
|
if (stream->IsSeekable())
|
||||||
{
|
{
|
||||||
GpUFilePos_t filePos = stream->Tell();
|
GpUFilePos_t filePos = stream->Tell();
|
||||||
if (stream->SeekEnd(0))
|
if (stream->SeekEnd(0))
|
||||||
{
|
{
|
||||||
GpUFilePos_t endPos = stream->Tell();
|
GpUFilePos_t endPos = stream->Tell();
|
||||||
if (!stream->SeekStart(filePos))
|
if (!stream->SeekStart(filePos))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (endPos > filePos && (endPos - filePos) < SIZE_MAX / 6)
|
if (endPos > filePos && (endPos - filePos) < SIZE_MAX / 6)
|
||||||
bytesAfter6To8.reserve(static_cast<size_t>(endPos - filePos) * 6 / 8);
|
bytesAfter6To8.reserve(static_cast<size_t>(endPos - filePos) * 6 / 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Undo 8-to-6 coding
|
// Undo 8-to-6 coding
|
||||||
const size_t bufferCapacity = 128;
|
const size_t bufferCapacity = 128;
|
||||||
size_t bufferReadPos = 0;
|
size_t bufferReadPos = 0;
|
||||||
size_t bufferSize = 0;
|
size_t bufferSize = 0;
|
||||||
char buffer[bufferCapacity];
|
char buffer[bufferCapacity];
|
||||||
|
|
||||||
bool isEOF = false;
|
bool isEOF = false;
|
||||||
|
|
||||||
int decodedByte = 0;
|
int decodedByte = 0;
|
||||||
int decodedByteBitPos = 8;
|
int decodedByteBitPos = 8;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (bufferReadPos == bufferSize)
|
if (bufferReadPos == bufferSize)
|
||||||
{
|
{
|
||||||
const size_t numRead = stream->Read(buffer, bufferCapacity);
|
const size_t numRead = stream->Read(buffer, bufferCapacity);
|
||||||
if (numRead == 0)
|
if (numRead == 0)
|
||||||
return nullptr; // Missing terminator
|
return nullptr; // Missing terminator
|
||||||
|
|
||||||
bufferSize = numRead;
|
bufferSize = numRead;
|
||||||
bufferReadPos = 0;
|
bufferReadPos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
char nextChar = buffer[bufferReadPos++];
|
char nextChar = buffer[bufferReadPos++];
|
||||||
|
|
||||||
if (nextChar == ':')
|
if (nextChar == ':')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (IsWhitespaceChar(nextChar))
|
if (IsWhitespaceChar(nextChar))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (nextChar < 0 || nextChar > 127)
|
if (nextChar < 0 || nextChar > 127)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
uint8_t value6Bit = charMap[nextChar];
|
uint8_t value6Bit = charMap[nextChar];
|
||||||
if (value6Bit == errCodeChar)
|
if (value6Bit == errCodeChar)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
switch (decodedByteBitPos)
|
switch (decodedByteBitPos)
|
||||||
{
|
{
|
||||||
case 8:
|
case 8:
|
||||||
decodedByte = value6Bit << 2;
|
decodedByte = value6Bit << 2;
|
||||||
decodedByteBitPos = 2;
|
decodedByteBitPos = 2;
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
decodedByte |= value6Bit;
|
decodedByte |= value6Bit;
|
||||||
bytesAfter6To8.push_back(decodedByte);
|
bytesAfter6To8.push_back(decodedByte);
|
||||||
decodedByte = 0;
|
decodedByte = 0;
|
||||||
decodedByteBitPos = 8;
|
decodedByteBitPos = 8;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
decodedByte |= (value6Bit >> 2);
|
decodedByte |= (value6Bit >> 2);
|
||||||
bytesAfter6To8.push_back(decodedByte);
|
bytesAfter6To8.push_back(decodedByte);
|
||||||
decodedByte = (value6Bit << 6) & 0xff;
|
decodedByte = (value6Bit << 6) & 0xff;
|
||||||
decodedByteBitPos = 6;
|
decodedByteBitPos = 6;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
decodedByte |= (value6Bit >> 4);
|
decodedByte |= (value6Bit >> 4);
|
||||||
bytesAfter6To8.push_back(decodedByte);
|
bytesAfter6To8.push_back(decodedByte);
|
||||||
decodedByte = (value6Bit << 4) & 0xff;
|
decodedByte = (value6Bit << 4) & 0xff;
|
||||||
decodedByteBitPos = 4;
|
decodedByteBitPos = 4;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const size_t bytesBeforeRLEDec = bytesAfter6To8.size();
|
const size_t bytesBeforeRLEDec = bytesAfter6To8.size();
|
||||||
size_t decodedDataSize = 0;
|
size_t decodedDataSize = 0;
|
||||||
for (size_t i = 0; i < bytesBeforeRLEDec; i++)
|
for (size_t i = 0; i < bytesBeforeRLEDec; i++)
|
||||||
{
|
{
|
||||||
const uint8_t b = bytesAfter6To8[i];
|
const uint8_t b = bytesAfter6To8[i];
|
||||||
if (b == 0x90)
|
if (b == 0x90)
|
||||||
{
|
{
|
||||||
if (i == bytesBeforeRLEDec - 1)
|
if (i == bytesBeforeRLEDec - 1)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const uint8_t runLength = bytesAfter6To8[++i];
|
const uint8_t runLength = bytesAfter6To8[++i];
|
||||||
|
|
||||||
if (runLength == 0)
|
if (runLength == 0)
|
||||||
decodedDataSize++; // 0x90 literal
|
decodedDataSize++; // 0x90 literal
|
||||||
else
|
else
|
||||||
decodedDataSize += runLength - 1; // RLE, runs of length 1 are permitted
|
decodedDataSize += runLength - 1; // RLE, runs of length 1 are permitted
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
decodedDataSize++;
|
decodedDataSize++;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<uint8_t> decodedBytes;
|
std::vector<uint8_t> decodedBytes;
|
||||||
decodedBytes.reserve(decodedDataSize);
|
decodedBytes.reserve(decodedDataSize);
|
||||||
|
|
||||||
for (size_t i = 0; i < bytesBeforeRLEDec; i++)
|
for (size_t i = 0; i < bytesBeforeRLEDec; i++)
|
||||||
{
|
{
|
||||||
const uint8_t b = bytesAfter6To8[i];
|
const uint8_t b = bytesAfter6To8[i];
|
||||||
|
|
||||||
if (b == 0x90)
|
if (b == 0x90)
|
||||||
{
|
{
|
||||||
const uint8_t runLength = bytesAfter6To8[++i];
|
const uint8_t runLength = bytesAfter6To8[++i];
|
||||||
|
|
||||||
if (runLength == 0)
|
if (runLength == 0)
|
||||||
decodedBytes.push_back(0x90);
|
decodedBytes.push_back(0x90);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (decodedBytes.size() == 0)
|
if (decodedBytes.size() == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const uint8_t lastByte = *(decodedBytes.end() - 1);
|
const uint8_t lastByte = *(decodedBytes.end() - 1);
|
||||||
for (size_t r = 1; r < runLength; r++)
|
for (size_t r = 1; r < runLength; r++)
|
||||||
decodedBytes.push_back(lastByte);
|
decodedBytes.push_back(lastByte);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
decodedBytes.push_back(b);
|
decodedBytes.push_back(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(decodedBytes.size() == decodedDataSize);
|
assert(decodedBytes.size() == decodedDataSize);
|
||||||
|
|
||||||
if (decodedBytes.size() == 0)
|
if (decodedBytes.size() == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const uint8_t nameLength = decodedBytes[0];
|
const uint8_t nameLength = decodedBytes[0];
|
||||||
if (decodedBytes.size() < 22 + nameLength || nameLength > 63)
|
if (decodedBytes.size() < 22 + nameLength || nameLength > 63)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Header format:
|
// Header format:
|
||||||
// uint8_t nameLength
|
// uint8_t nameLength
|
||||||
// char name[nameLength]
|
// char name[nameLength]
|
||||||
// char <null>
|
// char <null>
|
||||||
// char fileType[4]
|
// char fileType[4]
|
||||||
// char fileCreator[4]
|
// char fileCreator[4]
|
||||||
// word flags
|
// word flags
|
||||||
// dword dataLength
|
// dword dataLength
|
||||||
// dword resourceLength
|
// dword resourceLength
|
||||||
// word headerCRC
|
// word headerCRC
|
||||||
|
|
||||||
const size_t headerStartLoc = 2 + nameLength;
|
const size_t headerStartLoc = 2 + nameLength;
|
||||||
|
|
||||||
if (decodedBytes[nameLength + 1] != 0)
|
if (decodedBytes[nameLength + 1] != 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
MacFileInfo mfi;
|
MacFileInfo mfi;
|
||||||
mfi.m_fileName.Set(nameLength, reinterpret_cast<const char*>(&decodedBytes[1]));
|
mfi.m_fileName.Set(nameLength, reinterpret_cast<const char*>(&decodedBytes[1]));
|
||||||
memcpy(mfi.m_properties.m_fileType, &decodedBytes[headerStartLoc + 0], 4);
|
memcpy(mfi.m_properties.m_fileType, &decodedBytes[headerStartLoc + 0], 4);
|
||||||
memcpy(mfi.m_properties.m_fileCreator, &decodedBytes[headerStartLoc + 4], 4);
|
memcpy(mfi.m_properties.m_fileCreator, &decodedBytes[headerStartLoc + 4], 4);
|
||||||
mfi.m_properties.m_finderFlags = ByteUnpack::BigUInt16(&decodedBytes[headerStartLoc + 8]);
|
mfi.m_properties.m_finderFlags = ByteUnpack::BigUInt16(&decodedBytes[headerStartLoc + 8]);
|
||||||
mfi.m_dataForkSize = ByteUnpack::BigUInt32(&decodedBytes[headerStartLoc + 10]);
|
mfi.m_dataForkSize = ByteUnpack::BigUInt32(&decodedBytes[headerStartLoc + 10]);
|
||||||
mfi.m_resourceForkSize = ByteUnpack::BigUInt32(&decodedBytes[headerStartLoc + 14]);
|
mfi.m_resourceForkSize = ByteUnpack::BigUInt32(&decodedBytes[headerStartLoc + 14]);
|
||||||
|
|
||||||
const size_t availableDataSize = decodedBytes.size() - 26 - nameLength; // +4 bytes for CRCs
|
const size_t availableDataSize = decodedBytes.size() - 26 - nameLength; // +4 bytes for CRCs
|
||||||
|
|
||||||
if (mfi.m_dataForkSize > availableDataSize || availableDataSize - mfi.m_dataForkSize < mfi.m_resourceForkSize)
|
if (mfi.m_dataForkSize > availableDataSize || availableDataSize - mfi.m_dataForkSize < mfi.m_resourceForkSize)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const uint16_t expectedHeaderCRC = ByteUnpack::BigUInt16(&decodedBytes[headerStartLoc + 18]);
|
const uint16_t expectedHeaderCRC = ByteUnpack::BigUInt16(&decodedBytes[headerStartLoc + 18]);
|
||||||
const uint16_t actualHeaderCRC = BinHexCRC(&decodedBytes[0], headerStartLoc + 18);
|
const uint16_t actualHeaderCRC = BinHexCRC(&decodedBytes[0], headerStartLoc + 18);
|
||||||
|
|
||||||
if (expectedHeaderCRC != actualHeaderCRC)
|
if (expectedHeaderCRC != actualHeaderCRC)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const size_t dataForkStart = headerStartLoc + 20;
|
const size_t dataForkStart = headerStartLoc + 20;
|
||||||
const size_t dataForkCRCLoc = dataForkStart + mfi.m_dataForkSize;
|
const size_t dataForkCRCLoc = dataForkStart + mfi.m_dataForkSize;
|
||||||
const size_t resourceForkStart = dataForkCRCLoc + 2;
|
const size_t resourceForkStart = dataForkCRCLoc + 2;
|
||||||
const size_t resourceForkCRCLoc = resourceForkStart + mfi.m_resourceForkSize;
|
const size_t resourceForkCRCLoc = resourceForkStart + mfi.m_resourceForkSize;
|
||||||
|
|
||||||
const uint16_t expectedDataCRC = ByteUnpack::BigUInt16(&decodedBytes[dataForkCRCLoc]);
|
const uint16_t expectedDataCRC = ByteUnpack::BigUInt16(&decodedBytes[dataForkCRCLoc]);
|
||||||
const uint16_t expectedResCRC = ByteUnpack::BigUInt16(&decodedBytes[resourceForkCRCLoc]);
|
const uint16_t expectedResCRC = ByteUnpack::BigUInt16(&decodedBytes[resourceForkCRCLoc]);
|
||||||
|
|
||||||
if (expectedDataCRC != BinHexCRC(&decodedBytes[dataForkStart], mfi.m_dataForkSize))
|
if (expectedDataCRC != BinHexCRC(&decodedBytes[dataForkStart], mfi.m_dataForkSize))
|
||||||
return false;
|
return nullptr;
|
||||||
|
|
||||||
if (expectedResCRC != BinHexCRC(&decodedBytes[resourceForkStart], mfi.m_resourceForkSize))
|
if (expectedResCRC != BinHexCRC(&decodedBytes[resourceForkStart], mfi.m_resourceForkSize))
|
||||||
return false;
|
return nullptr;
|
||||||
|
|
||||||
return new MacFileMem(&decodedBytes[dataForkStart], &decodedBytes[resourceForkStart], nullptr, mfi);
|
return new MacFileMem(&decodedBytes[dataForkStart], &decodedBytes[resourceForkStart], nullptr, mfi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#include "VirtualDirectory.h"
|
#include "VirtualDirectory.h"
|
||||||
|
|
||||||
class PLPasStr;
|
class PLPasStr;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
struct IGpInputDriver;
|
struct IGpInputDriver;
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace PortabilityLayer
|
|||||||
virtual HostMutex *CreateMutex() = 0;
|
virtual HostMutex *CreateMutex() = 0;
|
||||||
virtual HostMutex *CreateRecursiveMutex() = 0;
|
virtual HostMutex *CreateRecursiveMutex() = 0;
|
||||||
virtual HostThreadEvent *CreateThreadEvent(bool autoReset, bool startSignaled) = 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;
|
virtual void Beep() const = 0;
|
||||||
|
|
||||||
static void SetInstance(HostSystemServices *instance);
|
static void SetInstance(HostSystemServices *instance);
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void Wait() = 0;
|
virtual void Wait() = 0;
|
||||||
virtual void WaitTimed(uint32_t msec) = 0;
|
virtual bool WaitTimed(uint32_t msec) = 0;
|
||||||
virtual void Signal() = 0;
|
virtual void Signal() = 0;
|
||||||
virtual void Destroy() = 0;
|
virtual void Destroy() = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,185 +1,185 @@
|
|||||||
#include "MacBinary2.h"
|
#include "MacBinary2.h"
|
||||||
|
|
||||||
#include "BytePack.h"
|
#include "BytePack.h"
|
||||||
#include "ByteUnpack.h"
|
#include "ByteUnpack.h"
|
||||||
#include "DataTypes.h"
|
#include "DataTypes.h"
|
||||||
#include "GpIOStream.h"
|
#include "GpIOStream.h"
|
||||||
#include "MacFileMem.h"
|
#include "MacFileMem.h"
|
||||||
#include "XModemCRC.h"
|
#include "XModemCRC.h"
|
||||||
|
|
||||||
// See: https://files.stairways.com/other/macbinaryii-standard-info.txt
|
// See: https://files.stairways.com/other/macbinaryii-standard-info.txt
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
namespace MB2FileOffsets
|
namespace MB2FileOffsets
|
||||||
{
|
{
|
||||||
const unsigned int Version = 0;
|
const unsigned int Version = 0;
|
||||||
const unsigned int FileNameLength = 1;
|
const unsigned int FileNameLength = 1;
|
||||||
const unsigned int FileName = 2;
|
const unsigned int FileName = 2;
|
||||||
const unsigned int FileType = 65;
|
const unsigned int FileType = 65;
|
||||||
const unsigned int FileCreator = 69;
|
const unsigned int FileCreator = 69;
|
||||||
const unsigned int FinderFlagsHigh = 73;
|
const unsigned int FinderFlagsHigh = 73;
|
||||||
const unsigned int YPos = 75;
|
const unsigned int YPos = 75;
|
||||||
const unsigned int XPos = 77;
|
const unsigned int XPos = 77;
|
||||||
const unsigned int Protected = 81;
|
const unsigned int Protected = 81;
|
||||||
const unsigned int DataForkSize = 83;
|
const unsigned int DataForkSize = 83;
|
||||||
const unsigned int ResourceForkSize = 87;
|
const unsigned int ResourceForkSize = 87;
|
||||||
const unsigned int CreationDate = 91;
|
const unsigned int CreationDate = 91;
|
||||||
const unsigned int ModifiedDate = 95;
|
const unsigned int ModifiedDate = 95;
|
||||||
const unsigned int CommentLength = 99;
|
const unsigned int CommentLength = 99;
|
||||||
const unsigned int FinderFlagsLow = 101;
|
const unsigned int FinderFlagsLow = 101;
|
||||||
const unsigned int DecompressedSize = 116;
|
const unsigned int DecompressedSize = 116;
|
||||||
const unsigned int SecondaryHeaderLength = 120;
|
const unsigned int SecondaryHeaderLength = 120;
|
||||||
|
|
||||||
const unsigned int WriterVersion = 122;
|
const unsigned int WriterVersion = 122;
|
||||||
const unsigned int MinVersion = 123;
|
const unsigned int MinVersion = 123;
|
||||||
const unsigned int Checksum = 124;
|
const unsigned int Checksum = 124;
|
||||||
const unsigned int ContentStart = 128;
|
const unsigned int ContentStart = 128;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PortabilityLayer
|
namespace PortabilityLayer
|
||||||
{
|
{
|
||||||
void MacBinary2::WriteBin(const MacFileMem *file, GpIOStream *stream)
|
void MacBinary2::WriteBin(const MacFileMem *file, GpIOStream *stream)
|
||||||
{
|
{
|
||||||
const MacFileInfo &fileInfo = file->FileInfo();
|
const MacFileInfo &fileInfo = file->FileInfo();
|
||||||
|
|
||||||
uint8_t mb2Header[128];
|
uint8_t mb2Header[128];
|
||||||
|
|
||||||
memset(mb2Header, 0, sizeof(mb2Header));
|
memset(mb2Header, 0, sizeof(mb2Header));
|
||||||
|
|
||||||
mb2Header[MB2FileOffsets::Version] = 0;
|
mb2Header[MB2FileOffsets::Version] = 0;
|
||||||
|
|
||||||
size_t fileNameLength = fileInfo.m_fileName.Length();
|
size_t fileNameLength = fileInfo.m_fileName.Length();
|
||||||
if (fileNameLength == 0)
|
if (fileNameLength == 0)
|
||||||
{
|
{
|
||||||
mb2Header[MB2FileOffsets::FileNameLength] = 1;
|
mb2Header[MB2FileOffsets::FileNameLength] = 1;
|
||||||
mb2Header[MB2FileOffsets::FileName] = '?';
|
mb2Header[MB2FileOffsets::FileName] = '?';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (fileNameLength > 63)
|
if (fileNameLength > 63)
|
||||||
fileNameLength = 63;
|
fileNameLength = 63;
|
||||||
|
|
||||||
mb2Header[MB2FileOffsets::FileNameLength] = static_cast<uint8_t>(fileNameLength);
|
mb2Header[MB2FileOffsets::FileNameLength] = static_cast<uint8_t>(fileNameLength);
|
||||||
memcpy(mb2Header + MB2FileOffsets::FileName, &fileInfo.m_fileName[0], fileNameLength);
|
memcpy(mb2Header + MB2FileOffsets::FileName, &fileInfo.m_fileName[0], fileNameLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(mb2Header + MB2FileOffsets::FileType, fileInfo.m_properties.m_fileType, 4);
|
memcpy(mb2Header + MB2FileOffsets::FileType, fileInfo.m_properties.m_fileType, 4);
|
||||||
memcpy(mb2Header + MB2FileOffsets::FileCreator, fileInfo.m_properties.m_fileCreator, 4);
|
memcpy(mb2Header + MB2FileOffsets::FileCreator, fileInfo.m_properties.m_fileCreator, 4);
|
||||||
|
|
||||||
mb2Header[MB2FileOffsets::FinderFlagsHigh] = static_cast<uint8_t>((fileInfo.m_properties.m_finderFlags >> 8) & 0xff);
|
mb2Header[MB2FileOffsets::FinderFlagsHigh] = static_cast<uint8_t>((fileInfo.m_properties.m_finderFlags >> 8) & 0xff);
|
||||||
|
|
||||||
BytePack::BigInt16(mb2Header + MB2FileOffsets::YPos, fileInfo.m_properties.m_yPos);
|
BytePack::BigInt16(mb2Header + MB2FileOffsets::YPos, fileInfo.m_properties.m_yPos);
|
||||||
BytePack::BigInt16(mb2Header + MB2FileOffsets::XPos, fileInfo.m_properties.m_xPos);
|
BytePack::BigInt16(mb2Header + MB2FileOffsets::XPos, fileInfo.m_properties.m_xPos);
|
||||||
mb2Header[MB2FileOffsets::Protected] = fileInfo.m_properties.m_protected;
|
mb2Header[MB2FileOffsets::Protected] = fileInfo.m_properties.m_protected;
|
||||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::DataForkSize, fileInfo.m_dataForkSize);
|
BytePack::BigUInt32(mb2Header + MB2FileOffsets::DataForkSize, fileInfo.m_dataForkSize);
|
||||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::ResourceForkSize, fileInfo.m_resourceForkSize);
|
BytePack::BigUInt32(mb2Header + MB2FileOffsets::ResourceForkSize, fileInfo.m_resourceForkSize);
|
||||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::CreationDate, fileInfo.m_properties.m_creationDate);
|
BytePack::BigUInt32(mb2Header + MB2FileOffsets::CreationDate, fileInfo.m_properties.m_creationDate);
|
||||||
BytePack::BigUInt32(mb2Header + MB2FileOffsets::ModifiedDate, fileInfo.m_properties.m_modifiedDate);
|
BytePack::BigUInt32(mb2Header + MB2FileOffsets::ModifiedDate, fileInfo.m_properties.m_modifiedDate);
|
||||||
|
|
||||||
BytePack::BigUInt16(mb2Header + MB2FileOffsets::CommentLength, fileInfo.m_commentSize);
|
BytePack::BigUInt16(mb2Header + MB2FileOffsets::CommentLength, fileInfo.m_commentSize);
|
||||||
mb2Header[MB2FileOffsets::FinderFlagsLow] = static_cast<uint8_t>(fileInfo.m_properties.m_finderFlags & 0xff);
|
mb2Header[MB2FileOffsets::FinderFlagsLow] = static_cast<uint8_t>(fileInfo.m_properties.m_finderFlags & 0xff);
|
||||||
// DecompressedSize is unused
|
// DecompressedSize is unused
|
||||||
// SecondaryHeaderLength is zero
|
// SecondaryHeaderLength is zero
|
||||||
|
|
||||||
mb2Header[MB2FileOffsets::WriterVersion] = 129;
|
mb2Header[MB2FileOffsets::WriterVersion] = 129;
|
||||||
mb2Header[MB2FileOffsets::MinVersion] = 129;
|
mb2Header[MB2FileOffsets::MinVersion] = 129;
|
||||||
|
|
||||||
BytePack::BigUInt16(mb2Header + MB2FileOffsets::Checksum, XModemCRC(mb2Header, 124, 0));
|
BytePack::BigUInt16(mb2Header + MB2FileOffsets::Checksum, XModemCRC(mb2Header, 124, 0));
|
||||||
|
|
||||||
stream->Write(mb2Header, 128);
|
stream->Write(mb2Header, 128);
|
||||||
|
|
||||||
uint8_t *padding = mb2Header;
|
uint8_t *padding = mb2Header;
|
||||||
memset(padding, 0, 128);
|
memset(padding, 0, 128);
|
||||||
|
|
||||||
const size_t dataForkPadding = 127 - ((fileInfo.m_dataForkSize + 127) % 128);
|
const size_t dataForkPadding = 127 - ((fileInfo.m_dataForkSize + 127) % 128);
|
||||||
const size_t resourceForkPadding = 127 - ((fileInfo.m_resourceForkSize + 127) % 128);
|
const size_t resourceForkPadding = 127 - ((fileInfo.m_resourceForkSize + 127) % 128);
|
||||||
|
|
||||||
stream->Write(file->DataFork(), fileInfo.m_dataForkSize);
|
stream->Write(file->DataFork(), fileInfo.m_dataForkSize);
|
||||||
stream->Write(padding, dataForkPadding);
|
stream->Write(padding, dataForkPadding);
|
||||||
stream->Write(file->ResourceFork(), fileInfo.m_resourceForkSize);
|
stream->Write(file->ResourceFork(), fileInfo.m_resourceForkSize);
|
||||||
stream->Write(padding, resourceForkPadding);
|
stream->Write(padding, resourceForkPadding);
|
||||||
}
|
}
|
||||||
|
|
||||||
MacFileMem *MacBinary2::ReadBin(GpIOStream *stream)
|
MacFileMem *MacBinary2::ReadBin(GpIOStream *stream)
|
||||||
{
|
{
|
||||||
MacFileInfo fileInfo;
|
MacFileInfo fileInfo;
|
||||||
|
|
||||||
uint8_t mb2Header[128];
|
uint8_t mb2Header[128];
|
||||||
|
|
||||||
if (stream->Read(mb2Header, 128) != 128)
|
if (stream->Read(mb2Header, 128) != 128)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (mb2Header[MB2FileOffsets::Version] != 0)
|
if (mb2Header[MB2FileOffsets::Version] != 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const uint8_t fileNameLength = mb2Header[MB2FileOffsets::FileNameLength];
|
const uint8_t fileNameLength = mb2Header[MB2FileOffsets::FileNameLength];
|
||||||
if (fileNameLength < 1 || fileNameLength > 63)
|
if (fileNameLength < 1 || fileNameLength > 63)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
fileInfo.m_fileName.Set(fileNameLength, reinterpret_cast<const char*>(mb2Header + MB2FileOffsets::FileName));
|
fileInfo.m_fileName.Set(fileNameLength, reinterpret_cast<const char*>(mb2Header + MB2FileOffsets::FileName));
|
||||||
|
|
||||||
memcpy(fileInfo.m_properties.m_fileType, mb2Header + MB2FileOffsets::FileType, 4);
|
memcpy(fileInfo.m_properties.m_fileType, mb2Header + MB2FileOffsets::FileType, 4);
|
||||||
memcpy(fileInfo.m_properties.m_fileCreator, mb2Header + MB2FileOffsets::FileCreator, 4);
|
memcpy(fileInfo.m_properties.m_fileCreator, mb2Header + MB2FileOffsets::FileCreator, 4);
|
||||||
|
|
||||||
fileInfo.m_properties.m_finderFlags = mb2Header[MB2FileOffsets::FinderFlagsHigh] << 8;
|
fileInfo.m_properties.m_finderFlags = mb2Header[MB2FileOffsets::FinderFlagsHigh] << 8;
|
||||||
|
|
||||||
fileInfo.m_properties.m_yPos = ByteUnpack::BigInt16(mb2Header + MB2FileOffsets::YPos);
|
fileInfo.m_properties.m_yPos = ByteUnpack::BigInt16(mb2Header + MB2FileOffsets::YPos);
|
||||||
fileInfo.m_properties.m_xPos = ByteUnpack::BigInt16(mb2Header + MB2FileOffsets::XPos);
|
fileInfo.m_properties.m_xPos = ByteUnpack::BigInt16(mb2Header + MB2FileOffsets::XPos);
|
||||||
fileInfo.m_properties.m_protected = mb2Header[MB2FileOffsets::Protected];
|
fileInfo.m_properties.m_protected = mb2Header[MB2FileOffsets::Protected];
|
||||||
fileInfo.m_dataForkSize = ByteUnpack::BigUInt32(mb2Header + MB2FileOffsets::DataForkSize);
|
fileInfo.m_dataForkSize = ByteUnpack::BigUInt32(mb2Header + MB2FileOffsets::DataForkSize);
|
||||||
fileInfo.m_resourceForkSize = ByteUnpack::BigUInt32(mb2Header + MB2FileOffsets::ResourceForkSize);
|
fileInfo.m_resourceForkSize = ByteUnpack::BigUInt32(mb2Header + MB2FileOffsets::ResourceForkSize);
|
||||||
fileInfo.m_properties.m_creationDate = ByteUnpack::BigUInt32(mb2Header + MB2FileOffsets::CreationDate);
|
fileInfo.m_properties.m_creationDate = ByteUnpack::BigUInt32(mb2Header + MB2FileOffsets::CreationDate);
|
||||||
fileInfo.m_properties.m_modifiedDate = ByteUnpack::BigUInt32(mb2Header + MB2FileOffsets::ModifiedDate);
|
fileInfo.m_properties.m_modifiedDate = ByteUnpack::BigUInt32(mb2Header + MB2FileOffsets::ModifiedDate);
|
||||||
|
|
||||||
fileInfo.m_commentSize = ByteUnpack::BigUInt16(mb2Header + MB2FileOffsets::CommentLength);
|
fileInfo.m_commentSize = ByteUnpack::BigUInt16(mb2Header + MB2FileOffsets::CommentLength);
|
||||||
fileInfo.m_properties.m_finderFlags |= mb2Header[MB2FileOffsets::FinderFlagsLow];
|
fileInfo.m_properties.m_finderFlags |= mb2Header[MB2FileOffsets::FinderFlagsLow];
|
||||||
|
|
||||||
if (ByteUnpack::BigInt16(mb2Header + MB2FileOffsets::SecondaryHeaderLength) != 0)
|
if (ByteUnpack::BigInt16(mb2Header + MB2FileOffsets::SecondaryHeaderLength) != 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
uint16_t crc = ByteUnpack::BigUInt16(mb2Header + MB2FileOffsets::Checksum);
|
uint16_t crc = ByteUnpack::BigUInt16(mb2Header + MB2FileOffsets::Checksum);
|
||||||
|
|
||||||
uint16_t expectedCRC = XModemCRC(mb2Header, 124, 0);
|
uint16_t expectedCRC = XModemCRC(mb2Header, 124, 0);
|
||||||
|
|
||||||
if (fileInfo.m_dataForkSize > SIZE_MAX)
|
if (fileInfo.m_dataForkSize > SIZE_MAX)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (fileInfo.m_resourceForkSize > SIZE_MAX)
|
if (fileInfo.m_resourceForkSize > SIZE_MAX)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
uint8_t *dataBuffer = nullptr;
|
uint8_t *dataBuffer = nullptr;
|
||||||
uint8_t *rsrcBuffer = nullptr;
|
uint8_t *rsrcBuffer = nullptr;
|
||||||
|
|
||||||
if (fileInfo.m_dataForkSize != 0)
|
if (fileInfo.m_dataForkSize != 0)
|
||||||
dataBuffer = new uint8_t[fileInfo.m_dataForkSize];
|
dataBuffer = new uint8_t[fileInfo.m_dataForkSize];
|
||||||
|
|
||||||
if (fileInfo.m_resourceForkSize != 0)
|
if (fileInfo.m_resourceForkSize != 0)
|
||||||
rsrcBuffer = new uint8_t[fileInfo.m_resourceForkSize];
|
rsrcBuffer = new uint8_t[fileInfo.m_resourceForkSize];
|
||||||
|
|
||||||
ScopedArray<uint8_t> dataContents = dataBuffer;
|
ScopedArray<uint8_t> dataContents(dataBuffer);
|
||||||
ScopedArray<uint8_t> rsrcContents = rsrcBuffer;
|
ScopedArray<uint8_t> rsrcContents(rsrcBuffer);
|
||||||
|
|
||||||
uint8_t *padding = mb2Header;
|
uint8_t *padding = mb2Header;
|
||||||
|
|
||||||
const size_t dataForkPadding = 127 - ((fileInfo.m_dataForkSize + 127) % 128);
|
const size_t dataForkPadding = 127 - ((fileInfo.m_dataForkSize + 127) % 128);
|
||||||
const size_t resourceForkPadding = 127 - ((fileInfo.m_resourceForkSize + 127) % 128);
|
const size_t resourceForkPadding = 127 - ((fileInfo.m_resourceForkSize + 127) % 128);
|
||||||
|
|
||||||
if (stream->Read(dataBuffer, fileInfo.m_dataForkSize) != fileInfo.m_dataForkSize)
|
if (stream->Read(dataBuffer, fileInfo.m_dataForkSize) != fileInfo.m_dataForkSize)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (stream->Read(padding, dataForkPadding) != dataForkPadding)
|
if (stream->Read(padding, dataForkPadding) != dataForkPadding)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (stream->Read(rsrcBuffer, fileInfo.m_resourceForkSize) != fileInfo.m_resourceForkSize)
|
if (stream->Read(rsrcBuffer, fileInfo.m_resourceForkSize) != fileInfo.m_resourceForkSize)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
if (stream->Read(padding, resourceForkPadding) != resourceForkPadding)
|
if (stream->Read(padding, resourceForkPadding) != resourceForkPadding)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Ignore comment for now
|
// Ignore comment for now
|
||||||
return new MacFileMem(dataBuffer, rsrcBuffer, nullptr, fileInfo);
|
return new MacFileMem(dataBuffer, rsrcBuffer, nullptr, fileInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -706,6 +706,8 @@ namespace PortabilityLayer
|
|||||||
if (evt.m_vosEvent.m_event.m_mouseInputEvent.m_button == GpMouseButtons::kLeft)
|
if (evt.m_vosEvent.m_event.m_mouseInputEvent.m_button == GpMouseButtons::kLeft)
|
||||||
canDismiss = true;
|
canDismiss = true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -764,6 +766,8 @@ namespace PortabilityLayer
|
|||||||
if (evt.m_vosEvent.m_event.m_mouseInputEvent.m_button == GpMouseButtons::kLeft)
|
if (evt.m_vosEvent.m_event.m_mouseInputEvent.m_button == GpMouseButtons::kLeft)
|
||||||
canDismiss = true;
|
canDismiss = true;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ void NumToString(long number, unsigned char *str)
|
|||||||
number /= 10;
|
number /= 10;
|
||||||
|
|
||||||
*outChar = '0' + digit;
|
*outChar = '0' + digit;
|
||||||
*outChar++;
|
outChar++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ptrdiff_t strLength = outChar - firstChar;
|
const ptrdiff_t strLength = outChar - firstChar;
|
||||||
@@ -753,7 +753,7 @@ bool Window::ReplaceWidget(PortabilityLayer::Widget *oldWidget, PortabilityLayer
|
|||||||
|
|
||||||
oldWidget->Destroy();
|
oldWidget->Destroy();
|
||||||
m_widgets[i] = newWidget;
|
m_widgets[i] = newWidget;
|
||||||
newWidget->m_window = this;
|
newWidget->SetWindow(this);
|
||||||
|
|
||||||
newWidget->DrawControl(&m_surface);
|
newWidget->DrawControl(&m_surface);
|
||||||
m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
m_surface.m_port.SetDirty(PortabilityLayer::QDPortDirtyFlag_Contents);
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
Rect GetExpandedRect() const override;
|
Rect GetExpandedRect() const override;
|
||||||
|
|
||||||
bool HandlesTickEvents() const;
|
bool HandlesTickEvents() const override;
|
||||||
|
|
||||||
void SetSelection(size_t startChar, size_t endChar);
|
void SetSelection(size_t startChar, size_t endChar);
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ namespace PortabilityLayer
|
|||||||
CaratSelectionAnchor m_caratSelectionAnchor; // Where the carat is attached to the selection range
|
CaratSelectionAnchor m_caratSelectionAnchor; // Where the carat is attached to the selection range
|
||||||
|
|
||||||
Vec2i m_caratScrollPosition; // Ideal position of the carat in the editbox, but not necessarily its actual location (i.e. may be in the middle of a glyph)
|
Vec2i m_caratScrollPosition; // Ideal position of the carat in the editbox, but not necessarily its actual location (i.e. may be in the middle of a glyph)
|
||||||
bool m_caratScrollLocked; // If true, the vertical position
|
bool m_caratScrollLocked; // If true, the vertical position
|
||||||
|
|
||||||
Vec2i m_scrollOffset;
|
Vec2i m_scrollOffset;
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ namespace PortabilityLayer
|
|||||||
|
|
||||||
bool Init(const WidgetBasicState &state, const void *additionalData) override;
|
bool Init(const WidgetBasicState &state, const void *additionalData) override;
|
||||||
|
|
||||||
WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt);
|
WidgetHandleState_t ProcessEvent(void *captureContext, const TimeTaggedVOSEvent &evt) override;
|
||||||
int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback);
|
int16_t Capture(void *captureContext, const Point &pos, WidgetUpdateCallback_t callback) override;
|
||||||
void DrawControl(DrawSurface *surface) override;
|
void DrawControl(DrawSurface *surface) override;
|
||||||
|
|
||||||
void OnStateChanged() override;
|
void OnStateChanged() override;
|
||||||
|
|||||||
@@ -1783,6 +1783,7 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap8,
|
|||||||
{
|
{
|
||||||
case GpPixelFormats::k8BitCustom:
|
case GpPixelFormats::k8BitCustom:
|
||||||
case GpPixelFormats::k8BitStandard:
|
case GpPixelFormats::k8BitStandard:
|
||||||
|
case GpPixelFormats::kBW1:
|
||||||
pixelSizeBytes = 1;
|
pixelSizeBytes = 1;
|
||||||
break;
|
break;
|
||||||
case GpPixelFormats::kRGB555:
|
case GpPixelFormats::kRGB555:
|
||||||
@@ -1794,6 +1795,8 @@ static void CopyBitsComplete(const BitMap *srcBitmap, const BitMap *maskBitmap8,
|
|||||||
case GpPixelFormats::kRGB32:
|
case GpPixelFormats::kRGB32:
|
||||||
pixelSizeBytes = 4;
|
pixelSizeBytes = 4;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
const uint8_t *srcBytes = static_cast<const uint8_t*>(srcBitmap->m_data);
|
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;
|
PixMap *pixMap = *pixMapH;
|
||||||
char outPath[1024];
|
char outPath[1024];
|
||||||
strcpy_s(outPath, outName);
|
strcpy(outPath, outName);
|
||||||
strcat_s(outPath, ".png");
|
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);
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ namespace PortabilityLayer
|
|||||||
{
|
{
|
||||||
AudioCommand cmd;
|
AudioCommand cmd;
|
||||||
cmd.m_commandType = AudioCommandTypes::kCallback;
|
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);
|
return this->PushCommand(cmd, blocking);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ static void TranslateKeyboardInputEvent(const GpVOSEvent &vosEventBase, uint32_t
|
|||||||
inputManager->ApplyKeyboardEvent(vosEvent);
|
inputManager->ApplyKeyboardEvent(vosEvent);
|
||||||
|
|
||||||
// Special handling of alt-enter, redirect to display driver
|
// 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_keyIDSubset == GpKeyIDSubsets::kSpecial &&
|
||||||
vosEventBase.m_event.m_keyboardInputEvent.m_key.m_specialKey == GpKeySpecials::kEnter)
|
vosEventBase.m_event.m_keyboardInputEvent.m_key.m_specialKey == GpKeySpecials::kEnter)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -139,6 +139,11 @@ namespace PortabilityLayer
|
|||||||
return m_rect;
|
return m_rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Widget::SetWindow(Window *window)
|
||||||
|
{
|
||||||
|
m_window = window;
|
||||||
|
}
|
||||||
|
|
||||||
Window *Widget::GetWindow() const
|
Window *Widget::GetWindow() const
|
||||||
{
|
{
|
||||||
return m_window;
|
return m_window;
|
||||||
|
|||||||
@@ -80,21 +80,23 @@ namespace PortabilityLayer
|
|||||||
virtual int ResolvePart(const Point &point) const;
|
virtual int ResolvePart(const Point &point) const;
|
||||||
|
|
||||||
const Rect &GetRect() const;
|
const Rect &GetRect() const;
|
||||||
Window *GetWindow() const;
|
|
||||||
|
|
||||||
protected:
|
void SetWindow(Window *window);
|
||||||
friend struct Window;
|
Window *GetWindow() const;
|
||||||
|
|
||||||
virtual void GainFocus();
|
virtual void GainFocus();
|
||||||
virtual void LoseFocus();
|
virtual void LoseFocus();
|
||||||
|
|
||||||
explicit Widget(const WidgetBasicState &state);
|
|
||||||
virtual ~Widget();
|
|
||||||
|
|
||||||
virtual void OnEnabledChanged();
|
virtual void OnEnabledChanged();
|
||||||
virtual void OnStateChanged();
|
virtual void OnStateChanged();
|
||||||
virtual void OnTick();
|
virtual void OnTick();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
friend struct Window;
|
||||||
|
|
||||||
|
explicit Widget(const WidgetBasicState &state);
|
||||||
|
virtual ~Widget();
|
||||||
|
|
||||||
static void BaseRelease(void *storage);
|
static void BaseRelease(void *storage);
|
||||||
static void *BaseAlloc(size_t sz);
|
static void *BaseAlloc(size_t sz);
|
||||||
|
|
||||||
|
|||||||
12
stb/Android.mk
Normal file
12
stb/Android.mk
Normal 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
19
zlib/Android.mk
Normal 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)
|
||||||
Reference in New Issue
Block a user