From beec2e7d38f5cd990460437f78cc91971f2a341a Mon Sep 17 00:00:00 2001 From: "p.kosyh" Date: Tue, 11 Jan 2011 18:41:46 +0000 Subject: [PATCH] first s60 build --- bld.inf | 5 + icon/instead-s60.svg | 136 ++++++++++++++++++++++++ icons.mk | 45 ++++++++ instead.mmp | 55 ++++++++++ instead.pkg | 103 ++++++++++++++++++ instead.rss | 56 ++++++++++ instead_reg.rss | 13 +++ src/sdl-instead/externals.h | 2 + src/sdl-instead/game.c | 65 +++++++----- src/sdl-instead/graphics.c | 35 +++++-- src/sdl-instead/graphics.h | 3 + src/sdl-instead/instead.c | 5 +- src/sdl-instead/internals.h | 4 + src/sdl-instead/main.c | 7 +- src/sdl-instead/s60.c | 203 ++++++++++++++++++++++++++++++++++++ src/sdl-instead/s60.h | 11 ++ src/sdl-instead/sound.c | 5 + src/sdl-instead/symbian.cpp | 143 +++++++++++++++++++++++++ src/sdl-instead/unpack.c | 4 + 19 files changed, 861 insertions(+), 39 deletions(-) create mode 100644 bld.inf create mode 100644 icon/instead-s60.svg create mode 100644 icons.mk create mode 100644 instead.mmp create mode 100644 instead.pkg create mode 100644 instead.rss create mode 100644 instead_reg.rss create mode 100644 src/sdl-instead/s60.c create mode 100644 src/sdl-instead/s60.h create mode 100644 src/sdl-instead/symbian.cpp diff --git a/bld.inf b/bld.inf new file mode 100644 index 0000000..0713a2e --- /dev/null +++ b/bld.inf @@ -0,0 +1,5 @@ +PRJ_PLATFORMS +DEFAULT +PRJ_MMPFILES +gnumakefile icons.mk +instead.mmp diff --git a/icon/instead-s60.svg b/icon/instead-s60.svg new file mode 100644 index 0000000..d176174 --- /dev/null +++ b/icon/instead-s60.svg @@ -0,0 +1,136 @@ + + + + + + + + image/svg+xml + + + + + + + + diff --git a/icons.mk b/icons.mk new file mode 100644 index 0000000..e3ee561 --- /dev/null +++ b/icons.mk @@ -0,0 +1,45 @@ +# ============================================================================== +# Name : Icons_scalable_dc.mk +# Part of : Helloworldbasic +# Description : This is file for creating .mif file (scalable icon) +# Version : +# +# Copyright (c) 2002-2006 Nokia Corporation. +# This material, including documentation and any related +# computer programs, is protected by copyright controlled by +# Nokia Corporation. +# ============================================================================== + +ZDIR=$(EPOCROOT)epoc32\data\z + +TARGETDIR=$(ZDIR)\resource\apps +ICONTARGETFILENAME=$(TARGETDIR)\instead.mif + +ICONDIR=.\icon + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : do_nothing + +LIB : do_nothing + +CLEANLIB : do_nothing + +RESOURCE : + mifconv $(ICONTARGETFILENAME) \ + /c32 $(ICONDIR)\instead-s60.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + diff --git a/instead.mmp b/instead.mmp new file mode 100644 index 0000000..ed32c85 --- /dev/null +++ b/instead.mmp @@ -0,0 +1,55 @@ +targettype exe +target instead.exe + +MACRO S60 +MACRO _USE_BROWSE +MACRO _USE_UNPACK +MACRO unix +MACRO _HAVE_ICONV +MACRO _LOCAL_APPDATA +MACRO _SDL_MOD_BUG + +SYSTEMINCLUDE /epoc32/include/libc /epoc32/include/esdl /epoc32/include/mmf/plugin /epoc32/include /epoc32/include/stdapis + +sourcepath ./src/sdl-instead +SOURCE symbian.cpp +SOURCE graphics.c input.c game.c main.c instead.c sound.c SDL_rotozoom.c SDL_anigif.c SDL_gfxBlitFunc.c config.c themes.c menu.c util.c cache.c unzip.c ioapi.c unpack.c s60.c + +USERINCLUDE ./src/sdl-instead + +MACRO S60V3 + +staticlibrary lua.lib sdl_image.lib sdl_ttf.lib SDL_Mixer_ogg.lib libpng.lib libjpeg.lib esdl.lib libiconv.lib libtremor.lib + +LIBRARY cone.lib eikcore.lib +LIBRARY euser.lib apparc.lib fbscli.lib +LIBRARY estlib.lib apgrfx.lib bafl.lib +LIBRARY gdi.lib hal.lib bitgdi.lib +LIBRARY mediaclientaudiostream.lib efsrv.lib ws32.lib +LIBRARY avkon.lib +LIBRARY ezlib.lib +LIBRARY libc.lib +library commondialogs.lib + +ALWAYS_BUILD_AS_ARM + +EPOCSTACKSIZE 81000 +EPOCHEAPSIZE 7192000 32384000 + +UID 0x100039ce 0xA0020410 + +CAPABILITY none + +sourcepath . +START RESOURCE instead.rss +HEADER +TARGETPATH /resource/apps +LANG SC +END + +sourcepath . +START RESOURCE instead_reg.rss +TARGETPATH /private/10003a3f/apps +END + +ALWAYS_BUILD_AS_ARM diff --git a/instead.pkg b/instead.pkg new file mode 100644 index 0000000..a5ce08f --- /dev/null +++ b/instead.pkg @@ -0,0 +1,103 @@ +; This is an auto-generated PKG file by Carbide. +; This file uses variables specific to Carbide builds that will not work +; on command-line builds. If you want to use this generated PKG file from the +; command-line tools you will need to modify the variables with the appropriate +; values: , $(PLATFORM), $(TARGET) +; +;Language - standard language definitions +&EN + +; standard SIS file header +#{"INSTEAD"},(0xA0020410),1,3,1 + +;Localised Vendor name +%{"Peter Kosyh"} + +;Unique Vendor name +:"Peter Kosyh" + +;Supports Series 60 v 3.0 +[0x101F7961], 0, 0, 0, {"Series60ProductID"} + +; +; Display GNU Public Licence +; + + +;Files to install +;You should change the source paths to match that of your environment +; + +"e:\epoc32\release\gcce\urel\instead.exe" -"!:\sys\bin\instead.exe" +"e:\epoc32\data\z\resource\apps\instead.rsc" -"!:\resource\apps\instead.rsc" +"e:\epoc32\data\z\private\10003a3f\apps\instead_reg.rsc" -"!:\private\10003a3f\import\apps\instead_reg.rsc" +"e:\epoc32\data\z\resource\apps\instead.mif" -"!:\resource\apps\instead.mif" +".\symbian_gamedata\appdata\games\tutorial2-en\main.lua" -"!:\data\instead\appdata\games\tutorial2-en\main.lua" +".\symbian_gamedata\appdata\games\tutorial2\instead.png" -"!:\data\instead\appdata\games\tutorial2\instead.png" +".\symbian_gamedata\appdata\games\tutorial2\ramparts.mod" -"!:\data\instead\appdata\games\tutorial2\ramparts.mod" +".\symbian_gamedata\appdata\games\tutorial2\main.lua" -"!:\data\instead\appdata\games\tutorial2\main.lua" +".\symbian_gamedata\stead\vars.lua" -"!:\data\instead\stead\vars.lua" +".\symbian_gamedata\stead\timer.lua" -"!:\data\instead\stead\timer.lua" +".\symbian_gamedata\stead\kbd.lua" -"!:\data\instead\stead\kbd.lua" +".\symbian_gamedata\stead\goto.lua" -"!:\data\instead\stead\goto.lua" +".\symbian_gamedata\stead\object.lua" -"!:\data\instead\stead\object.lua" +".\symbian_gamedata\stead\dash.lua" -"!:\data\instead\stead\dash.lua" +".\symbian_gamedata\stead\snapshots.lua" -"!:\data\instead\stead\snapshots.lua" +".\symbian_gamedata\stead\hideinv.lua" -"!:\data\instead\stead\hideinv.lua" +".\symbian_gamedata\stead\quotes.lua" -"!:\data\instead\stead\quotes.lua" +".\symbian_gamedata\stead\format.lua" -"!:\data\instead\stead\format.lua" +".\symbian_gamedata\stead\click.lua" -"!:\data\instead\stead\click.lua" +".\symbian_gamedata\stead\dbg.lua" -"!:\data\instead\stead\dbg.lua" +".\symbian_gamedata\stead\xact.lua" -"!:\data\instead\stead\xact.lua" +".\symbian_gamedata\stead\hotkeys.lua" -"!:\data\instead\stead\hotkeys.lua" +".\symbian_gamedata\stead\input.lua" -"!:\data\instead\stead\input.lua" +".\symbian_gamedata\stead\gui.lua" -"!:\data\instead\stead\gui.lua" +".\symbian_gamedata\stead\stead.lua" -"!:\data\instead\stead\stead.lua" +".\symbian_gamedata\stead\para.lua" -"!:\data\instead\stead\para.lua" +".\symbian_gamedata\stead\theme.lua" -"!:\data\instead\stead\theme.lua" +".\symbian_gamedata\stead\prefs.lua" -"!:\data\instead\stead\prefs.lua" +".\symbian_gamedata\languages\ru.ini" -"!:\data\instead\languages\ru.ini" +".\symbian_gamedata\languages\en.ini" -"!:\data\instead\languages\en.ini" +".\symbian_gamedata\themes\fantasy\down.png" -"!:\data\instead\themes\fantasy\down.png" +".\symbian_gamedata\themes\fantasy\up.png" -"!:\data\instead\themes\fantasy\up.png" +".\symbian_gamedata\themes\fantasy\menu.png" -"!:\data\instead\themes\fantasy\menu.png" +".\symbian_gamedata\themes\fantasy\bg.jpg" -"!:\data\instead\themes\fantasy\bg.jpg" +".\symbian_gamedata\themes\fantasy\theme.ini" -"!:\data\instead\themes\fantasy\theme.ini" +".\symbian_gamedata\themes\arctic\aup.png" -"!:\data\instead\themes\arctic\aup.png" +".\symbian_gamedata\themes\arctic\menu.png" -"!:\data\instead\themes\arctic\menu.png" +".\symbian_gamedata\themes\arctic\bg.jpg" -"!:\data\instead\themes\arctic\bg.jpg" +".\symbian_gamedata\themes\arctic\theme.ini" -"!:\data\instead\themes\arctic\theme.ini" +".\symbian_gamedata\themes\arctic\cursor.png" -"!:\data\instead\themes\arctic\cursor.png" +".\symbian_gamedata\themes\arctic\cursor-use.png" -"!:\data\instead\themes\arctic\cursor-use.png" +".\symbian_gamedata\themes\arctic\adown.png" -"!:\data\instead\themes\arctic\adown.png" +".\symbian_gamedata\themes\clearlooks\aup.png" -"!:\data\instead\themes\clearlooks\aup.png" +".\symbian_gamedata\themes\clearlooks\menu.png" -"!:\data\instead\themes\clearlooks\menu.png" +".\symbian_gamedata\themes\clearlooks\bg.jpg" -"!:\data\instead\themes\clearlooks\bg.jpg" +".\symbian_gamedata\themes\clearlooks\theme.ini" -"!:\data\instead\themes\clearlooks\theme.ini" +".\symbian_gamedata\themes\clearlooks\cursor.png" -"!:\data\instead\themes\clearlooks\cursor.png" +".\symbian_gamedata\themes\clearlooks\cursor-use.png" -"!:\data\instead\themes\clearlooks\cursor-use.png" +".\symbian_gamedata\themes\clearlooks\adown.png" -"!:\data\instead\themes\clearlooks\adown.png" +".\symbian_gamedata\themes\original\theme.ini" -"!:\data\instead\themes\original\theme.ini" +".\symbian_gamedata\themes\default\click.wav" -"!:\data\instead\themes\default\click.wav" +".\symbian_gamedata\themes\default\aup.png" -"!:\data\instead\themes\default\aup.png" +".\symbian_gamedata\themes\default\menu.png" -"!:\data\instead\themes\default\menu.png" +".\symbian_gamedata\themes\default\use.png" -"!:\data\instead\themes\default\use.png" +".\symbian_gamedata\themes\default\bg.jpg" -"!:\data\instead\themes\default\bg.jpg" +".\symbian_gamedata\themes\default\theme.ini" -"!:\data\instead\themes\default\theme.ini" +".\symbian_gamedata\themes\default\cursor.png" -"!:\data\instead\themes\default\cursor.png" +".\symbian_gamedata\themes\default\click.ogg" -"!:\data\instead\themes\default\click.ogg" +".\symbian_gamedata\themes\default\cursor-use.png" -"!:\data\instead\themes\default\cursor-use.png" +".\symbian_gamedata\themes\default\sans.ttf" -"!:\data\instead\themes\default\sans.ttf" +".\symbian_gamedata\themes\default\adown.png" -"!:\data\instead\themes\default\adown.png" +".\symbian_gamedata\themes\default\aup.gif" -"!:\data\instead\themes\default\aup.gif" +".\symbian_gamedata\themes\book\theme.ini" -"!:\data\instead\themes\book\theme.ini" +".\symbian_gamedata\themes\book\book.jpg" -"!:\data\instead\themes\book\book.jpg" +".\symbian_gamedata\themes\bluesteel\menu.png" -"!:\data\instead\themes\bluesteel\menu.png" +".\symbian_gamedata\themes\bluesteel\downarrow.png" -"!:\data\instead\themes\bluesteel\downarrow.png" +".\symbian_gamedata\themes\bluesteel\bg.jpg" -"!:\data\instead\themes\bluesteel\bg.jpg" +".\symbian_gamedata\themes\bluesteel\theme.ini" -"!:\data\instead\themes\bluesteel\theme.ini" +".\symbian_gamedata\themes\bluesteel\cursor.png" -"!:\data\instead\themes\bluesteel\cursor.png" +".\symbian_gamedata\themes\bluesteel\cursor-use.png" -"!:\data\instead\themes\bluesteel\cursor-use.png" +".\symbian_gamedata\themes\bluesteel\uparrow.png" -"!:\data\instead\themes\bluesteel\uparrow.png" +".\symbian_gamedata\themes\wide\theme.ini" -"!:\data\instead\themes\wide\theme.ini" +".\symbian_gamedata\icon\sdl_instead.png" -"!:\data\instead\icon\sdl_instead.png" diff --git a/instead.rss b/instead.rss new file mode 100644 index 0000000..5bcc85c --- /dev/null +++ b/instead.rss @@ -0,0 +1,56 @@ +NAME INST +#include +#include +#include +#include +#include // Enumerations +#include // Resource structures + +RESOURCE RSS_SIGNATURE + { + } + +RESOURCE TBUF16 { buf=""; } + +RESOURCE EIK_APP_INFO + { + + } + +// This file localise the applications icons and caption +RESOURCE LOCALISABLE_APP_INFO r_appinfo + { + short_caption = "INSTEAD"; + caption_and_icon = + { + CAPTION_AND_ICON_INFO + { + // The caption text is defined in the rls file + caption = "INSTEAD"; + // Icons are used to represent applications in the + // application launcher and application title bar. + // The number_of_icons value identifies how many icons + // that exist in the icon_file. + number_of_icons = 1; + // Using the application icons. + icon_file = "\\resource\\apps\\instead.mif"; + } + }; + } + +RESOURCE FILESELECTIONDIALOG r_file_selection_dialog { + title = "Select-a-file:"; + root_path = "C:\\"; + filters = { + FILTER { + filter_type = EAttributeFilter; + filter_style = EExclusiveFilter; + filter_data = { "SH" }; // Excludes system, hidden and read-only attributes + }, + FILTER { + filter_type = EFilenameFilter; + filter_style = EInclusiveFilter; + filter_data = { "*.lua", "*.zip" }; + } + }; +} diff --git a/instead_reg.rss b/instead_reg.rss new file mode 100644 index 0000000..ae7625f --- /dev/null +++ b/instead_reg.rss @@ -0,0 +1,13 @@ +#include +#include +UID2 KUidAppRegistrationResourceFile +UID3 0xA0020410 // application UID + +RESOURCE APP_REGISTRATION_INFO +{ + app_file = "instead"; // filename of application binary (minus extension) + // Specify the location of the localisable icon/caption definition file + localisable_resource_file = "\\resource\\apps\\instead"; + localisable_resource_id = R_APPINFO; +} + diff --git a/src/sdl-instead/externals.h b/src/sdl-instead/externals.h index d55f5fa..921e09e 100644 --- a/src/sdl-instead/externals.h +++ b/src/sdl-instead/externals.h @@ -22,4 +22,6 @@ #include #include #include +#ifndef S60 #include +#endif diff --git a/src/sdl-instead/game.c b/src/sdl-instead/game.c index 7243d4c..9d0c3d5 100644 --- a/src/sdl-instead/game.c +++ b/src/sdl-instead/game.c @@ -1098,14 +1098,14 @@ void game_menu_box_width(int show, const char *txt, int width) int x, y; int b = game_theme.border_w; int pad = game_theme.pad; - layout_t lay; + layout_t lay = NULL; menu_shown = show; el(el_menu)->drawn = 0; if (el_layout(el_menu)) { - txt_layout_free(el_layout(el_menu)); - el(el_menu)->p.p = NULL; + _txt_layout_free(el_layout(el_menu)); + lay = el_layout(el_menu); } if (menubg) { game_cursor(CURSOR_CLEAR); @@ -1118,40 +1118,35 @@ void game_menu_box_width(int show, const char *txt, int width) if (!show) el_draw(el_menu_button); -// el_update(el_menu_button); - if (!show) { game_cursor(CURSOR_DRAW); gfx_flip(); return; } - - game_menu_box_wh(txt, &w, &h); - - if (width) - w = width; - - lay = txt_layout(game_theme.menu_font, ALIGN_CENTER, w, 0); + if (!lay) { + lay = txt_layout(game_theme.menu_font, ALIGN_CENTER, game_theme.w - 2 * (b + pad), 0); + txt_layout_color(lay, game_theme.menu_fg); + txt_layout_link_color(lay, game_theme.menu_link); + txt_layout_active_color(lay, game_theme.menu_alink); + txt_layout_font_height(lay, game_theme.menu_font_height); + } + else + txt_layout_set_size(lay, game_theme.w - 2 * (b + pad), 0); txt_layout_set(lay, (char*)txt); txt_layout_real_size(lay, &w, &h); if (width) w = width; - txt_layout_color(lay, game_theme.menu_fg); - txt_layout_link_color(lay, game_theme.menu_link); - txt_layout_active_color(lay, game_theme.menu_alink); - txt_layout_font_height(lay, game_theme.menu_font_height); - + txt_layout_set_size(lay, w, h); txt_layout_set(lay, (char*)txt); - txt_layout_real_size(lay, &w, &h); - if (width) - w = width; + if (menu) { gfx_free_image(menu); menu = NULL; } + menu = gfx_new(w + (b + pad)*2, h + (b + pad)*2); gfx_img_fill(menu, 0, 0, w + (b + pad)*2, h + (b + pad)*2, game_theme.border_col); gfx_img_fill(menu, b, b, w + pad*2, h + pad*2, game_theme.menu_bg); @@ -2569,6 +2564,7 @@ int game_from_disk(void) char dir[PATH_MAX]; char base[PATH_MAX]; #ifndef MAEMO +#ifndef S60 if (opt_fs) { int old_menu = (menu_shown) ? cur_menu: -1; opt_fs ^= 1; @@ -2576,6 +2572,7 @@ int game_from_disk(void) if (old_menu != -1) game_menu(old_menu); } +#endif #endif mouse_cursor(1); game_cursor(CURSOR_OFF); @@ -2597,7 +2594,6 @@ int game_from_disk(void) } d = dirname(d); b = basename(b); -/* fprintf(stderr,"%s:%s\n", d, b); */ #ifdef _USE_UNPACK p = games_sw ? games_sw:game_local_games_path(1); fprintf(stderr,"Trying to install: %s\n", g); @@ -2682,7 +2678,11 @@ int game_loop(void) } else if (!is_key(&ev, "f10")) { mouse_reset(1); game_menu(menu_askquit); - } else if (!alt_pressed && (!is_key(&ev, "return") || !is_key(&ev, "enter"))) { + } else if (!alt_pressed && (!is_key(&ev, "return") || !is_key(&ev, "enter") + #ifdef S60 + || !is_key(&ev, ".") + #endif + )) { gfx_cursor(&x, &y, NULL, NULL); game_highlight(-1, -1, 0); /* reset */ @@ -2709,7 +2709,11 @@ int game_loop(void) } #endif #endif - } else if (!is_key(&ev, "escape")) { + } else if (!is_key(&ev, "escape") +#ifdef S60 + || !is_key(&ev, "space") +#endif + ) { if (use_xref) disable_use(); else @@ -2761,6 +2765,7 @@ int game_loop(void) else game_scroll_pdown(); } +#ifndef S60 } else if (!is_key(&ev, "left") || !is_key(&ev, "[4]")) { select_ref(1, 0); } else if (!is_key(&ev, "right") || !is_key(&ev, "[6]")) { @@ -2769,6 +2774,18 @@ int game_loop(void) scroll_pup(el_scene); } else if (!is_key(&ev, "space") && !menu_shown) { scroll_pdown(el_scene); +#else + } else if (!is_key(&ev, "left") || !is_key(&ev, "[4]")) { + if (menu_shown) + select_ref(1, 0); + else + select_frame(1); + } else if (!is_key(&ev, "right") || !is_key(&ev, "[6]")) { + if (menu_shown) + select_ref(0, 0); + else + select_frame(0); +#endif } else if (alt_pressed && (!is_key(&ev, "q") || !is_key(&ev, "f4"))) { break; } else if (alt_pressed && @@ -2804,7 +2821,7 @@ int game_loop(void) motion_y = ev.y; } // game_highlight(ev.x, ev.y, 1); - } + } if (old_xref) game_highlight(x, y, 1); diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c index 2ee7e87..0901006 100644 --- a/src/sdl-instead/graphics.c +++ b/src/sdl-instead/graphics.c @@ -1149,24 +1149,28 @@ int gfx_set_mode(int w, int h, int fs) gfx_width = w; gfx_height = h; SDL_ShowCursor(SDL_DISABLE); -#ifdef ANDROID - screen = SDL_SetVideoMode(gfx_width, gfx_height, 0, SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); +#ifdef S60 + screen = SDL_SetVideoMode(gfx_width, gfx_height, 0, SDL_ANYFORMAT | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); #else -#ifndef MAEMO - #ifdef __APPLE__ + #ifdef ANDROID + screen = SDL_SetVideoMode(gfx_width, gfx_height, 0, SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); + #else + #ifdef MAEMO + screen = SDL_SetVideoMode(gfx_width, gfx_height, 16, SDL_DOUBLEBUF | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); + #else + #ifdef __APPLE__ screen = SDL_SetVideoMode(gfx_width, gfx_height, (fs)?32:0, SDL_SWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); if (screen == NULL) /* ok, fallback to anyformat */ screen = SDL_SetVideoMode(gfx_width, gfx_height, 0, SDL_ANYFORMAT | SDL_SWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); - #else - #ifndef _WIN32_WCE + #else + #ifndef _WIN32_WCE screen = SDL_SetVideoMode(gfx_width, gfx_height, (fs)?32:0, SDL_DOUBLEBUF | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); if (screen == NULL) /* ok, fallback to anyformat */ - #endif + #endif screen = SDL_SetVideoMode(gfx_width, gfx_height, 0, SDL_ANYFORMAT | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); - #endif -#else - screen = SDL_SetVideoMode(gfx_width, gfx_height, 16, SDL_DOUBLEBUF | SDL_HWSURFACE | ( ( fs ) ? SDL_FULLSCREEN : 0 ) ); -#endif + #endif + #endif + #endif #endif if (screen == NULL) { fprintf(stderr, "Unable to set %dx%d video: %s\n", w, h, SDL_GetError()); @@ -1877,6 +1881,15 @@ void txt_layout_size(layout_t lay, int *w, int *h) *h = layout->h; } +void txt_layout_set_size(layout_t lay, int w, int h) +{ + struct layout *layout = (struct layout *)lay; + if (!lay) + return; + layout->w = w; + layout->h = h; +} + int txt_layout_add_img(layout_t lay, const char *name, img_t img) { struct layout *layout = (struct layout *)lay; diff --git a/src/sdl-instead/graphics.h b/src/sdl-instead/graphics.h index 2f426b6..34fe32c 100644 --- a/src/sdl-instead/graphics.h +++ b/src/sdl-instead/graphics.h @@ -100,6 +100,7 @@ extern void txt_layout_add(layout_t lay, char *txt); extern void txt_layout_set(layout_t lay, char *txt); extern void txt_layout_draw(layout_t lay, int x, int y); extern void txt_layout_free(layout_t lay); +extern void _txt_layout_free(layout_t lay); /* do not free lay obj */ extern xref_t txt_layout_xref(layout_t lay, int x, int y); extern void txt_layout_color(layout_t lay, color_t fg); extern fnt_t txt_layout_font(layout_t lay); @@ -136,6 +137,8 @@ typedef void (*clear_fn)(int x, int y, int w, int h); extern void txt_box_update_links(textbox_t tbox, int x, int y, clear_fn); extern void txt_layout_update_links(layout_t layout, int x, int y, clear_fn clear); extern void txt_layout_real_size(layout_t lay, int *w, int *h); +extern void txt_layout_set_size(layout_t lay, int w, int h); /* without text only */ + extern int txt_layout_pos2off(layout_t lay, int pos, int *hh); extern img_t txt_box_render(textbox_t tbox); diff --git a/src/sdl-instead/instead.c b/src/sdl-instead/instead.c index a4cf75d..9dae920 100644 --- a/src/sdl-instead/instead.c +++ b/src/sdl-instead/instead.c @@ -1,9 +1,10 @@ +#include "externals.h" +#include "internals.h" + #ifndef STEAD_PATH #define STEAD_PATH "./stead" #endif -#include "externals.h" -#include "internals.h" /* the Lua interpreter */ static gtimer_t instead_timer = NULL; diff --git a/src/sdl-instead/internals.h b/src/sdl-instead/internals.h index 314d7b3..4e42d8f 100644 --- a/src/sdl-instead/internals.h +++ b/src/sdl-instead/internals.h @@ -1,3 +1,7 @@ +#ifdef S60 +#include "s60.h" +#endif + #include "cache.h" #include "graphics.h" #include "sound.h" diff --git a/src/sdl-instead/main.c b/src/sdl-instead/main.c index b1eb3b9..3640001 100644 --- a/src/sdl-instead/main.c +++ b/src/sdl-instead/main.c @@ -1,6 +1,4 @@ -#ifdef __APPLE__ #include -#endif #include "externals.h" #include "internals.h" @@ -110,8 +108,13 @@ int main(int argc, char *argv[]) putenv("SDL_MOUSE_RELATIVE=0"); /* test this! */ #ifdef _WIN32_WCE wince_init(argv[0]); +#else +#ifdef S60 + extern char s60_data[]; + strcpy(game_cwd, s60_data); #else getcwd(game_cwd, sizeof(game_cwd)); +#endif #endif unix_path(game_cwd); setdir(game_cwd); diff --git a/src/sdl-instead/s60.c b/src/sdl-instead/s60.c new file mode 100644 index 0000000..a1b9147 --- /dev/null +++ b/src/sdl-instead/s60.c @@ -0,0 +1,203 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "sdl_iconv.h" +#include "internals.h" + +#ifndef PATH_MAX +#define PATH_MAX 256 +#endif + +static char save_path[PATH_MAX]; +static char cfg_path[PATH_MAX]; +static char local_games_path[PATH_MAX]; +static char local_themes_path[PATH_MAX]; +static char local_stead_path[PATH_MAX]; + + +void nsleep(int u) +{ + usleep(u); +} + +char *game_locale(void) +{ + char *p; + char *s; + p = getenv("LANG"); + if (!p || !(s = strdup(p))) + return NULL; + if ((p = strchr(s, '_'))) + *p = 0; + return s; +} + +char *game_tmp_path(void) +{ + static char tmp[PATH_MAX]="/tmp/instead-games"; + if (mkdir(tmp, S_IRWXU) && errno != EEXIST) + return NULL; + return tmp; +} + +extern char *BROWSE_MENU; + +extern char *get_file_name(void); + +char *open_file_dialog(void) +{ +#ifdef _USE_BROWSE + char *p; + unix_path((p = get_file_name())); + fprintf(stderr,"Selected file: %s\n", p); + return p; +#else + return NULL; +#endif +} + +char *appdir(void) +{ + static char dir[PATH_MAX]; + strcpy(dir, game_cwd); + strcat(dir, "/appdata"); + return dir; +} + +char *game_local_games_path(int cr) +{ + char *app = appdir(); + if (!app) + return NULL; + strcpy(local_games_path, app); + if (cr) { + if (mkdir(local_games_path, S_IRWXU) && errno != EEXIST) + return NULL; + } + strcat(local_games_path,"/games"); + if (cr) { + if (mkdir(local_games_path, S_IRWXU) && errno != EEXIST) + return NULL; + } + return local_games_path; +} + +char *game_local_themes_path(void) +{ + char *app = appdir(); + if (!app) + return NULL; + snprintf(local_themes_path, sizeof(local_themes_path) - 1 , "%s/themes", app); + return local_themes_path; +} + +char *game_local_stead_path(void) +{ + char *app = appdir(); + if (!app) + return NULL; + snprintf(local_stead_path, sizeof(local_stead_path) - 1 , "%s/stead/", app); + return local_stead_path; +} + +char *game_cfg_path(void) +{ + char *app = appdir(); + if (!app) + return NULL; + snprintf(cfg_path, sizeof(cfg_path) - 1 , "%s/insteadrc", app); + return cfg_path; +} + +char *game_save_path(int cr, int nr) +{ + char *app = appdir(); + if (!curgame_dir) + return NULL; + if (!access("saves", R_OK)) { + if (nr) + snprintf(save_path, sizeof(save_path) - 1, "saves/save%d", nr); + else + snprintf(save_path, sizeof(save_path) - 1, "saves/autosave"); + return save_path; + } + if (!app) + return NULL; + snprintf(save_path, sizeof(save_path) - 1 , "%s/", app); + if (cr && mkdir(save_path, S_IRWXU) && errno != EEXIST) + return NULL; + snprintf(save_path, sizeof(save_path) - 1 , "%s/saves", app); + if (cr && mkdir(save_path, S_IRWXU) && errno != EEXIST) + return NULL; + snprintf(save_path, sizeof(save_path) - 1, "%s/saves/%s/", app, curgame_dir); + if (cr && mkdir(save_path, S_IRWXU) && errno != EEXIST) + return NULL; + if (nr) + snprintf(save_path, sizeof(save_path) - 1, "%s/saves/%s/save%d", app, curgame_dir, nr); + else + snprintf(save_path, sizeof(save_path) - 1, "%s/saves/%s/autosave", app, curgame_dir); + return save_path; +} + +int debug_init(void) +{ + return 0; +} + +void debug_done() +{ + +} + +char *sdl_path(char *p) +{ + unix_path(p); + return p; +} +int setdir(const char *path) +{ + return chdir(path); +} + +char *getdir(char *path, size_t size) +{ + return getcwd(path, size); +} + +char *dirpath(const char *path) +{ + return (char*)path; +} + +char *dirname(char *path) +{ + char *p; + if (path == NULL || *path == '\0') + return "."; + p = path + strlen(path) - 1; + while (*p == '/') { + if (p == path) + return path; + *p-- = '\0'; + } + while (p >= path && *p != '/') + p--; + return p < path ? "." : p == path ? "/" : (*p = '\0', path); +} + +char* basename (char* path) +{ + char *ptr = path; + int l = 0; + while (ptr[(l = strcspn (ptr, "\\//"))]) + ptr += l + 1; + return ptr; +} diff --git a/src/sdl-instead/s60.h b/src/sdl-instead/s60.h new file mode 100644 index 0000000..5a0ecaa --- /dev/null +++ b/src/sdl-instead/s60.h @@ -0,0 +1,11 @@ +#ifndef S60_H +#define S60_H +#define PATH_MAX 256 +#define VERSION "1.3.1" +#define DATAPATH "./" +#define STEAD_PATH DATAPATH"stead/" +#define THEMES_PATH DATAPATH"themes/" +#define GAMES_PATH DATAPATH"games/" +#define ICON_PATH DATAPATH"icon/" +#define LANG_PATH DATAPATH"languages/" +#endif diff --git a/src/sdl-instead/sound.c b/src/sdl-instead/sound.c index 4e5e263..d5b40a9 100644 --- a/src/sdl-instead/sound.c +++ b/src/sdl-instead/sound.c @@ -4,7 +4,12 @@ #include #include +#ifdef S60 +int audio_rate = 11025; +#else int audio_rate = 22050; +#endif + Uint16 audio_format = MIX_DEFAULT_FORMAT; int audio_channels = 2; int audio_buffers = 8192; diff --git a/src/sdl-instead/symbian.cpp b/src/sdl-instead/symbian.cpp new file mode 100644 index 0000000..cf95539 --- /dev/null +++ b/src/sdl-instead/symbian.cpp @@ -0,0 +1,143 @@ +#include // For single function calls +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +FILE* mystdout = NULL; +FILE* mystderr = NULL; +#ifdef _USE_BROWSE +char* desc2str(const TDesC& aDescriptor) +{ + static char fname[256]; + TInt length = aDescriptor.Length(); + HBufC8* buffer = HBufC8::NewLC(length); + buffer->Des().Copy(aDescriptor); + char* str = fname; + Mem::Copy(str, buffer->Ptr(), length); + str[length] = '\0'; + CleanupStack::PopAndDestroy(buffer); + return str; +} +extern "C" { + +char s60_data[] = "E:\\data\\instead"; + +char *get_file_name(void) +{ + TFileName FileName; + if (!AknCommonDialogs::RunSelectDlgLD(FileName, 0)) + return NULL; + return desc2str(FileName); +} +void get_drives(char* drivelist) +{ + RFs& fs = CEikonEnv::Static()->FsSession(); + TPtr8 ptr((unsigned char*) drivelist,26); + TDriveList list; + fs.DriveList(list); + ptr.Copy(list); +} + +} +#endif +#if 1 +int isFolder(const char * filename) +{ + TBool folder = EFalse; + TPtrC8 ptr((unsigned char*) filename); + TFileName fname; + fname.Copy(ptr); + for(TInt loop = 0; loopFsSession(), fname, folder); + return folder; +} +#endif +class CSymbianApp : public CSDLApp { +public: + CSymbianApp(); + ~CSymbianApp(); + void PreInitializeAppL() + { + mystdout = fopen("c:\\data\\instead\\stdout.txt","w"); + mystderr = fopen("c:\\data\\instead\\stderr.txt","w"); + *stdout = *mystdout; + *stderr = *mystderr; + + char drives[26]; + char testpath[] = "C:/data/instead/appdata"; + get_drives(drives); + + for (int drive = 0; drive < 26; drive++) { + if (!drives[drive]) + continue; + testpath[0] = drive + 'A'; + if (isFolder(testpath)) { + s60_data[0] = 'A' + drive; + break; + } + } + } + TUid AppDllUid() const; +}; + +#ifdef EPOC_AS_APP +// this function is called automatically by the SymbianOS to deliver the new CApaApplication object +#if !defined (UIQ3) && !defined (S60V3) +EXPORT_C +#endif +CApaApplication* NewApplication() { + return new CSymbianApp; +} + +#if defined (UIQ3) || defined (S60V3) +#include +// E32Main() contains the program's start up code, the entry point for an EXE. +GLDEF_C TInt E32Main() { + return EikStart::RunApplication(NewApplication); +} +#endif + +#endif // EPOC_AS_APP + +#if !defined (UIQ3) && !defined (S60V3) +GLDEF_C TInt E32Dll(TDllReason) { + return KErrNone; +} +#endif + +CSymbianApp::CSymbianApp() +{ +} + +CSymbianApp::~CSymbianApp() +{ +} + +#if defined (UIQ3) +#include +/** + * Returns the resource id to be used to declare the views supported by this UIQ3 app + * @return TInt, resource id + */ +TInt CSymbianApp::ViewResourceId() { + return R_SDL_VIEW_UI_CONFIGURATIONS; +} +#endif + +/** + * Responsible for returning the unique UID of this application + * @return unique UID for this application in a TUid + **/ +TUid CSymbianApp::AppDllUid() const { + return TUid::Uid(0xA0020410); +} diff --git a/src/sdl-instead/unpack.c b/src/sdl-instead/unpack.c index 0f485fa..8514628 100644 --- a/src/sdl-instead/unpack.c +++ b/src/sdl-instead/unpack.c @@ -32,7 +32,9 @@ #ifdef unix # include +#ifndef S60 # include +#endif #else # include # include @@ -74,6 +76,7 @@ tm_unz tmu_date; CloseHandle(hFile); #else #ifdef unix +#ifndef S60 struct utimbuf ut; struct tm newdate; newdate.tm_sec = tmu_date.tm_sec; @@ -91,6 +94,7 @@ tm_unz tmu_date; utime(filename, &ut); #endif #endif +#endif } /* mymkdir and change_file_date are not 100 % portable