Merge branch 'main' into main

This commit is contained in:
トトも 2022-01-13 16:30:06 -05:00 committed by GitHub
commit c441567863
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19638 additions and 19297 deletions

View file

@ -12,7 +12,7 @@ Self-hosted **Javascript** emulation for various system.
---
**⸢ [Example Use] ⸥ ⸢ [Emulator Demo] ⸥**
**⸢ [Example Use] ⸥ ⸢ [Emulator Demo] ⸥ ⸢ [Beta] ⸥**
---
@ -47,6 +47,7 @@ Self-hosted **Javascript** emulation for various system.
---
## Usage
*For questions please use the* ***[Issue]*** *tab.*
@ -64,19 +65,48 @@ Self-hosted **Javascript** emulation for various system.
<br>
##### BIOS
Some **Games** and **Systems** require <br>
a `BIOS`, though most usually ***don't***.
<br>
##### ROMs
**ROMs** can be used as `zip` / `rar` / `7z` archives.
<br>
##### Netplay
By default **Netplay** is ***disabled***, <br>
to enable it, add the following:
```js
// ID of your website, required for netplay.
EJS_gameID = 1;
```
*I have successfully rewrote the server side portion* <br>
*of netplay, which you can now use to self host!*
1. Download the **[Server]**.
2. Install **NPM**
```sh
npm install
```
3. Start the server with:
```sh
node index.js
```
4. Specify the servers address with:
```js
// Absolute Url To Your Netplay Server
EJS_netplayUrl = `http://localhost:3000/`;
```
<br>
##### Custom Saves
To customize the filename of save states <br>
@ -99,16 +129,59 @@ To place an advertisement in front of the <br>
EJS_AdUrl = `URL`;
```
<br>
##### Interface Color
To use a different color for the emulator interface, use:
```js
EJS_color = '#FF0000'; // Hex Color Code
```
<br>
##### Direct Start
To start the emulator immediately, add this line:
```js
EJS_startOnLoaded = true;
```
*For audio to play the user still* <br>
*needs to interact with the page.*
<br>
##### Custom Paths
Paths to emulator files can be customized with:
```js
EJS_paths = {
'fileName' : `/somepath` ,
'emulator.js' : `https://example.com/emulator.js` ,
'n64-asmjs.data' : `/asdfds.data`
};
```
*If a file is not defined, the default is used.*
<!----------------------------------------------------------------------------->
[Example Use]: https://coldcast.org/games/1/Super-Mario-Bros
[Emulator Demo]: https://ethanaobrien.github.io/emulatorjs/
[Beta]: https://emulatorjs.netlify.app/
[Issue]: https://github.com/ethanaobrien/emulatorjs/issues
[This repository]: https://github.com/linuxserver/emulatorjs
[EJS]: https://www.emulatorjs.com/
[Server]: https://github.com/ethanaobrien/emuserver
[NES / Famicom]: docs/NES-Famicom.md
[SNES]: docs/SNES.md
[Nintendo 64]: docs/Nintendo%2064.md
@ -133,3 +206,4 @@ EJS_AdUrl = `URL`;
[TurboGrafs-16 / PC Engine]: docs/TurboGrafs%2016-PC%20Engine.md
[Arcade]: docs/Arcade.md
[Atari 2600]: docs/Atari%202600.md

5937
data/emu-main.js Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,103 +1,68 @@
var VERSION = '0.4.26'
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');
};
});
};
});
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'
scriptTag.parentNode.insertBefore(emulatorjs, scriptTag)
emulatorjs.onload = function() {
var config = {};
config.gameUrl = EJS_gameUrl
'undefined' != typeof EJS_biosUrl && (config.biosUrl = EJS_biosUrl)
'undefined' != typeof EJS_gameID && (config.gameId = EJS_gameID)
'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
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_mouse && (config.mouse = EJS_mouse)
'undefined' != typeof EJS_multitap && (config.multitap = EJS_multitap)
'undefined' != typeof EJS_playerName && (config.playerName = EJS_playerName)
'undefined' != typeof EJS_cheats && (config.cheats = EJS_cheats)
'undefined' != typeof EJS_color && (config.color = EJS_color)
window.EJS_emulator = new EJS(EJS_player, config)
'undefined' != typeof EJS_onGameStart && EJS_emulator.on('start-game', EJS_onGameStart);
var emu_main = document.createElement('script')
emu_main.src = function() {
if ('undefined' != typeof EJS_paths && typeof EJS_paths['emu-main.js'] == 'string') {
return EJS_paths['emu-main.js']
} else if ('undefined' != typeof EJS_pathtodata) {
return EJS_pathtodata + 'emu-main.js?v=' + VERSION
} else {
return 'emu-main.js?v=' + VERSION;
}
}();
scriptTag.parentNode.insertBefore(emu_main, scriptTag)
emu_main.onload = function() {
var emulatorjs = document.createElement('script')
emulatorjs.async = true
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 = {};
config.gameUrl = EJS_gameUrl
'undefined' != typeof EJS_biosUrl && (config.biosUrl = EJS_biosUrl)
'undefined' != typeof EJS_gameID && (config.gameId = EJS_gameID)
'undefined' != typeof EJS_gameParentUrl && (config.gameParentUrl = EJS_gameParentUrl)
'undefined' != typeof EJS_gamePatchUrl && (config.gamePatchUrl = EJS_gamePatchUrl)
'undefined' != typeof EJS_AdUrl && (config.adUrl = EJS_AdUrl)
'undefined' != typeof EJS_paths && (config.paths = EJS_paths)
'undefined' != typeof EJS_netplayUrl && (config.netplayUrl = EJS_netplayUrl)
'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)
'undefined' != typeof EJS_cheats && (config.cheats = EJS_cheats)
'undefined' != typeof EJS_color && (config.color = EJS_color)
window.EJS_emulator = new EJS(EJS_player, config)
'undefined' != typeof EJS_onGameStart && EJS_emulator.on('start-game', EJS_onGameStart);
};
};

View file

@ -1 +1 @@
{ "current_version": "0.4.24"}
{ "current_version": "0.4.26" }