web player works faster if monitor refresh rate > 60Hz #512

This commit is contained in:
BADIM-PC\Vadim 2018-01-21 17:28:28 +03:00
parent e77f825dcc
commit eeed981c6c
2 changed files with 24 additions and 3 deletions

View File

@ -3,6 +3,7 @@ window.addEventListener("keydown", function(e)
if((e.ctrlKey && [82].indexOf(e.keyCode) > -1) || ([8, 27, 33, 34, 35, 36, 37, 38, 39, 40, 122, 58, 59, 60, 61, 62].indexOf(e.keyCode) > -1)) e.preventDefault();
}, false);
Module.printErr = function(){}
Module.saveAs = Module.saveAs||function(e){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var t=e.document,n=function(){return e.URL||e.webkitURL||e},r=t.createElementNS("http://www.w3.org/1999/xhtml","a"),o="download"in r,i=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},a=/constructor/i.test(e.HTMLElement),f=/CriOS\/[\d]+/.test(navigator.userAgent),u=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},d="application/octet-stream",s=1e3*40,c=function(e){var t=function(){if(typeof e==="string"){n().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,s)},l=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(i){u(i)}}}},p=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},v=function(t,u,s){if(!s){t=p(t)}var v=this,w=t.type,m=w===d,y,h=function(){l(v,"writestart progress write writeend".split(" "))},S=function(){if((f||m&&a)&&e.FileReader){var r=new FileReader;r.onloadend=function(){var t=f?r.result:r.result.replace(/^data:[^;]*;/,"data:attachment/file;");var n=e.open(t,"_blank");if(!n)e.location.href=t;t=undefined;v.readyState=v.DONE;h()};r.readAsDataURL(t);v.readyState=v.INIT;return}if(!y){y=n().createObjectURL(t)}if(m){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}v.readyState=v.DONE;h();c(y)};v.readyState=v.INIT;if(o){y=n().createObjectURL(t);setTimeout(function(){r.href=y;r.download=u;i(r);h();c(y);v.readyState=v.DONE});return}S()},w=v.prototype,m=function(e,t,n){return new v(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){return function(e,t,n){t=t||e.name||"download";if(!n){e=p(e)}return navigator.msSaveOrOpenBlob(e,t)}}w.abort=function(){};w.readyState=w.INIT=0;w.WRITING=1;w.DONE=2;w.error=w.onwritestart=w.onprogress=w.onwrite=w.onabort=w.onerror=w.onwriteend=null;return m}(typeof self!=="undefined"&&self||typeof window!=="undefined"&&window||this.content);if(typeof module!=="undefined"&&module.exports){module.exports.saveAs=saveAs}else if(typeof define!=="undefined"&&define!==null&&define.amd!==null){define([],function(){return saveAs})};
Module.showAddPopup = function(callback)
{

View File

@ -2740,6 +2740,8 @@ static void onFSInitialized(FileSystem* fs)
studio.renderer = SDL_CreateRenderer(studio.window, -1,
#if defined(__CHIP__)
SDL_RENDERER_SOFTWARE
#elif defined(__EMSCRIPTEN__)
SDL_RENDERER_ACCELERATED
#else
SDL_RENDERER_ACCELERATED | (getConfig()->useVsync ? SDL_RENDERER_PRESENTVSYNC : 0)
#endif
@ -2754,13 +2756,30 @@ static void onFSInitialized(FileSystem* fs)
#define DEFAULT_CART "cart.tic"
void onEmscriptenWget(const char* file)
static void onEmscriptenWget(const char* file)
{
studio.argv[1] = DEFAULT_CART;
createFileSystem(NULL, onFSInitialized);
}
void onEmscriptenWgetError(const char* error) {}
static void onEmscriptenWgetError(const char* error) {}
static void emstick()
{
static double nextTick = -1.0;
if(nextTick < 0.0)
nextTick = emscripten_get_now();
nextTick += 1000.0/TIC_FRAMERATE;
tick();
double delay = nextTick - emscripten_get_now();
if(delay < 0.0)
nextTick -= delay;
else
emscripten_set_main_loop_timing(EM_TIMING_SETTIMEOUT, delay);
}
#endif
@ -2778,7 +2797,8 @@ s32 main(s32 argc, char **argv)
}
else createFileSystem(NULL, onFSInitialized);
emscripten_set_main_loop(tick, TIC_FRAMERATE, 1);
emscripten_set_main_loop(emstick, TIC_FRAMERATE, 1);
#else
createFileSystem(argc > 1 && fsExists(argv[1]) ? fsBasename(argv[1]) : NULL, onFSInitialized);