AZO234 / NP2kai

Neko Project II kai
http://domisan.sakura.ne.jp/article/np2kai/np2kai.html
MIT License
260 stars 61 forks source link

Libretro - Compilation failure on Emscripten #85

Open inactive123 opened 4 years ago

inactive123 commented 4 years ago

Hi there,

retroarch: [Status: fail] [recipes/emscripten/emscripten] [Finished: 2020-02-07 20:44:46.474131+00:00] [http://paste.libretro.com/191000]

Emscripten port is now broken and the problem with this platform is if one core is broken all compilation stops for all other cores after that point

Can a Travis job be setup for this so that compilation issues could be catched sooner?

AZO234 commented 4 years ago

I add to disable compile security (removing -fstack-protector option) for Emscripten build. Please pull my repo.

AZO234 commented 4 years ago

I saw RetroArch's emscripten port 2nd error. I fixed more. Please pull it.

Are emscripten's core libraries Static link Library?

inactive123 commented 4 years ago

Yes, they are statically linked.

Also, Emscripten DOES NOT support any threading at all. So I really think you will have to disable anything threading related and not even code it in for the Emscripten version. It won't work.

inactive123 commented 4 years ago

Did another git pull. We'll await how it goes now.

AZO234 commented 4 years ago

I fixed to remove all libretro's .c files compilation when build static library.

I'm sorry to work many times. Please pull this.

inactive123 commented 4 years ago

No problem, I hugely appreciate the upstream support.

I will pull again.

AZO234 commented 4 years ago

Looks like I have deleted too much. libretro.c has been added. Please pull.

And I'm sorry many times.

inactive123 commented 4 years ago

OK. Done.

Hopefully that fixes Switch as well.

AZO234 commented 4 years ago

I saw retroarch: [Status: fail] [recipes/emscripten/emscripten] [Finished: 2020-02-09 00:13:26.052519+00:00] [http://paste.libretro.com/191278]

I fixed to don't call semaphore API.

Please pull.

inactive123 commented 4 years ago

OK.

inactive123 commented 4 years ago

OK I did so.

Also, did the NP2Kai core ever work on PSP before? Or does NP2 Kai work on PSP right now?

Compilation error there too -

http://paste.libretro.com/191647

Perhaps if we can't get it to work we could disable it for PSP for now. Let me know.

AZO234 commented 4 years ago

I relieved.

It seems can be compiled with the current toolchain (pspthreadman.h). libretro-common expects that structure.

However, I will temporarily limit the function of PSP. Please wait a little.

AZO234 commented 4 years ago

I modified to disable rthread on PSP (and Emscripten). Please pull.

inactive123 commented 4 years ago

All changes pulled.

AZO234 commented 4 years ago

It seem worked good. Thank you!

yksoft1 commented 4 years ago

Should I continue my SDL2 emscripten port when there is Libretro emscripten port?

AZO234 commented 4 years ago

Libretro already have Emscripten port. (yksoft1-san's code was very helpful.) NP2kai core is as dynamic link bytecode.

Of course, I very interest NP2kai native Emscripten port!

AZO234 commented 4 years ago

Hi, sorry to long time no see.

I'm trying merge forked NP2kai source again. My goal is to write CMakeList.txt.

Before that, I wanted to see your Emscripten features. I put files to 'emscripten' branch.

I could merge and generate .js file, but .html file from make. Should I do to work this?

yksoft1 commented 4 years ago

Hi, sorry to long time no see.

I'm trying merge forked NP2kai source again. My goal is to write CMakeList.txt.

Before that, I wanted to see your Emscripten features. I put files to 'emscripten' branch.

I could merge and generate .js file, but .html file from make. Should I do to work this?

Did you specify "html" target when using Makefile21.em? without that, no .js/.wasm/.html files would be generated, only a large Emscripten module (np21kai.bc) would be generated.

To build sample Emscripten html with embedded data file mounted at Emscripten /:

make -f Makefile21.em html PRELOAD=1 PREFILE=/f/tmpweb/test1@/ TARGET=np21kai-test.bc -j4 (Replace /f/tmpweb/test1 with the path where your data file is at.)

To build .js/.wasm file for using Emularity loader:

make -f Makefile21.em html EMULARITY=1 -j4

You could change the default "all" target to also build "html" target at your convenience, or just rewrite the "all" target to generate html directly with $(OBJECTS) without that .bc file.

Note: You forgot #define RESOURCE_US in em compiler.h.

yksoft1 commented 4 years ago

Suggestion: Make fmgen optional. This doesn't sound any better than the ordinary NP2 OPNA emulator at all, requires a more uncommon OPNA rhythm data file set, and causes binaries to depend on a C++ runtime.

BTW: I built Emscripten files with the latest code in your emscripten tree, but Touhou 4 crashes in demo play. I also tried the game in Win32 sdl2 build with the same np21kai.cfg but the game didn't crash. image The game runs without such problem with my fork's emscripten build.

AZO234 commented 4 years ago

Thanks to replying. I'll try!

I used Makefile21.em to make. When make html, I got response follow.

emcc -O3 -s USE_SDL=2 -s WASM=1 -s TOTAL_MEMORY=67108864  -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 \
-s EMTERPRETIFY_WHITELIST="['_np2_main','_np2exec','_taskmng_sleep']" -s BINARYEN_TRAP_MODE="js" \
np21kai.bc -o np21kai.html 
emcc: error: BINARYEN_TRAP_MODE is not supported by the LLVM wasm backend
make: *** [Makefile21.em:106: html] Error 1

From NP2 policy, data inner chip cannot include code. Instead of, likely sound data can merge maybe.

Touhou 4 needs setting EMM386.EXE to CONFIG.SYS.

yksoft1 commented 4 years ago

Thanks to replying. I'll try!

I used Makefile21.em to make. When make html, I got response follow.

emcc -O3 -s USE_SDL=2 -s WASM=1 -s TOTAL_MEMORY=67108864  -s EMTERPRETIFY=1 -s EMTERPRETIFY_ASYNC=1 \
-s EMTERPRETIFY_WHITELIST="['_np2_main','_np2exec','_taskmng_sleep']" -s BINARYEN_TRAP_MODE="js" \
np21kai.bc -o np21kai.html 
emcc: error: BINARYEN_TRAP_MODE is not supported by the LLVM wasm backend
make: *** [Makefile21.em:106: html] Error 1

From NP2 policy, data inner chip cannot include code. Instead of, likely sound data can merge maybe.

Touhou 4 needs setting EMM386.EXE to CONFIG.SYS.

TH4 only need EMS for playing as Reimu as the game will crash at Yuka fight in Stage 5. EMS is not required if you play as Marisa.

I'm using the same HD image and np21kai.cfg in both Win32 and Emscripten builds. In Win32 it's all OK but in Emscripten I got that bug. so that crash is probably an Emscripten-only problem.

I have to use BINARYEN_TRAP_MODE="js" in my Emscripten environment (1.38.18) or the FPU emulation will be inaccurate. That option is not working anymore after Emscripten 1.39.0.

See: https://github.com/ocornut/imgui/issues/2877

AZO234 commented 4 years ago

Yuka fight in Stage 5

You are right! GAMER!

I tried with Emscripten 1.39.16. I could .html generate by my CMake script ('emcmake' branch), but could not run on 'emrun' with Ubuntu 20.04 Chromium(not Chrome) and Firefox.

'--verbose' seem not enough right with Chromium, And nothing😳 with Firefox.

I keep up trying.