Skip to content

Commit

Permalink
fix: fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Jul 30, 2023
1 parent 63e7bea commit c1fb2ab
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 34 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ jobs:
- uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*.zip
files: |
dist/cores/*
dist/*.zip
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.PHONY: all

all: patch_retroarch build_cores archive
all: patch_modules build_cores archive

patch_retroarch:
./scripts/patch-retroarch.sh
patch_modules:
./scripts/patch-modules.sh

build_cores:
./scripts/build-cores.sh
Expand Down
2 changes: 1 addition & 1 deletion modules/retroarch
123 changes: 123 additions & 0 deletions patches/retroarch.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
diff --git a/Makefile.emscripten b/Makefile.emscripten
index 88637560b3..91303bbe2b 100644
--- a/Makefile.emscripten
+++ b/Makefile.emscripten
@@ -76,10 +76,11 @@ PRECISE_F32 = 1
OBJDIR := obj-emscripten

#if you compile with SDL2 flag add this Emscripten flag "-s USE_SDL=2" to LDFLAGS:
+EXPORTED_FUNCTIONS = "['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot', '_cmd_toggle_menu', '_cmd_toggle_grab_mouse', '_cmd_toggle_game_focus', '_cmd_reset', '_cmd_toggle_pause', '_cmd_pause', '_cmd_unpause', '_cmd_cheat_set_code', '_cmd_cheat_get_code', '_cmd_cheat_toggle_index', '_cmd_cheat_get_code_state', '_cmd_cheat_realloc', '_cmd_cheat_get_size', '_cmd_cheat_apply_cheats']"

LIBS := -s USE_ZLIB=1
LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" \
- -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \
+ -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS=$(EXPORTED_FUNCTIONS) \
--js-library emscripten/library_errno_codes.js \
--js-library emscripten/library_rwebcam.js

diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c
index c842a49854..05c7e812f5 100644
--- a/frontend/drivers/platform_emscripten.c
+++ b/frontend/drivers/platform_emscripten.c
@@ -46,6 +46,7 @@
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../tasks/tasks_internal.h"
+#include "../../cheat_manager.h"

void dummyErrnoCodes(void);
void emscripten_mainloop(void);
@@ -70,6 +71,78 @@ void cmd_take_screenshot(void)
command_event(CMD_EVENT_TAKE_SCREENSHOT, NULL);
}

+void cmd_toggle_menu(void)
+{
+ command_event(CMD_EVENT_MENU_TOGGLE, NULL);
+}
+
+void cmd_toggle_grab_mouse(void)
+{
+ command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL);
+}
+
+void cmd_toggle_game_focus(void)
+{
+ command_event(CMD_EVENT_GAME_FOCUS_TOGGLE, NULL);
+}
+
+void cmd_reset(void)
+{
+ command_event(CMD_EVENT_RESET, NULL);
+}
+
+void cmd_toggle_pause(void)
+{
+ command_event(CMD_EVENT_PAUSE_TOGGLE, NULL);
+}
+
+void cmd_pause(void)
+{
+ command_event(CMD_EVENT_PAUSE, NULL);
+}
+
+void cmd_unpause(void)
+{
+ command_event(CMD_EVENT_UNPAUSE, NULL);
+}
+
+// cheats
+
+void cmd_cheat_set_code(unsigned index, const char *str)
+{
+ cheat_manager_set_code(index, str);
+}
+
+const char *cmd_cheat_get_code(unsigned index)
+{
+ return cheat_manager_get_code(index);
+}
+
+void cmd_cheat_toggle_index(bool apply_cheats_after_toggle, unsigned index)
+{
+ cheat_manager_toggle_index(apply_cheats_after_toggle, index);
+}
+
+bool cmd_cheat_get_code_state(unsigned index)
+{
+ return cheat_manager_get_code_state(index);
+}
+
+bool cmd_cheat_realloc(unsigned new_size)
+{
+ return cheat_manager_realloc(new_size, CHEAT_HANDLER_TYPE_EMU);
+}
+
+unsigned cmd_cheat_get_size(void)
+{
+ return cheat_manager_get_size();
+}
+
+void cmd_cheat_apply_cheats(void)
+{
+ cheat_manager_apply_cheats();
+}
+
static void frontend_emscripten_get_env(int *argc, char *argv[],
void *args, void *params_data)
{
diff --git a/tasks/task_save.c b/tasks/task_save.c
index 08bcf1f67f..b2edfab4aa 100644
--- a/tasks/task_save.c
+++ b/tasks/task_save.c
@@ -62,8 +62,8 @@
#include "../cheat_manager.h"
#endif

-#if defined(HAVE_LIBNX) || defined(_3DS)
-#define SAVE_STATE_CHUNK 4096 * 10
+#if defined(HAVE_LIBNX) || defined(_3DS) || defined(EMSCRIPTEN)
+#define SAVE_STATE_CHUNK 4096 * 1000
#else
#define SAVE_STATE_CHUNK 4096
#endif
21 changes: 0 additions & 21 deletions patches/retroarch/task_save.c.patch

This file was deleted.

2 changes: 1 addition & 1 deletion scripts/build-cores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fi

# remove early compiled outputs
cd "$retroarch_dir"
git clean -x
git clean -xf

# generate bitcode (.bc) files for each cores
cd "$cores_dir"
Expand Down
10 changes: 10 additions & 0 deletions scripts/patch-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

set -e

wd=$(pwd)
retroarch_dir=$wd/modules/retroarch

cd "$retroarch_dir"
git checkout -f
git apply "$wd/patches/retroarch.patch"
7 changes: 0 additions & 7 deletions scripts/patch-retroarch.sh

This file was deleted.

0 comments on commit c1fb2ab

Please sign in to comment.