diff --git a/.gitignore b/.gitignore index 69acc1cf6..2669370b6 100644 --- a/.gitignore +++ b/.gitignore @@ -229,3 +229,7 @@ _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm + +# Eclipse +.cproject +.project diff --git a/misc/certs/certs.h b/misc/certs/certs.h index f8cca0205..1a0c106c6 100644 --- a/misc/certs/certs.h +++ b/misc/certs/certs.h @@ -299,13 +299,17 @@ static const unsigned char TA6_EC_Q[] = { 0x8A }; -static const br_x509_trust_anchor TAs[7] = { +static +#ifndef CC_BUILD_SYMBIAN +const +#endif +br_x509_trust_anchor TAs[7] = { { { (unsigned char *)TA0_DN, sizeof TA0_DN }, BR_X509_TA_CA, { BR_KEYTYPE_RSA, - { .rsa = { + { { (unsigned char *)TA0_RSA_N, sizeof TA0_RSA_N, (unsigned char *)TA0_RSA_E, sizeof TA0_RSA_E, } } @@ -316,7 +320,7 @@ static const br_x509_trust_anchor TAs[7] = { BR_X509_TA_CA, { BR_KEYTYPE_RSA, - { .rsa = { + { { (unsigned char *)TA1_RSA_N, sizeof TA1_RSA_N, (unsigned char *)TA1_RSA_E, sizeof TA1_RSA_E, } } @@ -327,7 +331,7 @@ static const br_x509_trust_anchor TAs[7] = { BR_X509_TA_CA, { BR_KEYTYPE_RSA, - { .rsa = { + { { (unsigned char *)TA2_RSA_N, sizeof TA2_RSA_N, (unsigned char *)TA2_RSA_E, sizeof TA2_RSA_E, } } @@ -337,11 +341,17 @@ static const br_x509_trust_anchor TAs[7] = { { (unsigned char *)TA3_DN, sizeof TA3_DN }, BR_X509_TA_CA, { + +#if defined CC_BUILD_SYMBIAN + BR_KEYTYPE_EC + /* set in SSL.c */ +#else BR_KEYTYPE_EC, { .ec = { BR_EC_secp384r1, (unsigned char *)TA3_EC_Q, sizeof TA3_EC_Q, } } +#endif } }, { @@ -349,7 +359,7 @@ static const br_x509_trust_anchor TAs[7] = { BR_X509_TA_CA, { BR_KEYTYPE_RSA, - { .rsa = { + { { (unsigned char *)TA4_RSA_N, sizeof TA4_RSA_N, (unsigned char *)TA4_RSA_E, sizeof TA4_RSA_E, } } @@ -360,7 +370,7 @@ static const br_x509_trust_anchor TAs[7] = { BR_X509_TA_CA, { BR_KEYTYPE_RSA, - { .rsa = { + { { (unsigned char *)TA5_RSA_N, sizeof TA5_RSA_N, (unsigned char *)TA5_RSA_E, sizeof TA5_RSA_E, } } @@ -370,11 +380,16 @@ static const br_x509_trust_anchor TAs[7] = { { (unsigned char *)TA6_DN, sizeof TA6_DN }, BR_X509_TA_CA, { +#if defined CC_BUILD_SYMBIAN + BR_KEYTYPE_EC + /* set in SSL.c */ +#else BR_KEYTYPE_EC, { .ec = { BR_EC_secp384r1, (unsigned char *)TA6_EC_Q, sizeof TA6_EC_Q, } } +#endif } } }; diff --git a/misc/opengl/GLCommon.h b/misc/opengl/GLCommon.h index b894ad021..7de47a0eb 100644 --- a/misc/opengl/GLCommon.h +++ b/misc/opengl/GLCommon.h @@ -6,6 +6,9 @@ #define NOIME #include #define GLAPI WINGDIAPI +#elif defined CC_BUILD_SYMBIAN && !defined __WINSCW__ + #define GLAPI IMPORT_C + #define APIENTRY #else #define GLAPI extern #define APIENTRY diff --git a/misc/symbian/.gitignore b/misc/symbian/.gitignore new file mode 100644 index 000000000..1ff0297fd --- /dev/null +++ b/misc/symbian/.gitignore @@ -0,0 +1,8 @@ +ABLD.BAT +*.sis +!*.mmp +!*.mmh +!*.pkg +!*.rss +!*.svg +!*.txt \ No newline at end of file diff --git a/misc/symbian/ClassiCube.pkg b/misc/symbian/ClassiCube.pkg new file mode 100644 index 000000000..33b3cc473 --- /dev/null +++ b/misc/symbian/ClassiCube.pkg @@ -0,0 +1,30 @@ +&EN + +#{"ClassiCube"},(0xE212A5C2),1,0,0 + +[0x101F7961], 0, 0, 0, {"S60ProductID"} +[0x1028315F], 0, 0, 0, {"S60ProductID"} +[0x20022E6D], 0, 0, 0, {"S60ProductID"} + +%{"ClassiCube"} +:"ClassiCube" + +; Check OpenC versions +IF( version(0x20009a80, <, 1, 5, 0) ) AND NOT (EXISTS("Z:\sys\bin\libc.dll") OR EXISTS("C:\sys\bin\libc.dll")) + "incompatible_openc.txt"-"", FT, FORCEABORT +ENDIF + +IF exists("z:\system\install\Series60v5.2.sis") ; Symbian^3 + "$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\ClassiCube_sym3.exe" - "!:\sys\bin\ClassiCube.exe" +ELSE + IF exists("z:\system\install\Series60v5.0.sis") ; Symbian 9.4 + "$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\ClassiCube_s60v5.exe" - "!:\sys\bin\ClassiCube.exe" + ELSE ; Symbian 9.2-9.3 + "$(EPOCROOT)Epoc32\release\$(PLATFORM)\$(TARGET)\ClassiCube_s60v3.exe" - "!:\sys\bin\ClassiCube.exe" + ENDIF +ENDIF + +"$(EPOCROOT)\epoc32\data\z\private\10003a3f\import\apps\classicube_reg.rsc" - "!:\private\10003a3f\import\apps\classicube_reg.rsc" +"$(EPOCROOT)\epoc32\data\z\resource\apps\classicube.rsc" - "!:\resource\apps\classicube.rsc" +"$(EPOCROOT)\epoc32\data\z\resource\apps\classicube_icon.mif" - "!:\resource\apps\classicube_icon.mif" +;"$(EPOCROOT)\epoc32\winscw\c\private\e212a5c2\texpacks\classicube.zip" - "!:\private\e212a5c2\texpacks\classicube.zip" diff --git a/misc/symbian/ClassiCube_common.mmh b/misc/symbian/ClassiCube_common.mmh new file mode 100644 index 000000000..1a6267d3c --- /dev/null +++ b/misc/symbian/ClassiCube_common.mmh @@ -0,0 +1,58 @@ +TARGETTYPE exe +UID 0x100039CE 0xE212A5C2 + +SYSTEMINCLUDE /epoc32 +SYSTEMINCLUDE /epoc32/include +SYSTEMINCLUDE /epoc32/include/mw +SYSTEMINCLUDE /epoc32/include/app +SYSTEMINCLUDE /epoc32/include/platform +SYSTEMINCLUDE /epoc32/include/platform/mw +SYSTEMINCLUDE /epoc32/include/platform/app +SYSTEMINCLUDE /epoc32/include/gles +SYSTEMINCLUDE /epoc32/include/stdapis +SYSTEMINCLUDE /epoc32/include/stdapis/sys +//SYSTEMINCLUDE /epoc32/include/libc + +USERINCLUDE ../../src +USERINCLUDE ../../src/freetype +USERINCLUDE ../../third_party/bearssl/inc +USERINCLUDE ../../third_party/bearssl/src + +MACRO SYMBIAN_OE_POSIX_SIGNALS + +LIBRARY euser.lib +LIBRARY apgrfx.lib +LIBRARY cone.lib +LIBRARY avkon.lib +LIBRARY fbscli.lib +LIBRARY ws32.lib +LIBRARY hal.lib + +LIBRARY libc.lib +LIBRARY libm.lib +LIBRARY libdl.lib +LIBRARY libpthread.lib + +STATICLIBRARY libcrt0.lib + +OPTION GCCE -O2 -std=c99 + +OPTION ARMCC -Otime --diag_suppress 1296 --diag_suppress 1293 --diag_suppress 66 +OPTION_REPLACE ARMCC --cpu 6 +OPTION_REPLACE ARMCC --fpu softvfp+vfpv2 --fpmode fast + +SOURCEPATH ../../src +SOURCE Animations.c Audio.c AudioBackend.c AxisLinesRenderer.c Bitmap.c Block.c BlockPhysics.c Builder.c Camera.c Chat.c Commands.c Deflate.c Drawer.c Drawer2D.c Entity.c EntityComponents.c EntityRenderers.c EnvRenderer.c Event.c ExtMath.c FancyLighting.c Formats.c Game.c GameVersion.c Generator.c Graphics_GL1.c Graphics_SoftGPU.c Gui.c HeldBlockRenderer.c Http_Web.c Http_Worker.c Input.c InputHandler.c Inventory.c IsometricDrawer.c LBackend.c LScreens.c LWeb.c LWidgets.c Launcher.c Lighting.c Logger.c MapRenderer.c MenuOptions.c Menus.c Model.c Options.c PackedCol.c Particle.c Physics.c Picking.c Platform_Posix.c Protocol.c Queue.c Resources.c SSL.c Screens.c SelOutlineRenderer.c SelectionBox.c Server.c Stream.c String.c SystemFonts.c TexturePack.c TouchUI.c Utils.c Vectors.c Widgets.c World.c _autofit.c _cff.c _ftbase.c _ftbitmap.c _ftglyph.c _ftinit.c _ftsynth.c _psaux.c _pshinter.c _psmodule.c _sfnt.c _smooth.c _truetype.c _type1.c Vorbis.c main.c Platform_Symbian.cpp Graphics_GL2.c Window_Symbian.cpp + +SOURCEPATH ../../third_party/bearssl/src +SOURCE aes_big_cbcdec.c aes_big_cbcenc.c aes_big_ctr.c aes_big_ctrcbc.c aes_big_dec.c aes_big_enc.c aes_common.c aes_ct.c aes_ct64.c aes_ct64_cbcdec.c aes_ct64_cbcenc.c aes_ct64_ctr.c aes_ct64_ctrcbc.c aes_ct64_dec.c aes_ct64_enc.c aes_ct_cbcdec.c aes_ct_cbcenc.c aes_ct_ctr.c aes_ct_ctrcbc.c aes_ct_dec.c aes_ct_enc.c aes_small_cbcdec.c aes_small_cbcenc.c aes_small_ctr.c aes_small_ctrcbc.c aes_small_dec.c aes_small_enc.c aes_x86ni.c aes_x86ni_cbcdec.c aes_x86ni_cbcenc.c aes_x86ni_ctr.c aes_x86ni_ctrcbc.c aesctr_drbg.c asn1enc.c ccm.c ccopy.c chacha20_ct.c chacha20_sse2.c dec16be.c dec16le.c dec32be.c dec32le.c dec64be.c dec64le.c des_ct.c des_ct_cbcdec.c des_ct_cbcenc.c des_support.c des_tab.c des_tab_cbcdec.c des_tab_cbcenc.c dig_oid.c dig_size.c eax.c ec_all_m15.c ec_all_m31.c ec_c25519_i15.c ec_c25519_i31.c ec_c25519_m15.c ec_c25519_m31.c ec_c25519_m62.c ec_c25519_m64.c ec_curve25519.c ec_default.c ec_keygen.c ec_p256_m15.c ec_p256_m31.c ec_p256_m62.c ec_p256_m64.c ec_prime_i15.c ec_prime_i31.c ec_pubkey.c ec_secp256r1.c ec_secp384r1.c ec_secp521r1.c ecdsa_atr.c ecdsa_default_sign_asn1.c ecdsa_default_sign_raw.c ecdsa_default_vrfy_asn1.c ecdsa_default_vrfy_raw.c ecdsa_i15_bits.c ecdsa_i15_sign_asn1.c ecdsa_i15_sign_raw.c ecdsa_i15_vrfy_asn1.c ecdsa_i15_vrfy_raw.c ecdsa_i31_bits.c ecdsa_i31_sign_asn1.c ecdsa_i31_sign_raw.c ecdsa_i31_vrfy_asn1.c ecdsa_i31_vrfy_raw.c ecdsa_rta.c enc16be.c enc16le.c enc32be.c enc32le.c enc64be.c enc64le.c encode_ec_pk8der.c encode_ec_rawder.c encode_rsa_pk8der.c encode_rsa_rawder.c gcm.c ghash_ctmul.c ghash_ctmul32.c ghash_ctmul64.c ghash_pclmul.c hkdf.c hmac.c hmac_ct.c hmac_drbg.c i15_add.c i15_bitlen.c i15_decmod.c i15_decode.c i15_decred.c i15_encode.c i15_fmont.c i15_iszero.c i15_moddiv.c i15_modpow.c i15_modpow2.c i15_montmul.c i15_mulacc.c i15_muladd.c i15_ninv15.c i15_reduce.c i15_rshift.c i15_sub.c i15_tmont.c i31_add.c i31_bitlen.c i31_decmod.c i31_decode.c i31_decred.c i31_encode.c i31_fmont.c i31_iszero.c i31_moddiv.c i31_modpow.c i31_modpow2.c i31_montmul.c i31_mulacc.c i31_muladd.c i31_ninv31.c i31_reduce.c i31_rshift.c i31_sub.c i31_tmont.c i32_add.c i32_bitlen.c i32_decmod.c i32_decode.c i32_decred.c i32_div32.c i32_encode.c i32_fmont.c i32_iszero.c i32_modpow.c i32_montmul.c i32_mulacc.c i32_muladd.c i32_ninv32.c i32_reduce.c i32_sub.c i32_tmont.c i62_modpow2.c md5.c md5sha1.c mgf1.c multihash.c poly1305_ctmul.c poly1305_ctmul32.c poly1305_ctmulq.c poly1305_i15.c prf.c prf_md5sha1.c prf_sha256.c prf_sha384.c rsa_default_keygen.c rsa_default_modulus.c rsa_default_oaep_decrypt.c rsa_default_oaep_encrypt.c rsa_default_pkcs1_sign.c rsa_default_pkcs1_vrfy.c rsa_default_priv.c rsa_default_privexp.c rsa_default_pss_sign.c rsa_default_pss_vrfy.c rsa_default_pub.c rsa_default_pubexp.c rsa_i15_keygen.c rsa_i15_modulus.c rsa_i15_oaep_decrypt.c rsa_i15_oaep_encrypt.c rsa_i15_pkcs1_sign.c rsa_i15_pkcs1_vrfy.c rsa_i15_priv.c rsa_i15_privexp.c rsa_i15_pss_sign.c rsa_i15_pss_vrfy.c rsa_i15_pub.c rsa_i15_pubexp.c rsa_i31_keygen.c rsa_i31_keygen_inner.c rsa_i31_modulus.c rsa_i31_oaep_decrypt.c rsa_i31_oaep_encrypt.c rsa_i31_pkcs1_sign.c rsa_i31_pkcs1_vrfy.c rsa_i31_priv.c rsa_i31_privexp.c rsa_i31_pss_sign.c rsa_i31_pss_vrfy.c rsa_i31_pub.c rsa_i31_pubexp.c rsa_i32_oaep_decrypt.c rsa_i32_oaep_encrypt.c rsa_i32_pkcs1_sign.c rsa_i32_pkcs1_vrfy.c rsa_i32_priv.c rsa_i32_pss_sign.c rsa_i32_pss_vrfy.c rsa_i32_pub.c rsa_i62_keygen.c rsa_i62_oaep_decrypt.c rsa_i62_oaep_encrypt.c rsa_i62_pkcs1_sign.c rsa_i62_pkcs1_vrfy.c rsa_i62_priv.c rsa_i62_pss_sign.c rsa_i62_pss_vrfy.c rsa_i62_pub.c rsa_oaep_pad.c rsa_oaep_unpad.c rsa_pkcs1_sig_pad.c rsa_pkcs1_sig_unpad.c rsa_pss_sig_pad.c rsa_pss_sig_unpad.c rsa_ssl_decrypt.c settings.c sha1.c sha2big.c sha2small.c shake.c skey_decoder.c ssl_ccert_single_ec.c ssl_ccert_single_rsa.c ssl_client.c ssl_client_default_rsapub.c ssl_client_full.c ssl_engine.c ssl_engine_default_aescbc.c ssl_engine_default_aesccm.c ssl_engine_default_aesgcm.c ssl_engine_default_chapol.c ssl_engine_default_descbc.c ssl_engine_default_ec.c ssl_engine_default_ecdsa.c ssl_engine_default_rsavrfy.c ssl_hashes.c ssl_hs_client.c ssl_io.c ssl_keyexport.c ssl_lru.c ssl_rec_cbc.c ssl_rec_ccm.c ssl_rec_chapol.c ssl_rec_gcm.c ssl_scert_single_ec.c ssl_scert_single_rsa.c sysrng.c x509_decoder.c x509_knownkey.c x509_minimal.c x509_minimal_full.c + +CAPABILITY NetworkServices ReadUserData UserEnvironment WriteUserData + +EPOCSTACKSIZE 0x14000 +EPOCHEAPSIZE 0x80000 0x4000000 + +#ifdef _DEBUG +DEBUGGABLE_UDEBONLY +SRCDBG +#endif diff --git a/misc/symbian/ClassiCube_s60v3.mmp b/misc/symbian/ClassiCube_s60v3.mmp new file mode 100644 index 000000000..8f4044405 --- /dev/null +++ b/misc/symbian/ClassiCube_s60v3.mmp @@ -0,0 +1,16 @@ +TARGET ClassiCube_s60v3.exe + +LIBRARY libgles_cm.lib + +SOURCEPATH . +START RESOURCE classicube.rss +HEADER +TARGETPATH \resource\apps +LANG SC +END + +START RESOURCE classicube_reg.rss +TARGETPATH \private\10003a3f\import\apps +END + +#include "ClassiCube_common.mmh" \ No newline at end of file diff --git a/misc/symbian/ClassiCube_s60v5.mmp b/misc/symbian/ClassiCube_s60v5.mmp new file mode 100644 index 000000000..d9a30763e --- /dev/null +++ b/misc/symbian/ClassiCube_s60v5.mmp @@ -0,0 +1,18 @@ +TARGET ClassiCube_s60v5.exe + +MACRO CC_BUILD_SYMBIAN_S60V5 + +LIBRARY libgles_cm.lib + +SOURCEPATH . +START RESOURCE classicube.rss +HEADER +TARGETPATH \resource\apps +LANG SC +END + +START RESOURCE classicube_reg.rss +TARGETPATH \private\10003a3f\import\apps +END + +#include "ClassiCube_common.mmh" \ No newline at end of file diff --git a/misc/symbian/ClassiCube_sym3.mmp b/misc/symbian/ClassiCube_sym3.mmp new file mode 100644 index 000000000..123bd0ef8 --- /dev/null +++ b/misc/symbian/ClassiCube_sym3.mmp @@ -0,0 +1,22 @@ +TARGET ClassiCube_sym3.exe + +MACRO CC_BUILD_SYMBIAN_3 +MACRO CC_BUILD_SYMBIAN_LIBGLESV2 + +ARMFPU vfpv2 + +LIBRARY libglesv2.lib +LIBRARY libegl.lib + +SOURCEPATH . +START RESOURCE classicube.rss +HEADER +TARGETPATH \resource\apps +LANG SC +END + +START RESOURCE classicube_reg.rss +TARGETPATH \private\10003a3f\import\apps +END + +#include "ClassiCube_common.mmh" \ No newline at end of file diff --git a/misc/symbian/Icons_scalable_dc.mk b/misc/symbian/Icons_scalable_dc.mk new file mode 100644 index 000000000..2f9fef6a2 --- /dev/null +++ b/misc/symbian/Icons_scalable_dc.mk @@ -0,0 +1,47 @@ +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)\classicube_icon.mif + +ICONDIR=. + +do_nothing : + @rem do_nothing + +MAKMAKE : do_nothing + +BLD : do_nothing + +CLEAN : + @echo ...Deleting $(ICONTARGETFILENAME) + del /q /f $(ICONTARGETFILENAME) + +LIB : do_nothing + +CLEANLIB : do_nothing + +# ---------------------------------------------------------------------------- +# NOTE: if you have JUSTINTIME enabled for your S60 3rd FP1 or newer SDK +# and this command crashes, consider adding "/X" to the command line. +# See +# ---------------------------------------------------------------------------- + +RESOURCE : $(ICONTARGETFILENAME) + +$(ICONTARGETFILENAME) : $(ICONDIR)\qgn_menu_classicube.svg + mifconv $(ICONTARGETFILENAME) \ + /c32 $(ICONDIR)\qgn_menu_classicube.svg + +FREEZE : do_nothing + +SAVESPACE : do_nothing + +RELEASABLES : + @echo $(ICONTARGETFILENAME) + +FINAL : do_nothing + diff --git a/misc/symbian/bld.inf b/misc/symbian/bld.inf new file mode 100644 index 000000000..b5dd41a10 --- /dev/null +++ b/misc/symbian/bld.inf @@ -0,0 +1,8 @@ +PRJ_PLATFORMS +DEFAULT + +PRJ_MMPFILES +gnumakefile Icons_scalable_dc.mk +ClassiCube_sym3.mmp +ClassiCube_s60v5.mmp +ClassiCube_s60v3.mmp diff --git a/misc/symbian/classicube.rss b/misc/symbian/classicube.rss new file mode 100644 index 000000000..b8315b615 --- /dev/null +++ b/misc/symbian/classicube.rss @@ -0,0 +1,24 @@ +NAME CUBE + +#include +#include +#include +#include +#include + +RESOURCE RSS_SIGNATURE { } +RESOURCE TBUF { buf="ClassiCube"; } + +rls_string STRING_app_caption_string "ClassiCube" +rls_string STRING_app_short_caption_string "ClassiCube" + +RESOURCE LOCALISABLE_APP_INFO r_ClassiCube_localisable_app_info +{ + short_caption = STRING_app_short_caption_string; + caption_and_icon = CAPTION_AND_ICON_INFO + { + caption = STRING_app_caption_string; + number_of_icons = 1; + icon_file = "\\resource\\apps\\classicube_icon.mif"; + }; +} diff --git a/misc/symbian/classicube_reg.rss b/misc/symbian/classicube_reg.rss new file mode 100644 index 000000000..2b9730bf0 --- /dev/null +++ b/misc/symbian/classicube_reg.rss @@ -0,0 +1,17 @@ +#include +#include + +UID2 KUidAppRegistrationResourceFile +UID3 0xE212A5C2 + +RESOURCE APP_REGISTRATION_INFO +{ + app_file="ClassiCube"; + + localisable_resource_file="\\resource\\apps\\classicube"; + localisable_resource_id=R_CLASSICUBE_LOCALISABLE_APP_INFO; + + embeddability=KAppNotEmbeddable; + newfile=KAppDoesNotSupportNewFile; +} + diff --git a/misc/symbian/incompatible_openc.txt b/misc/symbian/incompatible_openc.txt new file mode 100644 index 000000000..29b844d13 --- /dev/null +++ b/misc/symbian/incompatible_openc.txt @@ -0,0 +1 @@ +OpenC version 1.5 or later is required for installation. \ No newline at end of file diff --git a/misc/symbian/qgn_menu_classicube.svg b/misc/symbian/qgn_menu_classicube.svg new file mode 100644 index 000000000..1e1092a38 --- /dev/null +++ b/misc/symbian/qgn_menu_classicube.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/Bitmap.c b/src/Bitmap.c index 36d341264..3d445021e 100644 --- a/src/Bitmap.c +++ b/src/Bitmap.c @@ -667,7 +667,12 @@ static cc_result Png_EncodeCore(struct Bitmap* bmp, struct Stream* stream, cc_ui cc_uint8* curLine = buffer + (bmp->width * 4) * 1; cc_uint8* bestLine = buffer + (bmp->width * 4) * 2; - struct ZLibState zlState; +#if CC_BUILD_MAXSTACK <= (50 * 1024) + struct ZLibState* zlState = (struct ZLibState*)Mem_TryAlloc(1, sizeof(struct ZLibState)); +#else + struct ZLibState _zlState; + struct ZLibState* zlState = &_zlState; +#endif struct Stream chunk, zlStream; cc_uint32 stream_end, stream_beg; int y, lineSize; @@ -700,7 +705,7 @@ static cc_result Png_EncodeCore(struct Bitmap* bmp, struct Stream* stream, cc_ui Stream_SetU32_BE(&tmp[0], PNG_FourCC('I','D','A','T')); if ((res = Stream_Write(&chunk, tmp, 4))) return res; - ZLib_MakeStream(&zlStream, &zlState, &chunk); + ZLib_MakeStream(&zlStream, zlState, &chunk); lineSize = bmp->width * (alpha ? 4 : 3); Mem_Set(prevLine, 0, lineSize); diff --git a/src/Camera.c b/src/Camera.c index 0a8d003eb..30442f324 100644 --- a/src/Camera.c +++ b/src/Camera.c @@ -355,6 +355,7 @@ void Camera_SetFov(int fov) { } void Camera_UpdateProjection(void) { + if (!Camera.Active) return; Camera.Active->GetProjection(&Gfx.Projection); Gfx_LoadMatrix(MATRIX_PROJ, &Gfx.Projection); Event_RaiseVoid(&GfxEvents.ProjectionChanged); @@ -377,6 +378,8 @@ static void OnInit(void) { #ifdef CC_BUILD_WIN Camera.Sensitivity = Options_GetInt(OPT_SENSITIVITY, 1, 200, 40); +#elif defined CC_BUILD_SYMBIAN && defined CC_BUILD_TOUCH + Camera.Sensitivity = Options_GetInt(OPT_SENSITIVITY, 1, 200, 70); #else Camera.Sensitivity = Options_GetInt(OPT_SENSITIVITY, 1, 200, 30); #endif diff --git a/src/Core.h b/src/Core.h index 2a55fd903..9c612f0cb 100644 --- a/src/Core.h +++ b/src/Core.h @@ -201,7 +201,7 @@ typedef cc_uint8 cc_bool; #define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN #define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_D3D11 #define DEFAULT_AUD_BACKEND CC_AUD_BACKEND_OPENAL -#elif defined _WIN32 +#elif defined _WIN32 && !defined __WINSCW__ #define CC_BUILD_WIN #define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN #define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_SCHANNEL @@ -551,6 +551,27 @@ typedef cc_uint8 cc_bool; #define CC_GFX_BACKEND CC_GFX_BACKEND_SOFTGPU #define CC_DISABLE_EXTRA_MODELS #define SOFTGPU_DISABLE_ZBUFFER +#elif defined __SYMBIAN32__ + #define CC_BUILD_SYMBIAN + #define CC_BUILD_MOBILE + #define CC_BUILD_POSIX + #define CC_BUILD_GLES + #define CC_BUILD_EGL + #define CC_BUILD_MAXSTACK (16 * 1024) + #define CC_BUILD_LOWMEM + #define CC_BUILD_NOMUSIC + #define CC_BUILD_NOSOUNDS + #define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN + #define DEFAULT_SSL_BACKEND CC_SSL_BACKEND_BEARSSL +#if defined CC_BUILD_SYMBIAN_LIBGLESV2 +#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL2 +#else +#define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL1 +#endif + +#if defined CC_BUILD_SYMBIAN_3 || defined CC_BUILD_SYMBIAN_S60V5 + #define CC_BUILD_TOUCH +#endif #endif #endif diff --git a/src/Deflate.c b/src/Deflate.c index 2665f9baf..89ef37444 100644 --- a/src/Deflate.c +++ b/src/Deflate.c @@ -1207,7 +1207,7 @@ static cc_result Zip_ReadLocalFileHeader(struct ZipState* state, struct ZipEntry Stream_ReadonlyPortion(&portion, stream, compressedSize); #if CC_BUILD_MAXSTACK <= (64 * 1024) - inflate = Mem_TryAlloc(1, sizeof(struct InflateState)); + inflate = (struct InflateState*)Mem_TryAlloc(1, sizeof(struct InflateState)); if (!inflate) return ERR_OUT_OF_MEMORY; Inflate_MakeStream2(&compStream, inflate, &portion); diff --git a/src/Game.c b/src/Game.c index f0699cfdf..b72e0a186 100644 --- a/src/Game.c +++ b/src/Game.c @@ -809,8 +809,10 @@ static CC_INLINE void Game_RenderFrame(void) { EnvRenderer_UpdateFog(); AudioBackend_Tick(); +#if !defined CC_BUILD_SYMBIAN /* TODO: Not calling Gfx_EndFrame doesn't work with Direct3D9 */ if (Window_Main.Inactive) return; +#endif Gfx_ClearBuffers(GFX_BUFFER_COLOR | GFX_BUFFER_DEPTH); #ifdef CC_BUILD_SPLITSCREEN diff --git a/src/Generator.c b/src/Generator.c index fed6f3e86..88ef2081c 100644 --- a/src/Generator.c +++ b/src/Generator.c @@ -565,10 +565,21 @@ static void NotchyGen_CreateSurfaceLayer(void) { int hIndex = 0, index; BlockRaw above; int x, y, z; - struct OctaveNoise n1, n2; +#if CC_BUILD_MAXSTACK <= (16 * 1024) + struct NoiseBuffer { + struct OctaveNoise n1, n2; + }; + struct NoiseBuffer* buf = TempMem_Alloc(sizeof(struct NoiseBuffer)); + struct OctaveNoise* n1 = &buf->n1; + struct OctaveNoise* n2 = &buf->n2; +#else + struct OctaveNoise _n1, _n2; + struct OctaveNoise* n1 = &_n1; + struct OctaveNoise* n2 = &_n2; +#endif - OctaveNoise_Init(&n1, &rnd, 8); - OctaveNoise_Init(&n2, &rnd, 8); + OctaveNoise_Init(n1, &rnd, 8); + OctaveNoise_Init(n2, &rnd, 8); Gen_CurrentState = "Creating surface"; for (z = 0; z < World.Length; z++) { @@ -582,10 +593,10 @@ static void NotchyGen_CreateSurfaceLayer(void) { above = y >= World.MaxY ? BLOCK_AIR : Gen_Blocks[index + World.OneY]; /* TODO: update heightmap */ - if (above == BLOCK_STILL_WATER && (OctaveNoise_Calc(&n2, (float)x, (float)z) > 12)) { + if (above == BLOCK_STILL_WATER && (OctaveNoise_Calc(n2, (float)x, (float)z) > 12)) { Gen_Blocks[index] = BLOCK_GRAVEL; } else if (above == BLOCK_AIR) { - Gen_Blocks[index] = (y <= waterLevel && (OctaveNoise_Calc(&n1, (float)x, (float)z) > 8)) ? BLOCK_SAND : BLOCK_GRASS; + Gen_Blocks[index] = (y <= waterLevel && (OctaveNoise_Calc(n1, (float)x, (float)z) > 8)) ? BLOCK_SAND : BLOCK_GRASS; } } } diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index a5bc560c7..68ddccf62 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -21,13 +21,21 @@ /* e.g. GLAPI void APIENTRY glFunction(int value); */ #define GL_FUNC(retType, name, args) GLAPI retType APIENTRY name args; #include "../misc/opengl/GL1Funcs.h" +#if defined CC_BUILD_SYMBIAN +#include "../misc/opengl/GL2Funcs.h" +#endif #if defined CC_BUILD_GL11 static GLuint activeList; #define gl_DYNAMICLISTID 1234567891 static void* dynamicListData; static cc_uint16 gl_indices[GFX_MAX_INDICES]; +#define GL_INDICES #else +#if CC_BUILD_MAXSTACK <= (64 * 1024) +static cc_uint16 gl_indices[GFX_MAX_INDICES]; +#define GL_INDICES +#endif /* OpenGL functions use stdcall instead of cdecl on Windows */ static void (APIENTRY *_glBindBuffer)(GLenum target, GfxResourceID buffer); /* NOTE: buffer is actually a GLuint in OpenGL */ static void (APIENTRY *_glDeleteBuffers)(GLsizei n, const GLuint *buffers); @@ -96,14 +104,16 @@ void Gfx_Create(void) { *#########################################################################################################################*/ #ifndef CC_BUILD_GL11 GfxResourceID Gfx_CreateIb2(int count, Gfx_FillIBFunc fillFunc, void* obj) { - cc_uint16 indices[GFX_MAX_INDICES]; +#ifndef GL_INDICES + cc_uint16* gl_indices[GFX_MAX_INDICES]; +#endif GfxResourceID id = NULL; cc_uint32 size = count * sizeof(cc_uint16); _glGenBuffers(1, (GLuint*)&id); - fillFunc(indices, count, obj); + fillFunc(gl_indices, count, obj); _glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, id); - _glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indices, GL_STATIC_DRAW); + _glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, gl_indices, GL_STATIC_DRAW); return id; } @@ -470,6 +480,9 @@ static void Gfx_RestoreState(void) { gfx_format = -1; _glHint(GL_FOG_HINT, GL_NICEST); +#if defined CC_BUILD_SYMBIAN + _glHint(0x0C50 /*GL_PERSPECTIVE_CORRECTION_HINT*/, GL_NICEST); +#endif _glAlphaFunc(GL_GREATER, 0.5f); _glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); _glDepthFunc(GL_LEQUAL); @@ -692,6 +705,22 @@ static void FallbackOpenGL(void) { #endif static void GLBackend_Init(void) { +#if defined CC_BUILD_SYMBIAN + static const cc_string bgra_ext = String_FromConst("EXT_texture_format_BGRA8888"); + static const cc_string bgra_sym = String_FromConst("GL_IMG_texture_format_BGRA8888"); + cc_string extensions = String_FromReadonly((const char*)_glGetString(GL_EXTENSIONS)); + + cc_bool has_ext_bgra = String_CaselessContains(&extensions, &bgra_ext); + cc_bool has_sym_bgra = String_CaselessContains(&extensions, &bgra_sym); + + _glGenBuffers = glGenBuffers; + _glDeleteBuffers = glDeleteBuffers; + _glBindBuffer = glBindBuffer; + _glBufferData = glBufferData; + _glBufferSubData = glBufferSubData; + + convert_rgba = PIXEL_FORMAT != GL_RGBA && !has_ext_bgra && !has_sym_bgra; +#else static const struct DynamicLibSym coreVboFuncs[] = { DynamicLib_ReqSym2("glBindBuffer", glBindBuffer), DynamicLib_ReqSym2("glDeleteBuffers", glDeleteBuffers), DynamicLib_ReqSym2("glGenBuffers", glGenBuffers), DynamicLib_ReqSym2("glBufferData", glBufferData), @@ -721,6 +750,7 @@ static void GLBackend_Init(void) { convert_rgba = major == 1 && minor <= 1 && !String_CaselessContains(&extensions, &bgraExt); FallbackOpenGL(); } +#endif } #endif #endif diff --git a/src/Graphics_GL2.c b/src/Graphics_GL2.c index a9aa8087f..e0ad13053 100644 --- a/src/Graphics_GL2.c +++ b/src/Graphics_GL2.c @@ -35,6 +35,11 @@ static const struct DynamicLibSym core_funcs[] = { #include "../misc/opengl/GL1Macros.h" +#if CC_BUILD_MAXSTACK <= (64 * 1024) +static cc_uint16 gl_indices[GFX_MAX_INDICES]; +#define GL_INDICES +#endif + #include "_GLShared.h" static void GLBackend_Init(void); @@ -68,12 +73,14 @@ static GLuint GL_GenAndBind(GLenum target) { } GfxResourceID Gfx_CreateIb2(int count, Gfx_FillIBFunc fillFunc, void* obj) { - cc_uint16 indices[GFX_MAX_INDICES]; +#ifndef GL_INDICES + cc_uint16 gl_indices[GFX_MAX_INDICES]; +#endif GLuint id = GL_GenAndBind(GL_ELEMENT_ARRAY_BUFFER); cc_uint32 size = count * sizeof(cc_uint16); - fillFunc(indices, count, obj); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, indices, GL_STATIC_DRAW); + fillFunc(gl_indices, count, obj); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, size, gl_indices, GL_STATIC_DRAW); return uint_to_ptr(id); } @@ -533,20 +540,24 @@ static void GLBackend_Init(void) { // don't try and set a value even when it's unsupported #define _GL_MAJOR_VERSION 33307 #define _GL_MINOR_VERSION 33308 - - GLint major = 0, minor = 0; - glGetIntegerv(_GL_MAJOR_VERSION, &major); - glGetIntegerv(_GL_MINOR_VERSION, &minor); - customMipmapsLevels = major >= 3 && minor >= 2; - static const cc_string bgra_ext = String_FromConst("EXT_texture_format_BGRA8888"); + GLint major = 0, minor = 0; + + static const cc_string bgra_ext = String_FromConst("EXT_texture_format_BGRA8888"); static const cc_string bgra_apl = String_FromConst("APPLE_texture_format_BGRA8888"); + static const cc_string bgra_sym = String_FromConst("GL_IMG_texture_format_BGRA8888"); cc_string extensions = String_FromReadonly((const char*)_glGetString(GL_EXTENSIONS)); cc_bool has_ext_bgra = String_CaselessContains(&extensions, &bgra_ext); cc_bool has_apl_bgra = String_CaselessContains(&extensions, &bgra_apl); + cc_bool has_sym_bgra = String_CaselessContains(&extensions, &bgra_sym); + + glGetIntegerv(_GL_MAJOR_VERSION, &major); + glGetIntegerv(_GL_MINOR_VERSION, &minor); + customMipmapsLevels = major >= 3 && minor >= 2; + Platform_Log2("BGRA support - Ext: %t, Apple: %t", &has_ext_bgra, &has_apl_bgra); - convert_rgba = PIXEL_FORMAT != GL_RGBA && !has_ext_bgra && !has_apl_bgra; + convert_rgba = PIXEL_FORMAT != GL_RGBA && !has_ext_bgra && !has_apl_bgra && !has_sym_bgra; #else customMipmapsLevels = true; const GLubyte* ver = glGetString(GL_VERSION); @@ -583,6 +594,9 @@ static void Gfx_FreeState(void) { } static void Gfx_RestoreState(void) { + struct Bitmap bmp; + BitmapCol pixels[1] = { BITMAPCOLOR_WHITE }; + InitDefaultResources(); glEnableVertexAttribArray(0); glEnableVertexAttribArray(1); @@ -594,8 +608,6 @@ static void Gfx_RestoreState(void) { glDepthFunc(GL_LEQUAL); /* 1x1 dummy white texture */ - struct Bitmap bmp; - BitmapCol pixels[1] = { BITMAPCOLOR_WHITE }; Bitmap_Init(bmp, 1, 1, pixels); Gfx_RecreateTexture(&white_square, &bmp, 0, false); } diff --git a/src/Gui.c b/src/Gui.c index ab9f166db..ff37f2724 100644 --- a/src/Gui.c +++ b/src/Gui.c @@ -124,7 +124,11 @@ static void LoadOptions(void) { Gui.ShowFPS = Options_GetBool(OPT_SHOW_FPS, true); Gui.RawInventoryScale = Options_GetFloat(OPT_INVENTORY_SCALE, 0.25f, 5.0f, 1.0f); +#if defined CC_BUILD_SYMBIAN && defined CC_BUILD_TOUCH + Gui.RawHotbarScale = Options_GetFloat(OPT_HOTBAR_SCALE, 0.25f, 5.0f, 2.0f); +#else Gui.RawHotbarScale = Options_GetFloat(OPT_HOTBAR_SCALE, 0.25f, 5.0f, 1.0f); +#endif Gui.RawChatScale = Options_GetFloat(OPT_CHAT_SCALE, 0.25f, 5.0f, 1.0f); Gui.RawCrosshairScale = Options_GetFloat(OPT_CROSSHAIR_SCALE, 0.25f, 5.0f, 1.0f); Gui.RawTouchScale = Options_GetFloat(OPT_TOUCH_SCALE, 0.25f, 5.0f, 1.0f); diff --git a/src/LScreens.c b/src/LScreens.c index 7bcad8594..0ae4aea7f 100644 --- a/src/LScreens.c +++ b/src/LScreens.c @@ -839,7 +839,7 @@ static void MainScreen_ApplyUpdateLabel(struct MainScreen* s) { } } -#ifdef CC_BUILD_CONSOLE +#if defined CC_BUILD_CONSOLE || defined CC_BUILD_SYMBIAN static void MainScreen_ExitApp(void* w) { Window_Main.Exists = false; } @@ -880,7 +880,7 @@ static void MainScreen_Activated(struct LScreen* s_) { LButton_Add(s, &s->btnOptions, 100, 35, "Options", SwitchToSettings, main_btnOptions); -#ifdef CC_BUILD_CONSOLE +#if defined CC_BUILD_CONSOLE || defined CC_BUILD_SYMBIAN LLabel_Add(s, &s->lblUpdate, "&eChecking..", main_lblUpdate_N); LButton_Add(s, &s->btnUpdates, 100, 35, "Exit", MainScreen_ExitApp, main_btnUpdates); diff --git a/src/Logger.c b/src/Logger.c index 7ac6b03a2..a5344f8c0 100644 --- a/src/Logger.c +++ b/src/Logger.c @@ -27,7 +27,7 @@ static HANDLE curProcess = CUR_PROCESS_HANDLE; static cc_uintptr spRegister; -#elif defined CC_BUILD_OPENBSD || defined CC_BUILD_HAIKU || defined CC_BUILD_SERENITY +#elif defined CC_BUILD_OPENBSD || defined CC_BUILD_HAIKU || defined CC_BUILD_SERENITY || defined CC_BUILD_SYMBIAN #include /* These operating systems don't provide sys/ucontext.h */ /* But register constants be found from includes in */ @@ -276,7 +276,7 @@ static void DumpFrame(cc_string* trace, void* addr) { cc_uintptr addr_ = (cc_uintptr)addr; String_Format1(trace, "%x", &addr_); } -#elif defined CC_BUILD_POSIX && !defined CC_BUILD_OS2 +#elif defined CC_BUILD_POSIX && !defined CC_BUILD_OS2 && !defined CC_BUILD_SYMBIAN /* need to define __USE_GNU for dladdr */ #ifndef __USE_GNU #define __USE_GNU @@ -446,6 +446,11 @@ void Logger_Backtrace(cc_string* trace, void* ctx) { } String_AppendConst(trace, _NL); } +#elif defined CC_BUILD_SYMBIAN +void Logger_Backtrace(cc_string* trace, void* ctx) { + String_AppendConst(trace, "-- backtrace unimplemented --"); + /* There is no dladdr on Symbian */ +} #elif defined CC_BUILD_POSIX /* musl etc - rely on unwind from GCC instead */ #define CC_BACKTRACE_UNWIND diff --git a/src/Menus.c b/src/Menus.c index edf9e42f1..b867470d0 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -1391,7 +1391,7 @@ static cc_result SaveLevelScreen_SaveMap(const cc_string* path) { struct GZipState* state; cc_result res; - state = Mem_TryAlloc(1, sizeof(struct GZipState)); + state = (struct GZipState*)Mem_TryAlloc(1, sizeof(struct GZipState)); res = ERR_OUT_OF_MEMORY; if (!state) { Logger_SysWarn(res, "allocating temp memory"); return res; } diff --git a/src/Model.c b/src/Model.c index 3c8a2532d..66e69fd68 100644 --- a/src/Model.c +++ b/src/Model.c @@ -200,7 +200,7 @@ void Model_LockVB(struct Entity* entity, int verticesCount) { #endif real_vertices = Models.Vertices; - Models.Vertices = Gfx_LockDynamicVb(modelVB, VERTEX_FORMAT_TEXTURED, verticesCount); + Models.Vertices = (struct VertexTextured*)Gfx_LockDynamicVb(modelVB, VERTEX_FORMAT_TEXTURED, verticesCount); } void Model_UnlockVB(void) { @@ -530,7 +530,7 @@ struct CustomModel* CustomModel_Get(int id) { /* TODO log message if allocation fails? */ if (!custom_models) - custom_models = Mem_TryAlloc(MAX_CUSTOM_MODELS, sizeof(struct CustomModel)); + custom_models = (struct CustomModel*)Mem_TryAlloc(MAX_CUSTOM_MODELS, sizeof(struct CustomModel)); if (!custom_models) return NULL; return &custom_models[id]; diff --git a/src/Platform_Posix.c b/src/Platform_Posix.c index c87f62d21..549da8071 100644 --- a/src/Platform_Posix.c +++ b/src/Platform_Posix.c @@ -14,11 +14,26 @@ #include #include #include -#include #include #include #include #include +#include +#include +#include +#if defined CC_BUILD_SYMBIAN +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#else +#include #include #include #include @@ -26,10 +41,8 @@ #include #include #include -#include -#include -#include #include +#endif const cc_result ReturnCode_FileShareViolation = 1000000000; /* TODO: not used apparently */ const cc_result ReturnCode_FileNotFound = ENOENT; @@ -87,10 +100,13 @@ cc_bool Platform_ReadonlyFilesystem; /*########################################################################################################################* *---------------------------------------------------------Memory----------------------------------------------------------* *#########################################################################################################################*/ -void* Mem_Set(void* dst, cc_uint8 value, unsigned numBytes) { return memset( dst, value, numBytes); } -void* Mem_Copy(void* dst, const void* src, unsigned numBytes) { return memcpy( dst, src, numBytes); } -void* Mem_Move(void* dst, const void* src, unsigned numBytes) { return memmove(dst, src, numBytes); } +void* Mem_Set(void* dst, cc_uint8 value, unsigned numBytes) { return (void*) memset( dst, value, numBytes); } +void* Mem_Copy(void* dst, const void* src, unsigned numBytes) { return (void*) memcpy( dst, src, numBytes); } +void* Mem_Move(void* dst, const void* src, unsigned numBytes) { return (void*) memmove(dst, src, numBytes); } +#if defined CC_BUILD_SYMBIAN +/* implemented in Platform_Symbian.cpp */ +#else void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) { cc_uint32 size = CalcMemSize(numElems, elemsSize); return size ? malloc(size) : NULL; @@ -108,6 +124,7 @@ void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) { void Mem_Free(void* mem) { if (mem) free(mem); } +#endif /*########################################################################################################################* @@ -135,8 +152,11 @@ TimeMS DateTime_CurrentUTC(void) { void DateTime_CurrentLocal(struct cc_datetime* t) { struct timeval cur; struct tm loc_time; + time_t s; + gettimeofday(&cur, NULL); - localtime_r(&cur.tv_sec, &loc_time); + s = cur.tv_sec; + localtime_r(&s, &loc_time); t->year = loc_time.tm_year + 1900; t->month = loc_time.tm_mon + 1; @@ -154,6 +174,8 @@ void DateTime_CurrentLocal(struct cc_datetime* t) { #if defined CC_BUILD_HAIKU || defined CC_BUILD_BEOS /* Implemented in interop_BeOS.cpp */ +#elif defined CC_BUILD_SYMBIAN +/* Implemented in Platform_Symbian.cpp */ #elif defined CC_BUILD_DARWIN static cc_uint64 sw_freqMul, sw_freqDiv; static void Stopwatch_Init(void) { @@ -251,6 +273,9 @@ static void SignalHandler(int sig, siginfo_t* info, void* ctx) { Logger_DoAbort(0, msg.buffer, ctx); } +#if defined CC_BUILD_SYMBIAN +/* implemented in Platform_Symbian.cpp */ +#else void CrashHandler_Install(void) { struct sigaction sa = { 0 }; /* sigemptyset(&sa.sa_mask); */ @@ -264,6 +289,7 @@ void CrashHandler_Install(void) { sigaction(SIGABRT, &sa, NULL); sigaction(SIGFPE, &sa, NULL); } +#endif void Process_Abort2(cc_result result, const char* raw_msg) { Logger_DoAbort(result, raw_msg, NULL); @@ -326,7 +352,7 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall len = String_Length(src); String_AppendUtf8(&path, src, len); -#if defined CC_BUILD_HAIKU || defined CC_BUILD_SOLARIS || defined CC_BUILD_HPUX || defined CC_BUILD_IRIX || defined CC_BUILD_BEOS +#if defined CC_BUILD_HAIKU || defined CC_BUILD_SOLARIS || defined CC_BUILD_HPUX || defined CC_BUILD_IRIX || defined CC_BUILD_BEOS || defined CC_BUILD_SYMBIAN { char full_path[NATIVE_STR_LEN]; struct stat sb; @@ -435,6 +461,11 @@ void Thread_Run(void** handle, Thread_StartFunc func, int stackSize, const char* *handle = ptr; pthread_attr_init(&attrs); +#if defined CC_BUILD_SYMBIAN + if (stackSize >= 64 * 1024) { + stackSize = 64 * 1024; + } +#endif pthread_attr_setstacksize(&attrs, stackSize); res = pthread_create(ptr, &attrs, ExecThread, (void*)func); @@ -631,6 +662,11 @@ void Platform_LoadSysFonts(void) { String_FromConst("/@unixroot/usr/share/fonts"), String_FromConst("/@unixroot/usr/local/share/fonts") }; +#elif defined CC_BUILD_SYMBIAN + static const cc_string dirs[] = { + String_FromConst("Z:\\resource\\fonts"), + String_FromConst("C:\\resource\\fonts") + }; #else static const cc_string dirs[] = { String_FromConst("/usr/share/fonts"), @@ -649,7 +685,7 @@ void Platform_LoadSysFonts(void) { /*########################################################################################################################* *---------------------------------------------------------Socket----------------------------------------------------------* *#########################################################################################################################*/ -#if defined CC_BUILD_OS2 +#if defined CC_BUILD_OS2 || defined CC_BUILD_SYMBIAN #undef AF_INET6 #endif @@ -766,7 +802,16 @@ cc_result Socket_Create(cc_socket* s, cc_sockaddr* addr, cc_bool nonblocking) { if (nonblocking) { int blocking_raw = -1; /* non-blocking mode */ - ioctl(*s, FIONBIO, &blocking_raw); +#if defined CC_BUILD_SYMBIAN + int res = fcntl(*s, F_GETFL, 0); + if (res < 0) return errno; + + res = fcntl(*s, F_SETFL, res | O_NONBLOCK); + if (res < 0) return errno; +#else + int err = ioctl(*s, FIONBIO, &blocking_raw); + if (err == -1) return errno; +#endif } return 0; } @@ -795,7 +840,7 @@ void Socket_Close(cc_socket s) { close(s); } -#if defined CC_BUILD_DARWIN || defined CC_BUILD_BEOS +#if defined CC_BUILD_DARWIN || defined CC_BUILD_BEOS || defined CC_BUILD_SYMBIAN /* poll is broken on old OSX apparently https://daniel.haxx.se/docs/poll-vs-select.html */ /* BeOS lacks support for poll */ static cc_result Socket_Poll(cc_socket s, int mode, cc_bool* success) { @@ -908,6 +953,8 @@ void Process_Exit(cc_result code) { exit(code); } /* Implemented in Platform_Android.c */ #elif defined CC_BUILD_IOS /* implemented in interop_ios.m */ +#elif defined CC_BUILD_SYMBIAN +/* implemented in Window_Symbian.cpp */ #elif defined CC_BUILD_MACOS cc_result Process_StartOpen(const cc_string* args) { UInt8 str[NATIVE_STR_LEN]; @@ -1123,6 +1170,7 @@ cc_bool Updater_Supported = true; /* implemented in Platform_Android.c */ #elif defined CC_BUILD_IOS /* implemented in interop_ios.m */ +#elif defined CC_BUILD_SYMBIAN #else cc_bool Updater_Clean(void) { return true; } @@ -1292,6 +1340,8 @@ cc_bool DynamicLib_DescribeError(cc_string* dst) { #ifdef CC_BUILD_DARWIN const cc_string DynamicLib_Ext = String_FromConst(".dylib"); +#elif defined CC_BUILD_SYMBIAN +const cc_string DynamicLib_Ext = String_FromConst(".dll"); #else const cc_string DynamicLib_Ext = String_FromConst(".so"); #endif @@ -1334,7 +1384,7 @@ static void Platform_InitPosix(void) { } void Platform_Free(void) { } -#if defined CC_BUILD_IRIX || defined CC_BUILD_HPUX +#if defined CC_BUILD_IRIX || defined CC_BUILD_HPUX || defined CC_BUILD_SYMBIAN cc_bool Platform_DescribeError(cc_result res, cc_string* dst) { const char* err = strerror(res); if (!err || res >= 1000) return false; @@ -1387,12 +1437,20 @@ void Platform_Init(void) { Platform_InitPosix(); Platform_InitSpecific(); } +#elif defined CC_BUILD_SYMBIAN + +extern void Symbian_Stopwatch_Init(void); +void Platform_Init(void) { + Platform_SingleProcess = true; + Symbian_Stopwatch_Init(); + Platform_InitPosix(); +} #else void Platform_Init(void) { #ifdef CC_BUILD_MOBILE Platform_SingleProcess = true; #endif - + Platform_InitPosix(); } #endif @@ -1542,11 +1600,28 @@ static cc_result GetMachineID(cc_uint32* key) { DecodeMachineID(strBuffer, str.length, key); return 0; } +#elif defined CC_BUILD_SYMBIAN + +extern cc_result Symbian_GetMachineID(cc_uint32* key); + +static cc_result GetMachineID(cc_uint32* key) { + return Symbian_GetMachineID(key); +} #else static cc_result GetMachineID(cc_uint32* key) { return ERR_NOT_SUPPORTED; } #endif cc_result Platform_GetEntropy(void* data, int len) { +#if defined CC_BUILD_SYMBIAN + cc_uint32 rnd = 0, i; + for (i = 0; i < len; ++i) { + if (i % 4 == 0) + rnd = rand(); + ((cc_uint8*) data)[i] = rnd; + rnd >>= 8; + } + return 0; +#else int ret; int fd = open("/dev/urandom", O_RDONLY); if (fd < 0) return ERR_NOT_SUPPORTED; @@ -1555,6 +1630,7 @@ cc_result Platform_GetEntropy(void* data, int len) { ret = read(fd, data, len); close(fd); return ret == -1 ? errno : 0; +#endif } diff --git a/src/Platform_Symbian.cpp b/src/Platform_Symbian.cpp new file mode 100644 index 000000000..f9aeffd5c --- /dev/null +++ b/src/Platform_Symbian.cpp @@ -0,0 +1,126 @@ +#include "Core.h" +#if defined CC_BUILD_SYMBIAN +extern "C" { +#include "Errors.h" +#include "Platform.h" +#include "Logger.h" +#include "String.h" +#include +#include +} +#include +#include + +TInt tickPeriod; + +const struct UpdaterInfo Updater_Info = { + "&eRedownload and reinstall to update", 0, NULL +}; + +cc_bool Updater_Clean(void) { return true; } +cc_result Updater_Start(const char** action) { + return ERR_NOT_SUPPORTED; +} + +cc_result Updater_GetBuildTime(cc_uint64* timestamp) { + return ERR_NOT_SUPPORTED; +} + +cc_result Updater_MarkExecutable(void) { + return ERR_NOT_SUPPORTED; +} + +cc_result Updater_SetNewBuildTime(cc_uint64 timestamp) { + return ERR_NOT_SUPPORTED; +} + +cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) { + // Directory is already set by platform: !:/private/e212a5c2 + return 0; +} + +void Platform_ShareScreenshot(const cc_string* filename) { + +} + +static CC_NOINLINE cc_uint32 CalcMemSize(cc_uint32 numElems, cc_uint32 elemsSize) { + cc_uint32 numBytes; + if (!numElems || !elemsSize) return 1; /* treat 0 size as 1 byte */ + + numBytes = numElems * elemsSize; + if (numBytes / elemsSize != numElems) return 0; /* Overflow */ + return numBytes; +} + +void* Mem_TryAlloc(cc_uint32 numElems, cc_uint32 elemsSize) { + cc_uint32 size = CalcMemSize(numElems, elemsSize); + return size ? User::Alloc(size) : NULL; +} + +void* Mem_TryAllocCleared(cc_uint32 numElems, cc_uint32 elemsSize) { + cc_uint32 size = CalcMemSize(numElems, elemsSize); + return size ? User::AllocZ(size) : NULL; +} + +void* Mem_TryRealloc(void* mem, cc_uint32 numElems, cc_uint32 elemsSize) { + cc_uint32 size = CalcMemSize(numElems, elemsSize); + return size ? User::ReAlloc(mem, size) : NULL; +} + +void Mem_Free(void* mem) { + if (mem) User::Free(mem); +} + +static void ExceptionHandler(TExcType type) { + cc_string msg; char msgB[64]; + String_InitArray(msg, msgB); + String_AppendConst(&msg, "Exception: "); + String_AppendInt(&msg, (int) type); + msg.buffer[msg.length] = '\0'; + + Logger_DoAbort(0, msg.buffer, 0); + + User::HandleException((TUint32*) &type); +} + +void CrashHandler_Install(void) { +#if !defined _DEBUG + User::SetExceptionHandler(ExceptionHandler, 0xffffffff); +#endif +} + +extern "C" void Symbian_Stopwatch_Init(void); + +void Symbian_Stopwatch_Init(void) { + if (HAL::Get(HAL::ENanoTickPeriod, tickPeriod) != KErrNone) { + User::Panic(_L("Could not init timer"), 0); + } +} + +cc_uint64 Stopwatch_Measure(void) { + return (cc_uint64)User::NTickCount(); +} + +cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) { + if (end < beg) return 0; + return (end - beg) * tickPeriod; +} + +#define MACHINE_KEY "Symbian_Symbian_" + +extern "C" cc_result Symbian_GetMachineID(cc_uint32* key); + +cc_result Symbian_GetMachineID(cc_uint32* key) { + TInt res; + Mem_Copy(key, MACHINE_KEY, sizeof(MACHINE_KEY) - 1); + + if (HAL::Get(HAL::ESerialNumber, res) == KErrNone) { + key[0] = res; + } + if (HAL::Get(HAL::EMachineUid, res) == KErrNone) { + key[1] = res; + } + return 0; +} + +#endif diff --git a/src/Resources.c b/src/Resources.c index 210e4c0d1..119e3f8e2 100644 --- a/src/Resources.c +++ b/src/Resources.c @@ -62,16 +62,26 @@ static cc_result ZipEntry_ExtractData(struct ResourceZipEntry* e, struct Stream* *------------------------------------------------------Utility functions -------------------------------------------------* *#########################################################################################################################*/ static void ZipFile_InspectEntries(const cc_string* path, Zip_SelectEntry selector) { - struct ZipEntry entries[64]; struct Stream stream; cc_result res; +#if CC_BUILD_MAXSTACK <= (16 * 1024) + struct ZipEntry* entries = (struct ZipEntry*)Mem_TryAllocCleared(64, sizeof(struct ZipEntry)); + if (!entries) { Logger_SysWarn2(ERR_OUT_OF_MEMORY, "allocating", path); return; } +#else + struct ZipEntry entries[64]; +#endif res = Stream_OpenFile(&stream, path); if (res == ReturnCode_FileNotFound) return; if (res) { Logger_SysWarn2(res, "opening", path); return; } +#if CC_BUILD_MAXSTACK <= (16 * 1024) + res = Zip_Extract(&stream, selector, NULL, + entries, 64); +#else res = Zip_Extract(&stream, selector, NULL, entries, Array_Elems(entries)); +#endif if (res) Logger_SysWarn2(res, "inspecting", path); /* No point logging error for closing readonly file */ @@ -80,7 +90,7 @@ static void ZipFile_InspectEntries(const cc_string* path, Zip_SelectEntry select static cc_result ZipEntry_ExtractData(struct ResourceZipEntry* e, struct Stream* data, struct ZipEntry* source) { cc_uint32 size = source->UncompressedSize; - e->value.data = Mem_TryAlloc(size, 1); + e->value.data = (cc_uint8*)Mem_TryAlloc(size, 1); e->size = size; if (!e->value.data) return ERR_OUT_OF_MEMORY; @@ -737,13 +747,22 @@ static cc_result CCTextures_ProcessEntry(const cc_string* path, struct Stream* d } static cc_result CCTextures_ExtractZip(struct HttpRequest* req) { - struct ZipEntry entries[64]; struct Stream src; cc_result res; +#if CC_BUILD_MAXSTACK <= (16 * 1024) + struct ZipEntry* entries = (struct ZipEntry*)Mem_TryAllocCleared(64, sizeof(struct ZipEntry)); + if (!entries) return ERR_OUT_OF_MEMORY; +#else + struct ZipEntry entries[64]; +#endif Stream_ReadonlyMemory(&src, req->data, req->size); if ((res = Zip_Extract(&src, CCTextures_SelectEntry, CCTextures_ProcessEntry, +#if CC_BUILD_MAXSTACK <= (16 * 1024) + entries, 64))) return res; +#else entries, Array_Elems(entries)))) return res; +#endif return Stream_WriteAllTo(&ccTexPack, req->data, req->size); } @@ -909,13 +928,27 @@ static cc_result ClassicPatcher_ProcessEntry(const cc_string* path, struct Strea } static cc_result ClassicPatcher_ExtractFiles(struct HttpRequest* req) { - struct ZipEntry entries[64]; struct Stream src; + cc_result res; +#if CC_BUILD_MAXSTACK <= (16 * 1024) + struct ZipEntry* entries = (struct ZipEntry*)Mem_TryAllocCleared(64, sizeof(struct ZipEntry)); + if (!entries) return ERR_OUT_OF_MEMORY; +#else + struct ZipEntry entries[64]; +#endif Stream_ReadonlyMemory(&src, req->data, req->size); - + +#if CC_BUILD_MAXSTACK <= (16 * 1024) + res = Zip_Extract(&src, + ClassicPatcher_SelectEntry, ClassicPatcher_ProcessEntry, + entries, 16); + Mem_Free(entries); + return res; +#else return Zip_Extract(&src, ClassicPatcher_SelectEntry, ClassicPatcher_ProcessEntry, entries, Array_Elems(entries)); +#endif } static void PatchTerrainTile(struct Bitmap* src, int srcX, int srcY, int tileX, int tileY) { @@ -1022,13 +1055,22 @@ static cc_result ModernPatcher_ProcessEntry(const cc_string* path, struct Stream } static cc_result ModernPatcher_ExtractFiles(struct HttpRequest* req) { - struct ZipEntry entries[64]; struct Stream src; +#if CC_BUILD_MAXSTACK <= (16 * 1024) + struct ZipEntry* entries = (struct ZipEntry*)Mem_TryAllocCleared(64, sizeof(struct ZipEntry)); + if (!entries) return ERR_OUT_OF_MEMORY; +#else + struct ZipEntry entries[64]; +#endif Stream_ReadonlyMemory(&src, req->data, req->size); return Zip_Extract(&src, ModernPatcher_SelectEntry, ModernPatcher_ProcessEntry, +#if CC_BUILD_MAXSTACK <= (16 * 1024) + entries, 64); +#else entries, Array_Elems(entries)); +#endif } diff --git a/src/SSL.c b/src/SSL.c index 37bd5dc0f..e0fbfd9bc 100644 --- a/src/SSL.c +++ b/src/SSL.c @@ -494,10 +494,22 @@ cc_result SSL_Init(cc_socket socket, const cc_string* host_, void** out_ctx) { char host[NATIVE_STR_LEN]; String_EncodeUtf8(host, host_); - ctx = Mem_TryAlloc(1, sizeof(SSLContext)); + ctx = (SSLContext*)Mem_TryAlloc(1, sizeof(SSLContext)); if (!ctx) return ERR_OUT_OF_MEMORY; *out_ctx = (void*)ctx; +#if defined CC_BUILD_SYMBIAN + { + TAs[3].pkey.key.ec.curve = BR_EC_secp384r1; + TAs[3].pkey.key.ec.q = (unsigned char *)TA3_EC_Q; + TAs[3].pkey.key.ec.qlen = sizeof TA3_EC_Q; + + TAs[6].pkey.key.ec.curve = BR_EC_secp384r1; + TAs[6].pkey.key.ec.q = (unsigned char *)TA6_EC_Q; + TAs[6].pkey.key.ec.qlen = sizeof TA6_EC_Q; + } +#endif + br_ssl_client_init_full(&ctx->sc, &ctx->xc, TAs, TAs_NUM); InjectEntropy(ctx); SetCurrentTime(ctx); @@ -557,10 +569,12 @@ cc_result SSL_WriteAll(void* ctx_, const cc_uint8* data, cc_uint32 count) { int res = br_sslio_write_all(&ctx->ioc, data, count); if (res < 0) { - if (ctx->writeError) return ctx->writeError; - - int err = br_ssl_engine_last_error(&ctx->sc.eng); - return SSL_ERROR_SHIFT | (err & 0xFFFF); + if (ctx->writeError) { + return ctx->writeError; + } else { + int err = br_ssl_engine_last_error(&ctx->sc.eng); + return SSL_ERROR_SHIFT | (err & 0xFFFF); + } } br_sslio_flush(&ctx->ioc); diff --git a/src/SystemFonts.c b/src/SystemFonts.c index 180f86106..1c2f3bbf3 100644 --- a/src/SystemFonts.c +++ b/src/SystemFonts.c @@ -536,6 +536,16 @@ static cc_string font_candidates[] = { String_FromConst("Roboto"), /* Android (broken on some Android 10 devices) */ String_FromConst("Geneva"), /* for ancient macOS versions */ String_FromConst("Droid Sans"), /* for old Android versions */ +#if defined CC_BUILD_SYMBIAN + String_FromConst("Nokia Sans TitleSmBd S60"), + String_FromConst("Nokia Sans S60"), + String_FromConst("Nokia Hindi S60"), + String_FromConst("Series 60 Sans TitleSmBd"), + String_FromConst("Series 60 Sans"), + String_FromConst("Series 60 Hindi"), + String_FromConst("Series 60 Korean"), + String_FromConst("Heisei Kaku Gothic S60"), +#endif String_FromConst("Google Sans") /* Droid Sans is now known as Google Sans on some Android devices (e.g. a Pixel 6) */ }; diff --git a/src/TexturePack.c b/src/TexturePack.c index 7ec4ea40c..a3cfea56b 100644 --- a/src/TexturePack.c +++ b/src/TexturePack.c @@ -529,25 +529,46 @@ static cc_result ExtractPng(struct Stream* stream) { static cc_bool needReload; static cc_result ExtractFrom(struct Stream* stream, const cc_string* path) { +#if CC_BUILD_MAXSTACK <= (32 * 1024) + struct ZipEntry* entries = (struct ZipEntry*)Mem_TryAllocCleared(512, sizeof(struct ZipEntry)); +#else struct ZipEntry entries[512]; +#endif cc_result res; +#if CC_BUILD_MAXSTACK <= (32 * 1024) + if (!entries) return ERR_OUT_OF_MEMORY; +#endif Event_RaiseVoid(&TextureEvents.PackChanged); /* If context is lost, then trying to load textures will just fail */ /* So defer loading the texture pack until context is restored */ - if (Gfx.LostContext) { needReload = true; return 0; } + if (Gfx.LostContext) { + needReload = true; + res = 0; + goto ret; + } needReload = false; res = ExtractPng(stream); if (res == PNG_ERR_INVALID_SIG) { /* file isn't a .png image, probably a .zip archive then */ + +#if CC_BUILD_MAXSTACK <= (32 * 1024) + res = Zip_Extract(stream, SelectZipEntry, ProcessZipEntry, + entries, 512); +#else res = Zip_Extract(stream, SelectZipEntry, ProcessZipEntry, entries, Array_Elems(entries)); +#endif if (res) Logger_SysWarn2(res, "extracting", path); } else if (res) { Logger_SysWarn2(res, "decoding", path); } + ret: +#if CC_BUILD_MAXSTACK <= (32 * 1024) + Mem_Free(entries); +#endif return res; } diff --git a/src/VirtualKeyboard.h b/src/VirtualKeyboard.h index b59ca754f..58607d397 100644 --- a/src/VirtualKeyboard.h +++ b/src/VirtualKeyboard.h @@ -277,9 +277,9 @@ static cc_bool VirtualKeyboard_OnInputDown(int key, struct InputDevice* device) if (deltaX || deltaY) { VirtualKeyboard_Scroll(deltaX, deltaY); - } else if (key == CCPAD_START || key == CCPAD_1) { + } else if (key == CCPAD_START || key == CCPAD_1 || key == CCKEY_ENTER) { VirtualKeyboard_ClickSelected(); - } else if (key == CCPAD_SELECT || key == CCPAD_2) { + } else if (key == CCPAD_SELECT || key == CCPAD_2 || key == CCKEY_ESCAPE) { VirtualKeyboard_Close(); } else if (key == CCPAD_3) { VirtualKeyboard_Backspace(); @@ -431,6 +431,7 @@ static void VirtualKeyboard_Hook(void) { /* the virtual keyboard in the first place gets mistakenly processed */ kb_needsHook = false; Event_Register_(&ControllerEvents.AxisUpdate, NULL, VirtualKeyboard_PadAxis); + PointerHooks.DownHook = VirtualKeyboard_PointerMove; PointerHooks.MoveHook = VirtualKeyboard_PointerMove; PointerHooks.UpHook = VirtualKeyboard_PointerUp; } @@ -478,6 +479,7 @@ static void VirtualKeyboard_Close(void) { VirtualKeyboard_Close3D(); Event_Unregister_(&ControllerEvents.AxisUpdate, NULL, VirtualKeyboard_PadAxis); + PointerHooks.DownHook = NULL; PointerHooks.MoveHook = NULL; PointerHooks.UpHook = NULL; Window_Main.SoftKeyboardFocus = false; diff --git a/src/Widgets.c b/src/Widgets.c index 63629681b..2580df3a5 100644 --- a/src/Widgets.c +++ b/src/Widgets.c @@ -684,9 +684,11 @@ void HotbarWidget_Create(struct HotbarWidget* w) { w->verticesCount = 0; #ifdef CC_BUILD_TOUCH - int i; - for (i = 0; i < INVENTORY_BLOCKS_PER_HOTBAR - 1; i++) { - w->touchId[i] = -1; + { + int i; + for (i = 0; i < INVENTORY_BLOCKS_PER_HOTBAR - 1; i++) { + w->touchId[i] = -1; + } } #endif } diff --git a/src/Window_Symbian.cpp b/src/Window_Symbian.cpp new file mode 100644 index 000000000..ff824c80b --- /dev/null +++ b/src/Window_Symbian.cpp @@ -0,0 +1,746 @@ +#include "Core.h" +#if defined CC_BUILD_SYMBIAN + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +extern "C" { +#include +#include +#include "_WindowBase.h" +#include "Errors.h" +#include "Logger.h" +#include "String.h" +#include "Gui.h" +#include "Graphics.h" +#include "Game.h" +#include "VirtualKeyboard.h" +} + +static cc_bool launcherMode; + +class CWindow; + +CWindow* window; + +class CWindow : public CBase +{ +public: + static CWindow* NewL(); + void HandleWsEvent(const TWsEvent& aEvent); + void AllocFrameBuffer(int width, int height); + void DrawFramebuffer(Rect2D r, struct Bitmap* bmp); + void FreeFrameBuffer(); + void ProcessEvents(float delta); + void RequestClose(); + void InitEvents(); + cc_result OpenBrowser(const cc_string* url); + ~CWindow(); + + TWsEvent iWsEvent; + TRequestStatus iWsEventStatus; + RWindow* iWindow; + +private: + CWindow(); + void ConstructL(); + void CreateWindowL(); + + RWsSession iWsSession; + RWindowGroup iWindowGroup; + CWsScreenDevice* iWsScreenDevice; + CWindowGc* iWindowGc; + CFbsBitmap* iBitmap; + CApaWindowGroupName* iWindowGroupName; + + TBool iEventsInitialized; +}; + +// + +CWindow* CWindow::NewL() { + CWindow* self = new (ELeave) CWindow(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; +} + +void CWindow::CreateWindowL() { + TPixelsTwipsAndRotation pixnrot; + iWsScreenDevice->GetScreenModeSizeAndRotation(iWsScreenDevice->CurrentScreenMode(), pixnrot); + + iWindow->SetExtent(TPoint(0, 0), pixnrot.iPixelSize); + iWindow->SetRequiredDisplayMode(iWsScreenDevice->DisplayMode()); +#ifdef CC_BUILD_SYMBIAN_3 + iWindow->EnableAdvancedPointers(); +#endif + iWindow->Activate(); + iWindow->SetVisible(ETrue); + iWindow->SetNonFading(ETrue); + iWindow->SetShadowDisabled(ETrue); + iWindow->EnableRedrawStore(EFalse); + iWindow->EnableVisibilityChangeEvents(); + iWindow->SetNonTransparent(); + iWindow->SetBackgroundColor(); + iWindow->SetOrdinalPosition(0); + // Enable drag events + iWindow->PointerFilter(EPointerFilterDrag, 0); + + WindowInfo.Focused = true; + WindowInfo.Exists = true; + WindowInfo.Handle.ptr = (void*) iWindow; +#ifdef CC_BUILD_TOUCH + WindowInfo.SoftKeyboard = SOFT_KEYBOARD_VIRTUAL; +#endif + + TInt w = pixnrot.iPixelSize.iWidth, + h = pixnrot.iPixelSize.iHeight; + + DisplayInfo.Width = w; + DisplayInfo.Height = h; + + WindowInfo.Width = w; + WindowInfo.Height = h; + + WindowInfo.UIScaleX = DEFAULT_UI_SCALE_X; + WindowInfo.UIScaleY = DEFAULT_UI_SCALE_Y; + if (w <= 360) { + DisplayInfo.ScaleX = 0.5f; + DisplayInfo.ScaleY = 0.5f; + } else { + DisplayInfo.ScaleX = 1; + DisplayInfo.ScaleY = 1; + } +} + +CWindow::CWindow() { + +} + +CWindow::~CWindow() { + if (iWindowGc) { + delete iWindowGc; + iWindowGc = NULL; + } + if (iWindow) { + iWindow->SetOrdinalPosition(KOrdinalPositionSwitchToOwningWindow); + iWindow->Close(); + delete iWindow; + iWindow = NULL; + } + if (iWsScreenDevice) { + delete iWsScreenDevice; + iWsScreenDevice = NULL; + } +} + +void CWindow::ConstructL() { + delete CActiveScheduler::Current(); + CActiveScheduler* actScheduler = new (ELeave) CActiveScheduler(); + CActiveScheduler::Install(actScheduler); + + CCoeEnv* env = CCoeEnv::Static(); + if (!env) { + User::Panic(_L("CoeEnv::Static not initialized"), 0); + } + + iWsSession = env->WsSession(); + iWsScreenDevice = new (ELeave) CWsScreenDevice(iWsSession); + User::LeaveIfError(iWsScreenDevice->Construct()); + + iWindowGroup = RWindowGroup(iWsSession); + User::LeaveIfError(iWindowGroup.Construct(reinterpret_cast(this) - 1)); + iWindowGroup.SetOrdinalPosition(0); + iWindowGroup.EnableScreenChangeEvents(); +#ifdef CC_BUILD_TOUCH + iWindowGroup.EnableReceiptOfFocus(EFalse); +#else + iWindowGroup.EnableReceiptOfFocus(ETrue); +#endif + + iWindowGroupName = CApaWindowGroupName::NewL(iWsSession, iWindowGroup.Identifier()); + iWindowGroupName->SetAppUid(TUid::Uid(0xE212A5C2)); + iWindowGroupName->SetCaptionL(_L("ClassiCube")); + iWindowGroupName->SetHidden(EFalse); + iWindowGroupName->SetSystem(EFalse); + iWindowGroupName->SetRespondsToShutdownEvent(ETrue); + iWindowGroupName->SetWindowGroupName(iWindowGroup); + + iWindow = new (ELeave) RWindow(iWsSession); + + TInt err = iWindow->Construct(iWindowGroup, reinterpret_cast(this)); + User::LeaveIfError(err); + + TRAP(err, CreateWindowL()); + if (err) { + User::Panic(_L("Window creation failed"), err); + } + + RWindowGroup rootWin = CCoeEnv::Static()->RootWin(); + CApaWindowGroupName* rootWindGroupName = 0; + TRAP_IGNORE(rootWindGroupName = CApaWindowGroupName::NewL(iWsSession, rootWin.Identifier())); + if (rootWindGroupName) { + rootWindGroupName->SetHidden(ETrue); + rootWindGroupName->SetWindowGroupName(rootWin); + } + + TDisplayMode displayMode = iWindow->DisplayMode(); + TInt bufferSize = 0; + + switch (displayMode) { + case EColor4K: + bufferSize = 12; + break; + case EColor64K: + bufferSize = 16; + break; + case EColor16M: + bufferSize = 24; + break; + case EColor16MU: + case EColor16MA: + bufferSize = 32; + break; + default: + break; + } + + DisplayInfo.Depth = bufferSize; + + iWsSession.EventReadyCancel(); +} + +static int ConvertKey(TInt aScanCode) { + // TODO array? + switch (aScanCode) { + case EStdKeyBackspace: + return CCKEY_BACKSPACE; + case EStdKeyTab: + return CCKEY_TAB; + case EStdKeyEnter: + return CCKEY_ENTER; + case EStdKeyEscape: + return CCKEY_ESCAPE; + case EStdKeySpace: + return CCKEY_SPACE; + case EStdKeyPrintScreen: + return CCKEY_PRINTSCREEN; + case EStdKeyPause: + return CCKEY_PAUSE; + case EStdKeyHome: + return CCKEY_HOME; + case EStdKeyEnd: + return CCKEY_END; + case EStdKeyPageUp: + return CCKEY_PAGEUP; + case EStdKeyPageDown: + return CCKEY_PAGEDOWN; + case EStdKeyInsert: + return CCKEY_INSERT; + case EStdKeyDelete: + return CCKEY_DELETE; + case EStdKeyLeftArrow: + return CCKEY_LEFT; + case EStdKeyRightArrow: + return CCKEY_RIGHT; + case EStdKeyUpArrow: + return CCKEY_UP; + case EStdKeyDownArrow: + return CCKEY_DOWN; + case EStdKeyLeftShift: + return CCKEY_LSHIFT; + case EStdKeyRightShift: + return CCKEY_RSHIFT; + case EStdKeyLeftAlt: + return CCKEY_LALT; + case EStdKeyRightAlt: + return CCKEY_RALT; + case EStdKeyLeftCtrl: + return CCKEY_LCTRL; + case EStdKeyRightCtrl: + return CCKEY_RCTRL; + case EStdKeyLeftFunc: + return CCKEY_LWIN; + case EStdKeyRightFunc: + return CCKEY_RWIN; + case EStdKeyNumLock: + return CCKEY_NUMLOCK; + case EStdKeyScrollLock: + return CCKEY_SCROLLLOCK; + + case 0x30: + return CCKEY_0; + case 0x31: + return CCKEY_1; + case 0x32: + return CCKEY_2; + case 0x33: + return CCKEY_3; + case 0x34: + return CCKEY_4; + case 0x35: + return CCKEY_5; + case 0x36: + return CCKEY_6; + case 0x37: + return CCKEY_7; + case 0x38: + return CCKEY_8; + case 0x39: + return CCKEY_9; + + case EStdKeyComma: + return CCKEY_COMMA; + case EStdKeyFullStop: + return CCKEY_PERIOD; + case EStdKeyForwardSlash: + return CCKEY_SLASH; + case EStdKeyBackSlash: + return CCKEY_BACKSLASH; + case EStdKeySemiColon: + return CCKEY_SEMICOLON; + case EStdKeySingleQuote: + return CCKEY_QUOTE; + case EStdKeyHash: + return '#'; + case EStdKeySquareBracketLeft: + return CCKEY_LBRACKET; + case EStdKeySquareBracketRight: + return CCKEY_RBRACKET; + case EStdKeyMinus: + return CCKEY_MINUS; + case EStdKeyEquals: + return CCKEY_EQUALS; + + case EStdKeyNkpForwardSlash: + return CCKEY_KP_DIVIDE; + case EStdKeyNkpAsterisk: + return CCKEY_KP_MULTIPLY; + case EStdKeyNkpMinus: + return CCKEY_KP_MINUS; + case EStdKeyNkpPlus: + return CCKEY_KP_PLUS; + case EStdKeyNkpEnter: + return CCKEY_KP_ENTER; + case EStdKeyNkp1: + return CCKEY_KP1; + case EStdKeyNkp2: + return CCKEY_KP2; + case EStdKeyNkp3: + return CCKEY_KP3; + case EStdKeyNkp4: + return CCKEY_KP4; + case EStdKeyNkp5: + return CCKEY_KP5; + case EStdKeyNkp6: + return CCKEY_KP6; + case EStdKeyNkp7: + return CCKEY_KP7; + case EStdKeyNkp8: + return CCKEY_KP8; + case EStdKeyNkp9: + return CCKEY_KP9; + case EStdKeyNkp0: + return CCKEY_KP0; + case EStdKeyNkpFullStop: + return CCKEY_KP_DECIMAL; + + case EStdKeyIncVolume: + return CCKEY_VOLUME_UP; + case EStdKeyDecVolume: + return CCKEY_VOLUME_DOWN; + +// softkeys + case EStdKeyDevice0: // left soft + return CCKEY_F1; + case EStdKeyDevice1: // right soft + return CCKEY_ESCAPE; + case EStdKeyDevice3: // d-pad center + return CCKEY_ENTER; + } + + return aScanCode; +} + +void CWindow::HandleWsEvent(const TWsEvent& aWsEvent) { + TInt eventType = aWsEvent.Type(); + switch (eventType) { + case EEventKeyDown: { + Input_Set(ConvertKey(aWsEvent.Key()->iScanCode), true); + break; + } + case EEventKeyUp: { + Input_Set(ConvertKey(aWsEvent.Key()->iScanCode), false); + break; + } + case EEventScreenDeviceChanged: + //case 27: /* EEventDisplayChanged */ + { + TPixelsTwipsAndRotation pixnrot; + iWsScreenDevice->GetScreenModeSizeAndRotation(iWsScreenDevice->CurrentScreenMode(), pixnrot); + if (pixnrot.iPixelSize != iWindow->Size()) { + iWindow->SetExtent(TPoint(0, 0), pixnrot.iPixelSize); + + TInt w = pixnrot.iPixelSize.iWidth, + h = pixnrot.iPixelSize.iHeight; + + DisplayInfo.Width = w; + DisplayInfo.Height = h; + + WindowInfo.Width = w; + WindowInfo.Height = h; + + Event_RaiseVoid(&WindowEvents.Resized); + } + Event_RaiseVoid(&WindowEvents.RedrawNeeded); + break; + } + case EEventFocusLost: { +#if 0 // TODO + if (!WindowInfo.Focused) break; + WindowInfo.Focused = false; + + Event_RaiseVoid(&WindowEvents.FocusChanged); +#endif + break; + } + case EEventFocusGained: { + if (!WindowInfo.Focused) { + WindowInfo.Focused = true; + + Event_RaiseVoid(&WindowEvents.FocusChanged); + } + Event_RaiseVoid(&WindowEvents.RedrawNeeded); + break; + } + // shutdown request from task manager + case KAknShutOrHideApp: { + RequestClose(); + break; + } + // shutdown request from system (out of memory) + case EEventUser: { + TApaSystemEvent apaSystemEvent = *(TApaSystemEvent*) aWsEvent.EventData(); + if (apaSystemEvent == EApaSystemEventShutdown) { + RequestClose(); + } + break; + } + case EEventWindowVisibilityChanged: { + if (aWsEvent.Handle() == reinterpret_cast(this)) { + WindowInfo.Inactive = (aWsEvent.VisibilityChanged()->iFlags & TWsVisibilityChangedEvent::EFullyVisible) == 0; + Event_RaiseVoid(&WindowEvents.InactiveChanged); + } + break; + } +#ifdef CC_BUILD_TOUCH + case EEventPointer: { +#ifdef CC_BUILD_SYMBIAN_3 + TAdvancedPointerEvent* pointer = aWsEvent.Pointer(); + long num = pointer->IsAdvancedPointerEvent() ? pointer->PointerNumber() : 0; +#else + TPointerEvent* pointer = aWsEvent.Pointer(); + long num = 0; +#endif + TPoint pos = pointer->iPosition; + switch (pointer->iType) { + case TPointerEvent::EButton1Down: + Input_AddTouch(num, pos.iX, pos.iY); + break; + case TPointerEvent::EDrag: + Input_AddTouch(num, pos.iX, pos.iY); + break; + case TPointerEvent::EButton1Up: + Input_RemoveTouch(num, pos.iX, pos.iY); + break; + default: + break; + } + break; + } +#endif + } +} + +void CWindow::AllocFrameBuffer(int width, int height) { + FreeFrameBuffer(); + if (!iWindowGc) { + iWindowGc = new (ELeave) CWindowGc(iWsScreenDevice); + iWindowGc->Construct(); + } + iBitmap = new CFbsBitmap(); + iBitmap->Create(TSize(width, height), EColor16MA); +} + +void CWindow::FreeFrameBuffer() { + if (iWindowGc != NULL) { + delete iWindowGc; + iWindowGc = NULL; + } + if (iBitmap != NULL) { + delete iBitmap; + iBitmap = NULL; + } +} + +void CWindow::DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { + if (!iWindowGc) return; + iWindow->Invalidate(/*TRect(r.x, r.y, r.width, r.height)*/); + iWindow->BeginRedraw(); + iWindowGc->Activate(*iWindow); + + if (iBitmap) { +// iBitmap->BeginDataAccess(); + iBitmap->LockHeap(); + TUint8* data = (TUint8*) iBitmap->DataAddress(); + const TUint8* src = (TUint8*) bmp->scan0; + for (TInt row = bmp->height - 1; row >= 0; --row) { + memcpy(data, src, bmp->width * BITMAPCOLOR_SIZE); + src += bmp->width * BITMAPCOLOR_SIZE; + data += iBitmap->DataStride(); + } +// iBitmap->EndDataAccess(); + iBitmap->UnlockHeap(); + + iWindowGc->BitBlt(TPoint(0, 0), iBitmap/*, TRect(r.x, r.y, r.width, r.height)*/); + } + iWindowGc->Deactivate(); + iWindow->EndRedraw(); + iWsSession.Flush(); +} + +void CWindow::ProcessEvents(float delta) { + RThread thread; + TInt error = KErrNone; + while (thread.RequestCount()) { + CActiveScheduler::RunIfReady(error, CActive::EPriorityIdle); + User::WaitForAnyRequest(); + } + + while (iWsEventStatus != KRequestPending) { + iWsSession.GetEvent(window->iWsEvent); + HandleWsEvent(window->iWsEvent); + iWsEventStatus = KRequestPending; + iWsSession.EventReady(&iWsEventStatus); + } +} + +void CWindow::RequestClose() { + WindowInfo.Exists = false; + Event_RaiseVoid(&WindowEvents.Closing); +} + +void CWindow::InitEvents() { + iWindow->Invalidate(); + iWindow->BeginRedraw(); + iWindow->EndRedraw(); + iWsSession.Flush(); + if (iEventsInitialized) + return; + iEventsInitialized = ETrue; + iWsEventStatus = KRequestPending; + iWsSession.EventReady(&iWsEventStatus); +} + +cc_result CWindow::OpenBrowser(const cc_string* url) { +#if 0 + TUid browserUid = {0x1020724d}; + TApaTaskList tasklist(window->iWsSession); + TApaTask task = tasklist.FindApp(browserUid); + TPtrC des; + // TODO convert url to utf16 + + if (task.Exists()) { + task.BringToForeground(); + + + } else { + RApaLsSession ls; + if (!ls.Connect()) { + TThreadId tid; + ls.StartDocument(des, browserUid, tid); + ls.Close(); + } + } +#endif + return ERR_NOT_SUPPORTED; +} + +// + +void Window_PreInit(void) { + CCoeEnv* env = new (ELeave) CCoeEnv(); + TRAPD(err, env->ConstructL(ETrue, 0)); + + if (err != KErrNone) { + User::Panic(_L("Failed to create CoeEnv"), 0); + } +} + +void Window_Init(void) { + TRAPD(err, window = CWindow::NewL()); + if (err) { + User::Panic(_L("Failed to initialize CWindow"), err); + } + +#ifdef CC_BUILD_TOUCH + //TBool touch = AknLayoutUtils::PenEnabled(); + + bool touch = true; + Input_SetTouchMode(touch); + Gui_SetTouchUI(touch); +#endif +} + +void Window_Free(void) { + if (window) { + delete window; + window = NULL; + } + + CCoeEnv::Static()->DestroyEnvironment(); + delete CCoeEnv::Static(); +} + +void Window_Create2D(int width, int height) { + launcherMode = true; + window->InitEvents(); +} +void Window_Create3D(int width, int height) { + launcherMode = false; + window->InitEvents(); +} + +void Window_Destroy(void) { +} + +void Window_SetTitle(const cc_string* title) { } + +void Clipboard_GetText(cc_string* value) { } + +void Clipboard_SetText(const cc_string* value) { } + +int Window_GetWindowState(void) { return WINDOW_STATE_FULLSCREEN; } + +cc_result Window_EnterFullscreen(void) { return 0; } + +cc_result Window_ExitFullscreen(void) { return 0; } + +int Window_IsObscured(void) { + return WindowInfo.Inactive; +} + +void Window_Show(void) { } + +void Window_SetSize(int width, int height) { } + +void Window_RequestClose(void) { + window->RequestClose(); +} + +void Window_ProcessEvents(float delta) { + window->ProcessEvents(delta); +} + +void Window_EnableRawMouse(void) { Input.RawMode = true; } + +void Window_UpdateRawMouse(void) { } + +void Window_DisableRawMouse(void) { Input.RawMode = false; } + +void Gamepads_Init(void) { + +} + +void Gamepads_Process(float delta) { + +} + +void ShowDialogCore(const char* title, const char* msg) { + // TODO + static const cc_string t2 = String_Init((char*) title, String_Length(title), String_Length(title)); + Logger_Log(&t2); + static const cc_string msg2 = String_Init((char*) msg, String_Length(msg), String_Length(msg)); + Logger_Log(&msg2); + +} + +void OnscreenKeyboard_Open(struct OpenKeyboardArgs* args) { + VirtualKeyboard_Open(args, launcherMode); +} + +void OnscreenKeyboard_SetText(const cc_string* text) { + VirtualKeyboard_SetText(text); +} + +void OnscreenKeyboard_Close(void) { + VirtualKeyboard_Close(); +} + +void Window_LockLandscapeOrientation(cc_bool lock) { + // TODO +} + +static void Cursor_GetRawPos(int* x, int* y) { *x = 0; *y = 0; } +void Cursor_SetPosition(int x, int y) { } +static void Cursor_DoSetVisible(cc_bool visible) { } + +cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) { + return ERR_NOT_SUPPORTED; +} + +cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) { + return ERR_NOT_SUPPORTED; +} + +void Window_AllocFramebuffer(struct Bitmap* bmp, int width, int height) { + bmp->scan0 = (BitmapCol*)Mem_Alloc(width * height, BITMAPCOLOR_SIZE, "bitmap"); + bmp->width = width; + bmp->height = height; + window->AllocFrameBuffer(width, height); +} + +void Window_DrawFramebuffer(Rect2D r, struct Bitmap* bmp) { + window->DrawFramebuffer(r, bmp); +} + +void Window_FreeFramebuffer(struct Bitmap* bmp) { + window->FreeFrameBuffer(); + Mem_Free(bmp->scan0); +} + +#if CC_GFX_BACKEND == CC_GFX_BACKEND_GL1 +void GLContext_Create(void) { + static EGLint attribs[] = { + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_BUFFER_SIZE, DisplayInfo.Depth, + EGL_DEPTH_SIZE, 16, + EGL_NONE + }; + + ctx_display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + eglInitialize(ctx_display, NULL, NULL); + EGLint numConfigs; + + eglChooseConfig(ctx_display, attribs, &ctx_config, 1, &numConfigs); + ctx_context = eglCreateContext(ctx_display, ctx_config, EGL_NO_CONTEXT, NULL); + if (!ctx_context) Process_Abort2(eglGetError(), "Failed to create EGL context"); + GLContext_InitSurface(); +} +#endif + +cc_result Process_StartOpen(const cc_string* args) { + TInt err = 0; + TRAP(err, err = window->OpenBrowser(args)); + return (cc_result) err; +} + +#endif diff --git a/src/_GLShared.h b/src/_GLShared.h index 2d049aa15..3003017e4 100644 --- a/src/_GLShared.h +++ b/src/_GLShared.h @@ -107,7 +107,11 @@ static void CallTexSubImage2D(int lvl, int x, int y, int width, int height, void static void CallTexImage2D(int lvl, int width, int height, void* pixels) { void* tmp; if (!convert_rgba) { +#if defined CC_BUILD_SYMBIAN + _glTexImage2D(GL_TEXTURE_2D, lvl, _GL_BGRA_EXT, width, height, 0, PIXEL_FORMAT, TRANSFER_FORMAT, pixels); +#else _glTexImage2D(GL_TEXTURE_2D, lvl, GL_RGBA, width, height, 0, PIXEL_FORMAT, TRANSFER_FORMAT, pixels); +#endif return; } @@ -310,7 +314,21 @@ cc_result Gfx_TakeScreenshot(struct Stream* output) { bmp.scan0 = (BitmapCol*)Mem_TryAlloc(bmp.width * bmp.height, BITMAPCOLOR_SIZE); if (!bmp.scan0) return ERR_OUT_OF_MEMORY; +#if defined CC_BUILD_SYMBIAN + _glReadPixels(0, 0, bmp.width, bmp.height, GL_RGBA, TRANSFER_FORMAT, bmp.scan0); + /* ??? */ + if (convert_rgba) { + BitmapCol* tmp = (BitmapCol*)Mem_TryAlloc(bmp.width * bmp.height, BITMAPCOLOR_SIZE); + if (!tmp) return ERR_OUT_OF_MEMORY; + + ConvertRGBA(tmp, bmp.scan0, bmp.width * bmp.height); + + Mem_Free(bmp.scan0); + bmp.scan0 = tmp; + } +#else _glReadPixels(0, 0, bmp.width, bmp.height, PIXEL_FORMAT, TRANSFER_FORMAT, bmp.scan0); +#endif res = Png_Encode(&bmp, output, GL_GetRow, false, NULL); Mem_Free(bmp.scan0); @@ -371,6 +389,10 @@ void Gfx_EndFrame(void) { #if CC_GFX_BACKEND == CC_GFX_BACKEND_GL1 if (Window_IsObscured()) { TickReducedPerformance(); +#if defined CC_BUILD_SYMBIAN + /* eglSwapBuffers on Symbian 9.2 renders on top of everything */ + return; +#endif } else { EndReducedPerformance(); } diff --git a/src/_GraphicsBase.h b/src/_GraphicsBase.h index f6e1c9ca9..5e5d91dff 100644 --- a/src/_GraphicsBase.h +++ b/src/_GraphicsBase.h @@ -254,7 +254,7 @@ void Gfx_Begin2D(int width, int height) { Gfx_SetDepthTest(false); Gfx_SetDepthWrite(false); Gfx_SetAlphaBlending(true); - + gfx_hadFog = Gfx_GetFog(); if (gfx_hadFog) Gfx_SetFog(false); } diff --git a/src/_PlatformBase.h b/src/_PlatformBase.h index 0800484ad..2249bff83 100644 --- a/src/_PlatformBase.h +++ b/src/_PlatformBase.h @@ -202,7 +202,7 @@ static void EncipherBlock(cc_uint32* v, const cc_uint32* key, cc_string* dst) { cc_uint32 v0 = v[0], v1 = v[1], sum = 0, delta = 0x9E3779B9; int i; - for (i = 0; i < 12; i++) + for (i = 0; i < 12; i++) { v0 += (((v1 << 4) ^ (v1 >> 5)) + v1) ^ (sum + key[sum & 3]); sum += delta; @@ -216,7 +216,7 @@ static void DecipherBlock(cc_uint32* v, const cc_uint32* key) { cc_uint32 v0 = v[0], v1 = v[1], delta = 0x9E3779B9, sum = delta * 12; int i; - for (i = 0; i < 12; i++) + for (i = 0; i < 12; i++) { v1 -= (((v0 << 4) ^ (v0 >> 5)) + v0) ^ (sum + key[(sum>>11) & 3]); sum -= delta; diff --git a/src/_WindowBase.h b/src/_WindowBase.h index 5fece17f2..cf379db45 100644 --- a/src/_WindowBase.h +++ b/src/_WindowBase.h @@ -103,7 +103,9 @@ static CC_INLINE void InitGraphicsMode(struct GraphicsMode* m) { /*########################################################################################################################* *-------------------------------------------------------EGL OpenGL--------------------------------------------------------* *#########################################################################################################################*/ +#if !defined CC_BUILD_SYMBIAN #include +#endif static EGLDisplay ctx_display; static EGLContext ctx_context; static EGLSurface ctx_surface; @@ -114,7 +116,11 @@ static cc_uintptr ctx_visualID; static void GLContext_InitSurface(void); // replacement in Window_Switch.c for handheld/docked resolution fix #else static void GLContext_InitSurface(void) { +#if defined EGLNativeWindowType EGLNativeWindowType window = (EGLNativeWindowType)Window_Main.Handle.ptr; +#else + NativeWindowType window = (NativeWindowType)Window_Main.Handle.ptr; +#endif if (!window) return; /* window not created or lost */ ctx_surface = eglCreateWindowSurface(ctx_display, ctx_config, window, NULL); @@ -139,7 +145,10 @@ static void DumpEGLConfig(EGLConfig config) { eglGetConfigAttrib(ctx_display, config, EGL_ALPHA_SIZE, &alpha); eglGetConfigAttrib(ctx_display, config, EGL_DEPTH_SIZE, &depth); eglGetConfigAttrib(ctx_display, config, EGL_NATIVE_VISUAL_ID, &vid); +#if defined EGL_RENDERABLE_TYPE + /* e.g Symbian 9.2-9.4 only support EGL 1.1 */ eglGetConfigAttrib(ctx_display, config, EGL_RENDERABLE_TYPE, &mode); +#endif Platform_Log4("EGL R:%i, G:%i, B:%i, A:%i", &red, &green, &blue, &alpha); Platform_Log3("EGL D: %i, V: %h, S: %h", &depth, &vid, &mode); @@ -161,6 +170,9 @@ static void ChooseEGLConfig(EGLConfig* configs, EGLint num_configs) { } } +#if defined CC_BUILD_SYMBIAN && CC_GFX_BACKEND != CC_GFX_BACKEND_GL2 +/* Implemented in Window_Symbian.cpp */ +#else void GLContext_Create(void) { #if CC_GFX_BACKEND == CC_GFX_BACKEND_GL2 static EGLint context_attribs[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE }; @@ -221,6 +233,7 @@ void GLContext_Create(void) { if (!ctx_context) Process_Abort2(eglGetError(), "Failed to create EGL context"); GLContext_InitSurface(); } +#endif void GLContext_Update(void) { GLContext_FreeSurface(); @@ -240,14 +253,18 @@ void GLContext_Free(void) { } void* GLContext_GetAddress(const char* function) { - return eglGetProcAddress(function); + return (void*) eglGetProcAddress(function); } cc_bool GLContext_SwapBuffers(void) { EGLint err; if (!ctx_surface) return false; if (eglSwapBuffers(ctx_display, ctx_surface)) return true; - +#if defined CC_BUILD_SYMBIAN + if (GLContext_TryRestore() && eglSwapBuffers(ctx_display, ctx_surface)) { + return true; + } +#endif err = eglGetError(); /* TODO: figure out what errors need to be handled here */ Process_Abort2(err, "Failed to swap buffers"); diff --git a/src/freetype/ftoption.h b/src/freetype/ftoption.h index a76486647..caf733cd7 100644 --- a/src/freetype/ftoption.h +++ b/src/freetype/ftoption.h @@ -101,7 +101,10 @@ FT_BEGIN_HEADER /* performance-critical functions (e.g. FT_MulFix). You should only do */ /* that to verify that the assembler function works properly, or to */ /* execute benchmark tests of the various implementations. */ -/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ +#ifdef CC_BUILD_SYMBIAN +#define FT_CONFIG_OPTION_NO_ASSEMBLER +#endif + /*************************************************************************/ diff --git a/src/main.c b/src/main.c index 6abab2a5a..0c5a63dca 100644 --- a/src/main.c +++ b/src/main.c @@ -251,7 +251,7 @@ int main_real(int argc, char** argv) { #elif defined CC_BUILD_WEB /* webclient does some asynchronous initialisation first, then kickstarts the game after that */ int web_main(int argc, char** argv) { -#else +#else int main(int argc, char** argv) { #endif cc_result res; diff --git a/third_party/bearssl/inc/bearssl.h b/third_party/bearssl/inc/bearssl.h index 310edb258..0679cdd4b 100644 --- a/third_party/bearssl/inc/bearssl.h +++ b/third_party/bearssl/inc/bearssl.h @@ -124,6 +124,10 @@ * BearSSL source archive also comes with sample code. */ +#if defined __ARMCC__ && defined __SYMBIAN32__ +#define inline __inline +#endif + #include "bearssl_hash.h" #include "bearssl_hmac.h" #include "bearssl_kdf.h" diff --git a/third_party/bearssl/inc/bearssl_hash.h b/third_party/bearssl/inc/bearssl_hash.h index 39de6da94..554683d91 100644 --- a/third_party/bearssl/inc/bearssl_hash.h +++ b/third_party/bearssl/inc/bearssl_hash.h @@ -27,7 +27,11 @@ #include #include +#ifdef __SYMBIAN32__ +#include +#else #include +#endif #ifdef __cplusplus extern "C" { diff --git a/third_party/bearssl/src/inner.h b/third_party/bearssl/src/inner.h index c84ec9aad..719843e72 100644 --- a/third_party/bearssl/src/inner.h +++ b/third_party/bearssl/src/inner.h @@ -25,7 +25,11 @@ #ifndef INNER_H__ #define INNER_H__ +#ifdef __SYMBIAN32__ +#include +#else #include +#endif #include #include "config.h" diff --git a/third_party/bearssl/src/ssl_engine.c b/third_party/bearssl/src/ssl_engine.c index b36a46d94..4b895489d 100644 --- a/third_party/bearssl/src/ssl_engine.c +++ b/third_party/bearssl/src/ssl_engine.c @@ -1284,10 +1284,11 @@ br_ssl_engine_compute_master(br_ssl_engine_context *cc, int prf_id, const void *pms, size_t pms_len) { br_tls_prf_impl iprf; - br_tls_prf_seed_chunk seed[2] = { - { cc->client_random, sizeof cc->client_random }, - { cc->server_random, sizeof cc->server_random } - }; + br_tls_prf_seed_chunk seed[2]; + seed[0].data = cc->client_random; + seed[0].len = sizeof cc->client_random; + seed[1].data = cc->server_random; + seed[1].len = sizeof cc->server_random; iprf = br_ssl_engine_get_PRF(cc, prf_id); iprf(cc->session.master_secret, sizeof cc->session.master_secret, @@ -1302,10 +1303,11 @@ compute_key_block(br_ssl_engine_context *cc, int prf_id, size_t half_len, unsigned char *kb) { br_tls_prf_impl iprf; - br_tls_prf_seed_chunk seed[2] = { - { cc->server_random, sizeof cc->server_random }, - { cc->client_random, sizeof cc->client_random } - }; + br_tls_prf_seed_chunk seed[2]; + seed[0].data = cc->server_random; + seed[0].len = sizeof cc->server_random; + seed[1].data = cc->client_random; + seed[1].len = sizeof cc->client_random; iprf = br_ssl_engine_get_PRF(cc, prf_id); iprf(kb, half_len << 1, diff --git a/third_party/bearssl/src/ssl_hs_client.c b/third_party/bearssl/src/ssl_hs_client.c index de36165aa..579d8abb7 100644 --- a/third_party/bearssl/src/ssl_hs_client.c +++ b/third_party/bearssl/src/ssl_hs_client.c @@ -68,7 +68,11 @@ void br_ssl_hs_client_run(void *t0ctx); #include +#ifdef __SYMBIAN32__ +#include +#else #include +#endif #include "inner.h"