From 631fd03dd8c4bf17ed08077c145d23c110563b23 Mon Sep 17 00:00:00 2001 From: "BADIM-PC\\Vadim" Date: Wed, 14 Feb 2018 16:22:33 +0300 Subject: [PATCH] no message --- src/console.c | 22 ++++++++-------------- src/fs.c | 4 ++++ src/run.c | 12 +----------- src/studio.h | 4 ---- src/surf.c | 2 +- src/system.c | 17 +++++++++++++++++ src/system.h | 2 ++ 7 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/console.c b/src/console.c index 5d20cc1..7fb8f8e 100644 --- a/src/console.c +++ b/src/console.c @@ -35,6 +35,10 @@ #include #include +#if defined(__EMSCRIPTEN__) +#include +#endif + #define CONSOLE_CURSOR_COLOR ((tic_color_red)) #define CONSOLE_BACK_TEXT_COLOR ((tic_color_dark_gray)) #define CONSOLE_FRONT_TEXT_COLOR ((tic_color_white)) @@ -54,7 +58,7 @@ typedef enum WrenScript, } ScriptLang; -#if defined(__TIC_WINDOWS__) || defined(__LINUX__) || defined(__MACOSX__) +#if defined(__TIC_WINDOWS__) || defined(__TIC_LINUX__) || defined(__TIC_MACOSX__) #define CAN_EXPORT 1 #endif @@ -1644,9 +1648,7 @@ static void onConsoleExportCommand(Console* console, const char* param) #else -#if !defined(__ANDROID__) && !defined(__MACOSX__) && !defined(__LINUX__) - -static void *memmem(const void* haystack, size_t hlen, const void* needle, size_t nlen) +static void *ticMemmem(const void* haystack, size_t hlen, const void* needle, size_t nlen) { const u8* p = haystack; size_t plen = hlen; @@ -1667,8 +1669,6 @@ static void *memmem(const void* haystack, size_t hlen, const void* needle, size_ return NULL; } -#endif - typedef struct { Console* console; @@ -1722,7 +1722,7 @@ static void onConsoleExportHtmlCommand(Console* console, const char* name) u8* EmbedTicJs = NULL; u32 EmbedTicJsSize = unzip(&EmbedTicJs, EmbedTicJsZip, EmbedTicJsZipSize); - u8* ptr = memmem(EmbedIndex, EmbedIndexSize, Placeholder, sizeof(Placeholder)-1); + u8* ptr = ticMemmem(EmbedIndex, EmbedIndexSize, Placeholder, sizeof(Placeholder)-1); if(ptr) { @@ -2363,13 +2363,7 @@ static void onConsoleHelpCommand(Console* console, const char* param) } printBack(console, "\npress "); - -#if defined(__ANDROID__) - printFront(console, "BACK"); -#else printFront(console, "ESC"); -#endif - printBack(console, " to enter UI mode\n"); commandDone(console); @@ -3108,7 +3102,7 @@ void initConsole(Console* console, tic_mem* tic, FileSystem* fs, Config* config, while(true) { - const EmbedHeader* header = (const EmbedHeader*)memmem(ptr, size, TicCartSig, SIG_SIZE); + const EmbedHeader* header = (const EmbedHeader*)ticMemmem(ptr, size, TicCartSig, SIG_SIZE); if(header) { diff --git a/src/fs.c b/src/fs.c index b0439b1..ddf8a7d 100644 --- a/src/fs.c +++ b/src/fs.c @@ -165,6 +165,8 @@ int _wremove(const wchar_t *); #endif +#if !defined(__EMSCRIPTEN__) + typedef struct { ListCallback callback; @@ -286,6 +288,8 @@ static void netDirRequest(const char* path, ListCallback callback, void* data) onDirResponse(buffer, size, &netDirData); } +#endif + void fsEnumFiles(FileSystem* fs, ListCallback callback, void* data) { #if !defined(__EMSCRIPTEN__) diff --git a/src/run.c b/src/run.c index 85a8e02..f284578 100644 --- a/src/run.c +++ b/src/run.c @@ -155,16 +155,6 @@ static void processDoFile(void* data, char* dst) return; } -static void preseed() -{ -#if defined(__MACOSX__) - srandom(time(NULL)); - random(); -#else - srand(time(NULL)); - rand(); -#endif -} static bool forceExit(void* data) { @@ -213,5 +203,5 @@ void initRun(Run* run, Console* console, tic_mem* tic) if(data) free(data); } - preseed(); + getSystem()->preseed(); } diff --git a/src/studio.h b/src/studio.h index 5c51f43..765c525 100644 --- a/src/studio.h +++ b/src/studio.h @@ -27,10 +27,6 @@ #include #include -#if defined(__EMSCRIPTEN__) -#include -#endif - #include "tic.h" #include "ticapi.h" #include "defines.h" diff --git a/src/surf.c b/src/surf.c index dd91146..90c2d9e 100644 --- a/src/surf.c +++ b/src/surf.c @@ -37,7 +37,7 @@ #define COVER_Y 5 #define COVER_X (TIC80_WIDTH - COVER_WIDTH - COVER_Y) -#if defined(__TIC_WINDOWS__) || defined(__LINUX__) || defined(__MACOSX__) +#if defined(__TIC_WINDOWS__) || defined(__TIC_LINUX__) || defined(__TIC_MACOSX__) #define CAN_OPEN_URL 1 #endif diff --git a/src/system.c b/src/system.c index 1080bad..70b2f59 100644 --- a/src/system.c +++ b/src/system.c @@ -4,8 +4,13 @@ #include #include +#include #include +#if defined(__EMSCRIPTEN__) +#include +#endif + #define STUDIO_UI_SCALE 3 #define STUDIO_PIXEL_FORMAT SDL_PIXELFORMAT_ARGB8888 #define TEXTURE_SIZE (TIC80_FULLWIDTH) @@ -967,6 +972,17 @@ static void* getUrlRequest(const char* url, s32* size) return netGetRequest(platform.net, url, size); } +static void preseed() +{ +#if defined(__MACOSX__) + srandom(time(NULL)); + random(); +#else + srand(time(NULL)); + rand(); +#endif +} + static System systemInterface = { .setClipboardText = setClipboardText, @@ -985,6 +1001,7 @@ static System systemInterface = .setWindowTitle = setWindowTitle, .openSystemPath = openSystemPath, + .preseed = preseed, }; #if defined(__EMSCRIPTEN__) diff --git a/src/system.h b/src/system.h index 33ef9e6..0768788 100644 --- a/src/system.h +++ b/src/system.h @@ -21,6 +21,8 @@ typedef struct void (*setWindowTitle)(const char* title); void (*openSystemPath)(const char* path); + + void (*preseed)(); } System;