Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Makefile.linux
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@

CFLAGS=-Wall -Wpedantic -std=c99

LDLIBS=-lSDL2

EXE = jc_reborn
BASE_EXE = jc_reborn

ifdef EMSCRIPTEN
EXE = $(BASE_EXE).js
ASSET_DIR=./assets@/
CFLAGS+=-sUSE_SDL=2 -Os
LDFLAGS+=--embed-file $(ASSET_DIR) -sASYNCIFY -sALLOW_MEMORY_GROWTH -sSTANDALONE_WASM=0 -sEXIT_RUNTIME
else
EXE = $(BASE_EXE)
endif

OBJ = jc_reborn.o \
utils.o \
Expand All @@ -22,11 +30,13 @@ OBJ = jc_reborn.o \
events.o \
config.o


all: $(EXE)

$(EXE): $(OBJ)
ifdef EMSCRIPTEN
emcc $(OBJ) -o $(EXE) $(LDLIBS) $(LDFLAGS)
endif

clean:
rm -v $(OBJ) $(EXE) 2> /dev/null ; true
rm -v $(OBJ) $(BASE_EXE) $(BASE_EXE).js $(BASE_EXE).wasm 2> /dev/null ; true

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Johnny Reborn is an open source engine for the classic Johnny Castaway screen saver, developed by Dynamix for Windows 3.x and published by Sierra, back in 1992.

It is written in C using the SDL2 library, and was successfully compiled and tested on Linux as well as Windows (MinGW), both 32 and 64 bits.
It is written in C using the SDL2 library, and was successfully compiled and tested on Linux, on MacOSX, on Chrome and FireFox via Emscripten, as well as Windows (MinGW), both 32 and 64 bits.


## How to install
Expand Down
19 changes: 19 additions & 0 deletions events.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <stdio.h>

#include <SDL2/SDL.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
#endif
#include "mytypes.h"
#include "graphics.h"
#include "events.h"
Expand Down Expand Up @@ -72,15 +75,23 @@ static void eventsProcessEvents()

case SDLK_ESCAPE:
graphicsEnd();
#ifdef __EMSCRIPTEN__
emscripten_force_exit(255);
#else
exit(255);
#endif
break;
}
}
else {
// Normal behaviour : no hot keys, the screen saver
// terminates if any key is pressed
graphicsEnd();
#ifdef __EMSCRIPTEN__
emscripten_force_exit(255);
#else
exit(255);
#endif
}
break;

Expand All @@ -90,7 +101,11 @@ static void eventsProcessEvents()

case SDL_QUIT:
graphicsEnd();
#ifdef __EMSCRIPTEN__
emscripten_force_exit(255);
#else
exit(255);
#endif
break;
}
}
Expand All @@ -112,7 +127,11 @@ void eventsWaitTick(uint16 delay)

while ((paused && !oneFrame)
|| (!maxSpeed && (SDL_GetTicks() - lastTicks < delay))) {
#ifdef __EMSCRIPTEN__
emscripten_sleep(5);
#else
SDL_Delay(5);
#endif
eventsProcessEvents();
}

Expand Down
6 changes: 6 additions & 0 deletions graphics.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <string.h>
#include <time.h>
#include <SDL2/SDL.h>
#ifdef __EMSCRIPTEN__
#include <emscripten/html5.h>
#endif

#include "mytypes.h"
#include "utils.h"
Expand Down Expand Up @@ -122,6 +125,9 @@ void graphicsInit()
SCREEN_HEIGHT,
(grWindowed ? 0 : SDL_WINDOW_FULLSCREEN)
);
#ifdef __EMSCRIPTEN__
emscripten_set_canvas_element_size("#canvas", 640, 480);
#endif

if (sdl_window == NULL)
fatalError("Could not create window: %s", SDL_GetError());
Expand Down
4 changes: 4 additions & 0 deletions sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
*/

#include <SDL2/SDL.h>
#ifdef __EMSCRIPTEN__
#include <emscripten.h>
EM_JS_DEPS(sdlaudio, "$autoResumeAudioContext,$dynCall")
#endif
#include <string.h>

#include "mytypes.h"
Expand Down
1 change: 0 additions & 1 deletion story.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,3 @@ void storyPlay()
adsReleaseIsland();
}
}