From 50664a6f713920c9f1fdca023faa17e2971c2bf0 Mon Sep 17 00:00:00 2001 From: gewlitys Date: Sun, 31 Aug 2008 00:34:29 +0000 Subject: [PATCH] Experimental support for Symbian S60 3rd edition git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@3064 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 3 +- sc2/INSTALL.symbian | 86 ++++++ sc2/Makeproject | 2 +- sc2/build/unix/build.config | 181 +++++++++--- sc2/build/unix/config_proginfo_build | 2 +- sc2/build/unix/config_proginfo_host | 65 ++++- sc2/build/unix/make/buildtools-armv5 | 2 +- sc2/src/config.h | 2 + sc2/src/port.h | 1 + sc2/src/sc2code/libs/graphics/sdl/rotozoom.c | 54 +++- sc2/src/sc2code/libs/sound/decoders/modaud.c | 4 + .../libs/sound/mixer/sdl/audiodrv_sdl.c | 11 +- sc2/src/sc2code/planets/plangen.c | 8 + sc2/src/starcon2.c | 12 +- sc2/src/symbian/bld.inf | 9 + sc2/src/symbian/config.h | 57 ++++ sc2/src/symbian/icons_scalable_dc.mk | 37 +++ sc2/src/symbian/uqm.cfg | 26 ++ sc2/src/symbian/uqm.mmp | 43 +++ sc2/src/symbian/uqm.pkg | 26 ++ sc2/src/symbian/uqm.rss | 26 ++ sc2/src/symbian/uqm.svg | 70 +++++ sc2/src/symbian/uqm_reg.rss | 12 + sc2/src/symbian/uqmapp.cpp | 260 ++++++++++++++++++ 24 files changed, 939 insertions(+), 60 deletions(-) create mode 100644 sc2/INSTALL.symbian create mode 100644 sc2/src/symbian/bld.inf create mode 100644 sc2/src/symbian/config.h create mode 100644 sc2/src/symbian/icons_scalable_dc.mk create mode 100644 sc2/src/symbian/uqm.cfg create mode 100644 sc2/src/symbian/uqm.mmp create mode 100644 sc2/src/symbian/uqm.pkg create mode 100644 sc2/src/symbian/uqm.rss create mode 100644 sc2/src/symbian/uqm.svg create mode 100644 sc2/src/symbian/uqm_reg.rss create mode 100644 sc2/src/symbian/uqmapp.cpp diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 1bba96fa7..9e4f32ab6 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,5 +1,6 @@ Changes towards version 0.7: -- Pthread support - Gwl +- Experimental support for Symbian S60 3rd edition - Mika & SvdB +- Pthread support - Mika - Content Dirs completely reorganized; 3DO and PC segregation - Coredev - Voiceovers controlled by a synthetic '3dovoice' addon - Michael - CONVERSATION explicitly names text/voice/timestamps - Michael diff --git a/sc2/INSTALL.symbian b/sc2/INSTALL.symbian new file mode 100644 index 000000000..4bfffe58b --- /dev/null +++ b/sc2/INSTALL.symbian @@ -0,0 +1,86 @@ +UQM for Symbian S60 3rd ed. +=========================== + +First some general notes. These instructions might be somewhat incomplete or +unclear. If you encounter any problems or have suggestions how to improve this +document, please report them to our Bugzilla at + http://bugs.uqm.stack.nl/ + +UQM's Symbian support is currently at experimental stage and is tested only on +Nokia N73, which has too little memory to run it reliably for long time. +Reports of successes and failures on other devices are very welcome. + +Known problems: +- No OGG support so voices and 3DO music are not available. +- No netmelee. + + +Prerequisites: +-------------- + +- Platform SDK for S60 3rd ed. (MR) / 3rd ed. FP1 / 3rd ed. FP2, depending on + target hardware + * Download from http://www.forum.nokia.com/ + +- Open C plugins (if SDK is other than FP2; in FP2 those should be included already) + * Download from http://www.forum.nokia.com/main/resources/tools_and_sdks/openc_cpp/ + +- Carbide.c++ (if building for emulator) + * Download from http://www.forum.nokia.com/ + * Command line compiling must be enabled + +- ARM RealView compiler (if building for hardware) + * Commercial, see http://www.arm.com/products/DevTools/ + +- MinGW and MSYS (for build scripts) + * Download from http://www.mingw.org/ + +- Info-Zip (for building content package) + * Download from http://www.info-zip.org/Zip.html + +- SDL for S60 3rd ed. + * Download from http://koti.mbnet.fi/mertama/sdl.html + * You also need the sources from http://www.libsdl.org/ + +Building: +--------- + +1) Set up platform SDK, compilers, Open C plugins and MinGW + MSYS. + * Be sure zip and other tools are listed in path so they can be accessed + directly from command line. + +2) Subst your Symbian SDK to a new drive along the following example: + subst z: C:\Symbian\9.1\S60_3rd_MR_2 + +3) Put UQM sources inside the substed drive, if not already there. + +4) Install and build SDL, instructions are inside the package. + +5) Build a partial port of libpng and SDL_image, which are included + in UQM SVN repository at trunk/symbian/png: + cd png\group + bldmake bldfiles + abld build + +6) Open MSYS terminal. All following steps are done inside it. + +7) Two environment variables control the building, BUILD_EPOCROOT and BUILD_HOST. + + Set BUILD_EPOCROOT to point to the substed drive: + export BUILD_EPOCROOT=/z + + Set BUILD_HOST to either WINSCW (emulator) or ARMV5 (hardware), depending + for which target you want to build: + export BUILD_HOST=ARMV5 + +8) Compile (you don't need to change any options from the interactive menu): + ./build.sh uqm + +9) Install. It builds the content zip and puts everything to proper + place (WINSCW) or creates a self-signed SIS package (ARMV5): + ./build.sh uqm install + +10) If you built for ARMV5, you should now have uqm.sisx in the same directory + from where you did the build. Remember to also install SDL SIS package and + if not using FP2 SDK, Open C plugins before attempting to run UQM on actual + device. diff --git a/sc2/Makeproject b/sc2/Makeproject index 277b3bfed..93600df8a 100644 --- a/sc2/Makeproject +++ b/sc2/Makeproject @@ -10,7 +10,7 @@ else fi case "$HOST_SYSTEM" in ARMV5|WINSCW) - uqm_NAME="$uqm_NAME.lib" + uqm_NAME="uqm.lib" ;; MINGW32*|CYGWIN*) uqm_NAME="$uqm_NAME.exe" diff --git a/sc2/build/unix/build.config b/sc2/build/unix/build.config index 43db75c16..53f0f2765 100644 --- a/sc2/build/unix/build.config +++ b/sc2/build/unix/build.config @@ -72,7 +72,7 @@ uqm_prepare_config() MENU_main_ITEMS="debug graphics sound mikmod ovcodec netplay joystick \ ioformat accel threadlib" case "$HOST_SYSTEM" in - Darwin) + Darwin|WINSCW|ARMV5) # Installation directory not modifiable ;; MINGW32*|cegcc) @@ -133,35 +133,53 @@ uqm_prepare_config() CHOICE_debug_OPTION_strictdebug_TITLE="Debug + strict compile checks" CHOICE_debug_OPTION_strictdebug_ACTION='strictdebug_action' strictdebug_action() { - CFLAGS="$CFLAGS -O1" # This is needed for -Wunitialized - CFLAGS="$CFLAGS -W -Wall \ - -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \ - -Wstrict-prototypes -Wmissing-declarations \ - -Wwrite-strings -Wimplicit -Wreturn-type -Wformat \ - -Wswitch -Wcomment -Wchar-subscripts \ - -Wparentheses -Wcast-align \ - -Winline -Wuninitialized" -# CFLAGS="$CFLAGS -Waggregate-return" - # It's not unreasonable to return structs at times. -# CFLAGS="$CFLAGS "-Wpointer-arith" - # Some standard header won't even compile with this on -# CFLAGS="$CFLAGS -Wshadow" - # This gives absurd conflicts with standard files, - # like from 'y0 and y1' -# CFLAGS="$CFLAGS -Werror" - # We shouldn't do this until we actually nail them - # all in the original code. Then we can enforce them - # on ourselves. -# CFLAGS="$CFLAGS -pedantic-errors -ansi -trigraphs" # ANSI -# CFLAGS="$CFLAGS -Wnested-externs" - # We know they're in the code, and though we'd like to get - # rid of them, they're not bugs. - CFLAGS=`echo $CFLAGS` - # Remove all the unnecessary spaces from $CFLAGS, - # for more readable messages. + case "$HOST_SYSTEM" in + WINSCW) + CFLAGS="$CFLAGS -g -O0 -W all -d DEBUG -d _DEBUG" + ;; + ARMV5) + CFLAGS="$CFLAGS -g -O0 -DDEBUG -D_DEBUG" + ;; + *) + CFLAGS="$CFLAGS -O1" # This is needed for -Wunitialized + CFLAGS="$CFLAGS -W -Wall \ + -Wbad-function-cast -Wcast-qual -Wmissing-prototypes \ + -Wstrict-prototypes -Wmissing-declarations \ + -Wwrite-strings -Wimplicit -Wreturn-type -Wformat \ + -Wswitch -Wcomment -Wchar-subscripts \ + -Wparentheses -Wcast-align \ + -Winline -Wuninitialized" +# CFLAGS="$CFLAGS -Waggregate-return" + # It's not unreasonable to return structs at times. +# CFLAGS="$CFLAGS "-Wpointer-arith" + # Some standard header won't even compile with this on +# CFLAGS="$CFLAGS -Wshadow" + # This gives absurd conflicts with standard files, + # like from 'y0 and y1' +# CFLAGS="$CFLAGS -Werror" + # We shouldn't do this until we actually nail them + # all in the original code. Then we can enforce them + # on ourselves. +# CFLAGS="$CFLAGS -pedantic-errors -ansi -trigraphs" # ANSI +# CFLAGS="$CFLAGS -Wnested-externs" + # We know they're in the code, and though we'd like to get + # rid of them, they're not bugs. + CFLAGS=`echo $CFLAGS` + # Remove all the unnecessary spaces from $CFLAGS, + # for more readable messages. + ;; + esac DEBUG=1 - } - CHOICE_debug_DEFAULT=debug + } + case "$HOST_SYSTEM" in + ARMV5|WINSCW) + CHOICE_debug_DEFAULT=nodebug + ;; + *) + CHOICE_debug_DEFAULT=debug + ;; + esac + CHOICE_graphics_OPTIONS="pure opengl" CHOICE_graphics_TITLE="OpenGL graphics support" @@ -253,7 +271,15 @@ uqm_prepare_config() CFLAGS="$CFLAGS -DHAVE_JOYSTICK" } CHOICE_joystick_OPTION_disabled_TITLE="disabled" - CHOICE_joystick_DEFAULT=enabled + case "$HOST_SYSTEM" in + ARMV5|WINSCW) + CHOICE_joystick_DEFAULT=disabled + ;; + *) + CHOICE_joystick_DEFAULT=enabled + ;; + esac + CHOICE_netplay_OPTIONS="none full ipv4" CHOICE_netplay_TITLE="Network Supermelee support" @@ -438,7 +464,7 @@ uqm_post_build() { RFORK="src/res/darwin/${BUILD_PROJECT}.r" test -f "$TARGET_FILE" || return - + # If run from the command-line on OSX, the Window Manager # will refuse to recognize the window unless the program has # a resource fork; so we give it a small one here. When @@ -449,6 +475,20 @@ uqm_post_build() { Darwin) $REZ "$RFORK" -o "$TARGET_FILE" ;; + ARMV5) + cp "$TARGET_FILE" "$BUILD_EPOCROOT/epoc32/release/armv5/urel/" + cd src/symbian + cmd \\/C bldmake bldfiles armv5 + cmd \\/C abld build armv5 urel + cd ../.. + ;; + WINSCW) + cp "$TARGET_FILE" "$BUILD_EPOCROOT/epoc32/release/winscw/udeb/" + cd src/symbian + cmd \\/C bldmake bldfiles winscw + cmd \\/C abld build winscw udeb + cd ../.. + ;; esac } @@ -469,6 +509,12 @@ uqm_install() { echo "No installation procedure available for Windows CE." echo "Read the manual for more information." ;; + WINSCW) + uqm_install_winscw + ;; + ARMV5) + uqm_install_armv5 + ;; *) generic_install ;; @@ -543,11 +589,84 @@ uqm_install_osx() { cp $uqm_NAME "$INSTROOT/MacOS/The Ur-Quan Masters" } +uqm_install_winscw() { + local PRIVATE_DIR + + PRIVATE_DIR="$BUILD_EPOCROOT/epoc32/winscw/c/private/A000A0C3" + + uqm_create_symbian_content_package + + echo "Creating directory structure to $PRIVATE_DIR ..." + mkdir "$PRIVATE_DIR" + mkdir "$PRIVATE_DIR/content" + mkdir "$PRIVATE_DIR/content/packages" + mkdir "$PRIVATE_DIR/userdata" + + echo "Copying data to $PRIVATE_DIR ..." + cp content/version "$PRIVATE_DIR/content" + cp content.uqm "$PRIVATE_DIR/content/packages" + cp src/symbian/uqm.cfg "$PRIVATE_DIR/userdata" +} + +uqm_install_armv5() { + uqm_create_symbian_content_package + + cd src/symbian + cmd \\/C makekeys -cert -password asdfgh -len 2048 -dname "CN=UQM OR=Ur-Quan Masters CO=FI" uqm.key uqm.cer + cmd \\/C makesis uqm.pkg + cmd \\/C signsis -v uqm.sis uqm.sisx uqm.cer uqm.key asdfgh + mv uqm.sisx ../.. + cd ../.. +} + +uqm_create_symbian_content_package() { + if [ -e "content.uqm" ]; then + echo "Content package already exists, skipping" + return + fi + + echo "Creating content package..." + cd content + echo "Building file list..." + find . -type f -not -path '*/CVS*' -not -path '*/.svn*' -not -path './addons*' -not -name "version" >../content.lst + echo "Zipping..." + zip -q ../content.uqm -r . -i@../content.lst + cd .. + rm content.lst +} + uqm_clean() { case "$HOST_SYSTEM" in MINGW32*|CYGWIN*) rm -f "$BUILD_WORK/config_win.h" ;; + ARMV5) + local TARGET_FILE + eval TARGET_FILE="\$BUILD_WORK/\${${BUILD_PROJECT}_NAME}" + + rm -f "$BUILD_WORK/config_unix.h" + rm -f "$BUILD_EPOCROOT/epoc32/release/armv5/urel/$TARGET_FILE" + rm -f $TARGET_FILE uqm.sisx content.uqm + + cd src/symbian + cmd \\/C abld reallyclean armv5 + cmd \\/C bldmake clean + rm -f uqm.sis uqm.key uqm.cer + cd ../.. + ;; + WINSCW) + local TARGET_FILE + eval TARGET_FILE="\$BUILD_WORK/\${${BUILD_PROJECT}_NAME}" + + rm -f "$BUILD_WORK/config_unix.h" + rm -f "$BUILD_EPOCROOT/epoc32/release/winscw/udeb/$TARGET_FILE" + rm -f $TARGET_FILE content.uqm + + cd src/symbian + cmd \\/C abld reallyclean winscw + cmd \\/C bldmake clean + cd ../.. + ;; *) rm -f "$BUILD_WORK/config_unix.h" ;; diff --git a/sc2/build/unix/config_proginfo_build b/sc2/build/unix/config_proginfo_build index b8d969616..d8328a704 100644 --- a/sc2/build/unix/config_proginfo_build +++ b/sc2/build/unix/config_proginfo_build @@ -68,7 +68,7 @@ case "$HOST_SYSTEM" in useGccBuildTools ;; WINSCW) - EXTRA_WINSCW_FLAGS_COMPILE='-msgstyle gcc -gccinc -wchar_t off -align 4 -warnings on -w nohidevirtual,nounusedexpr -enum int -str pool -exc ms -trigraphs on -nostdinc -d _UNICODE -d __SYMBIAN32__ -d __SERIES60_30__ -d __SERIES60_3X__ -d __CW32__ -d __WINS__ -d __WINSCW__ -d __EXE__ -d __SUPPORT_CPP_EXCEPTIONS__ -I$BUILD_EPOCROOT/epoc32/include -I$BUILD_EPOCROOT/epoc32/include/stdapis -I$BUILD_EPOCROOT/epoc32/include/variant -include Symbian_OS_v9.1.hrh' + EXTRA_WINSCW_FLAGS_COMPILE="-msgstyle gcc -gccinc -dialect c99 -relax_pointers -wchar_t off -align 4 -warnings on -w nohidevirtual,nounusedexpr -enum int -str pool -exc ms -trigraphs on -nostdinc -d _UNICODE -d __SYMBIAN32__ -d __SERIES60_30__ -d __SERIES60_3X__ -d __CW32__ -d __WINS__ -d __WINSCW__ -d __EXE__ -d __SUPPORT_CPP_EXCEPTIONS__ -I$BUILD_EPOCROOT/epoc32/include -I$BUILD_EPOCROOT/epoc32/include/stdapis -I$BUILD_EPOCROOT/epoc32/include/variant -include Symbian_OS_v9.1.hrh" EXTRA_WINSCW_FLAGS_LINK='-library -msgstyle gcc -stdlib -noimplib -search' BUILDTOOL_PREPROC_C_COMMAND="\$PROG_mwccsym2_FILE -E $EXTRA_WINSCW_FLAGS_COMPILE" diff --git a/sc2/build/unix/config_proginfo_host b/sc2/build/unix/config_proginfo_host index 7bdb52883..3573ff2b6 100644 --- a/sc2/build/unix/config_proginfo_host +++ b/sc2/build/unix/config_proginfo_host @@ -67,6 +67,16 @@ case "$HOST_SYSTEM" in gcc -E -include SDL/SDL_version.h $LIB_SDL_CFLAGS - | \ tail -1 | tr -d ' ') ;; + WINSCW) + LIB_SDL_CFLAGS='-I$BUILD_EPOCROOT/epoc32/include/SDL' + LIB_SDL_LDFLAGS='' + LIB_SDL_VERSION='1.2.13' + ;; + ARMV5) + LIB_SDL_CFLAGS='-J$BUILD_EPOCROOT/epoc32/include/SDL' + LIB_SDL_LDFLAGS='' + LIB_SDL_VERSION='1.2.13' + ;; *) LIB_SDL_CFLAGS='$(sdl-config --cflags)' LIB_SDL_LDFLAGS='$(sdl-config --libs)' @@ -89,6 +99,10 @@ case "$HOST_SYSTEM" in LIB_SDL_image_CFLAGS='' LIB_SDL_image_LDFLAGS="-framework SDL_image" ;; + ARMV5|WINSCW) + LIB_SDL_image_CFLAGS="$LIB_SDL_CFLAGS" + LIB_SDL_image_LDFLAGS="$LIB_SDL_LDFLAGS" + ;; *) LIB_SDL_image_CFLAGS="$LIB_SDL_CFLAGS" LIB_SDL_image_LDFLAGS="$LIB_SDL_LDFLAGS -lSDL_image" @@ -135,6 +149,9 @@ case "$HOST_SYSTEM" in LIB_opengl_CFLAGS="" LIB_opengl_LDFLAGS="-framework OpenGL" ;; + ARMV5|WINSCW) + LIB_opengl_DETECT="false" + ;; *) LIB_opengl_CFLAGS="" LIB_opengl_LDFLAGS="-lGL" @@ -148,6 +165,11 @@ LIB_vorbis_NAME="libvorbis" LIB_vorbis_CFLAGS="" LIB_vorbis_LDFLAGS="-lvorbis" LIB_vorbis_VERSION="" +case "$HOST_SYSTEM" in + ARMV5|WINSCW) + LIB_vorbis_DETECT="false" + ;; +esac ### Vorbisfile ### @@ -175,8 +197,15 @@ case "$HOST_SYSTEM" in ;; esac LIB_vorbisfile_VERSION="" -LIB_vorbisfile_DETECT="try_pkgconfig_lib vorbisfile vorbisfile" -LIB_vorbisfile_DEPEND_DETECT_BIN="pkgconfig" +case "$HOST_SYSTEM" in + ARMV5|WINSCW) + LIB_vorbisfile_DETECT="false" + ;; + *) + LIB_vorbisfile_DETECT="try_pkgconfig_lib vorbisfile vorbisfile" + LIB_vorbisfile_DEPEND_DETECT_BIN="pkgconfig" + ;; +esac ### Tremor ### @@ -190,6 +219,9 @@ case "$HOST_SYSTEM" in # Assumed values - please let me know if you can verify this. LIB_tremor_CFLAGS="" LIB_tremor_LDFLAGS="-framework Tremor" + ;; + ARMV5|WINSCW) + LIB_tremor_DETECT="false" ;; *) LIB_tremor_CFLAGS="" @@ -204,6 +236,11 @@ LIB_libmikmod_NAME="libmikmod" LIB_libmikmod_CFLAGS="$(libmikmod-config --cflags)" LIB_libmikmod_LDFLAGS="$(libmikmod-config --libs)" LIB_libmikmod_VERSION="$(libmikmod-config --version)" +case "$HOST_SYSTEM" in + ARMV5|WINSCW) + LIB_libmikmod_DETECT="false" + ;; +esac ### zlib ### @@ -213,13 +250,24 @@ case "$HOST_SYSTEM" in MINGW32*|CYGWIN*|cegcc) LIB_zlib_LDFLAGS="-lzdll" ;; + ARMV5|WINSCW) + LIB_zlib_LDFLAGS="" + ;; *) LIB_zlib_LDFLAGS="-lz" ;; esac LIB_zlib_VERSION="" -LIB_zlib_DETECT="try_pkgconfig_lib zlib zlib" -LIB_zlib_DEPEND_DETECT_BIN="pkgconfig" +case "$HOST_SYSTEM" in + ARMV5|WINSCW) + LIB_zlib_DETECT="true" + ;; + *) + LIB_zlib_DETECT="try_pkgconfig_lib zlib zlib" + LIB_zlib_DEPEND_DETECT_BIN="pkgconfig" + ;; +esac + ### pthread ### @@ -235,6 +283,11 @@ case "$HOST_SYSTEM" in LIB_pthread_LDFLAGS="$(pthread-config --ldflags)" LIB_pthread_VERSION="$(pthread-config --version)" ;; + WINSCW|ARMV5) + LIB_pthread_CFLAGS="" + LIB_pthread_LDFLAGS="" + LIB_pthread_VERSION="" + ;; *) LIB_pthread_CFLAGS="" LIB_pthread_LDFLAGS="-lpthread" @@ -251,6 +304,9 @@ case "$HOST_SYSTEM" in LIB_netlibs_LDFLAGS="-lsocket" LIB_netlibs_VERSION="" ;; + ARMV5|WINSCW) + LIB_netlibs_DETECT="false" + ;; esac @@ -265,6 +321,7 @@ SYMBOL_readdir_r_EXTRA="#include " SYMBOL_setenv_EXTRA="#include " SYMBOL_strcasecmp_EXTRA="#include " + SYMBOL_strcasecmp_DEFNAME="HAVE_STRCASECMP_UQM" # HAVE_STRCASECMP would conflict with SDL (SDL_config.h). diff --git a/sc2/build/unix/make/buildtools-armv5 b/sc2/build/unix/make/buildtools-armv5 index f49ea574e..0711d89c3 100644 --- a/sc2/build/unix/make/buildtools-armv5 +++ b/sc2/build/unix/make/buildtools-armv5 @@ -8,6 +8,6 @@ define act_mkdep_c endef define act_link - $(LINK) --create "$@".lib $^ $(LDFLAGS) + $(LINK) --create "$@" $^ $(LDFLAGS) endef diff --git a/sc2/src/config.h b/sc2/src/config.h index 1dbbfd598..d943f6262 100644 --- a/sc2/src/config.h +++ b/sc2/src/config.h @@ -7,6 +7,8 @@ * If you want anything else than the defaults, you'll have to edit * that file manually. */ # include "msvc++/config.h" +#elif defined(__SYMBIAN32__) +# include "symbian/config.h" #elif defined (__MINGW32__) || defined (__CYGWIN__) /* If we're compiling on MS Windows using build.sh, use * config_win.h, generated from src/config_win.h.in. */ diff --git a/sc2/src/port.h b/sc2/src/port.h index 1f110b7fd..2d805ae36 100644 --- a/sc2/src/port.h +++ b/sc2/src/port.h @@ -24,6 +24,7 @@ // Compilation related #ifdef _MSC_VER # define inline __inline +#elif defined(__SYMBIAN32__) #else # define inline __inline__ # ifdef __MINGW32__ diff --git a/sc2/src/sc2code/libs/graphics/sdl/rotozoom.c b/sc2/src/sc2code/libs/graphics/sdl/rotozoom.c index 070f011c4..a281fb911 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/rotozoom.c +++ b/sc2/src/sc2code/libs/graphics/sdl/rotozoom.c @@ -19,6 +19,8 @@ #define MAX(a,b) (((a) > (b)) ? (a) : (b)) + + /* 32bit Zoomer with optional anti-aliasing by bilinear interpolation. @@ -54,12 +56,22 @@ int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int smooth) /* * Allocate memory for row increments */ - if ((sax = (int *) alloca((dst->w + 1) * sizeof(Uint32))) == NULL) { - return (-1); - } - if ((say = (int *) alloca((dst->h + 1) * sizeof(Uint32))) == NULL) { - return (-1); - } + +#ifndef __SYMBIAN32__ + if ((sax = (int *) alloca((dst->w + 1) * sizeof(Uint32))) == NULL) + return (-1); + if ((say = (int *) alloca((dst->h + 1) * sizeof(Uint32))) == NULL) + return (-1); +#else + if ((sax = (int *) HMalloc((dst->w + 1) * sizeof(Uint32))) == NULL) + return (-1); + if ((say = (int *) HMalloc((dst->h + 1) * sizeof(Uint32))) == NULL) + { + HFree(sax); + return (-1); + } +#endif + /* * Precalculate row increments @@ -196,6 +208,11 @@ int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int smooth) } +#ifdef __SYMBIAN32__ + HFree(sax); + HFree(say); +#endif + return (0); } @@ -223,12 +240,20 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst) /* * Allocate memory for row increments */ - if ((sax = (Uint32 *) alloca(dst->w * sizeof(Uint32))) == NULL) { - return (-1); - } - if ((say = (Uint32 *) alloca(dst->h * sizeof(Uint32))) == NULL) { - return (-1); - } +#ifndef __SYMBIAN32__ + if ((sax = (Uint32 *) alloca(dst->w * sizeof(Uint32))) == NULL) + return (-1); + if ((say = (Uint32 *) alloca(dst->h * sizeof(Uint32))) == NULL) + return (-1); +#else + if ((sax = (Uint32 *) HMalloc(dst->w * sizeof(Uint32))) == NULL) + return (-1); + if ((say = (Uint32 *) HMalloc(dst->h * sizeof(Uint32))) == NULL) + { + HFree(sax); + return (-1); + } +#endif /* * Precalculate row increments @@ -303,6 +328,11 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst) dp += dgap; } +#ifdef __SYMBIAN32__ + HFree(sax); + HFree(say); +#endif + return (0); } diff --git a/sc2/src/sc2code/libs/sound/decoders/modaud.c b/sc2/src/sc2code/libs/sound/decoders/modaud.c index fa9ceaf90..31ada3901 100644 --- a/sc2/src/sc2code/libs/sound/decoders/modaud.c +++ b/sc2/src/sc2code/libs/sound/decoders/modaud.c @@ -260,7 +260,11 @@ moda_InitModule (int flags, const TFB_DecoderFormats* fmts) else if (flags & audio_QUALITY_LOW) { md_mode = DMODE_SOFT_MUSIC|DMODE_STEREO|DMODE_16BITS; +#ifdef __SYMBIAN32__ + md_mixfreq = 11025; +#else md_mixfreq = 22050; +#endif md_reverb = 0; } else diff --git a/sc2/src/sc2code/libs/sound/mixer/sdl/audiodrv_sdl.c b/sc2/src/sc2code/libs/sound/mixer/sdl/audiodrv_sdl.c index a4ff6ef65..8045552c0 100644 --- a/sc2/src/sc2code/libs/sound/mixer/sdl/audiodrv_sdl.c +++ b/sc2/src/sc2code/libs/sound/mixer/sdl/audiodrv_sdl.c @@ -119,7 +119,7 @@ mixSDL_Init (audio_Driver *driver, sint32 flags) return -1; } log_add (log_Info, "SDL audio subsystem initialized."); - + if (flags & audio_QUALITY_HIGH) { quality = MIX_QUALITY_HIGH; @@ -129,8 +129,13 @@ mixSDL_Init (audio_Driver *driver, sint32 flags) else if (flags & audio_QUALITY_LOW) { quality = MIX_QUALITY_LOW; +#ifdef __SYMBIAN32__ + desired.freq = 11025; + desired.samples = 4096; +#else desired.freq = 22050; desired.samples = 2048; +#endif } else { @@ -208,12 +213,12 @@ mixSDL_Init (audio_Driver *driver, sint32 flags) SetSFXVolume (sfxVolumeScale); SetSpeechVolume (speechVolumeScale); SetMusicVolume ((COUNT)musicVolume); - + StreamDecoderTask = AssignTask (StreamDecoderTaskFunc, 1024, "audio stream decoder"); SDL_PauseAudio (0); - + return 0; } diff --git a/sc2/src/sc2code/planets/plangen.c b/sc2/src/sc2code/planets/plangen.c index 3f84937b9..624e12641 100644 --- a/sc2/src/sc2code/planets/plangen.c +++ b/sc2/src/sc2code/planets/plangen.c @@ -1455,7 +1455,11 @@ TopoScale4x (BYTE *pDstTopo, BYTE *pSrcTopo, int num_faults, int fault_var) }, }; +#ifndef __SYMBIAN32__ prevrow = (int *) alloca ((MAP_WIDTH * 4 + 1) * sizeof(prevrow[0])); +#else + prevrow = (int *) HMalloc ((MAP_WIDTH * 4 + 1) * sizeof(prevrow[0])); +#endif var_allow = (num_faults << SCALE_SHIFT) / AVG_VARIANCE; var_min = fault_var << SCALE_SHIFT; @@ -1592,6 +1596,10 @@ TopoScale4x (BYTE *pDstTopo, BYTE *pSrcTopo, int num_faults, int fault_var) // save last row point prow[0] = elev[4][4]; } + +#ifdef __SYMBIAN32__ + HFree(prevrow); +#endif } diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index 8f78f45cf..a7d52c9cc 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -235,17 +235,17 @@ main (int argc, char *argv[]) } if (res_HasKey ("config.scaler")) { - const char *optarg = res_GetString ("config.scaler"); + const char *arg = res_GetString ("config.scaler"); - if (!strcmp (optarg, "bilinear")) + if (!strcmp (arg, "bilinear")) options.gfxFlags |= TFB_GFXFLAGS_SCALE_BILINEAR; - else if (!strcmp (optarg, "biadapt")) + else if (!strcmp (arg, "biadapt")) options.gfxFlags |= TFB_GFXFLAGS_SCALE_BIADAPT; - else if (!strcmp (optarg, "biadv")) + else if (!strcmp (arg, "biadv")) options.gfxFlags |= TFB_GFXFLAGS_SCALE_BIADAPTADV; - else if (!strcmp (optarg, "triscan")) + else if (!strcmp (arg, "triscan")) options.gfxFlags |= TFB_GFXFLAGS_SCALE_TRISCAN; - else if (!strcmp (optarg, "hq")) + else if (!strcmp (arg, "hq")) options.gfxFlags |= TFB_GFXFLAGS_SCALE_HQXX; } if (res_HasKey ("config.scanlines") && res_GetBoolean ("config.scanlines")) diff --git a/sc2/src/symbian/bld.inf b/sc2/src/symbian/bld.inf new file mode 100644 index 000000000..f9f1ad4e6 --- /dev/null +++ b/sc2/src/symbian/bld.inf @@ -0,0 +1,9 @@ +PRJ_PLATFORMS + + +PRJ_EXPORTS + + +PRJ_MMPFILES +gnumakefile icons_scalable_dc.mk +uqm.mmp diff --git a/sc2/src/symbian/config.h b/sc2/src/symbian/config.h new file mode 100644 index 000000000..328902060 --- /dev/null +++ b/sc2/src/symbian/config.h @@ -0,0 +1,57 @@ +/* This file contains some compile-time configuration options for Symbian + */ + +#ifndef _CONFIG_H +#define _CONFIG_H + +/* Directory where the UQM game data is located */ +#define CONTENTDIR "content" + +/* Directory where game data will be stored */ +#define USERDIR "userdata" + +/* Directory where config files will be stored */ +#define CONFIGDIR USERDIR + +/* Directory where supermelee teams will be stored */ +#define MELEEDIR "userdata\\teams\\" + +/* Directory where save games will be stored */ +#define SAVEDIR "userdata\\save\\" + +/* Define if words are stored with the most significant byte first */ +#undef WORDS_BIGENDIAN + +/* Defined if your system has readdir_r of its own */ +#undef HAVE_READDIR_R + +/* Defined if your system has setenv of its own */ +#define HAVE_SETENV + +/* Defined if your system has strupr of its own */ +#undef HAVE_STRUPR + +/* Defined if your system has strcasecmp of its own */ +#define HAVE_STRCASECMP_UQM + // Not using "HAVE_STRCASECMP" as that conflicts with SDL. + +/* Defined if your system has stricmp of its own */ +#undef HAVE_STRICMP + +/* Defined if your system has getopt_long */ +#undef HAVE_GETOPT_LONG + +/* Defined if your system has iswgraph of its own*/ +#define HAVE_ISWGRAPH + +/* Defined if your system has wchar_t of its own */ +#define HAVE_WCHAR_T + +/* Defined if your system has wint_t of its own */ +#define HAVE_WINT_T + +#define HAVE__BOOL + +#define PATH_MAX _POSIX_PATH_MAX + +#endif /* _CONFIG_H */ diff --git a/sc2/src/symbian/icons_scalable_dc.mk b/sc2/src/symbian/icons_scalable_dc.mk new file mode 100644 index 000000000..99ac5914b --- /dev/null +++ b/sc2/src/symbian/icons_scalable_dc.mk @@ -0,0 +1,37 @@ +ifeq (WINS,$(findstring WINS, $(PLATFORM))) +ZDIR=$(EPOCROOT)epoc32\release\$(PLATFORM)\$(CFG)\Z +else +ZDIR=$(EPOCROOT)epoc32\data\z +endif + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\uqm_icon.mif + +ICONDIR= + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : + mifconv $(ICONTARGETFILENAME) \ + /c32 uqm.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + diff --git a/sc2/src/symbian/uqm.cfg b/sc2/src/symbian/uqm.cfg new file mode 100644 index 000000000..3d0ee902d --- /dev/null +++ b/sc2/src/symbian/uqm.cfg @@ -0,0 +1,26 @@ +config.textmenu = yes +config.alwaysgl = no +config.sfxvol = 20 +config.iconicscan = no +config.pulseshield = no +config.3domusic = no +config.smoothmelee = no +config.positionalsfx = no +config.resheight = 240 +config.musicvol = 20 +config.textgradients = yes +config.reswidth = 320 +config.scaler = no +config.audiodriver = mixsdl +config.fullscreen = no +config.usegl = no +config.player2control = 3 +config.player1control = 0 +config.subtitles = yes +config.3domovies = yes +config.scanlines = no +config.showfps = no +config.speechvol = 0 +config.remixmusic = no +config.smoothscroll = no +config.audioquality = low diff --git a/sc2/src/symbian/uqm.mmp b/sc2/src/symbian/uqm.mmp new file mode 100644 index 000000000..46b49ca93 --- /dev/null +++ b/sc2/src/symbian/uqm.mmp @@ -0,0 +1,43 @@ +TARGET uqm.exe +TARGETTYPE exe +UID 0 0xA000A0C3 +EPOCHEAPSIZE 1000000 50000000 +EPOCSTACKSIZE 0x13500 + +SYSTEMINCLUDE \epoc32\include \epoc32\include\stdapis + +SOURCEPATH . +SOURCE uqmapp.cpp + +START RESOURCE uqm.rss +HEADER +TARGETPATH resource\apps +LANG SC +END // RESOURCE + +START RESOURCE uqm_reg.rss +#ifdef WINSCW +TARGETPATH \private\10003a3f\apps +#else +TARGETPATH \private\10003a3f\import\apps +#endif +END + +OPTION_REPLACE ARMCC --cpu ARM926EJ-S -O3 -Otime +ALWAYS_BUILD_AS_ARM + +LIBRARY avkon.lib +LIBRARY apparc.lib +LIBRARY cone.lib +LIBRARY eikcore.lib +LIBRARY ws32.lib +LIBRARY bafl.lib +LIBRARY euser.lib +LIBRARY sdl.lib +LIBRARY libc.lib +LIBRARY libm.lib +LIBRARY libz.lib +LIBRARY libpthread.lib + +STATICLIBRARY SDL_image.lib +STATICLIBRARY uqm.lib diff --git a/sc2/src/symbian/uqm.pkg b/sc2/src/symbian/uqm.pkg new file mode 100644 index 000000000..cbb90bec8 --- /dev/null +++ b/sc2/src/symbian/uqm.pkg @@ -0,0 +1,26 @@ +;Language - standard language definitions +&EN + +; standard SIS file header +#{"Ur-Quan Masters"},(0xA000A0C3),1,0,0 + +;Localised Vendor name +%{"Interstellar Frungy League"} + +;Unique Vendor name +:"Interstellar Frungy League" + +;Supports Series 60 v 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +*"uqm.key", "uqm.cer" + +;Files to install +; +"\Epoc32\release\Armv5\urel\uqm.exe" - "!:\sys\bin\uqm.exe" +"\Epoc32\data\z\resource\apps\uqm.rsc" - "!:\resource\apps\uqm.rsc" +"\Epoc32\data\z\resource\apps\uqm_icon.mif" - "!:\resource\apps\uqm_icon.mif" +"\Epoc32\data\z\private\10003a3f\import\apps\uqm_reg.rsc" - "!:\private\10003a3f\import\apps\uqm_reg.rsc" +"uqm.cfg" - "c:\private\A000A0C3\userdata\uqm.cfg" +"..\..\content\version" - "c:\private\A000A0C3\content\version" +"..\..\content.uqm" - "c:\private\A000A0C3\content\packages\content.uqm" diff --git a/sc2/src/symbian/uqm.rss b/sc2/src/symbian/uqm.rss new file mode 100644 index 000000000..8f9ea8cab --- /dev/null +++ b/sc2/src/symbian/uqm.rss @@ -0,0 +1,26 @@ +NAME UQM + +#include +#include +#include +#include +#include + +RESOURCE RSS_SIGNATURE { } + +RESOURCE TBUF { buf="UQM"; } + +RESOURCE EIK_APP_INFO + { + } + +RESOURCE LOCALISABLE_APP_INFO r_uqm_localisable_app_info + { + short_caption = "UQM"; + caption_and_icon = CAPTION_AND_ICON_INFO + { + caption = "UrQuanMasters"; + number_of_icons = 1; + icon_file = "\\resource\\apps\\uqm_icon.mif"; + }; + } diff --git a/sc2/src/symbian/uqm.svg b/sc2/src/symbian/uqm.svg new file mode 100644 index 000000000..b95264b6b --- /dev/null +++ b/sc2/src/symbian/uqm.svg @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sc2/src/symbian/uqm_reg.rss b/sc2/src/symbian/uqm_reg.rss new file mode 100644 index 000000000..a57e670f4 --- /dev/null +++ b/sc2/src/symbian/uqm_reg.rss @@ -0,0 +1,12 @@ +#include +#include + +UID2 KUidAppRegistrationResourceFile +UID3 0xA000A0C3 + +RESOURCE APP_REGISTRATION_INFO + { + app_file = "uqm"; + localisable_resource_file = "\\resource\\apps\\uqm"; + localisable_resource_id = R_UQM_LOCALISABLE_APP_INFO; + } diff --git a/sc2/src/symbian/uqmapp.cpp b/sc2/src/symbian/uqmapp.cpp new file mode 100644 index 000000000..d4aa9be4b --- /dev/null +++ b/sc2/src/symbian/uqmapp.cpp @@ -0,0 +1,260 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +const TUid KUidSdlApp={ 0xA000A0C3 }; + + +class CSDLObserver : public CBase, public MSDLObserver +{ +public: + TInt SdlEvent(TInt aEvent, TInt aParam); + TInt SdlThreadEvent(TInt aEvent, TInt aParam); +}; + +class MExitWait + { + public: + virtual void DoExit(TInt aErr) = 0; + }; + +class CExitWait : public CActive + { + public: + CExitWait(MExitWait& aWait); + void Start(); + ~CExitWait(); + private: + void RunL(); + void DoCancel(); + private: + MExitWait& iWait; + TRequestStatus* iStatusPtr; + }; + +class CSDLWin : public CCoeControl + { + public: + void ConstructL(const TRect& aRect); + RWindow& GetWindow() const; + void SetNoDraw(); + private: + void Draw(const TRect& aRect) const; + }; + +class CSdlApplication : public CAknApplication + { +private: + // from CApaApplication + CApaDocument* CreateDocumentL(); + TUid AppDllUid() const; + }; + + +class CSdlAppDocument : public CAknDocument + { +public: + CSdlAppDocument(CEikApplication& aApp): CAknDocument(aApp) { } +private: + CEikAppUi* CreateAppUiL(); + }; + + +class CSdlAppUi : public CAknAppUi, public MExitWait + { +public: + void ConstructL(); + ~CSdlAppUi(); +private: + void HandleCommandL(TInt aCommand); + void DoExit(TInt aErr); + void HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination); + void HandleResourceChangeL(TInt aType); +private: + CExitWait* iWait; + CSDLWin* iSDLWin; + CSDL* iSdl; + CSDLObserver* iSdlObserver; + TBool iExit; + }; + + +CExitWait::CExitWait(MExitWait& aWait) : CActive(CActive::EPriorityStandard), iWait(aWait) + { + CActiveScheduler::Add(this); + } + +CExitWait::~CExitWait() + { + Cancel(); + } + +void CExitWait::RunL() + { + if(iStatusPtr != NULL ) + iWait.DoExit(iStatus.Int()); + } + +void CExitWait::DoCancel() + { + if(iStatusPtr != NULL ) + User::RequestComplete(iStatusPtr , KErrCancel); + } + +void CExitWait::Start() + { + SetActive(); + iStatusPtr = &iStatus; + } + +void CSDLWin:: ConstructL(const TRect& aRect) + { + CreateWindowL(); + SetRect(aRect); + ActivateL(); + } + + +RWindow& CSDLWin::GetWindow() const + { + return Window(); + } + + +void CSDLWin::Draw(const TRect& /*aRect*/) const + { + CWindowGc& gc = SystemGc(); + gc.SetPenStyle(CGraphicsContext::ESolidPen); + gc.SetPenColor(KRgbBlack); + gc.SetBrushStyle(CGraphicsContext::ESolidBrush); + gc.SetBrushColor(0x000000); + gc.DrawRect(Rect()); + } + +void CSdlAppUi::ConstructL() + { + BaseConstructL(ENoScreenFurniture | EAppOrientationLandscape); + + iSDLWin = new (ELeave) CSDLWin; + iSDLWin->ConstructL(ApplicationRect()); + + iWait = new (ELeave) CExitWait(*this); + + iSdl = CSDL::NewL(CSDL::ENoFlags); + iSdlObserver = new (ELeave) CSDLObserver; + + iSdl->SetContainerWindowL( + iSDLWin->GetWindow(), + iEikonEnv->WsSession(), + *iEikonEnv->ScreenDevice()); + + iSdl->SetObserver(iSdlObserver); + + CDesC8ArrayFlat* args = new (ELeave)CDesC8ArrayFlat(10); + iSdl->CallMainL(iWait->iStatus, *args, 75000); + delete args; + + iWait->Start(); + } + +void CSdlAppUi::HandleCommandL(TInt aCommand) + { + switch(aCommand) + { + case EAknCmdExit: + case EAknSoftkeyExit: + case EEikCmdExit: + iExit = ETrue; + if(iWait == NULL || !iWait->IsActive()) + Exit(); + break; + default: + break; + } + } + +void CSdlAppUi::DoExit(TInt aErr) + { + delete iSdl; + iSdl = NULL; + + if(iExit) + Exit(); + } + +void CSdlAppUi::HandleWsEventL(const TWsEvent& aEvent, CCoeControl* aDestination) + { + if(iSdl != NULL) + iSdl->AppendWsEvent(aEvent); + CAknAppUi::HandleWsEventL(aEvent, aDestination); + } + +void CSdlAppUi::HandleResourceChangeL(TInt aType) + { + CAknAppUi::HandleResourceChangeL(aType); + + if(aType == KEikDynamicLayoutVariantSwitch) + { + iSDLWin->SetRect(ApplicationRect()); + if (iSdl) + { + iSdl->SetContainerWindowL( + iSDLWin->GetWindow(), + iEikonEnv->WsSession(), + *iEikonEnv->ScreenDevice()); + } + } + } + +CSdlAppUi::~CSdlAppUi() + { + if(iWait != NULL) + iWait->Cancel(); + delete iSdl; + delete iWait; + delete iSDLWin; + delete iSdlObserver; + } + +CEikAppUi* CSdlAppDocument::CreateAppUiL() + { + return new(ELeave) CSdlAppUi(); + } + +TUid CSdlApplication::AppDllUid() const + { + return KUidSdlApp; + } + + +CApaDocument* CSdlApplication::CreateDocumentL() + { + CSdlAppDocument* document = new (ELeave) CSdlAppDocument(*this); + return document; + } + +LOCAL_C CApaApplication* NewApplication() + { + return new CSdlApplication; + } + +GLDEF_C TInt E32Main() + { + return EikStart::RunApplication(NewApplication); + } + +TInt CSDLObserver::SdlEvent(TInt aEvent, TInt aParam) +{ + return 0; +} + +TInt CSDLObserver::SdlThreadEvent(TInt aEvent, TInt aParam) +{ + return 0; +}