diff --git a/Makefile b/Makefile index 3e5877f0..7b57b639 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ # command name of your favorite ANSI C compiler # (this must be set to "cc" for some systems) -CC = gcc +CC = emcc # command name of GNU make on your system # (this must be set to "gmake" for some systems) diff --git a/music/mus_classic/mod.apoplexy b/music/mus_classic/mod.apoplexy deleted file mode 100644 index f2faff18..00000000 Binary files a/music/mus_classic/mod.apoplexy and /dev/null differ diff --git a/music/mus_classic/mod.chiptune b/music/mus_classic/mod.chiptune deleted file mode 100644 index b199e4ce..00000000 Binary files a/music/mus_classic/mod.chiptune and /dev/null differ diff --git a/music/mus_classic/mod.cream_of_the_earth b/music/mus_classic/mod.cream_of_the_earth deleted file mode 100644 index 55b3b811..00000000 Binary files a/music/mus_classic/mod.cream_of_the_earth and /dev/null differ diff --git a/src/Makefile b/src/Makefile index af907f8c..ee9c2cb4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -38,7 +38,7 @@ WINDRES = windres CONVERT_ICON_ARGS = -transparent black -background transparent -PROGBASE = rocksndiamonds +PROGBASE = rocksndiamonds.js PROGNAME = ../$(PROGBASE) EDITION ?= default @@ -84,8 +84,8 @@ endif # $(info Using SDL version $(SDL_VERSION) [TARGET == $(TARGET)]) ifeq ($(TARGET),sdl2) # compiling for SDL2 target -SYS_CFLAGS = -DTARGET_SDL2 $(shell sdl2-config --cflags) -SDL_LIBS = -lSDL2_image -lSDL2_mixer -lSDL2_net +SYS_CFLAGS = -DTARGET_SDL2 $(shell sdl2-config --cflags) -s USE_ZLIB=1 +SDL_LIBS = -s USE_SDL_IMAGE=2 -s USE_SDL_NET=2 -s USE_SDL_MIXER=2 -s SDL2_IMAGE_FORMATS='["bmp","png","pcx","xpm"]' SYS_LDFLAGS = $(SDL_LIBS) $(shell sdl2-config --libs) endif @@ -111,10 +111,10 @@ DEBUG = -DDEBUG -g # OPTIONS = $(DEBUG) -Wall # only for debugging purposes # OPTIONS = $(DEBUG) -O2 -Wall # only for debugging purposes # OPTIONS = $(DEBUG) -Wall # only for debugging purposes -OPTIONS = $(DEBUG) -Wall -Wstrict-prototypes -Wmissing-prototypes +#OPTIONS = $(DEBUG) -Wall -Wstrict-prototypes -Wmissing-prototypes # OPTIONS = $(DEBUG) -Wall -ansi -pedantic # only for debugging purposes # OPTIONS = -O2 -Wall -ansi -pedantic -# OPTIONS = -O2 -Wall + OPTIONS = -O2 -Wall # OPTIONS = -O2 ifdef BUILD_DIST # distribution build @@ -124,7 +124,7 @@ OPTIONS = -O2 -Wall endif CFLAGS = $(OPTIONS) $(SYS_CFLAGS) $(EXTRA_CFLAGS) $(CONFIG) -LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm -lz +LDFLAGS = $(SYS_LDFLAGS) $(EXTRA_LDFLAGS) -lm -lz -s INITIAL_MEMORY=65536000 -s ALLOW_MEMORY_GROWTH=1 --preload-file ../graphics/ --preload-file ../sounds/ --preload-file ../levels/ --preload-file ../music/ -s NO_EXIT_RUNTIME=0 -s ASYNCIFY SRCS = main.c \ diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 7863159b..cc2f6cc9 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -796,7 +796,7 @@ char *getLoginName(void) if (GetUserName(login_name, &buffer_size) == 0) strcpy(login_name, ANONYMOUS_NAME); } -#elif defined(PLATFORM_UNIX) && !defined(PLATFORM_ANDROID) +#elif defined(PLATFORM_UNIX) && !defined(PLATFORM_ANDROID) && !defined(__EMSCRIPTEN__) if (login_name == NULL) { struct passwd *pwd; @@ -828,7 +828,7 @@ char *getRealName(void) else real_name = ANONYMOUS_NAME; } -#elif defined(PLATFORM_UNIX) && !defined(PLATFORM_ANDROID) +#elif defined(PLATFORM_UNIX) && !defined(PLATFORM_ANDROID) && !defined(__EMSCRIPTEN__) if (real_name == NULL) { struct passwd *pwd; diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 9f82d3a0..202af730 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -1499,7 +1499,7 @@ char *getHomeDir(void) if (!SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PERSONAL, NULL, 0, dir))) strcpy(dir, "."); } -#elif defined(PLATFORM_UNIX) +#elif defined(PLATFORM_UNIX) && !defined(__EMSCRIPTEN__) if (dir == NULL) { if ((dir = getenv("HOME")) == NULL) diff --git a/src/libgame/system.h b/src/libgame/system.h index 0d74426f..d8bc5a13 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -65,14 +65,22 @@ #define STR_SPECIAL_RENDERING_TARGET "target_texture_only" #define STR_SPECIAL_RENDERING_DOUBLE "stream_and_target_texture" +#ifndef __EMSCRIPTEN__ #define STR_SPECIAL_RENDERING_DEFAULT STR_SPECIAL_RENDERING_DOUBLE +#else +#define STR_SPECIAL_RENDERING_DEFAULT STR_SPECIAL_RENDERING_BITMAP +#endif #define SPECIAL_RENDERING_OFF 0 #define SPECIAL_RENDERING_BITMAP 1 #define SPECIAL_RENDERING_TARGET 2 #define SPECIAL_RENDERING_DOUBLE 3 +#ifndef __EMSCRIPTEN__ #define SPECIAL_RENDERING_DEFAULT SPECIAL_RENDERING_DOUBLE +#else +#define SPECIAL_RENDERING_DEFAULT SPECIAL_RENDERING_BITMAP +#endif // values for vertical screen retrace synchronization (vsync) #define STR_VSYNC_MODE_OFF "off" diff --git a/src/libgame/zip/ioapi.c b/src/libgame/zip/ioapi.c index 5b6fcc63..f73778ce 100644 --- a/src/libgame/zip/ioapi.c +++ b/src/libgame/zip/ioapi.c @@ -141,7 +141,7 @@ static voidpf ZCALLBACK fopen64_file_func(ZIP_UNUSED voidpf opaque, const void * if ((filename != NULL) && (mode_fopen != NULL)) { - file = fopen64((const char*)filename, mode_fopen); + file = fopen((const char*)filename, mode_fopen); return file_build_ioposix(file, (const char*)filename); } return file; @@ -237,7 +237,7 @@ static uint64_t ZCALLBACK ftell64_file_func(ZIP_UNUSED voidpf opaque, voidpf str if (stream == NULL) return ret; ioposix = (FILE_IOPOSIX*)stream; - ret = ftello64(ioposix->file); + ret = ftello(ioposix->file); return ret; } @@ -295,7 +295,7 @@ static long ZCALLBACK fseek64_file_func(ZIP_UNUSED voidpf opaque, voidpf stream, return -1; } - if (fseeko64(ioposix->file, offset, fseek_origin) != 0) + if (fseeko(ioposix->file, offset, fseek_origin) != 0) ret = -1; return ret; diff --git a/src/libgame/zip/miniunz.c b/src/libgame/zip/miniunz.c index cf9839b1..7b35a44e 100644 --- a/src/libgame/zip/miniunz.c +++ b/src/libgame/zip/miniunz.c @@ -248,7 +248,7 @@ static FILE *get_file_handle(const char *path) handle = _wfopen((const wchar_t*)pathWide, L"rb"); free(pathWide); #else - handle = fopen64(path, "rb"); + handle = fopen(path, "rb"); #endif return handle; @@ -455,7 +455,7 @@ static int miniunz_extract_currentfile(unzFile uf, int opt_extract_without_path, /* Create the file on disk so we can unzip to it */ if ((skip == 0) && (err == UNZ_OK)) { - fout = fopen64(write_filename, "wb"); + fout = fopen(write_filename, "wb"); /* Some zips don't contain directory alone before file */ if ((fout == NULL) && (opt_extract_without_path == 0) && (filename_withoutpath != (char*)filename_inzip)) @@ -464,7 +464,7 @@ static int miniunz_extract_currentfile(unzFile uf, int opt_extract_without_path, *(filename_withoutpath-1) = 0; makedir(write_filename); *(filename_withoutpath-1) = c; - fout = fopen64(write_filename, "wb"); + fout = fopen(write_filename, "wb"); } if (fout == NULL) debug_printf("error opening %s\n", write_filename);