What happened to the Emscripten branch?

Emscripten, WASM, and asm.js related questions
Post Reply
VANYA
Posts: 1837
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: What happened to the Emscripten branch?

Post by VANYA »

Thanks for the file! Compilation runs smoothly , but I get an error when running in the browser:
Exception thrown, see JavaScript console
And in the javascript console:
exception thrown: SyntaxError: Document.querySelector: '0' is not a valid selector,findEventTarget@http://localhost:8000/FBFILE.js:7193:98
__registerKeyEventCallback@http://localhost:8000/FBFILE.js:7251:17
_emscripten_set_keypress_callback_on_thread@http://localhost:8000/FBFILE.js:7266:33
$4@http://localhost:8000/FBFILE.js:627:12
$9@http://localhost:8000/FBFILE.js:714:4
$2@http://localhost:8000/FBFILE.js:603:5
createExportWrapper/<@http://localhost:8000/FBFILE.js:6743:22
callMain@http://localhost:8000/FBFILE.js:8597:28
doRun@http://localhost:8000/FBFILE.js:8656:31
run/<@http://localhost:8000/FBFILE.js:8667:7
setTimeout handler*run@http://localhost:8000/FBFILE.js:8663:15
runCaller@http://localhost:8000/FBFILE.js:8575:19
removeRunDependency@http://localhost:8000/FBFILE.js:6646:7
receiveInstance@http://localhost:8000/FBFILE.js:6813:24
receiveInstantiatedSource@http://localhost:8000/FBFILE.js:6829:20
promise callback*instantiateArrayBuffer@http://localhost:8000/FBFILE.js:6835:8
instantiateAsync@http://localhost:8000/FBFILE.js:6861:14
createWasm@http://localhost:8000/FBFILE.js:6877:3
@http://localhost:8000/FBFILE.js:8332:11
Okay, I will not distract you anymore, it looks like the version for JS is still far from working. Unfortunately, I'm only good for testing, but it looks like it's still a long way off. Thanks for your work.
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: What happened to the Emscripten branch?

Post by angros47 »

Have you edited hinit.c as I showed you before?
Also, what have you tried to compile?

Try something basic like

Code: Select all

screenres 640,480
Print "Hello world"
VANYA
Posts: 1837
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: What happened to the Emscripten branch?

Post by VANYA »

Sorry, I really haven't updated the hinit.c file. Actually I made edits, but it looks like I forgot to save to file. Indeed, graphical commands began to work. Thank you for your patience!

I just don’t understand why V1ctor's program doesn’t exit when you press Esc. The key is caught, the END command is executed, but the program continues.
VANYA
Posts: 1837
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: What happened to the Emscripten branch?

Post by VANYA »

Looks like the "mainloop" function should run continuously? I see a solution like this:

Code: Select all

type em_callback_func as sub
#ifdef __FB_JS__
   declare sub emscripten_set_main_loop cdecl alias "emscripten_set_main_loop" (byval func as em_callback_func, byval fps as integer = 0, byval simulate_infinite_loop as integer = 0)
#else
sub emscripten_set_main_loop(byval func as em_callback_func, byval fps as integer = 0, byval simulate_infinite_loop as integer = 0)
   if fps = 0 then
      fps = 60
   end if
   
   do
      func()
      sleep 1000/fps
   loop
end sub
#endif

sub mainloop
    static iE as Long
    
    var k = inkey

    if( k = chr(27) ) andalso iE = 0 then
         iE = 1
         print "END!!!"
         END
    elseif iE = 0 then

        	print time
        	

    end if
end sub
screen 15
emscripten_set_main_loop @mainloop
In any case, it's already cool that you can adapt programs to HTML+JS.
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: What happened to the Emscripten branch?

Post by angros47 »

You are welcome!

What have you tried so far?

Anyway, I assume there is no real need for end for the program. If the program is running into a web page, it will end when you close the page, there is no need to end it before (what is it supposed to do after ending? Displaying a blank screen?)
VANYA
Posts: 1837
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: What happened to the Emscripten branch?

Post by VANYA »

What have you tried so far?
I'm trying different examples for now. When I tried to compile one of the simple games, I ran into a problem:

Code: Select all

screen 15

Dim TV As Integer

TV = 2 ^ (Int(Rnd * 2))
print TV
wasm-ld: error: symbol type mismatch: pow
Looks like a problem with the operator ^
VANYA
Posts: 1837
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: What happened to the Emscripten branch?

Post by VANYA »

There are still unavailable functions:

sin, cos.

In fact, I think there are many inaccessible functions, I just tried a little.

it is also impossible to create arrays without the shared specifier, for example, such a record will give an error:

Code: Select all

Dim X(500) As Integer
wasm-ld: error: symbol type mismatch: memset
D.J.Peters
Posts: 8586
Joined: May 28, 2005 3:28
Contact:

Re: What happened to the Emscripten branch?

Post by D.J.Peters »

Maybe you can help emscript by using more c-runtime function !

#include "crt.bi"
cosf(), sinf(), powf() ...

or

#undef cos
#undef sin
#include "crt.bi"
#define cos cos_
#define sin sin_
...

only an idea or workaround

Joshy
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: What happened to the Emscripten branch?

Post by angros47 »

Likely you are right, but at the moment we are trying to get the compiler to work, so using a workaround to get a test to work is not the best solution.

It looks like some module might not be linked properly
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: What happened to the Emscripten branch?

Post by angros47 »

That's weird:

Code: Select all

Dim X(15) as integer
works

Code: Select all

Dim X(16) as integer
returns error
VANYA
Posts: 1837
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: What happened to the Emscripten branch?

Post by VANYA »

D.J.Peters wrote:Maybe you can help emscript by using more c-runtime function !

#include "crt.bi"
cosf(), sinf(), powf() ...

or

#undef cos
#undef sin
#include "crt.bi"
#define cos cos_
#define sin sin_
...

only an idea or workaround

Joshy
This does not work. In all cases, an error appears like:
wasm-ld: error: symbol type mismatch: sinf
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: What happened to the Emscripten branch?

Post by angros47 »

VANYA
Posts: 1837
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: What happened to the Emscripten branch?

Post by VANYA »

angros47 wrote:Seems related to this, perhaps?
Unfortunately for me this is a dark forest. I do not know the specifics of compilers, interpreters, etc.
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: What happened to the Emscripten branch?

Post by angros47 »

Looks like it's possible to see the symbols of the .o file using llvm-nm, that is located in emsdk/upstream/bin/llvm-nm
Post Reply