diff --git a/build-scripts/rename_macros.py b/build-scripts/rename_macros.py index ba386cd41f..978120ccf7 100755 --- a/build-scripts/rename_macros.py +++ b/build-scripts/rename_macros.py @@ -113,7 +113,6 @@ RENAMED_MACROS = { "__LINUX__": "SDL_PLATFORM_LINUX", "__OS2__": "SDL_PLATFORM_OS2", # "__ANDROID__": "SDL_PLATFORM_ANDROID, - "__NGAGE__": "SDL_PLATFORM_NGAGE", "__APPLE__": "SDL_PLATFORM_APPLE", "__TVOS__": "SDL_PLATFORM_TVOS", "__IPHONEOS__": "SDL_PLATFORM_IOS", diff --git a/docs/README-migration.md b/docs/README-migration.md index a6f9a64acb..d1693faa4d 100644 --- a/docs/README-migration.md +++ b/docs/README-migration.md @@ -1290,7 +1290,6 @@ The following platform preprocessor macros have been renamed: | `__LINUX__` | `SDL_PLATFORM_LINUX` | | `__MACOSX__` | `SDL_PLATFORM_MACOS` | | `__NETBSD__` | `SDL_PLATFORM_NETBSD` | -| `__NGAGE__` | `SDL_PLATFORM_NGAGE` | | `__OPENBSD__` | `SDL_PLATFORM_OPENBSD` | | `__OS2__` | `SDL_PLATFORM_OS2` | | `__OSF__` | `SDL_PLATFORM_OSF` | diff --git a/docs/README-ngage.md b/docs/README-ngage.md index 363760b992..84192b01ab 100644 --- a/docs/README-ngage.md +++ b/docs/README-ngage.md @@ -1,44 +1,5 @@ -Nokia N-Gage -============ +Support for the Nokia N-Gage has been removed from SDL3 (but will make a +comeback when newer compilers are available for the platform). -SDL port for Symbian S60v1 and v2 with a main focus on the Nokia N-Gage -(Classic and QD) by [Michael Fitzmayer](https://github.com/mupfdev). +SDL2 still supports this platform. -Compiling ---------- - -SDL is part of the [N-Gage SDK.](https://github.com/ngagesdk) project. -The library is included in the -[toolchain](https://github.com/ngagesdk/ngage-toolchain) as a -sub-module. - -A complete example project based on SDL can be found in the GitHub -account of the SDK: [Wordle](https://github.com/ngagesdk/wordle). - -Current level of implementation -------------------------------- - -The video driver currently provides full screen video support with -keyboard input. - -At the moment only the software renderer works. - -Audio is not yet implemented. - -Acknowledgements ----------------- - -Thanks to Hannu Viitala, Kimmo Kinnunen and Markus Mertama for the -valuable insight into Symbian programming. Without the SDL 1.2 port -which was specially developed for CDoom (Doom for the Nokia 9210), this -adaptation would not have been possible. - -I would like to thank my friends -[Razvan](https://twitter.com/bewarerazvan) and [Dan -Whelan](https://danwhelan.ie/), for their continuous support. Without -you and the [N-Gage community](https://discord.gg/dbUzqJ26vs), I would -have lost my patience long ago. - -Last but not least, I would like to thank the development team of -[EKA2L1](https://12z1.com/) (an experimental Symbian OS emulator). Your -patience and support in troubleshooting helped me a lot. diff --git a/include/SDL3/SDL_main.h b/include/SDL3/SDL_main.h index 9b97abda6d..047c6be94b 100644 --- a/include/SDL3/SDL_main.h +++ b/include/SDL3/SDL_main.h @@ -134,13 +134,6 @@ */ #define SDL_MAIN_AVAILABLE - #elif defined(SDL_PLATFORM_NGAGE) - /* - TODO: not sure if it should be SDL_MAIN_NEEDED, in SDL2 ngage had a - main implementation, but wasn't mentioned in SDL_main.h - */ - #define SDL_MAIN_AVAILABLE - #endif #endif /* SDL_MAIN_HANDLED */ diff --git a/include/SDL3/SDL_main_impl.h b/include/SDL3/SDL_main_impl.h index e5560e388a..761e6b887c 100644 --- a/include/SDL3/SDL_main_impl.h +++ b/include/SDL3/SDL_main_impl.h @@ -131,18 +131,6 @@ /* end of SDL_PLATFORM_WINDOWS impls */ - #elif defined(SDL_PLATFORM_NGAGE) - /* same typedef as in ngage SDKs e32def.h */ - typedef signed int TInt; - /* TODO: if it turns out that this only works when built as C++, - move SDL_PLATFORM_NGAGE into the C++ section in SDL_main.h */ - TInt E32Main() - { - return SDL_RunApp(0, NULL, SDL_main, NULL); - } - - /* end of SDL_PLATFORM_NGAGE impl */ - #else /* platforms that use a standard main() and just call SDL_RunApp(), like iOS and 3DS */ int main(int argc, char *argv[]) { diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h index 89ce02d452..0030a15fec 100644 --- a/include/SDL3/SDL_platform_defines.h +++ b/include/SDL3/SDL_platform_defines.h @@ -112,16 +112,6 @@ #undef SDL_PLATFORM_LINUX #endif -#ifdef __NGAGE__ - -/** - * A preprocessor macro that is only defined if compiling for Nokia N-Gage. - * - * \since This macro is available since SDL 3.1.3. - */ -#define SDL_PLATFORM_NGAGE 1 -#endif - #if defined(__unix__) || defined(__unix) || defined(unix) /** diff --git a/include/build_config/SDL_build_config.h b/include/build_config/SDL_build_config.h index b712b1e3e4..afd1dbd58b 100644 --- a/include/build_config/SDL_build_config.h +++ b/include/build_config/SDL_build_config.h @@ -45,8 +45,6 @@ #include "SDL_build_config_ios.h" #elif defined(SDL_PLATFORM_ANDROID) #include "SDL_build_config_android.h" -#elif defined(SDL_PLATFORM_NGAGE) -#include "SDL_build_config_ngage.h" #else /* This is a minimal configuration just to get SDL running on new platforms. */ #include "SDL_build_config_minimal.h" diff --git a/include/build_config/SDL_build_config_ngage.h b/include/build_config/SDL_build_config_ngage.h deleted file mode 100644 index 9ccf75a89c..0000000000 --- a/include/build_config/SDL_build_config_ngage.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SDL_build_config_ngage_h_ -#define SDL_build_config_ngage_h_ -#define SDL_build_config_h_ - -#include - -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed long long int64_t; -typedef unsigned long long uint64_t; -typedef unsigned long uintptr_t; - -#define HAVE_STDARG_H 1 -#define HAVE_STDDEF_H 1 -#define HAVE_STDIO_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_MATH_H 1 -#define HAVE_CEIL 1 -#define HAVE_COPYSIGN 1 -#define HAVE_COS 1 -#define HAVE_EXP 1 -#define HAVE_FABS 1 -#define HAVE_FLOOR 1 -#define HAVE_LOG 1 -#define HAVE_LOG10 1 -#define HAVE_SCALBN 1 -#define HAVE_SIN 1 -#define HAVE_SQRT 1 -#define HAVE_TAN 1 -#define HAVE_MALLOC 1 -#define SDL_MAIN_NEEDED 1 -#define LACKS_SYS_MMAN_H 1 - -/* Enable the N-Gage thread support (src/thread/ngage/\*.c) */ -#define SDL_THREAD_NGAGE 1 - -/* Enable the N-Gage timer support (src/timer/ngage/\*.c) */ -#define SDL_TIMER_NGAGE 1 - -/* Enable the N-Gage video driver (src/video/ngage/\*.c) */ -#define SDL_VIDEO_DRIVER_NGAGE 1 - -/* Enable the dummy audio driver (src/audio/dummy/\*.c) */ -#define SDL_AUDIO_DRIVER_DUMMY 1 - -/* Enable the stub joystick driver (src/joystick/dummy/\*.c) */ -#define SDL_JOYSTICK_DISABLED 1 - -/* Enable the stub haptic driver (src/haptic/dummy/\*.c) */ -#define SDL_HAPTIC_DISABLED 1 - -/* Enable the stub HIDAPI */ -#define SDL_HIDAPI_DISABLED 1 - -/* Enable the stub process support */ -#define SDL_PROCESS_DUMMY 1 - -/* Enable the stub sensor driver (src/sensor/dummy/\*.c) */ -#define SDL_SENSOR_DISABLED 1 - -/* Enable the dummy shared object loader (src/loadso/dummy/\*.c) */ -#define SDL_LOADSO_DUMMY 1 - -/* Enable the dummy filesystem driver (src/filesystem/dummy/\*.c) */ -#define SDL_FILESYSTEM_DUMMY 1 -#define SDL_FSOPS_DUMMY 1 - -/* Enable the camera driver (src/camera/dummy/\*.c) */ -#define SDL_CAMERA_DRIVER_DUMMY 1 - -/* Enable dialog subsystem */ -#define SDL_DIALOG_DUMMY 1 - -#endif /* SDL_build_config_ngage_h_ */ diff --git a/src/SDL.c b/src/SDL.c index 5eb9c616a8..c99ee40138 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -742,8 +742,6 @@ const char *SDL_GetPlatform(void) return "PlayStation Portable"; #elif defined(SDL_PLATFORM_VITA) return "PlayStation Vita"; -#elif defined(SDL_PLATFORM_NGAGE) - return "Nokia N-Gage"; #elif defined(SDL_PLATFORM_3DS) return "Nintendo 3DS"; #elif defined(__managarm__) diff --git a/src/dynapi/SDL_dynapi.h b/src/dynapi/SDL_dynapi.h index fd2e3b06ab..e03882e76c 100644 --- a/src/dynapi/SDL_dynapi.h +++ b/src/dynapi/SDL_dynapi.h @@ -61,8 +61,6 @@ #define SDL_DYNAMIC_API 0 // Turn off for static analysis, so reports are more clear. #elif defined(SDL_PLATFORM_VITA) #define SDL_DYNAMIC_API 0 // vitasdk doesn't support dynamic linking -#elif defined(SDL_PLATFORM_NGAGE) -#define SDL_DYNAMIC_API 0 // The N-Gage doesn't support dynamic linking either #elif defined(SDL_PLATFORM_3DS) #define SDL_DYNAMIC_API 0 // devkitARM doesn't support dynamic linking #elif defined(DYNAPI_NEEDS_DLOPEN) && !defined(HAVE_DLOPEN) diff --git a/src/main/ngage/SDL_sysmain_runapp.cpp b/src/main/ngage/SDL_sysmain_runapp.cpp deleted file mode 100644 index c675b13039..0000000000 --- a/src/main/ngage/SDL_sysmain_runapp.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - based on SDL_ngage_main.c, originally for SDL 1.2 by Hannu Viitala -*/ - -#include "SDL_internal.h" - -#ifdef SDL_PLATFORM_NGAGE - -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -int SDL_RunApp(int argc_, char* argv_[], SDL_main_func mainFunction, void * reserved) -{ - (void)argc_; (void)argv_; (void)reserved; - // Get the clean-up stack - CTrapCleanup *cleanup = CTrapCleanup::New(); - - // Arrange for multi-threaded operation - SpawnPosixServerThread(); - - // Get args and environment - int argc = 0; - char **argv = 0; - char **envp = 0; - - __crt0(argc, argv, envp); - - // Start the application! - - // Create stdlib - _REENT; - - // Set process and thread priority and name - - RThread currentThread; - RProcess thisProcess; - TParse exeName; - exeName.Set(thisProcess.FileName(), NULL, NULL); - currentThread.Rename(exeName.Name()); - currentThread.SetProcessPriority(EPriorityLow); - currentThread.SetPriority(EPriorityMuchLess); - - // Increase heap size - RHeap *newHeap = NULL; - RHeap *oldHeap = NULL; - TInt heapSize = 7500000; - int ret; - - newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy); - - if (!newHeap) { - ret = 3; - goto cleanup; - } else { - oldHeap = User::SwitchHeap(newHeap); - // Call stdlib main - SDL_SetMainReady(); - ret = mainFunction(argc, argv); - } - -cleanup: - _cleanup(); - - CloseSTDLIB(); - delete cleanup; - return ret; -} - -#endif // SDL_PLATFORM_NGAGE diff --git a/src/stdlib/SDL_vacopy.h b/src/stdlib/SDL_vacopy.h index c50c17f0f1..ef4d17dc11 100644 --- a/src/stdlib/SDL_vacopy.h +++ b/src/stdlib/SDL_vacopy.h @@ -20,11 +20,7 @@ */ // Do our best to make sure va_copy is working -#ifdef SDL_PLATFORM_NGAGE -#undef va_copy -#define va_copy(dst, src) dst = src - -#elif defined(_MSC_VER) && _MSC_VER <= 1800 +#if defined(_MSC_VER) && _MSC_VER <= 1800 // Visual Studio 2013 tries to link with _vacopy in the C runtime. Newer versions do an inline assignment #undef va_copy #define va_copy(dst, src) dst = src diff --git a/src/thread/SDL_thread_c.h b/src/thread/SDL_thread_c.h index ec6107bb2b..c703e52621 100644 --- a/src/thread/SDL_thread_c.h +++ b/src/thread/SDL_thread_c.h @@ -38,8 +38,6 @@ #include "vita/SDL_systhread_c.h" #elif defined(SDL_THREAD_N3DS) #include "n3ds/SDL_systhread_c.h" -#elif defined(SDL_THREAD_NGAGE) -#include "ngage/SDL_systhread_c.h" #else #error Need thread implementation for this platform #include "generic/SDL_systhread_c.h" diff --git a/src/thread/ngage/SDL_sysmutex.cpp b/src/thread/ngage/SDL_sysmutex.cpp deleted file mode 100644 index 307896e947..0000000000 --- a/src/thread/ngage/SDL_sysmutex.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -// An implementation of mutexes using the Symbian API. - -#include - -#include "SDL_systhread_c.h" - -struct SDL_Mutex -{ - TInt handle; -}; - -extern TInt CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *, TAny *); - -static TInt NewMutex(const TDesC &aName, TAny *aPtr1, TAny *) -{ - return ((RMutex *)aPtr1)->CreateGlobal(aName); -} - -// Create a mutex -SDL_Mutex *SDL_CreateMutex(void) -{ - RMutex rmutex; - - TInt status = CreateUnique(NewMutex, &rmutex, NULL); - if (status != KErrNone) { - SDL_SetError("Couldn't create mutex."); - return NULL; - } - SDL_Mutex *mutex = new /*(ELeave)*/ SDL_Mutex; - mutex->handle = rmutex.Handle(); - return mutex; -} - -// Free the mutex -void SDL_DestroyMutex(SDL_Mutex *mutex) -{ - if (mutex) { - RMutex rmutex; - rmutex.SetHandle(mutex->handle); - rmutex.Signal(); - rmutex.Close(); - delete (mutex); - mutex = NULL; - } -} - -// Lock the mutex -void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes -{ - if (mutex) { - RMutex rmutex; - rmutex.SetHandle(mutex->handle); - rmutex.Wait(); - } -} - -// Try to lock the mutex -#if 0 -bool SDL_TryLockMutex(SDL_Mutex *mutex) -{ - if (mutex) { - // Not yet implemented. - return true; - } - return true; -} -#endif - -// Unlock the mutex -void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes -{ - if (mutex) { - RMutex rmutex; - rmutex.SetHandle(mutex->handle); - rmutex.Signal(); - } -} - diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp deleted file mode 100644 index 01de3845f4..0000000000 --- a/src/thread/ngage/SDL_syssem.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -// An implementation of semaphores using the Symbian API. - -#include - -struct SDL_Semaphore -{ - TInt handle; - TInt count; -}; - -struct TInfo -{ - TInfo(TInt aTime, TInt aHandle) : iTime(aTime), iHandle(aHandle), iVal(true) {} - TInt iTime; - TInt iHandle; - bool iVal; -}; - -extern TInt CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *, TAny *); - -static TBool RunThread(TAny *aInfo) -{ - TInfo *info = STATIC_CAST(TInfo *, aInfo); - User::After(info->iTime); - RSemaphore sema; - sema.SetHandle(info->iHandle); - sema.Signal(); - info->iVal = false; - return 0; -} - -static TInt NewThread(const TDesC &aName, TAny *aPtr1, TAny *aPtr2) -{ - return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2); -} - -static TInt NewSema(const TDesC &aName, TAny *aPtr1, TAny *aPtr2) -{ - TInt value = *((TInt *)aPtr2); - return ((RSemaphore *)aPtr1)->CreateGlobal(aName, value); -} - -static void WaitAll(SDL_Semaphore *sem) -{ - RSemaphore sema; - sema.SetHandle(sem->handle); - sema.Wait(); - while (sem->count < 0) { - sema.Wait(); - } -} - -SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) -{ - RSemaphore s; - TInt status = CreateUnique(NewSema, &s, &initial_value); - if (status != KErrNone) { - SDL_SetError("Couldn't create semaphore"); - } - SDL_Semaphore *sem = new /*(ELeave)*/ SDL_Semaphore; - sem->handle = s.Handle(); - sem->count = initial_value; - return sem; -} - -void SDL_DestroySemaphore(SDL_Semaphore *sem) -{ - if (sem) { - RSemaphore sema; - sema.SetHandle(sem->handle); - sema.Signal(sema.Count()); - sema.Close(); - delete sem; - sem = NULL; - } -} - -bool SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) -{ - if (!sem) { - return true; - } - - if (timeoutNS == 0) { - if (sem->count > 0) { - --sem->count; - return true; - } - return false; - } - - if (timeoutNS == -1) { // -1 == wait indefinitely. - WaitAll(sem); - return true; - } - - RThread thread; - TInfo *info = new (ELeave) TInfo((TInt)SDL_NS_TO_MS(timeoutNS), sem->handle); - TInt status = CreateUnique(NewThread, &thread, info); - - if (status != KErrNone) { - return false; - } - - thread.Resume(); - WaitAll(sem); - - if (thread.ExitType() == EExitPending) { - thread.Kill(false); - } - - thread.Close(); - return info->iVal; -} - -Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) -{ - if (!sem) { - SDL_InvalidParamError("sem"); - return 0; - } - return sem->count; -} - -int SDL_SignalSemaphore(SDL_Semaphore *sem) -{ - if (!sem) { - return SDL_InvalidParamError("sem"); - } - sem->count++; - RSemaphore sema; - sema.SetHandle(sem->handle); - sema.Signal(); - return 0; -} diff --git a/src/thread/ngage/SDL_systhread.cpp b/src/thread/ngage/SDL_systhread.cpp deleted file mode 100644 index ff3e3e2f44..0000000000 --- a/src/thread/ngage/SDL_systhread.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#ifdef SDL_THREAD_NGAGE - -// N-Gage thread management routines for SDL - -#include - -extern "C" { -#undef NULL -#include "../SDL_systhread.h" -#include "../SDL_thread_c.h" -}; - -static int object_count; - -static int RunThread(TAny *data) -{ - SDL_RunThread((SDL_Thread *)data); - return 0; -} - -static TInt NewThread(const TDesC &aName, TAny *aPtr1, TAny *aPtr2) -{ - return ((RThread *)(aPtr1))->Create(aName, RunThread, KDefaultStackSize, NULL, aPtr2); -} - -int CreateUnique(TInt (*aFunc)(const TDesC &aName, TAny *, TAny *), TAny *aPtr1, TAny *aPtr2) -{ - TBuf<16> name; - TInt status = KErrNone; - do { - object_count++; - name.Format(_L("SDL_%x"), object_count); - status = aFunc(name, aPtr1, aPtr2); - } while (status == KErrAlreadyExists); - return status; -} - -bool SDL_SYS_CreateThread(SDL_Thread *thread, - SDL_FunctionPointer pfnBeginThread, - SDL_FunctionPointer pfnEndThread) -{ - RThread rthread; - - TInt status = CreateUnique(NewThread, &rthread, thread); - if (status != KErrNone) { - delete (RThread *)thread->handle; - thread->handle = NULL; - return SDL_SetError("Not enough resources to create thread"); - } - - rthread.Resume(); - thread->handle = rthread.Handle(); - return true; -} - -void SDL_SYS_SetupThread(const char *name) -{ - return; -} - -SDL_ThreadID SDL_GetCurrentThreadID(void) -{ - RThread current; - TThreadId id = current.Id(); - return id; -} - -bool SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) -{ - return true; -} - -void SDL_SYS_WaitThread(SDL_Thread *thread) -{ - RThread t; - t.Open(thread->threadid); - if (t.ExitReason() == EExitPending) { - TRequestStatus status; - t.Logon(status); - User::WaitForRequest(status); - } - t.Close(); -} - -void SDL_SYS_DetachThread(SDL_Thread *thread) -{ - return; -} - -#endif // SDL_THREAD_NGAGE diff --git a/src/thread/ngage/SDL_systhread_c.h b/src/thread/ngage/SDL_systhread_c.h deleted file mode 100644 index c0b697282d..0000000000 --- a/src/thread/ngage/SDL_systhread_c.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -typedef int SYS_ThreadHandle; diff --git a/src/timer/ngage/SDL_systimer.cpp b/src/timer/ngage/SDL_systimer.cpp deleted file mode 100644 index bfcacc630d..0000000000 --- a/src/timer/ngage/SDL_systimer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ -#include "SDL_internal.h" - -#ifdef SDL_TIMER_NGAGE - -#include -#include - -static TUint start_tick = 0; - -#ifdef __cplusplus -extern "C" { -#endif - - -Uint64 SDL_GetPerformanceCounter(void) -{ - // FIXME: Need to account for 32-bit wrapping - return (Uint64)User::TickCount(); -} - -Uint64 SDL_GetPerformanceFrequency(void) -{ - return SDL_US_PER_SECOND; -} - -void SDL_SYS_DelayNS(Uint64 ns) -{ - const Uint64 max_delay = 0x7fffffffLL * SDL_NS_PER_US; - if (ns > max_delay) { - ns = max_delay; - } - User::After(TTimeIntervalMicroSeconds32((TInt)SDL_NS_TO_US(ns))); -} - -#ifdef __cplusplus -} -#endif - -#endif // SDL_TIMER_NGAGE diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 8649c7b500..cd63a18d2e 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -521,7 +521,6 @@ extern VideoBootStrap Wayland_bootstrap; extern VideoBootStrap VIVANTE_bootstrap; extern VideoBootStrap Emscripten_bootstrap; extern VideoBootStrap OFFSCREEN_bootstrap; -extern VideoBootStrap NGAGE_bootstrap; extern VideoBootStrap QNX_bootstrap; extern VideoBootStrap OPENVR_bootstrap; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 6f47520eda..b62d5c53a0 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -128,9 +128,6 @@ static VideoBootStrap *bootstrap[] = { #ifdef SDL_VIDEO_DRIVER_QNX &QNX_bootstrap, #endif -#ifdef SDL_VIDEO_DRIVER_NGAGE - &NGAGE_bootstrap, -#endif #ifdef SDL_VIDEO_DRIVER_OFFSCREEN &OFFSCREEN_bootstrap, #endif diff --git a/src/video/ngage/SDL_ngageevents.cpp b/src/video/ngage/SDL_ngageevents.cpp deleted file mode 100644 index bfe3b7fc85..0000000000 --- a/src/video/ngage/SDL_ngageevents.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_internal.h" - -#ifdef SDL_VIDEO_DRIVER_NGAGE - -/* Being a ngage driver, there's no event stream. We just define stubs for - most of the API. */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "../../events/SDL_events_c.h" -#include "../../events/SDL_keyboard_c.h" - -#ifdef __cplusplus -} -#endif - -#include "SDL_ngagevideo.h" -#include "SDL_ngageevents_c.h" - -static void HandleWsEvent(SDL_VideoDevice *_this, const TWsEvent &aWsEvent); - -void NGAGE_PumpEvents(SDL_VideoDevice *_this) -{ - SDL_VideoData *data = _this->internal; - - while (data->NGAGE_WsEventStatus != KRequestPending) { - data->NGAGE_WsSession.GetEvent(data->NGAGE_WsEvent); - - HandleWsEvent(_this, data->NGAGE_WsEvent); - - data->NGAGE_WsEventStatus = KRequestPending; - data->NGAGE_WsSession.EventReady(&data->NGAGE_WsEventStatus); - } -} - -/*****************************************************************************/ -// Internal -/*****************************************************************************/ - -#include -#include - -extern void DisableKeyBlocking(SDL_VideoDevice *_this); -extern void RedrawWindowL(SDL_VideoDevice *_this); - -TBool isCursorVisible = EFalse; - -static SDL_Scancode ConvertScancode(SDL_VideoDevice *_this, int key) -{ - SDL_Keycode scancode; - - switch (key) { - case EStdKeyBackspace: // Clear key - scancode = SDL_SCANCODE_BACKSPACE; - break; - case 0x31: // 1 - scancode = SDL_SCANCODE_1; - break; - case 0x32: // 2 - scancode = SDL_SCANCODE_2; - break; - case 0x33: // 3 - scancode = SDL_SCANCODE_3; - break; - case 0x34: // 4 - scancode = SDL_SCANCODE_4; - break; - case 0x35: // 5 - scancode = SDL_SCANCODE_5; - break; - case 0x36: // 6 - scancode = SDL_SCANCODE_6; - break; - case 0x37: // 7 - scancode = SDL_SCANCODE_7; - break; - case 0x38: // 8 - scancode = SDL_SCANCODE_8; - break; - case 0x39: // 9 - scancode = SDL_SCANCODE_9; - break; - case 0x30: // 0 - scancode = SDL_SCANCODE_0; - break; - case 0x2a: // Asterisk - scancode = SDL_SCANCODE_ASTERISK; - break; - case EStdKeyHash: // Hash - scancode = SDL_SCANCODE_HASH; - break; - case EStdKeyDevice0: // Left softkey - scancode = SDL_SCANCODE_SOFTLEFT; - break; - case EStdKeyDevice1: // Right softkey - scancode = SDL_SCANCODE_SOFTRIGHT; - break; - case EStdKeyApplication0: // Call softkey - scancode = SDL_SCANCODE_CALL; - break; - case EStdKeyApplication1: // End call softkey - scancode = SDL_SCANCODE_ENDCALL; - break; - case EStdKeyDevice3: // Middle softkey - scancode = SDL_SCANCODE_SELECT; - break; - case EStdKeyUpArrow: // Up arrow - scancode = SDL_SCANCODE_UP; - break; - case EStdKeyDownArrow: // Down arrow - scancode = SDL_SCANCODE_DOWN; - break; - case EStdKeyLeftArrow: // Left arrow - scancode = SDL_SCANCODE_LEFT; - break; - case EStdKeyRightArrow: // Right arrow - scancode = SDL_SCANCODE_RIGHT; - break; - default: - scancode = SDL_SCANCODE_UNKNOWN; - break; - } - - return scancode; -} - -static void HandleWsEvent(SDL_VideoDevice *_this, const TWsEvent &aWsEvent) -{ - SDL_VideoData *data = _this->internal; - - switch (aWsEvent.Type()) { - case EEventKeyDown: // Key events - SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, aWsEvent.Key()->iScanCode, ConvertScancode(_this, aWsEvent.Key()->iScanCode), true); - break; - case EEventKeyUp: // Key events - SDL_SendKeyboardKey(0, SDL_GLOBAL_KEYBOARD_ID, aWsEvent.Key()->iScanCode, ConvertScancode(_this, aWsEvent.Key()->iScanCode), false); - break; - case EEventFocusGained: // SDL window got focus - data->NGAGE_IsWindowFocused = ETrue; - // Draw window background and screen buffer - DisableKeyBlocking(_this); - RedrawWindowL(_this); - break; - case EEventFocusLost: // SDL window lost focus - { - data->NGAGE_IsWindowFocused = EFalse; - RWsSession s; - s.Connect(); - RWindowGroup g(s); - g.Construct(TUint32(&g), EFalse); - g.EnableReceiptOfFocus(EFalse); - RWindow w(s); - w.Construct(g, TUint32(&w)); - w.SetExtent(TPoint(0, 0), data->NGAGE_WsWindow.Size()); - w.SetOrdinalPosition(0); - w.Activate(); - w.Close(); - g.Close(); - s.Close(); - break; - } - case EEventModifiersChanged: - break; - default: - break; - } -} - -#endif // SDL_VIDEO_DRIVER_NGAGE diff --git a/src/video/ngage/SDL_ngageevents_c.h b/src/video/ngage/SDL_ngageevents_c.h deleted file mode 100644 index 46fa908818..0000000000 --- a/src/video/ngage/SDL_ngageevents_c.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_internal.h" - -#include "SDL_ngagevideo.h" - -extern void NGAGE_PumpEvents(SDL_VideoDevice *_this); diff --git a/src/video/ngage/SDL_ngageframebuffer.cpp b/src/video/ngage/SDL_ngageframebuffer.cpp deleted file mode 100644 index b854c73add..0000000000 --- a/src/video/ngage/SDL_ngageframebuffer.cpp +++ /dev/null @@ -1,380 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_internal.h" - -#ifdef SDL_VIDEO_DRIVER_NGAGE - -#include - -#include "../SDL_sysvideo.h" -#include "SDL_ngagevideo.h" -#include "SDL_ngageframebuffer_c.h" - -#define NGAGE_SURFACE "NGAGE_FrameBuffer" - -/* For 12 bit screen HW. Table for fast conversion from 8 bit to 12 bit - * - * TUint16 is enough, but using TUint32 so we can use better instruction - * selection on ARMI. - */ -static TUint32 NGAGE_HWPalette_256_to_Screen[256]; - -bool GetBpp(TDisplayMode displaymode); -void DirectUpdate(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects); -void DrawBackground(SDL_VideoDevice *_this); -void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 *screenBuffer); -void RedrawWindowL(SDL_VideoDevice *_this); - -bool SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch) -{ - SDL_VideoData *phdata = _this->internal; - SDL_Surface *surface; - const SDL_PixelFormat surface_format = SDL_PIXELFORMAT_XRGB4444; - int w, h; - - // Free the old framebuffer surface - SDL_NGAGE_DestroyWindowFramebuffer(_this, window); - - // Create a new one - SDL_GetWindowSizeInPixels(window, &w, &h); - surface = SDL_CreateSurface(w, h, surface_format); - if (!surface) { - return false; - } - - // Save the info and return! - SDL_SetWindowData(window, NGAGE_SURFACE, surface); - *format = surface_format; - *pixels = surface->pixels; - *pitch = surface->pitch; - - // Initialise Epoc frame buffer - - TDisplayMode displayMode = phdata->NGAGE_WsScreen->DisplayMode(); - - TScreenInfoV01 screenInfo; - TPckg sInfo(screenInfo); - UserSvr::ScreenInfo(sInfo); - - phdata->NGAGE_ScreenSize = screenInfo.iScreenSize; - phdata->NGAGE_DisplayMode = displayMode; - phdata->NGAGE_HasFrameBuffer = screenInfo.iScreenAddressValid; - phdata->NGAGE_FrameBuffer = phdata->NGAGE_HasFrameBuffer ? (TUint8 *)screenInfo.iScreenAddress : NULL; - phdata->NGAGE_BytesPerPixel = ((GetBpp(displayMode) - 1) / 8) + 1; - - phdata->NGAGE_BytesPerScanLine = screenInfo.iScreenSize.iWidth * phdata->NGAGE_BytesPerPixel; - phdata->NGAGE_BytesPerScreen = phdata->NGAGE_BytesPerScanLine * phdata->NGAGE_ScreenSize.iHeight; - - SDL_Log("Screen width %d", screenInfo.iScreenSize.iWidth); - SDL_Log("Screen height %d", screenInfo.iScreenSize.iHeight); - SDL_Log("Screen dmode %d", displayMode); - SDL_Log("Screen valid %d", screenInfo.iScreenAddressValid); - - SDL_Log("Bytes per pixel %d", phdata->NGAGE_BytesPerPixel); - SDL_Log("Bytes per scan line %d", phdata->NGAGE_BytesPerScanLine); - SDL_Log("Bytes per screen %d", phdata->NGAGE_BytesPerScreen); - - /* It seems that in SA1100 machines for 8bpp displays there is a 512 - * palette table at the beginning of the frame buffer. - * - * In 12 bpp machines the table has 16 entries. - */ - if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 8) { - phdata->NGAGE_FrameBuffer += 512; - } else { - phdata->NGAGE_FrameBuffer += 32; - } -#if 0 - if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 12) { - phdata->NGAGE_FrameBuffer += 16 * 2; - } - if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 16) { - phdata->NGAGE_FrameBuffer += 16 * 2; - } -#endif - - // Get draw device for updating the screen - TScreenInfoV01 screenInfo2; - - NGAGE_Runtime::GetScreenInfo(screenInfo2); - - TRAPD(status, phdata->NGAGE_DrawDevice = CFbsDrawDevice::NewScreenDeviceL(screenInfo2, displayMode)); - User::LeaveIfError(status); - - // Activate events for me - phdata->NGAGE_WsEventStatus = KRequestPending; - phdata->NGAGE_WsSession.EventReady(&phdata->NGAGE_WsEventStatus); - - SDL_Log("SDL:WsEventStatus"); - User::WaitForRequest(phdata->NGAGE_WsEventStatus); - - phdata->NGAGE_RedrawEventStatus = KRequestPending; - phdata->NGAGE_WsSession.RedrawReady(&phdata->NGAGE_RedrawEventStatus); - - SDL_Log("SDL:RedrawEventStatus"); - User::WaitForRequest(phdata->NGAGE_RedrawEventStatus); - - phdata->NGAGE_WsWindow.PointerFilter(EPointerFilterDrag, 0); - - phdata->NGAGE_ScreenOffset = TPoint(0, 0); - - SDL_Log("SDL:DrawBackground"); - DrawBackground(_this); // Clear screen - - return true; -} - -bool SDL_NGAGE_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects) -{ - DirectUpdate(_this, numrects, (SDL_Rect *)rects); - return true; -} - -void SDL_NGAGE_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) -{ - SDL_Surface *surface; - - surface = (SDL_Surface *)SDL_SetWindowData(window, NGAGE_SURFACE, NULL); - SDL_DestroySurface(surface); -} - -/*****************************************************************************/ -// Runtime -/*****************************************************************************/ - -#include -#include -#include - -EXPORT_C void NGAGE_Runtime::GetScreenInfo(TScreenInfoV01 &screenInfo2) -{ - TPckg sInfo2(screenInfo2); - UserSvr::ScreenInfo(sInfo2); -} - -/*****************************************************************************/ -// Internal -/*****************************************************************************/ - -bool GetBpp(TDisplayMode displaymode) -{ - return TDisplayModeUtils::NumDisplayModeBitsPerPixel(displaymode); -} - -void DrawBackground(SDL_VideoDevice *_this) -{ - SDL_VideoData *phdata = _this->internal; - // Draw background - TUint16 *screenBuffer = (TUint16 *)phdata->NGAGE_FrameBuffer; - // Draw black background - Mem::FillZ(screenBuffer, phdata->NGAGE_BytesPerScreen); -} - -void DirectDraw(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects, TUint16 *screenBuffer) -{ - SDL_VideoData *phdata = _this->internal; - SDL_Surface *screen = (SDL_Surface *)SDL_GetWindowData(_this->windows, NGAGE_SURFACE); - - TInt i; - - TDisplayMode displayMode = phdata->NGAGE_DisplayMode; - const TInt sourceNumBytesPerPixel = ((GetBpp(displayMode) - 1) / 8) + 1; - - const TPoint fixedOffset = phdata->NGAGE_ScreenOffset; - const TInt screenW = screen->w; - const TInt screenH = screen->h; - const TInt sourceScanlineLength = screenW; - const TInt targetScanlineLength = phdata->NGAGE_ScreenSize.iWidth; - - // Render the rectangles in the list - - for (i = 0; i < numrects; ++i) { - const SDL_Rect ¤tRect = rects[i]; - SDL_Rect rect2; - rect2.x = currentRect.x; - rect2.y = currentRect.y; - rect2.w = currentRect.w; - rect2.h = currentRect.h; - - if (rect2.w <= 0 || rect2.h <= 0) /* Sanity check */ { - continue; - } - - // All variables are measured in pixels - - // Check rects validity, i.e. upper and lower bounds - TInt maxX = Min(screenW - 1, rect2.x + rect2.w - 1); - TInt maxY = Min(screenH - 1, rect2.y + rect2.h - 1); - if (maxX < 0 || maxY < 0) /* sanity check */ { - continue; - } - // Clip from bottom - - maxY = Min(maxY, phdata->NGAGE_ScreenSize.iHeight - 1); - // TODO: Clip from the right side - - const TInt sourceRectWidth = maxX - rect2.x + 1; - const TInt sourceRectWidthInBytes = sourceRectWidth * sourceNumBytesPerPixel; - const TInt sourceRectHeight = maxY - rect2.y + 1; - const TInt sourceStartOffset = rect2.x + rect2.y * sourceScanlineLength; - const TUint skipValue = 1; // 1 = No skip - - TInt targetStartOffset = fixedOffset.iX + rect2.x + (fixedOffset.iY + rect2.y) * targetScanlineLength; - - switch (screen->format->bits_per_pixel) { - case 12: - { - TUint16 *bitmapLine = (TUint16 *)screen->pixels + sourceStartOffset; - TUint16 *screenMemory = screenBuffer + targetStartOffset; - - if (skipValue == 1) { - for (TInt y = 0; y < sourceRectHeight; y++) { - Mem::Copy(screenMemory, bitmapLine, sourceRectWidthInBytes); - bitmapLine += sourceScanlineLength; - screenMemory += targetScanlineLength; - } - } else { - for (TInt y = 0; y < sourceRectHeight; y++) { - TUint16 *bitmapPos = bitmapLine; // 2 bytes per pixel - TUint16 *screenMemoryLinePos = screenMemory; // 2 bytes per pixel - for (TInt x = 0; x < sourceRectWidth; x++) { - __ASSERT_DEBUG(screenMemory < (screenBuffer + phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(screenMemory >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapLine < ((TUint16 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapLine >= (TUint16 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); - - *screenMemoryLinePos++ = *bitmapPos; - bitmapPos += skipValue; - } - bitmapLine += sourceScanlineLength; - screenMemory += targetScanlineLength; - } - } - } break; - // 256 color paletted mode: 8 bpp --> 12 bpp - default: - { - if (phdata->NGAGE_BytesPerPixel <= 2) { - TUint8 *bitmapLine = (TUint8 *)screen->pixels + sourceStartOffset; - TUint16 *screenMemory = screenBuffer + targetStartOffset; - - for (TInt y = 0; y < sourceRectHeight; y++) { - TUint8 *bitmapPos = bitmapLine; // 1 byte per pixel - TUint16 *screenMemoryLinePos = screenMemory; // 2 bytes per pixel - // Convert each pixel from 256 palette to 4k color values - for (TInt x = 0; x < sourceRectWidth; x++) { - __ASSERT_DEBUG(screenMemoryLinePos < (screenBuffer + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(screenMemoryLinePos >= screenBuffer, User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapPos < ((TUint8 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapPos >= (TUint8 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); - *screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++]; - } - bitmapLine += sourceScanlineLength; - screenMemory += targetScanlineLength; - } - } else { - TUint8 *bitmapLine = (TUint8 *)screen->pixels + sourceStartOffset; - TUint32 *screenMemory = reinterpret_cast(screenBuffer + targetStartOffset); - for (TInt y = 0; y < sourceRectHeight; y++) { - TUint8 *bitmapPos = bitmapLine; // 1 byte per pixel - TUint32 *screenMemoryLinePos = screenMemory; // 2 bytes per pixel - // Convert each pixel from 256 palette to 4k color values - for (TInt x = 0; x < sourceRectWidth; x++) { - __ASSERT_DEBUG(screenMemoryLinePos < (reinterpret_cast(screenBuffer) + (phdata->NGAGE_ScreenSize.iWidth * phdata->NGAGE_ScreenSize.iHeight)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(screenMemoryLinePos >= reinterpret_cast(screenBuffer), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapPos < ((TUint8 *)screen->pixels + (screen->w * screen->h)), User::Panic(_L("SDL"), KErrCorrupt)); - __ASSERT_DEBUG(bitmapPos >= (TUint8 *)screen->pixels, User::Panic(_L("SDL"), KErrCorrupt)); - *screenMemoryLinePos++ = NGAGE_HWPalette_256_to_Screen[*bitmapPos++]; - } - bitmapLine += sourceScanlineLength; - screenMemory += targetScanlineLength; - } - } - } - } - } -} - -void DirectUpdate(SDL_VideoDevice *_this, int numrects, SDL_Rect *rects) -{ - SDL_VideoData *phdata = _this->internal; - - if (!phdata->NGAGE_IsWindowFocused) { - SDL_PauseAudio(1); - SDL_Delay(1000); - return; - } - - SDL_PauseAudio(0); - - TUint16 *screenBuffer = (TUint16 *)phdata->NGAGE_FrameBuffer; - -#if 0 - if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) { - // ... - } else -#endif - { - DirectDraw(_this, numrects, rects, screenBuffer); - } - - for (int i = 0; i < numrects; ++i) { - TInt aAx = rects[i].x; - TInt aAy = rects[i].y; - TInt aBx = rects[i].w; - TInt aBy = rects[i].h; - TRect rect2 = TRect(aAx, aAy, aBx, aBy); - - phdata->NGAGE_DrawDevice->UpdateRegion(rect2); // Should we update rects parameter area only? - phdata->NGAGE_DrawDevice->Update(); - } -} - -void RedrawWindowL(SDL_VideoDevice *_this) -{ - SDL_VideoData *phdata = _this->internal; - SDL_Surface *screen = (SDL_Surface *)SDL_GetWindowData(_this->windows, NGAGE_SURFACE); - - int w = screen->w; - int h = screen->h; - if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270) { - w = screen->h; - h = screen->w; - } - if ((w < phdata->NGAGE_ScreenSize.iWidth) || (h < phdata->NGAGE_ScreenSize.iHeight)) { - DrawBackground(_this); - } - - // Tell the system that something has been drawn - TRect rect = TRect(phdata->NGAGE_WsWindow.Size()); - phdata->NGAGE_WsWindow.Invalidate(rect); - - // Draw current buffer - SDL_Rect fullScreen; - fullScreen.x = 0; - fullScreen.y = 0; - fullScreen.w = screen->w; - fullScreen.h = screen->h; - DirectUpdate(_this, 1, &fullScreen); -} - -#endif // SDL_VIDEO_DRIVER_NGAGE diff --git a/src/video/ngage/SDL_ngageframebuffer_c.h b/src/video/ngage/SDL_ngageframebuffer_c.h deleted file mode 100644 index 578cc5681c..0000000000 --- a/src/video/ngage/SDL_ngageframebuffer_c.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_internal.h" - -extern bool SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_PixelFormat *format, void **pixels, int *pitch); -extern bool SDL_NGAGE_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, const SDL_Rect *rects, int numrects); -extern void SDL_NGAGE_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window); - -/****************************************************************************/ -// Runtime -/****************************************************************************/ - -class NGAGE_Runtime -{ - public: - IMPORT_C static void GetScreenInfo(TScreenInfoV01 &screenInfo2); -}; diff --git a/src/video/ngage/SDL_ngagevideo.cpp b/src/video/ngage/SDL_ngagevideo.cpp deleted file mode 100644 index 1694a9d787..0000000000 --- a/src/video/ngage/SDL_ngagevideo.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include -#ifdef NULL -#undef NULL -#endif -#include "SDL_internal.h" - -#ifdef SDL_VIDEO_DRIVER_NGAGE - -#ifdef __cplusplus -extern "C" { -#endif - -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" - -#ifdef __cplusplus -} -#endif - -#include "SDL_ngagevideo.h" -#include "SDL_ngagewindow.h" -#include "SDL_ngageevents_c.h" -#include "SDL_ngageframebuffer_c.h" - -#define NGAGEVID_DRIVER_NAME "ngage" - -// Initialization/Query functions -static bool NGAGE_VideoInit(SDL_VideoDevice *_this); -static void NGAGE_VideoQuit(SDL_VideoDevice *_this); - -// NGAGE driver bootstrap functions - -static void NGAGE_DeleteDevice(SDL_VideoDevice *device) -{ - SDL_VideoData *phdata = device->internal; - - if (phdata) { - // Free Epoc resources - - // Disable events for me - if (phdata->NGAGE_WsEventStatus != KRequestPending) { - phdata->NGAGE_WsSession.EventReadyCancel(); - } - if (phdata->NGAGE_RedrawEventStatus != KRequestPending) { - phdata->NGAGE_WsSession.RedrawReadyCancel(); - } - - free(phdata->NGAGE_DrawDevice); // This should NOT be SDL_free() - - if (phdata->NGAGE_WsWindow.WsHandle()) { - phdata->NGAGE_WsWindow.Close(); - } - - if (phdata->NGAGE_WsWindowGroup.WsHandle()) { - phdata->NGAGE_WsWindowGroup.Close(); - } - - delete phdata->NGAGE_WindowGc; - phdata->NGAGE_WindowGc = NULL; - - delete phdata->NGAGE_WsScreen; - phdata->NGAGE_WsScreen = NULL; - - if (phdata->NGAGE_WsSession.WsHandle()) { - phdata->NGAGE_WsSession.Close(); - } - - SDL_free(phdata); - phdata = NULL; - } - - if (device) { - SDL_free(device); - device = NULL; - } -} - -static SDL_VideoDevice *NGAGE_CreateDevice(void) -{ - SDL_VideoDevice *device; - SDL_VideoData *phdata; - - // Initialize all variables that we clean on shutdown - device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (!device) { - return NULL; - } - - // Initialize internal N-Gage specific data - phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (!phdata) { - SDL_free(device); - return NULL; - } - - // General video - device->VideoInit = NGAGE_VideoInit; - device->VideoQuit = NGAGE_VideoQuit; - device->PumpEvents = NGAGE_PumpEvents; - device->CreateWindowFramebuffer = SDL_NGAGE_CreateWindowFramebuffer; - device->UpdateWindowFramebuffer = SDL_NGAGE_UpdateWindowFramebuffer; - device->DestroyWindowFramebuffer = SDL_NGAGE_DestroyWindowFramebuffer; - device->free = NGAGE_DeleteDevice; - - // "Window" - device->CreateSDLWindow = NGAGE_CreateWindow; - device->DestroyWindow = NGAGE_DestroyWindow; - - // N-Gage specific data - device->internal = phdata; - - return device; -} - -VideoBootStrap NGAGE_bootstrap = { - NGAGEVID_DRIVER_NAME, "SDL ngage video driver", - NGAGE_CreateDevice, - NULL // no ShowMessageBox implementation -}; - -static bool NGAGE_VideoInit(SDL_VideoDevice *_this) -{ - SDL_DisplayMode mode; - - // Use 12-bpp desktop mode - SDL_zero(mode); - mode.format = SDL_PIXELFORMAT_XRGB4444; - mode.w = 176; - mode.h = 208; - if (SDL_AddBasicVideoDisplay(&mode) == 0) { - return false; - } - - // We're done! - return true; -} - -static void NGAGE_VideoQuit(SDL_VideoDevice *_this) -{ -} - -#endif // SDL_VIDEO_DRIVER_NGAGE diff --git a/src/video/ngage/SDL_ngagevideo.h b/src/video/ngage/SDL_ngagevideo.h deleted file mode 100644 index 8f1b07b70a..0000000000 --- a/src/video/ngage/SDL_ngagevideo.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_internal.h" - -#ifndef SDL_ngagevideo_h -#define SDL_ngagevideo_h - -#include "../SDL_sysvideo.h" - -#include -#include -#include -#include -#include "bitdraw.h" // CFbsDrawDevice - -#define SDL_VideoDevice *_this SDL_VideoDevice *_this - -struct SDL_VideoData -{ - // Epoc window server info - RWsSession NGAGE_WsSession; - RWindowGroup NGAGE_WsWindowGroup; - TInt NGAGE_WsWindowGroupID; - RWindow NGAGE_WsWindow; - CWsScreenDevice *NGAGE_WsScreen; - CWindowGc *NGAGE_WindowGc; - TRequestStatus NGAGE_WsEventStatus; - TRequestStatus NGAGE_RedrawEventStatus; - TWsEvent NGAGE_WsEvent; - CFbsDrawDevice *NGAGE_DrawDevice; - TBool NGAGE_IsWindowFocused; // Not used yet - - // Screen hardware frame buffer info - TBool NGAGE_HasFrameBuffer; - TInt NGAGE_BytesPerPixel; - TInt NGAGE_BytesPerScanLine; - TInt NGAGE_BytesPerScreen; - TDisplayMode NGAGE_DisplayMode; - TSize NGAGE_ScreenSize; - TUint8 *NGAGE_FrameBuffer; - TPoint NGAGE_ScreenOffset; - - CFbsBitGc::TGraphicsOrientation NGAGE_ScreenOrientation; -}; - -#endif // SDL_ngagevideo_h diff --git a/src/video/ngage/SDL_ngagewindow.cpp b/src/video/ngage/SDL_ngagewindow.cpp deleted file mode 100644 index f916e1fae7..0000000000 --- a/src/video/ngage/SDL_ngagewindow.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#include "SDL_internal.h" - -#ifdef SDL_VIDEO_DRIVER_NGAGE - -#include "../SDL_sysvideo.h" - -#include "SDL_ngagewindow.h" - -const TUint32 WindowClientHandle = 9210; - -void DisableKeyBlocking(SDL_VideoDevice *_this); -void ConstructWindowL(SDL_VideoDevice *_this); - -bool NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props) -{ - NGAGE_Window *ngage_window = (NGAGE_Window *)SDL_calloc(1, sizeof(NGAGE_Window)); - - if (!ngage_window) { - return false; - } - - window->internal = ngage_window; - - if (window->x == SDL_WINDOWPOS_UNDEFINED) { - window->x = 0; - } - - if (window->y == SDL_WINDOWPOS_UNDEFINED) { - window->y = 0; - } - - ngage_window->sdl_window = window; - - ConstructWindowL(_this); - - return true; -} - -void NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) -{ - NGAGE_Window *ngage_window = (NGAGE_Window *)window->internal; - - if (ngage_window) { - SDL_free(ngage_window); - } - - window->internal = NULL; -} - -/*****************************************************************************/ -// Internal -/*****************************************************************************/ - -void DisableKeyBlocking(SDL_VideoDevice *_this) -{ - SDL_VideoData *phdata = _this->internal; - TRawEvent event; - - event.Set((TRawEvent::TType) /*EDisableKeyBlock*/ 51); - phdata->NGAGE_WsSession.SimulateRawEvent(event); -} - -void ConstructWindowL(SDL_VideoDevice *_this) -{ - SDL_VideoData *phdata = _this->internal; - TInt error; - - error = phdata->NGAGE_WsSession.Connect(); - User::LeaveIfError(error); - phdata->NGAGE_WsScreen = new (ELeave) CWsScreenDevice(phdata->NGAGE_WsSession); - User::LeaveIfError(phdata->NGAGE_WsScreen->Construct()); - User::LeaveIfError(phdata->NGAGE_WsScreen->CreateContext(phdata->NGAGE_WindowGc)); - - phdata->NGAGE_WsWindowGroup = RWindowGroup(phdata->NGAGE_WsSession); - User::LeaveIfError(phdata->NGAGE_WsWindowGroup.Construct(WindowClientHandle)); - phdata->NGAGE_WsWindowGroup.SetOrdinalPosition(0); - - RProcess thisProcess; - TParse exeName; - exeName.Set(thisProcess.FileName(), NULL, NULL); - TBuf<32> winGroupName; - winGroupName.Append(0); - winGroupName.Append(0); - winGroupName.Append(0); // UID - winGroupName.Append(0); - winGroupName.Append(exeName.Name()); // Caption - winGroupName.Append(0); - winGroupName.Append(0); // DOC name - phdata->NGAGE_WsWindowGroup.SetName(winGroupName); - - phdata->NGAGE_WsWindow = RWindow(phdata->NGAGE_WsSession); - User::LeaveIfError(phdata->NGAGE_WsWindow.Construct(phdata->NGAGE_WsWindowGroup, WindowClientHandle - 1)); - phdata->NGAGE_WsWindow.SetBackgroundColor(KRgbWhite); - phdata->NGAGE_WsWindow.Activate(); - phdata->NGAGE_WsWindow.SetSize(phdata->NGAGE_WsScreen->SizeInPixels()); - phdata->NGAGE_WsWindow.SetVisible(ETrue); - - phdata->NGAGE_WsWindowGroupID = phdata->NGAGE_WsWindowGroup.Identifier(); - phdata->NGAGE_IsWindowFocused = EFalse; - - DisableKeyBlocking(_this); -} - -#endif // SDL_VIDEO_DRIVER_NGAGE diff --git a/src/video/ngage/SDL_ngagewindow.h b/src/video/ngage/SDL_ngagewindow.h deleted file mode 100644 index 317e03b221..0000000000 --- a/src/video/ngage/SDL_ngagewindow.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - Simple DirectMedia Layer - Copyright (C) 1997-2024 Sam Lantinga - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef SDL_ngagewindow_h -#define SDL_ngagewindow_h - -#include "../SDL_sysvideo.h" - -#include "SDL_ngagevideo.h" - -typedef struct -{ - SDL_Window *sdl_window; - -} NGAGE_Window; - -extern int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesID create_props); -extern void NGAGE_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window); - -#endif // SDL_ngagewindow