N-Gage port: add changes from code reviews, overall cleanup (#5618) * Add changes from code review by @ccawley2011, #5597, overall cleanup * Update N-Gage README, minor cleanup and rephrasing * Call SDL_SetMainReady() before calling SDL_main, return SDL_main instead of main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
diff --git a/docs/README-ngage.md b/docs/README-ngage.md
index 7387887..83c2e33 100644
--- a/docs/README-ngage.md
+++ b/docs/README-ngage.md
@@ -1,7 +1,7 @@
Nokia N-Gage
============
-SDL2 port for Symbian S60v1/2 with a main focus on the Nokia N-Gage
+SDL2 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).
Compiling
@@ -13,8 +13,7 @@ The library is included in the
sub-module.
A complete example project based on SDL2 can be found in the GitHub
-account of the SDK: [Example
-project](https://github.com/ngagesdk/wordle).
+account of the SDK: [Wordle](https://github.com/ngagesdk/wordle).
Current level of implementation
-------------------------------
@@ -30,8 +29,9 @@ Acknowledgements
----------------
Thanks to Hannu Viitala, Kimmo Kinnunen and Markus Mertama for the
-valuable insight into Symbian programming. Without the SDL 1.2 port for
-CDoom, this adaptation would not have been possible.
+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
@@ -39,6 +39,6 @@ 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 say a special thank you to the
-[EKA2L1](https://12z1.com/) team. Thank you for all your patience and
-support in troubleshooting.
+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/SDL_config_ngage.h b/include/SDL_config_ngage.h
index 07f9254..a9d2d37 100644
--- a/include/SDL_config_ngage.h
+++ b/include/SDL_config_ngage.h
@@ -62,7 +62,7 @@ typedef unsigned long uintptr_t;
/* Enable the N-Gage timer support (src/timer/ngage/\*.c) */
#define SDL_TIMER_NGAGE 1
-/* Enable the N=Hahe video driver (src/video/ngage/\*.c) */
+/* 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) */
diff --git a/src/main/ngage/SDL_ngage_main.cpp b/src/main/ngage/SDL_ngage_main.cpp
index bb0f07c..6dbf2f1 100644
--- a/src/main/ngage/SDL_ngage_main.cpp
+++ b/src/main/ngage/SDL_ngage_main.cpp
@@ -1,6 +1,5 @@
/*
- EPOC version (originally for SDL 1.2) by Hannu Viitala
- (hannu.j.viitala@mbnet.fi).
+ SDL_ngage_main.c, originally for SDL 1.2 by Hannu Viitala
*/
#include "../../SDL_internal.h"
@@ -68,7 +67,8 @@ TInt E32Main()
{
oldHeap = User::SwitchHeap(newHeap);
/* Call stdlib main */
- ret = main(argc, argv);
+ SDL_SetMainReady();
+ ret = SDL_main(argc, argv);
}
cleanup:
diff --git a/src/thread/ngage/SDL_sysmutex.cpp b/src/thread/ngage/SDL_sysmutex.cpp
index a79b8ae..34cf451 100644
--- a/src/thread/ngage/SDL_sysmutex.cpp
+++ b/src/thread/ngage/SDL_sysmutex.cpp
@@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
-/* An implementation of mutexes using semaphores */
+/* An implementation of mutexes using the Symbian API. */
#include <e32std.h>
@@ -70,6 +70,22 @@ SDL_DestroyMutex(SDL_mutex * mutex)
}
}
+/* Try to lock the mutex */
+#if 0
+int
+SDL_TryLockMutex(SDL_mutex * mutex)
+{
+ if (mutex == NULL)
+ {
+ SDL_SetError("Passed a NULL mutex.");
+ return -1;
+ }
+
+ // Not yet implemented.
+ return 0;
+}
+#endif
+
/* Lock the mutex */
int
SDL_LockMutex(SDL_mutex * mutex)
@@ -89,7 +105,7 @@ SDL_LockMutex(SDL_mutex * mutex)
/* Unlock the mutex */
int
-SDL_mutexV(SDL_mutex * mutex)
+SDL_UnlockMutex(SDL_mutex * mutex)
{
if ( mutex == NULL )
{
diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp
index f7e97ad..ab277ca 100644
--- a/src/thread/ngage/SDL_syssem.cpp
+++ b/src/thread/ngage/SDL_syssem.cpp
@@ -20,7 +20,7 @@
*/
#include "../../SDL_internal.h"
-/* An implementation of semaphores using mutexes and condition variables */
+/* An implementation of semaphores using the Symbian API. */
#include <e32std.h>
diff --git a/src/thread/ngage/SDL_systhread.cpp b/src/thread/ngage/SDL_systhread.cpp
index 18596d9..f2c30f7 100644
--- a/src/thread/ngage/SDL_systhread.cpp
+++ b/src/thread/ngage/SDL_systhread.cpp
@@ -128,19 +128,6 @@ SDL_SYS_DetachThread(SDL_Thread * thread)
return;
}
-/* WARNING: This function is really a last resort.
- * Threads should be signaled and then exit by themselves.
- * TerminateThread() doesn't perform stack and DLL cleanup.
- */
-void
-SDL_SYS_KillThread(SDL_Thread *thread)
-{
- RThread rthread;
- rthread.SetHandle(thread->handle);
- rthread.Kill(0);
- rthread.Close();
-}
-
#endif /* SDL_THREAD_NGAGE */
/* vim: ts=4 sw=4
diff --git a/src/video/ngage/SDL_ngageevents.cpp b/src/video/ngage/SDL_ngageevents.cpp
index 659548a..a136333 100644
--- a/src/video/ngage/SDL_ngageevents.cpp
+++ b/src/video/ngage/SDL_ngageevents.cpp
@@ -113,7 +113,7 @@ static SDL_Scancode ConvertScancode(_THIS, int key)
keycode = SDLK_ASTERISK;
break;
case EStdKeyHash: // Hash
- keycode = SDLK_SLASH;
+ keycode = SDLK_HASH;
break;
case EStdKeyDevice0: // Left softkey
keycode = SDLK_SOFTLEFT;
@@ -121,14 +121,14 @@ static SDL_Scancode ConvertScancode(_THIS, int key)
case EStdKeyDevice1: // Right softkey
keycode = SDLK_SOFTRIGHT;
break;
- case EStdKeyApplication0: // Green softkey
+ case EStdKeyApplication0: // Call softkey
keycode = SDLK_CALL;
break;
- case EStdKeyApplication1: // Red softkey
+ case EStdKeyApplication1: // End call softkey
keycode = SDLK_ENDCALL;
break;
case EStdKeyDevice3: // Middle softkey
- keycode = SDLK_RETURN;
+ keycode = SDLK_SELECT;
break;
case EStdKeyUpArrow: // Up arrow
keycode = SDLK_UP;
@@ -166,7 +166,7 @@ int HandleWsEvent(_THIS, const TWsEvent& aWsEvent)
case EEventFocusGained: /* SDL window got focus */
phdata->NGAGE_IsWindowFocused = ETrue;
/* Draw window background and screen buffer */
- DisableKeyBlocking(_this); //Markus: guess why :-)
+ DisableKeyBlocking(_this);
RedrawWindowL(_this);
break;
case EEventFocusLost: /* SDL window lost focus */
diff --git a/src/video/ngage/SDL_ngageframebuffer.cpp b/src/video/ngage/SDL_ngageframebuffer.cpp
index 139d46f..a67fa5a 100644
--- a/src/video/ngage/SDL_ngageframebuffer.cpp
+++ b/src/video/ngage/SDL_ngageframebuffer.cpp
@@ -106,11 +106,16 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * forma
{
phdata->NGAGE_FrameBuffer += 32;
}
- /*if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 12)
- phdata->NGAGE_FrameBuffer += 16 * 2;
- if (phdata->NGAGE_HasFrameBuffer && GetBpp(displayMode) == 16)
- phdata->NGAGE_FrameBuffer += 16 * 2;
- */
+ #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;
@@ -367,11 +372,13 @@ void DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
TUint16* screenBuffer = (TUint16*)phdata->NGAGE_FrameBuffer;
- /*if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270)
+#if 0
+ if (phdata->NGAGE_ScreenOrientation == CFbsBitGc::EGraphicsOrientationRotated270)
{
// ...
}
- else */
+ else
+#endif
{
DirectDraw(_this, numrects, rects, screenBuffer);
}
@@ -385,7 +392,7 @@ void DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
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->UpdateRegion(rect2); /* Should we update rects parameter area only? */
phdata->NGAGE_DrawDevice->Update();
}
}