Alon, thanks for clarification.
Floh, very interesting!
> What are you using the asyncify changes for? Just for "slicing up" the execution loop into frames, or also for other things?
I am using it just for slicing, to prevent browser freeze. I think
that emulation flow of js-dos is very similar:
- emulation and rendering happens inside infinite loop. Function of
this loop can call it self recursively, this is reason why it's not
easy to use emscripten frame callback instead of asyncify. So this
loop is paused by asyncify each 16ms (1 frame), and then resumes
execution with post message call. setTimeout is not so effective (min
interval is 4ms). This execution flow have simmilar performance that
emulation through emscripten frame callback.
- inside each frame js-dos tries to emulate N instructions. This N is
defined config or can be calculated automatically based on host
performance. Of course real count of emulated instructions is clamped
to fit 16 ms interval. In "auto" mode, js-dos used simple algorithm to
compare how many instructions is executed and increase of decrease N
dynamically.
- emulation updates SDL pixel buffer, that rendered to canvas. updates
is smart, only changed parts are updated (not sure that it's have
effect on emscripten sdl implementation, guess all canvas is updated
each time)
- sound emulation is made by sdl mixer callback, again it's memory
buffer that updated each frame, and pushed to emscripten sdl
implementations (which used AudioNode). this is not very good,
sometimes sound can lag.
- mouse and keyboard input are made through emscripten sdl impelementation.
Actually, I really want to drop SDL and replace it with something
ligther like your sokol abstraction. Not sure that it will give better
performance, but I think code will be much easier to understand. To do
this I plan to add messages abstraction, to have chance to switch to
workers/WASI env if needed.
I also have no idea how to increse performance more. Original dos box
have "dynamic core" that recompiles program to host CPU (x86), but it
used a lot of assembler code, that can't be compiled with WebAssembly,
and I don't understand it very well yet. Maybe there is some way to
make "dynamic core" for WebAssembly.
Also, do you think that future SMID support can increase performance
of emulator? All emulated cpu instructions are emulated one by one, so
looks SMID is also useless.
пт, 17 янв. 2020 г. в 00:35, Alon Zakai <
alon...@gmail.com>:
> To view this discussion on the web visit
https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpR%3Di102C76Gp2NeDbHGv93j_XDgRW_EnEOSVoBX_h5diQ%40mail.gmail.com.