Patch for Qtopia port of SDL


I’m a user of SL-5500 and SL-C700(Linux Zaurus), and am developing a
game engine clone using SDL. My game engine has been tested on
Linux(i386), Solaris(sparc), MacOS X and Windows, and works fine so

I ported the engine to linux zaurus and, at that stage, I needed some
modifications on SDL-1.2.5. If the maintainer of Qtopia port of SDL
agrees with the patch below, please merge it into the CVS tree. Note
that, I didn’t apply David’s patch(Dec.27 2002). I haven’t subscribed
to this list yet and I noticed his patch just after I wrote the
message below.

The patch on SDL_dspaudio.c is for SL-A300 only. In SL-A300, a process
is occasionally locked for 200msec and 2 fragments is too small to
play audio stream continuously, i.e. it leads to noisy broken MP3
music. I know this is a problem of the kernel in SL-A300, however
SL-A300 users need it for now. This is another guy’s hack and I
haven’t checked the effect by myself. (This patch is not needed for
SL-5500 and I’m not sure it is necessary for SL-C700 or SL-B500.)

In, I added a handler of Key Qt::Key_F33 to handle OK

The most important thing in my patch is the deletion of
in SDL_QWin.h.

Most Linux Zaurus works fine with this line. But on SL-C700, it causes
occasional hang-up of input event delivery process. It means, after
several drawing commands (SDL_UpdateRect) are issued, key and mouse
events are never delivered to the application any more, while the
event loop of SDL is running as usual. If this happens, what I can do
is to login to the zaurus and kill the process manually, and then
everything gets back to normal.

QPainter::end() is called in QPainter::~QPainter and I suppose it is
not good to call QPainter::end() before executing
QDirectPainter::~QDirectPainter(). The modified SDL also works fine on
SL-5500, and SL-C700 never gets stuck since then.

The last modification in is intended to emit
SDL_MOUSEMOTION event after calling SDL_WarpMouse. My game engine
makes use of this mechanism and other ports of SDL works just like

Except for the above modifications, Qtopia port of SDL works pretty
fine and I can enjoy many games in VGA screen on SL-C700 as in the
desktop environment, although I have to allocate an image buffer as
SDL_SetVideoMode( 480, 640, 16, SDL_SWSURFACE) and rotate the VGA
(640x480) screen CW before calling SDL_UpdateRect().

My game engine interpretes japanese game scripts written for
NScripter(a game engine on Windows). If you are interested in this
program and are not reluctant to read japanese, please see the web
page below.

diff -Nur SDL-1.2.5-org/src/audio/dsp/SDL_dspaudio.c SDL-1.2.5/src/audio/dsp/SDL_dspaudio.c
— SDL-1.2.5-org/src/audio/dsp/SDL_dspaudio.c 2002-04-15 16:38:54.000000000 +0900
+++ SDL-1.2.5/src/audio/dsp/SDL_dspaudio.c 2002-12-15 18:06:29.000000000 +0900
@@ -263,7 +263,11 @@
SDL_SetError(“Fragment size must be a power of two”);
+#if 0
frag_spec |= 0x00020000; /* two fragments, for low latency /
+#else /
for SL-A300 */

  • frag_spec |= 0x00120000; /* 18 fragments, for smoothness */

    /* Set the audio buffering parameters */
    #ifdef DEBUG_AUDIO
    diff -Nur SDL-1.2.5-org/src/audio/dsp/SDL_dspaudio.h SDL-1.2.5/src/audio/dsp/SDL_dspaudio.h
    — SDL-1.2.5-org/src/audio/dsp/SDL_dspaudio.h 2002-03-06 20:23:02.000000000 +0900
    +++ SDL-1.2.5/src/audio/dsp/SDL_dspaudio.h 2002-12-15 18:06:29.000000000 +0900
    @@ -27,6 +27,7 @@

#ifndef _SDL_dspaudio_h
#define _SDL_dspaudio_h
+// #define DEBUG_AUDIO

#include “SDL_sysaudio.h”

diff -Nur SDL-1.2.5-org/src/video/qtopia/ SDL-1.2.5/src/video/qtopia/
— SDL-1.2.5-org/src/video/qtopia/ 2002-09-01 09:37:24.000000000 +0900
+++ SDL-1.2.5/src/video/qtopia/ 2002-12-16 03:45:24.000000000 +0900
@@ -279,6 +279,7 @@
} else if(scancode >= 0x1000) {
// Special keys
switch(scancode) {

  • case Qt::Key_F33: scancode = SDLK_RETURN; break; // added
    case Qt::Key_Escape: scancode = SDLK_ESCAPE; break;
    case Qt::Key_Tab: scancode = SDLK_TAB; break;
    case Qt::Key_Backspace: scancode = SDLK_BACKSPACE; break;
    diff -Nur SDL-1.2.5-org/src/video/qtopia/SDL_QWin.h SDL-1.2.5/src/video/qtopia/SDL_QWin.h
    — SDL-1.2.5-org/src/video/qtopia/SDL_QWin.h 2002-09-01 09:37:24.000000000 +0900
    +++ SDL-1.2.5/src/video/qtopia/SDL_QWin.h 2003-01-02 11:43:35.000000000 +0900
    @@ -98,7 +98,7 @@
    my_locked–; // decrease lock refcount;
    if(!my_locked && my_painter) {
  •  my_painter->end();
  •  /*my_painter->end();*/
     delete my_painter;
     my_painter = 0;
    diff -Nur SDL-1.2.5-org/src/video/qtopia/ SDL-1.2.5/src/video/qtopia/
    — SDL-1.2.5-org/src/video/qtopia/ 2002-05-20 05:06:01.000000000 +0900
    +++ SDL-1.2.5/src/video/qtopia/ 2002-12-15 18:06:29.000000000 +0900
    @@ -60,6 +60,7 @@
    void QT_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
    SDL_Win->setMousePos(QPoint(x, y));
  • SDL_PrivateMouseMotion( 0, 0, SDL_Win->mousePos().x(), SDL_Win->mousePos().y());

}; /* Extern C */