Play AGS Games via browser

Started by Sledgy, Sun 04/10/2020 20:13:08

Previous topic - Next topic

Crimson Wizard

Do command line args work in browser version, or it's a non-thing there?

cat

I mostly noticed because I have an in-game option to switch language in two of my games.
I just realised that I can upload multiple files with your link - I also uploaded the translation file and it works  8-0

This is so amazing! Just to understand what you did - you took the engine source code and just used a tool to compile it to web assembly?

eri0o

#22
Quote from: Crimson Wizard on Thu 12/11/2020 18:05:14
Do command line args work in browser version, or it's a non-thing there?

Yes, I can pass command line things there. The game starts "windowed" because I pass the windowed option :)

Calling main and passing parameters has helping functions, but technically any function from the cpp code can be exposed and called and it's possible to pass objects between JS and cpp. The call to main can be seen  here and here. Passing parameters to other functions requires a bit more work but they are doable too.

Quote from: cat on Thu 12/11/2020 19:04:20
I mostly noticed because I have an in-game option to switch language in two of my games.
I just realised that I can upload multiple files with your link - I also uploaded the translation file and it works  8-0

This is so amazing! Just to understand what you did - you took the engine source code and just used a tool to compile it to web assembly?

Basically, there are some other minor adjustments but the gist was that. :)

Crimson Wizard

Quote from: eri0o on Thu 12/11/2020 19:36:21
Yes, I can pass command line things there. The game starts "windowed" because I pass the windowed option :)

Calling main and passing parameters has helping functions, but technically any function from the cpp code can be exposed and called and it's possible to pass objects between JS and cpp. The call to main can be seen  here and here. Passing parameters to other functions requires a bit more work but they are doable too.

No, I mean, is it possible to do for end-user (player)?

I guess for better experience it needs some kind of setup overlay though.

eri0o

#24
Uhm. Then in this case no. I can add my agsconfig thing and use it or just redo winsetup using one of the Engine renderers at some default resolution, then it would run - either with current Engine GUI components or adding ImGui.

Alternatively, I could create a JS/html Gui for editing acsetup.cfg, before running. It's mostly about figuring out what would work best - which I am not sure, but open to any ideas. :) (I think the biggest problem with the JS/HTML GUI is I am not good at it)

eri0o

Quote from: Creamy on Sat 07/11/2020 23:06:48
The MIDI tunes from Oh du lieber Augustin are playing but with incorrect samples.

Hey Creamy, do you have this game somewhere? The download link is not working for me!

arj0n


Monsieur OUXX

#27
Can you briefly explain wat we're supposed to see in @eri0o's thing when the upload works? I don't get it. I click upload, I get some debug logging on the right side of the screen, and then nothing. I tried a few games, always the same.


That was some time ago. Today I just tried and it works!!! (Too bad our game cannot actually run on this as it relies on mandatory translation files :/ )
 

arj0n

Is OpenGL or DX set as driver for the game mandatory to get it working with https://ericoporto.github.io/agsjs/?
When using Software Renderer as driver it doesn't seem to work:

Code: ags

14:16:28:980: Adventure Game Studio v3.5 Interpreter
14:16:28:986: Copyright (c) 1999-2011 Chris Jones and 2011-2020 others
14:16:28:986: ACI version 3.5.1.0
14:16:28:987: 
14:16:28:987: Initializing allegro
14:16:28:990: Initializing game data
14:16:28:991: Opened game data file: game28.dta
14:16:28:992: Game data version: 50
14:16:28:992: Compiled with: 3.5.0.27
14:16:28:993: Setting up game configuration
14:16:28:995: Logging to warnings.log
14:16:28:995: Data directory: /
14:16:28:997: Setting up window
14:16:28:998: Initializing TTF renderer
14:16:28:999: Initializing mouse: number of buttons reported is 3
14:16:28:999: Install timer
14:16:29:056: Opened "Emscripten OpenAL"
14:16:29:058: Install exit handler
14:16:29:059: Initialize path finder library
14:16:29:061: Game GUI version: 119
14:16:29:063: Requested script API: v3.5.0.7 (7), compat level: v3.5.0.7 (7)
14:16:29:088: Game title: 'Barahir-8-bit'
14:16:29:089: Checking for disk space
14:16:29:090: Game native resolution: 320 x 240 (8 bit)
14:16:29:091: Graphic settings: driver: OGL, windowed: yes, screen def: scaling, screen size: 0 x 0, match device ratio: ignore, game scale: max_round
14:16:29:091: Failed to init gfx mode. Error: OpenGL driver does not support 256-color display mode
14:16:29:092: There was a problem finding and/or creating valid graphics mode for game size 320 x 240 (8-bit) and requested filter 'StdScale'.
14:16:29:092: (Problem: 'OpenGL driver does not support 256-color display mode')
14:16:29:093: Try to correct the problem, or seek help from the AGS homepage.

arj0n


Crimson Wizard

#30
arjon, it's only OpenGL (or WebGL?), because it runs in browser.

arj0n

Quote from: Crimson Wizard on Mon 14/12/2020 13:30:40
arjon, it's only OpenGL (or WebGL?), because it runs in browser.
Ah, thanx for the clarification.

eri0o

#32
@Monsieur OUXX, what you mean? Have you tried adding all files in it, including the translation files? What happened? Translation has to be selected by handwriting it in the acsetup.cfg for now.

@arj0n, behind the scenes it uses WebGL, but there are both the OpenGL renderer and the Software renderer ported. I am not familiar with 256 bit games, can you link me one of them so I can try it? Also thanks for the other game. If you want to try to force Software, just write driver = Software (I think that is it at least) in the  acsetup.cfg file and add it toget with your game when uploading and it should work.

There will be soon an update to this JS version of the Engine using a better code with less of my adaptations that will hopefully work better. :)

The idea of the one to push games (launcher) is to test own games, and find bugs, and the single game version would be to release said games (if they work).

Snarky

I just wanted to say that this is very cool!

Bòógieman

#34
this is soooo awesome!  8-0 :-*
just tried it with my old AGS2.7.2 game and it works great (Firefox and "Samsung Internet" on Android)
except for MIDI, I can hear something but it is way to slow and completely out of tune  :~(
also the "fade out - fade in" effect I used for room changes seems to just invert the colors before leaving the room
this is the game if you want to try it yourself: Maniac Mansion Mania Episode 53
>>>> END OF LINE <<<<

eri0o

@Snarky Thanks!  :-D

@Bòógieman, the fade out and fade in inverted colors is my error, I will fix it. Thanks for spotting it!

I recommend not using MIDI in new games. There are other formats that AGS supports that ship their own soundfonts on the track if tracker format is absolutely desired - next version will have some fixes for modplug tracker too. The midi errors, so far from my tests, appear to be in JS code, I think I will endup modifying Emscripten (the JS libraries part) to use a different backend for midi, but need more testing yet. But it should be possible to fix eventually - just a lot of work.

Manu

Hi @eri0o
This is simply fantastic! I just tried my (work-in-progress) mini-game, I played it for a while and it works perfectly.
I just have one problem with the initial cutscene. It seems like the js version does not wait when the characters are talking, and it just skips to the end of the cutscene.

The code is like that:

Code: ags

function room_AfterFadeIn()
StartCutscene(eSkipESCOrRightButton);
cBene.SayAt(10, 40, 300, "bla bla bla");
cBene.SayAt(10, 40, 300, "bla bla bla");
 ...
EndCutscene();
mouse.Visible=true;
gIconbar.Visible=true;
gStatusline.Visible=true;
player.ChangeRoom(1, 164, 170);
cBene.ChangeRoom(1, 280, 170);


On Windows, it's working: room appears, the character says everything, and then the game opens the main room. But on the JS version, the cutscene room appears for a second, and then the characters go room#1, you don't see her talking. Do you know why? Is there any workaround?
Thanks!

eri0o

#37
Hi @emabolo!

I have some guesses, I can try to offer a different build of this in the weekend to see if it's fixed. AGS has a bunch of inner game loops that make a bit hard to properly sync the engine and the browser so I use a tool that unrolls this to fake having a single game loop - it mostly works fine though. I wonder if this may be a problem.

Not that long ago, Creamy reported a similar problem with Phylactere module. I am currently working on an Android build of the Engine using the SDL2 port, once it's done, I will start more serious work on this JS/WASM/WebGL port.

About the cutscene may I ask how it's being skipped? I mean, are you actually using Start and End cutscene commands around the cutscene or when you say cutscene you mean just a game dialog? My guess is if it accepts any key, some key is fakely being sent by accident, so if it's the case, I would ask to try to accept only mouse clicks.

@Creamy the MIDI problem has been tracked down, but not sure when a fix will be available - it's in the library in use for playing the sound files for all formats (the good news is the library is still in active development and fixes are being worked on). :/

Spoiler
[close]

Manu

#38
I tried to comment StartCutscene and EndCutscene and it's the same. The room fades in and fades out, the character doesn't even start talking.

I discovered that the reason is the room has the property ShowPlayerCharacter = FALSE. If I set it to TRUE, everything works normally (apart from the fact that I didn't want the character to appear :)
With False, it seems the code ignores everything and goes to the end.

EDIT: I solved it by setting ShowPlayerCharacter = TRUE, and adding "cEgo.on=0;" inside room_Load(). Now it's perfect!

I hope you will continue working on it, this is a great way to distribute the games, for small ones like mine, probably the best way.
Thanks a lot!

eri0o

#39
Hey, since people really liked this (thanks for the award everyone!) I decided to do a new port.

AGS Web Player (3.6.0 Alpha) ericoporto.github.io/agsjs/3_6_0/index.html

Above is based on code synced with the 3.6.0 Alpha version instead (a comparison here, the repo is github.com/ericoporto/ags/tree/ags3--sdl2--emscripten.

The Software Driver Fullscreen mode is broken but this should not be a problem if your game uses the OGL driver. The software driver is working embedded - there's a lot of change on the fullscreen handling and AFAICT is the only thing that broke (I will eventually fix...) , nevermind, Crimson Wizard fixed it!

As before Alt+Enter toggles fullscreen - same as normal AGS. I will try to revamp the HTML so it's prettier and add some sort of preferences menu, but the idea of this build was to sync to current SDL port that is a bit different on how it was in this version.

building from source note: Building with Emscripten 2.0.16 it works everywhere but has slightly performance issues and has "resting finger bug" (game runs faster when finger is touching the screen), this is the version available above.
Building with latest Emscripten (Tip of Tree), fixes the "resting finger bug" and performance is much improved, but crashes on Chrome Mobile (works everywhere else apparently), so this is why I am not building with the latest version of Emscripten.

notes:

  • this version apparently has a bug that eventually crashes my chrome browser on my phone, but I can't reproduce this on my desktop and the crash on the phone also crashes the chrome debug tools so I can't pickup what's going on :/ It doesn't crash on Firefox mobile so I can't use it's tools instead :( fixed
  • Also, apparently there's some change in the FreeType used by AGS, unfortunate building FreeType to WASM is super hard and I can't figure out, for now I am using a prebuilt FreeType from Emscripten itself, but it's an older version that is different from the one used by AGS and some fonts will render wrong.
  • The game FreakChic is working on this version, the dialog from Phylactere is no longer automatically skipped (previous bug reported by Creamy here).
  • MIDI output is mute in the games I tested, probably need a sound font but using one makes the size huuuge, so I probably won't fix this.
  • resting finger bug, previous version would run slightly faster if the finger was resting on the mobile screen than if wasn't, this one doesn't have this bug. I haven't tracked down why it happened but I think it may be related to the crash on Chrome mobile that is happening in this version. got this bug back
  • why is audio not using multithread?, multithread in JS (pthreads) will require https and some server header configs (coop and coep), I explain a bit here on itch.io, I could not get answer for GitHub pages though. So for now it would be best to make the audio single thread for maximum host compatibility.

There are currently some out of AGS bugs that needs to be fixed. If you try to build the ags js code locally and it doesn't work, it's probably one of these. I applied all fixes for the issues below manually for now.


Because I am using GitHub Pages, the caching is agressive, so if you tried the previous version that crashed on mobile before, you will need to refresh a lot or load with an anonymous session to update to the newer version.

SMF spam blocked by CleanTalk