Skip to content

Commit

Permalink
Merge pull request #34 from Im-Rises/develop
Browse files Browse the repository at this point in the history
Corrected wasm build
  • Loading branch information
Im-Rises authored Apr 15, 2024
2 parents bd6b021 + 30fa964 commit 366fd11
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 28 deletions.
19 changes: 7 additions & 12 deletions .github/workflows/cmake-vcpkg-emscripten-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,17 @@ jobs:
- name: Create build directory
run: mkdir build

# - name: Configure CMake
# run: emcmake cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten "-DCMAKE_EXE_LINKER_FLAGS=-s USE_GLFW=3 -s FULL_ES3=1 -s WASM=1 -s EXPORTED_RUNTIME_METHODS=[ccall] -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS=[_main,_malloc,_free] --preload-file ../../Chip8Games --preload-file ../../shaders --preload-file ../../fonts" -DCMAKE_BUILD_TYPE=Release
#
# - name: Build
# run: emmake make -C build
- name: Configure CMake
run: emcmake cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten "-DCMAKE_EXE_LINKER_FLAGS=-s USE_SDL=2 -s FULL_ES3=1 -s WASM=1 -s EXPORTED_RUNTIME_METHODS=[ccall] -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS=[_main,_malloc,_free] --preload-file ../../Chip8Games --preload-file ../../shaders --preload-file ../../fonts" -DCMAKE_BUILD_TYPE=Release

- name: Configure and build with CMake
run: |
chmod +x build-wasm.sh
./build-wasm.sh buildWasm
- name: Build
run: emmake make -C build

- name: Copy artefacts to web folder
run: |
cp buildWasm/Chip8topia/Chip8topia.js web/
cp buildWasm/Chip8topia/Chip8topia.wasm web/
cp buildWasm/Chip8topia/Chip8topia.data web/
cp build/Chip8topia/Chip8topia.js web/
cp build/Chip8topia/Chip8topia.wasm web/
cp build/Chip8topia/Chip8topia.data web/
- name: Setup Pages
uses: actions/configure-pages@v3
Expand Down
13 changes: 4 additions & 9 deletions .github/workflows/cmake-vcpkg-emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ jobs:
- name: Create build directory
run: mkdir build

# - name: Configure CMake
# run: emcmake cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten "-DCMAKE_EXE_LINKER_FLAGS=-s USE_GLFW=3 -s FULL_ES3=1 -s WASM=1 -s EXPORTED_RUNTIME_METHODS=[ccall] -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS=[_main,_malloc,_free] --preload-file ../../Chip8Games --preload-file ../../shaders --preload-file ../../fonts" -DCMAKE_BUILD_TYPE=Release
#
# - name: Build
# run: emmake make -C build
- name: Configure CMake
run: emcmake cmake -B build -S . -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DVCPKG_TARGET_TRIPLET=wasm32-emscripten "-DCMAKE_EXE_LINKER_FLAGS=-s USE_SDL=2 -s FULL_ES3=1 -s WASM=1 -s EXPORTED_RUNTIME_METHODS=[ccall] -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS=[_main,_malloc,_free] --preload-file ../../Chip8Games --preload-file ../../shaders --preload-file ../../fonts" -DCMAKE_BUILD_TYPE=Release

- name: Configure and build with CMake
run: |
chmod +x build-wasm.sh
./build-wasm.sh buildWasm
- name: Build
run: emmake make -C build
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

set(CHIP8TOPIA_VERSION "2.1.0")
set(CHIP8TOPIA_VERSION "2.1.1")

project("Chip8topia" VERSION ${CHIP8TOPIA_VERSION})
add_subdirectory(${PROJECT_NAME})
Expand Down
6 changes: 4 additions & 2 deletions Chip8topia/Chip8topia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,13 @@ auto Chip8topia::init() -> int
// Set input callbacks
#ifndef __EMSCRIPTEN__
// m_chip8topiaInputHandler.m_ExitChip8topiaEvent.subscribe(this, &Chip8topia::closeRequest);
m_chip8topiaInputHandler.m_ToggleTurboModeEvent.subscribe(this, &Chip8topia::toggleTurboMode);
m_chip8topiaInputHandler.m_CenterWindowEvent.subscribe(this, &Chip8topia::centerWindow);
m_chip8topiaInputHandler.m_ToggleFullScreenEvent.subscribe(this, &Chip8topia::toggleFullScreen);
m_chip8topiaInputHandler.m_LoadRomFromPath.subscribe(this, &Chip8topia::loadRomFromPath);
#endif

m_chip8topiaInputHandler.m_ToggleTurboModeEvent.subscribe(this, &Chip8topia::toggleTurboMode);

#if !defined(BUILD_RELEASE) && !defined(__EMSCRIPTEN__)
m_chip8topiaInputHandler.m_DebugRomFastLoadEvent.subscribe(this, &Chip8topia::loadDebugRom);
#endif
Expand All @@ -242,12 +243,13 @@ void Chip8topia::cleanup()
{
#ifndef __EMSCRIPTEN__
// m_chip8topiaInputHandler.m_ExitChip8topiaEvent.unsubscribe(this, &Chip8topia::closeRequest);
m_chip8topiaInputHandler.m_ToggleTurboModeEvent.unsubscribe(this, &Chip8topia::toggleTurboMode);
m_chip8topiaInputHandler.m_CenterWindowEvent.unsubscribe(this, &Chip8topia::centerWindow);
m_chip8topiaInputHandler.m_ToggleFullScreenEvent.unsubscribe(this, &Chip8topia::toggleFullScreen);
m_chip8topiaInputHandler.m_LoadRomFromPath.unsubscribe(this, &Chip8topia::loadRomFromPath);
#endif

m_chip8topiaInputHandler.m_ToggleTurboModeEvent.unsubscribe(this, &Chip8topia::toggleTurboMode);

#if !defined(BUILD_RELEASE)
m_chip8topiaInputHandler.m_DebugRomFastLoadEvent.unsubscribe(this, &Chip8topia::loadDebugRom);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ void Chip8topiaInputHandler::update(Chip8topia& chip8topia, SDL_Event& event) co
#endif

#if !defined(__EMSCRIPTEN__)
case SDLK_y: m_ToggleTurboModeEvent.trigger(); break;
case SDLK_F10: m_CenterWindowEvent.trigger(); break;
case SDLK_F11: m_ToggleFullScreenEvent.trigger(); break;
#endif

case SDLK_y: m_ToggleTurboModeEvent.trigger(); break;
case SDLK_u: m_ToggleMainBarEvent.trigger(); break;
case SDLK_i: m_CloseAllWindowsEvent.trigger(); break;
case SDLK_p: m_TogglePauseEmulationEvent.trigger(); break;
Expand Down
2 changes: 1 addition & 1 deletion Chip8topia/Chip8topiaInputHandler/Chip8topiaInputHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ class Chip8topiaInputHandler final : public Singleton<Chip8topiaInputHandler>
/* Input Events */
#ifndef __EMSCRIPTEN__
// SingleSubscriberEvent<> m_ExitChip8topiaEvent;
SingleSubscriberEvent<> m_ToggleTurboModeEvent;
SingleSubscriberEvent<> m_CenterWindowEvent;
SingleSubscriberEvent<> m_ToggleFullScreenEvent;
#endif
#if !defined(BUILD_RELEASE)
SingleSubscriberEvent<> m_DebugRomFastLoadEvent;
#endif
SingleSubscriberEvent<> m_ToggleTurboModeEvent;
SingleSubscriberEvent<> m_ToggleMainBarEvent;
SingleSubscriberEvent<> m_CloseAllWindowsEvent;
SingleSubscriberEvent<> m_TogglePauseEmulationEvent;
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ The application is compiled with CMake and uses Vcpkg for most dependencies.
For the WebAssembly version, it uses Emscripten to compile with vcpkg for most dependencies as well.

It can emulate the original Chip8, the SCHIP1.1, SCHIPC and Xo-Chip.
Currently, no sound is implemented, but it is planned.

Platforms:

Expand Down Expand Up @@ -91,7 +90,8 @@ Emulated consoles:

Major:

- [ ] Add audio
- [x] Add Chip8 audio
- [ ] Add Xo-Chip audio
- [ ] Replace the input handler singleton with another pattern...

Minor:
Expand Down

0 comments on commit 366fd11

Please sign in to comment.