-
Notifications
You must be signed in to change notification settings - Fork 402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mobile test version #79
Open
nenge123
wants to merge
5
commits into
BinBashBanana:master
Choose a base branch
from
nenge123:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ad9ab1b
Mobile test version
nenge123 483dd84
Mobile test version
nenge123 9252496
Mobile,add cheat code/cache manger/shader/volume
nenge123 9e3ea89
ios pointerdown cant import => click
nenge123 b39a1a4
add mobile.md/clear html log status/fix sound bug
nenge123 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
How to use | ||
====== | ||
>exmple:[**Official Instance**](https://binbashbanana.github.io/webretro/m.html) | ||
|
||
way 1 | ||
===== | ||
```html | ||
<div id="emu-webretro" class="webretro" style="position: fixed;width:100%;height: 100%;"></div> | ||
<script type="text/javascript" src="https://binbashbanana.github.io/webretro/assets/Mobile/Module.js"></script> | ||
|
||
``` | ||
way 2 | ||
==== | ||
```html | ||
<div id="emu-webretro" class="webretro" style="position: fixed;width:100%;height: 100%;"></div> | ||
<script type="text/javascript"> | ||
var emu_system = ""; | ||
var emu_rom = ""; | ||
var emu_bios = []; | ||
</script> | ||
<script type="text/javascript" src="https://binbashbanana.github.io/webretro/assets/Mobile/Module.js"></script> | ||
|
||
``` | ||
|
||
way3 | ||
==== | ||
```html | ||
<div id="emu-webretro" class="webretro" style="position: fixed;width:100%;height: 100%;"></div> | ||
<script type="text/javascript" src="https://binbashbanana.github.io/webretro/assets/Mobile/Module.js?rom=xx.gbc&system=mgba"></script> | ||
|
||
``` | ||
|
||
way4 | ||
==== | ||
> yousite/m.html?rom=xx.gbc&system=mgba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
; | ||
function _RWebAudioStart() { | ||
Module.CF('resume'); | ||
return true | ||
} | ||
function _RWebAudioInit(latency) { | ||
RA.numBuffers = latency * RA.context.sampleRate / (1e3 * RA.BUFFER_SIZE) | 0; | ||
if (RA.numBuffers < 2) RA.numBuffers = 2; | ||
for (var i = 0; i < RA.numBuffers; i++) { | ||
RA.buffers[i] = RA.context.createBuffer(2, RA.BUFFER_SIZE, RA.context.sampleRate); | ||
RA.buffers[i].endTime = 0 | ||
} | ||
RA.nonblock = false; | ||
RA.startTime = 0; | ||
RA.context.createGain(); | ||
window["setTimeout"](RA.setStartTime, 0); | ||
Module["pauseMainLoop"](); | ||
return 1 | ||
} | ||
function findEventTarget(target) { | ||
target = maybeCStringToJsString(target); | ||
if(target=="#canvas") return Module.canvas; | ||
var domElement = specialHTMLTargets[target] || (typeof document !== "undefined" ? document.querySelector(target) : undefined); | ||
return domElement | ||
} | ||
|
||
if (!Module.cwrap) { | ||
let ccall = function ccall(ident, returnType, argTypes, args, opts) { | ||
var toC = { | ||
string: (str) => { | ||
var ret = 0; | ||
if (str !== null && str !== undefined && str !== 0) { | ||
var len = (str.length << 2) + 1; | ||
ret = stackAlloc(len); | ||
stringToUTF8(str, ret, len); | ||
} | ||
return ret; | ||
}, | ||
array: (arr) => { | ||
var ret = stackAlloc(arr.length); | ||
writeArrayToMemory(arr, ret); | ||
return ret; | ||
}, | ||
}; | ||
|
||
function convertReturnValue(ret) { | ||
if (returnType === "string") { | ||
return UTF8ToString(ret); | ||
} | ||
if (returnType === "boolean") return Boolean(ret); | ||
return ret; | ||
} | ||
var func = Module['_'+ident]; | ||
var cArgs = []; | ||
var stack = 0; | ||
if (args) { | ||
for (var i = 0; i < args.length; i++) { | ||
var converter = toC[argTypes[i]]; | ||
if (converter) { | ||
if (stack === 0) stack = stackSave(); | ||
cArgs[i] = converter(args[i]); | ||
} else { | ||
cArgs[i] = args[i]; | ||
} | ||
} | ||
} | ||
var ret = func.apply(null, cArgs); | ||
|
||
function onDone(ret) { | ||
if (stack !== 0) stackRestore(stack); | ||
return convertReturnValue(ret); | ||
} | ||
ret = onDone(ret); | ||
return ret; | ||
}; | ||
Module.cwrap = function cwrap(ident, returnType, argTypes, opts) { | ||
argTypes = argTypes || []; | ||
var numericArgs = argTypes.every(function (type) { | ||
return type === "number" | ||
}); | ||
var numericRet = returnType !== "string"; | ||
if (numericRet && numericArgs && !opts) { | ||
return Module['_' + ident]; | ||
} | ||
return function () { | ||
return ccall(ident, returnType, argTypes, arguments, opts) | ||
} | ||
}; | ||
} | ||
var GLOBAL_BASE, RI, RA, MEMFS, FS; | ||
Module.setMEMFS(MEMFS, FS, RA, GLOBAL_BASE); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
const Module = new class{ | ||
noInitialRun = true; | ||
arguments = ["-v", "--menu"]; | ||
preRun = []; | ||
postRun = []; | ||
totalDependencies = 0; | ||
serviceVersion = 'cache_v1'; | ||
version = 'v6.5'; | ||
JSversion = 1; | ||
elmid = '#emu-webretro'; | ||
bundleCdn = "https://cdn.jsdelivr.net/gh/BinBashBanana/webretro@master/"; | ||
bundleCdnLatest = "https://cdn.jsdelivr.net/gh/BinBashBanana/webretro/"; | ||
biosCdn = "https://cdn.jsdelivr.net/gh/archtaurus/RetroPieBIOS@master/BIOS/"; | ||
action={}; | ||
isLocal = /^(127|localhost|172)/.test(location.host) | ||
constructor(T){ | ||
const M=this; | ||
M.JSURLINFO = document.currentScript && document.currentScript.src.split('?'); | ||
M.JSpath = (M.JSURLINFO||[''])[0].split('/').slice(0, -1).join('/') + '/'; | ||
if(!T){ | ||
let script = document.createElement('script'); | ||
script.src = M.JSpath+'common.min.js'; | ||
document.addEventListener('NengeReady',e=>{ | ||
console.log(e); | ||
M.RunSart(e.detail); | ||
M.installStart(); | ||
|
||
}) | ||
document.body.appendChild(script); | ||
}else{ | ||
M.RunSart(T); | ||
T.docload(e=>M.installStart(T)); | ||
} | ||
} | ||
RunSart(T){ | ||
const M=this, I = T.Set(M),ElmBody = T.$(M.elmid); | ||
T.DB_NAME = 'webretro_mobile'; //定义 indexdb name | ||
T.LibStore = 'data-libjs'; //定义 储存js文件表 | ||
T.version = 1; | ||
T.DB_STORE_MAP = { //所有表 | ||
'data-roms': {system: false}, | ||
'data-system': {version:false}, | ||
'data-bios': {system: false}, | ||
'data-config': {timestamp: false}, | ||
'data-userdata': {timestamp: false}, | ||
'data-libjs': {}, | ||
} | ||
ElmBody.classList.add('emu-container'); | ||
ElmBody.classList.add('emu-'+T.i18nName); | ||
ElmBody.innerHTML = | ||
`<div class="emu-welcome"><h3 id="emu-status"></h3><img id="emu-logo" src="${(M.JSpath+'zan.jpg')}"><div id="emu-welcome-result"></div></div> | ||
<div class="emu-screen" hidden><canvas id="canvas" class="texturePixelated"></canvas></div> | ||
<div class="emu-resume" hidden></div> | ||
<div class="emu-settings" hidden></div> | ||
<div class="emu-controls" hidden> </div> | ||
<div class="emu-dialog" hidden></div>`; | ||
|
||
} | ||
async installStart(){ | ||
let M = this,T=M.T,I=T.I,isInit=!0,status = '#emu-status'; | ||
I.toArr(await indexedDB.databases(),entry=>{ | ||
if(entry['name']==T.DB_NAME)isInit = !1; | ||
}); | ||
var assets = (M.JSpath).split('/').slice(0, -2).join('/') + '/'; | ||
M.URL_PATH = { | ||
root:M.isLocal?M.JSpath:M.bundleCdnLatest+'Mobile/', | ||
assets:M.isLocal?assets:M.bundleCdnLatest+'assets/', | ||
cores:M.isLocal?assets+'cores/':M.bundleCdnLatest+'cores/', | ||
bios:M.isLocal?assets+'bios/':M.biosCdn | ||
}; | ||
var ROOT = M.URL_PATH,version = M.isLocal?undefined:M.JSversion; | ||
T.lang = await T.FetchItem({ | ||
url:ROOT['root']+'i18n/'+T.i18nName+'.json?'+T.time, | ||
process:e=>T.$(status).innerHTML = e, | ||
type:'json', | ||
version | ||
}); | ||
/* | ||
if(isInit){ | ||
await T.FetchItem({ | ||
url:ROOT['root']+'zip/base.zip', | ||
key:T.F.LibKey, | ||
store:T.LibStore, | ||
unpack:true, | ||
process:e=>T.$(status).innerHTML = e, | ||
}); | ||
} | ||
*/ | ||
if(M.isLocal){ | ||
await T.addJS(ROOT['root']+'Module_Start.js?'+T.time); | ||
if(!T.$('link[rel="stylesheet"]')){ | ||
await T.addScript( | ||
ROOT['root']+'webretro.css', | ||
{ | ||
process:e=>T.$(status).innerHTML = e, | ||
version | ||
} | ||
); | ||
} | ||
}else{ | ||
//await T.loadLibjs(ROOT['root']+'Module_Start.min.zip',e=>T.$(status).innerHTML = e,version); | ||
await T.addScript( | ||
ROOT['root']+'webretro.css', | ||
{ | ||
process:e=>T.$(status).innerHTML = e, | ||
version | ||
} | ||
); | ||
//await T.loadLibjs(ROOT['root']+'nipplejs.js',e=>T.$(status).innerHTML = e,version); | ||
//await T.loadLibjs(ROOT['root']+'gamepad.min.js',e=>T.$(status).innerHTML = e,version); | ||
await T.loadLibjs(ROOT['root']+'Module_Start.min.js',e=>T.$(status).innerHTML = e,version); | ||
} | ||
return; | ||
if(location.protocol=='http:') return; | ||
//var mobile_sw_version = localStorage.getItem('mobile_sw_version'); | ||
//if(!mobile_sw_version)localStorage.setItem('mobile_sw_version',M.version); | ||
if('serviceWorker' in navigator){ | ||
navigator.serviceWorker.register(ROOT['root']+'sw.js').then(worker=>{ | ||
/* | ||
if(mobile_sw_version != M.version){ | ||
worker.update(()=>{ | ||
localStorage.setItem('mobile_sw_version',M.version); | ||
}) | ||
} | ||
*/ | ||
}).catch(e=>console.log('reg errot',e)); | ||
navigator.serviceWorker.addEventListener('message', event => { | ||
console.log('sw msg', event); | ||
if(!M.serviceWorker)M.serviceWorker = event.source; | ||
M.CF('server_'+event.data.type,event.data); | ||
}); | ||
} | ||
} | ||
setMEMFS(MEMFS, FS, RA, GLOBAL_BASE) { | ||
var M = this,I=M.I; | ||
if (!M.MEMFS && MEMFS) I.defines(M, { | ||
MEMFS | ||
}, 1); | ||
if (!M.FS && FS) I.defines(M, { | ||
FS | ||
}, 1); | ||
if (!M.RA && RA) I.defines(M, { | ||
RA | ||
}, 1); | ||
if (!M.GLOBAL_BASE && GLOBAL_BASE) I.defines(M, { | ||
GLOBAL_BASE | ||
}, 1); | ||
} | ||
}(window.Nenge); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.