-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add emscripten(web/wasm) build target #445
Conversation
Nice job! I did a similar thing for https://fallout-nevada.ru but still did not make a local version (that was in my TODO). My main concern was memory requirement because if we pre-load all files into memory then it might fail on tablets or mobiles. Some improvements which I made in my branch:
It will be really nice to have a web build in github pages |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also open a PR into fallout2-ce organization (https://github.com/fallout2-ce/fallout2-ce). Alexander shows up here not so often as we wish to so we created a github organization to merge some PRs and to have releases there.
We can also do a fork of your webinterface into organization if you want. Or even copy-paste web code into the repository (so it will rebuild and redeploy when fallout code changes or web page)
else() | ||
find_package(ZLIB) | ||
find_package(SDL2) | ||
endif() | ||
else() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What optimization level will it have by default? Using -O2
or -O3
caused my build to crash on iphone or ipad so I have to use -O1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emscripten wasm has serious issue with memory on handheld devices. This option -sALLOW_MEMORY_GROWTH
creates copy of entire virtual memory when malloc requests additional block. I think we need to experiment with -sINITIAL_MEMORY
to find optimal pre-allocated memory size.
@@ -57,6 +62,20 @@ int xfileClose(XFile* stream) | |||
break; | |||
default: | |||
rc = fclose(stream->file); | |||
#if defined( __EMSCRIPTEN__ ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small note: In my branch I've used fsync
call which causes IDBFS to write changes into the database. Also, it pauses game process (via asyncify) so when player sees "game saved" all data is actually written into idbfs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to make seamless process of syncing virtual fs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe to use EM_ASYNC_JS
to ensure that file is saved?
EM_ASYNC_JS(void, do_save_idbfs, (), {
await new Promise((resolve, reject) => FS.syncfs(err => err ? reject(err) : resolve())
})
CMakeLists.txt
Outdated
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sEXPORTED_RUNTIME_METHODS=callMain,addRunDependency,removeRunDependency" ) | ||
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sEXPORT_ALL" ) | ||
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-sEXPORT_NAME=fallout2ce" ) | ||
target_link_options( ${EXECUTABLE_NAME} PRIVATE "-gsource-map" ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add -sCASE_INSENSITIVE_FS
? Just in case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I will add this option.
Merged here fallout2-ce#32 |
Simple way to run build
Demo
Demo sources https://github.com/ololoken/fallout2-ce-ems