mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-19 18:36:25 +00:00
Version 0.4.25
Co-authored-by: ElectronicsArchiver <85485984+ElectronicsArchiver@users.noreply.github.com>
This commit is contained in:
parent
aa32d25717
commit
508d0eeaa2
4 changed files with 484 additions and 201 deletions
44
README.md
44
README.md
|
@ -34,6 +34,8 @@ Example page: https://coldcast.org/games/1/Super-Mario-Bros
|
|||
|
||||
<p>demo: <a href='https://ethanaobrien.github.io/emulatorjs/'>https://ethanaobrien.github.io/emulatorjs/</a></p>
|
||||
|
||||
BETA site: https://emulatorjs.netlify.app/
|
||||
|
||||
## Where did I get this?
|
||||
|
||||
So I found this website called [emulatorjs](https://www.emulatorjs.com/) and I went into inspect and downloaded the resources. I removed the ad server, and made everything work within your own domain.
|
||||
|
@ -54,6 +56,14 @@ IF SOMETHING DOES NOT WORK - Please make an issue!! Include as many details as p
|
|||
|
||||
All roms can be zipped into a `.zip`, `.rar`, or `.7z` archive
|
||||
|
||||
|
||||
NETPLAY IS DISABLED BY DEFAULT. To enable, add this line to your code
|
||||
|
||||
```
|
||||
EJS_gameID = 1; // ID in your website, required for netplay.
|
||||
```
|
||||
|
||||
|
||||
## Supported systems!
|
||||
|
||||
| Supported Systems |
|
||||
|
@ -83,7 +93,7 @@ All roms can be zipped into a `.zip`, `.rar`, or `.7z` archive
|
|||
| [Arcade] |
|
||||
| [Atari 2600] |
|
||||
|
||||
## Tips
|
||||
## More Features
|
||||
|
||||
To customize the filename of save states, add the line of code below
|
||||
|
||||
|
@ -99,3 +109,35 @@ To add an ad to the play now screen, add the following line to your code
|
|||
```
|
||||
EJS_AdUrl = ''; //path to AD page
|
||||
```
|
||||
|
||||
<br>
|
||||
|
||||
To change the default color of the emulator interface, add the line below
|
||||
|
||||
```
|
||||
EJS_color = ''; //hex color id
|
||||
```
|
||||
You can set the color to a hex color code, for example `#FF0000` (red)
|
||||
|
||||
<br>
|
||||
|
||||
To start the emulator immediately, add this line to your code
|
||||
|
||||
```
|
||||
EJS_startOnLoaded = true;
|
||||
```
|
||||
This will start the emulator instantly
|
||||
Please note, the Audio cannot start until the user interacts with the page
|
||||
|
||||
<br>
|
||||
|
||||
To specify an exact path for a file, add this line to your code
|
||||
|
||||
```
|
||||
EJS_paths = {
|
||||
"fileName": "/somepath",
|
||||
"emulator.js": "https://example.com/emulator.js",
|
||||
"n64-asmjs.data": "/asdfds.data"
|
||||
}
|
||||
```
|
||||
If a file is not defined, it be set to default
|
||||
|
|
559
data/emulator.js
559
data/emulator.js
File diff suppressed because one or more lines are too long
|
@ -1,8 +1,9 @@
|
|||
var VERSION = '0.4.25'
|
||||
fetch('https://raw.githack.com/ethanaobrien/emulatorjs/main/data/version.json').then(response => {
|
||||
if (response.ok) {
|
||||
response.text().then(body => {
|
||||
var version = JSON.parse(body);
|
||||
var usingVersion = '0.4.24';
|
||||
var usingVersion = VERSION;
|
||||
if (usingVersion != version.current_version) {
|
||||
console.log('Using emulatorjs version ' + usingVersion + ' but the newest version is ' + version.current_version + '\n\nopen https://github.com/ethanaobrien/emulatorjs to update');
|
||||
};
|
||||
|
@ -10,71 +11,18 @@ fetch('https://raw.githack.com/ethanaobrien/emulatorjs/main/data/version.json').
|
|||
};
|
||||
});
|
||||
|
||||
if (! window.EJS_pathtodata) {
|
||||
EJS_pathtodata = './'
|
||||
}
|
||||
var path2Send = EJS_pathtodata
|
||||
var finpath = window.location.pathname.split('/').pop();
|
||||
var finalpath = window.location.pathname.substring(0, window.location.pathname.length - finpath.length);
|
||||
var split3 = finalpath.split('/')
|
||||
var split2 = path2Send.split('/')
|
||||
var split1 = [ ]
|
||||
for (var i=0; i<split3.length; i++) {
|
||||
if (split3[i] != '') {
|
||||
split1.push(split3[i])
|
||||
}
|
||||
}
|
||||
if (! path2Send.startsWith('/') && path2Send.split('://').length == 1 && path2Send.split('http:').length == 1 && path2Send.split('https:').length == 1) {
|
||||
for (var w=0; w<split2.length; w++) {
|
||||
if (split2[w] == '' || split2[w] == '.') {
|
||||
} else if (split2[w] == '..') {
|
||||
if (split1.length > 0) {
|
||||
var split1 = split1.splice(-1,1)
|
||||
}
|
||||
} else {
|
||||
split1.push(split2[w])
|
||||
}
|
||||
}
|
||||
var path2Send = split1.join('/')
|
||||
if (! path2Send.startsWith('/')) {
|
||||
var path2Send = '/' + path2Send
|
||||
}
|
||||
path2Send = window.location.protocol + '//' + window.location.host + path2Send
|
||||
EJS_pathtodata = path2Send
|
||||
}
|
||||
if (EJS_pathtodata.startsWith('/')) {
|
||||
EJS_pathtodata = window.location.protocol + '//' + window.location.host + path2Send
|
||||
}
|
||||
|
||||
if (!EJS_pathtodata.endsWith('/')) {
|
||||
EJS_pathtodata = EJS_pathtodata+'/'
|
||||
}
|
||||
console.log('Path to data is set to ' + EJS_pathtodata)
|
||||
|
||||
window.readAsBufferrr = function(fileBlob) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var reader = new FileReader()
|
||||
reader.onload = function(e) {
|
||||
resolve(e.target.result)
|
||||
}
|
||||
reader.readAsArrayBuffer(fileBlob)
|
||||
})
|
||||
}
|
||||
|
||||
window.EJS_loadStateFromURL = async function() {
|
||||
if (! window.EJS_loadStateURL) {return}
|
||||
var a = await fetch(EJS_loadStateURL)
|
||||
var a = await a.blob()
|
||||
var a = await readAsBufferrr(a)
|
||||
var a = new Uint8Array(a)
|
||||
EJS_loadState(a)
|
||||
}
|
||||
|
||||
|
||||
var emulatorjs = document.createElement('script')
|
||||
var scriptTag = document.getElementsByTagName('script')[0]
|
||||
emulatorjs.async = true
|
||||
emulatorjs.src = EJS_pathtodata + 'emulator.js?v=' + '0.4.24'
|
||||
emulatorjs.src = function() {
|
||||
if ('undefined' != typeof EJS_paths && typeof EJS_paths['emulator.js'] == 'string') {
|
||||
return EJS_paths['emulator.js']
|
||||
} else if ('undefined' != typeof EJS_pathtodata) {
|
||||
return EJS_pathtodata + 'emulator.js?v=' + VERSION
|
||||
} else {
|
||||
return 'emulator.js?v=' + VERSION;
|
||||
}
|
||||
}()
|
||||
scriptTag.parentNode.insertBefore(emulatorjs, scriptTag)
|
||||
emulatorjs.onload = function() {
|
||||
var config = {};
|
||||
|
@ -85,13 +33,17 @@ emulatorjs.onload = function() {
|
|||
'undefined' != typeof EJS_gameParentUrl && (config.gameParentUrl = EJS_gameParentUrl)
|
||||
'undefined' != typeof EJS_gamePatchUrl && (config.gamePatchUrl = EJS_gamePatchUrl)
|
||||
'undefined' != typeof EJS_AdUrl && (config.adUrl = EJS_AdUrl)
|
||||
config.system = EJS_core
|
||||
'undefined' != typeof EJS_paths && (config.paths = EJS_paths)
|
||||
'undefined' != typeof EJS_startOnLoaded && (config.startOnLoad = EJS_startOnLoaded)
|
||||
'undefined' != typeof EJS_core && (config.system = EJS_core)
|
||||
'undefined' != typeof EJS_loadStateURL && (config.loadStateOnStart = EJS_loadStateURL)
|
||||
config.onsavestate = null
|
||||
config.onloadstate = null
|
||||
'undefined' != typeof EJS_onSaveState && (config.onsavestate = EJS_onSaveState)
|
||||
'undefined' != typeof EJS_onLoadState && (config.onloadstate = EJS_onLoadState)
|
||||
'undefined' != typeof EJS_lightgun && (config.lightgun = EJS_lightgun)
|
||||
'undefined' != typeof EJS_gameName && (config.gameName = EJS_gameName)
|
||||
'undefined' != typeof EJS_pathtodata && (config.dataPath = EJS_pathtodata)
|
||||
'undefined' != typeof EJS_mouse && (config.mouse = EJS_mouse)
|
||||
'undefined' != typeof EJS_multitap && (config.multitap = EJS_multitap)
|
||||
'undefined' != typeof EJS_playerName && (config.playerName = EJS_playerName)
|
||||
|
|
|
@ -1 +1 @@
|
|||
{ "current_version": "0.4.24"}
|
||||
{ "current_version": "0.4.25"}
|
||||
|
|
Loading…
Reference in a new issue