Skip to content

Commit

Permalink
web port (#82)
Browse files Browse the repository at this point in the history
* web port

a few misc changes were made to the core and other frontends

core:
- audio callback now requires a buffer to be set for the samples to be written to.
  this is much more optimal than spamming the audio callback and pushing 2 samples at a
  time to the sdl_audio_stream.

frontend:
- added the layer viewer back to imgui frontend, there's some UB involved though, see the comments!
- added a sdl2 base which sdl2 frontends will inherit from. not really sure if this was a good idea or not
- sdl2 frontend implements my hacky audio catch-up thing (idk what to name it) where it will tick the core
  if not enough samples are generated.
- zlib/minizip is now linked publically in the frontend_base. i don't like having to do this, but its due
  to a bug in emsdk with std::filesystem::directory_iterator() with -pthread linked. the wasm32-ld will have
  a meltdown ad fail to link. only work around is to enable lto and to use directory_iterator in the exe
  file.
  i haven't yet reported the bug.
  • Loading branch information
ITotalJustice authored Aug 29, 2022
1 parent 83d5949 commit b0a4ad1
Show file tree
Hide file tree
Showing 73 changed files with 3,857 additions and 745 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ imgui.ini
CMakeUserPresets.json
rtc.md
n64-emu
deploy_netlify.yml
deploy_pages.yml
32 changes: 32 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
cmake_minimum_required(VERSION 3.20.0)

if (VCPKG)
# checks the documented env variable for vcpkg
if (DEFINED ENV{VCPKG_ROOT} AND EXISTS $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
message(STATUS "found VCPKG_ROOT, using system installed vcpkg at: $ENV{VCPKG_ROOT}")
set(vcpkg_toolchain_file $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)

# this checks for github actions installed vcpkg
elseif (DEFINED ENV{VCPKG_INSTALLATION_ROOT} AND EXISTS $ENV{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake)
message(STATUS "found VCPKG_INSTALLATION_ROOT, using system installed vcpkg at: $ENV{VCPKG_INSTALLATION_ROOT}")
set(vcpkg_toolchain_file $ENV{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake)

# fallback to fetching latest vcpkg from git
else()
message(STATUS "installing latest vcpkg from git root: $ENV{VCPKG_ROOT} insta: $ENV{VCPKG_INSTALLATION_ROOT}")

include(FetchContent)
FetchContent_Declare(vcpkg GIT_REPOSITORY https://github.com/microsoft/vcpkg.git)
FetchContent_MakeAvailable(vcpkg)

set(vcpkg_toolchain_file ${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake)
endif()

# if this was already set, then we need to chainload the toolchain file
# vcpkg offers support for this, which basically does include(toolchain)
# need to make sure that we don't chainload our own toolchain file!
if (CMAKE_TOOLCHAIN_FILE AND NOT ${CMAKE_TOOLCHAIN_FILE} STREQUAL ${vcpkg_toolchain_file})
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
endif()

set(CMAKE_TOOLCHAIN_FILE ${vcpkg_toolchain_file})
endif()

project(notorious_beeg
VERSION 0.0.3
DESCRIPTION "GBA emulator written in c++23"
Expand Down
42 changes: 32 additions & 10 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,17 @@
{
"name": "vcpkg",
"displayName": "vcpkg",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake",
"inherits": ["imgui"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"SINGLE_FILE": true,
"IMGUI": true
"VCPKG": true
}
},
{
"name": "vcpkg-dev",
"displayName": "vcpkg-dev",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "$env{VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake",
"inherits": ["imgui-dev"],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"GBA_DEV": true,
"IMGUI": true
"VCPKG": true
}
},
{
Expand Down Expand Up @@ -90,6 +84,26 @@
"GBA_DEV": true,
"SDL2": true
}
},
{
"name": "emsdk",
"displayName": "emsdk",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"SINGLE_FILE": true
}
},
{
"name": "emsdk-dev",
"displayName": "emsdk-dev",
"binaryDir": "${sourceDir}/build/${presetName}",
"toolchainFile": "$env{EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"EMRUN": true
}
}
],
"buildPresets": [
Expand Down Expand Up @@ -124,6 +138,14 @@
{
"name": "vcpkg-sdl2-dev",
"configurePreset": "vcpkg-sdl2-dev"
},
{
"name": "emsdk",
"configurePreset": "emsdk"
},
{
"name": "emsdk-dev",
"configurePreset": "emsdk-dev"
}
]
}
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ v0.0.3-dev

gba emulator witten in c++23.

[![Netlify Status](https://api.netlify.com/api/v1/badges/bfd72dd6-557d-41a3-87ac-480c686624a2/deploy-status)](https://app.netlify.com/sites/notorious-beeg/deploys)

---

## web builds

web builds are the easiest way to quickly test a game. builds are automatically built from master. please report any bugs you find, giving as much info as possible such as browser, os, game etc.

gh-pages version doesn't support threads / mutexs. may crash.

netlify version supports threads / mutexes, won't crash.

---

## changelog
Expand Down Expand Up @@ -198,3 +210,4 @@ gba emulator witten in c++23.
- xproger for openlara (fixed several bugs in my emu) <https://github.com/XProger/OpenLara>
- zayd for info on rtc <https://beanmachine.alt.icu/post/rtc/>
- pokeemerald for a being a good reference <https://github.com/pret/pokeemerald>
- kenney for the onscreen control buttons <https://www.kenney.nl/assets/onscreen-controls>
Binary file added assets/buttons/a.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/b.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/dpad_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/dpad_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/dpad_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/dpad_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/fastForward.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/fullscreen.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/l.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/larger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions assets/buttons/license.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

###############################################################################

Onscreen Controls by Kenney Vleugels (www.kenney.nl)

------------------------------

License (CC0)
http://creativecommons.org/publicdomain/zero/1.0/

You may use these graphics in personal and commercial projects.
Credit (Kenney or www.kenney.nl) would be nice but is not mandatory.

###############################################################################
Binary file added assets/buttons/musicOn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/r.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/setting_sandwich.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/buttons/start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/back.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/export.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/import.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/load.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/menu/title.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions assets/web/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Your Favicon Package

This package was generated with [RealFaviconGenerator](https://realfavicongenerator.net/) [v0.16](https://realfavicongenerator.net/change_log#v0.16)

## Install instructions

To install this package:

Extract this package in the root of your web site. If your site is <code>http://www.example.com</code>, you should be able to access a file named <code>http://www.example.com/favicon.ico</code>.

Insert the following code in the `head` section of your pages:

<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-chrome-192x192.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<link rel="mask-icon" href="/safari-pinned-tab.svg" color="#0075c0">
<meta name="apple-mobile-web-app-title" content="TotalGBA">
<meta name="application-name" content="TotalGBA">
<meta name="msapplication-TileColor" content="#0075c0">
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
<meta name="theme-color" content="#ffffff">

*Optional* - Check your favicon with the [favicon checker](https://realfavicongenerator.net/favicon_checker)
Binary file added assets/web/android-chrome-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/web/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/web/android-chrome-256x256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/web/android-chrome-36x36.png
Binary file added assets/web/android-chrome-384x384.png
Binary file added assets/web/android-chrome-48x48.png
Binary file added assets/web/android-chrome-512x512.png
Binary file added assets/web/android-chrome-72x72.png
Binary file added assets/web/android-chrome-96x96.png
Binary file added assets/web/apple-touch-icon.png
10 changes: 10 additions & 0 deletions assets/web/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<square310x310logo src="/mstile-310x310.png"/>
<TileColor>#0075c0</TileColor>
</tile>
</msapplication>
</browserconfig>
Binary file added assets/web/favicon-16x16.png
Binary file added assets/web/favicon-32x32.png
Binary file added assets/web/favicon.ico
Binary file not shown.
Binary file added assets/web/mstile-144x144.png
Binary file added assets/web/mstile-150x150.png
Binary file added assets/web/mstile-310x310.png
Loading

0 comments on commit b0a4ad1

Please sign in to comment.