LibRetroJS support

Added preliminary support for LibRetroJS as well, configured in the config.ini
This commit is contained in:
Ramaerel 2022-07-29 13:41:58 +10:00
parent 01942e09e7
commit ed5bc929d8
6 changed files with 348 additions and 32 deletions

View File

@ -11,12 +11,11 @@
mkdir($romdirectory);
$gamedata = buildRomList($romdirectory);
}
echo("\r\n<div style='width:". 640*$conf["scale"] ."px;height:". 480*$conf["scale"] ."px;max-width:100%;margin:auto auto;'>");
} else {
echo('<html style="background-color:#333333;">');
$romdirectory = './roms/';
$gamedata = buildRomList($romdirectory);
echo("\r\n<div style='width:640px;height:480px;max-width:100%;margin:auto auto;'>");
}
$romlist = scandir($romdirectory);
for($i=0; $i<count($romlist)-2; $i++) {
@ -28,32 +27,9 @@
?>
<div id='game'></div>
</div>
<script type='text/javascript'>
<?php if (isset($_GET['games'])) {
$gid = $_GET['games'];
} else {
$gid = 0;
}
?>
EJS_player = '#game';
EJS_core = <?php echo("'".$gamedata[$gid]["Console"]."'"); ?>;
EJS_gameUrl = <?php echo('"./roms/'.$romlistfin[$gid].'"'); ?>;
<?php if($gamedata[$gid]["Console"] == "psx") {
echo("EJS_biosUrl = './bios/psx.bin';\r\n");
}
?>
<?php if($conf["netplay"] == "true") {
echo("EJS_gameID = ".$gid.";\r\n");
}
if($conf["beta"] == "true") {
echo("EJS_BETA = true; \r\n");
}
?>
EJS_pathtodata = 'data/';
</script>
<script src='data/loader.js'></script>
<?php
if($conf["core"]=="ejs") { include("./ejs.php"); }
elseif($conf["core"]=="ljs") { include("./ljs.php"); }
else { include("./ejs.php"); }
?>

View File

@ -2,4 +2,5 @@ rom_dir = "./roms/" ;The ROM Directory. Defaults to ./roms/
scale = 1 ;Scale the viewport up, parts of a number work (eg 1.25, 1.5). Defaults to 1
bgcolor = "#333333" ;Background color. Defaults to #333333 (The same as the client background)
netplay = "false" ;Enable or disable netplay. Requires a hosted environment and all players to be on the same website. Defaults to false
beta = "false" ;Enable the beta emulators for systems that support it. Defaults to false
beta = "false" ;Enable the beta emulators for systems that support it. Defaults to false
core = "ljs" ;Change between ethanobrien's EmulatorJS (ejs) and linuxserver's libretrojs (ljs). Defaults to ejs

30
Source/ejs.php Normal file
View File

@ -0,0 +1,30 @@
<?php echo("\r\n<div style='width:". 640*$conf["scale"] ."px;height:". 480*$conf["scale"] ."px;max-width:100%;margin: auto auto;'>"); ?>
<div id='game'></div>
</div>
</div>
<script type='text/javascript'>
<?php if (isset($_GET['games'])) {
$gid = $_GET['games'];
} else {
$gid = 0;
}
?>
EJS_player = '#game';
EJS_core = <?php echo("'".$gamedata[$gid]["Console"]."'"); ?>;
EJS_gameUrl = <?php echo('"./roms/'.$romlistfin[$gid].'"'); ?>;
<?php if($gamedata[$gid]["Console"] == "psx") {
echo("EJS_biosUrl = './bios/psx.bin';\r\n");
}
?>
<?php if($conf["netplay"] == "true") {
echo("EJS_gameID = ".$gid.";\r\n");
}
if($conf["beta"] == "true") {
echo("EJS_BETA = true; \r\n");
}
?>
EJS_pathtodata = 'data/';
</script>
<script src='data/loader.js'></script>

View File

@ -13,6 +13,7 @@
$rom[$i] = getRomExtension($romlistfin[$i]);
$gamedata[$i]["Name"] = $rom[$i][0];
$gamedata[$i]["Console"] = $rom[$i][1];
$gamedata[$i]["Core"] = $rom[$i][3];
echo("\r\n<option value='".$i."'>".$gamedata[$i]["Name"]." (".$gamedata[$i]["Console"].")</option>");
}
echo("\r\n</select>\r\n<input type='submit' value='Play'></form>");
@ -29,59 +30,75 @@
//NES formats
case "nes":
$romdata[1] = "nes";
$romdata[3] = "fceumm";
break;
case "fds":
$romdata[1] = "nes";
$romdata[3] = "fceumm";
break;
case "unif":
$romdata[1] = "nes";
$romdata[3] = "fceumm";
break;
case "unf":
$romdata[1] = "nes";
$romdata[3] = "fceumm";
break;
//SNES formats
case "smc":
$romdata[1] = "snes";
$romdata[3] = "snes9x";
break;
case "fig":
$romdata[1] = "snes";
$romdata[3] = "snes9x";
break;
case "sfc":
$romdata[1] = "snes";
$romdata[3] = "snes9x";
break;
case "gd3":
$romdata[1] = "snes";
$romdata[3] = "snes9x";
break;
case "gd7":
$romdata[1] = "snes";
$romdata[3] = "snes9x";
break;
case "dx2":
$romdata[1] = "snes";
$romdata[3] = "snes9x";
break;
case "bsx":
$romdata[1] = "snes";
$romdata[3] = "snes9x";
break;
case "swc":
$romdata[1] = "snes";
$romdata[3] = "snes9x";
break;
//Gameboy Formats
case "gb":
$romdata[1] = "gb";
$romdata[3] = "gamebatte";
break;
case "gbc":
$romdata[1] = "gb";
$romdata[3] = "gamebatte";
break;
//Gameboy Advanced Formats
case "gba":
$romdata[1] = "gba";
$romdata[3] = "vba_next";
break;
//Nintendo DS Formats
case "nds":
$romdata[1] = "nds";
$romdata[1] = "nds";
$romdata[3] = "melonds";
break;
//Nintendo 64 Formats
@ -100,21 +117,25 @@
//Sega Master System Formats
case "sms":
$romdata[1] = "segaMS";
$romdata[3] = "genesis_plus_gx";
break;
//Sega Mega Drive Formats
case "md":
$romdata[1] = "segaMD";
$romdata[3] = "genesis_plus_gx";
break;
//Sega Game Gear Formats
case "gg":
$romdata[1] = "segaGG";
$romdata[3] = "genesis_plus_gx";
break;
//Sega 32x Formats
case "sega32x":
$romdata[1] = "sega32x";
$romdata[3] = "genesis_plus_gx";
break;
//Atari 2600 Formats
@ -140,6 +161,7 @@
//PSX Formats
case "psx":
$romdata[1] = "psx";
$romdata[3] = "mednafen_psx";
break;

265
Source/js/libretro.js Normal file

File diff suppressed because one or more lines are too long

22
Source/ljs.php Normal file
View File

@ -0,0 +1,22 @@
<?php echo("\r\n<div style='width:". 640*$conf["scale"] ."px;height:". 480*$conf["scale"] ."px;max-width:100%;'>"); ?>
<button onclick="load()">Load Game</button>
<div id="game"></div>
<script type="text/javascript">
<?php if (isset($_GET['games'])) {
$gid = $_GET['games'];
} else {
$gid = 0;
}
?>
EJS_player = '#game';
EJS_gameUrl = <?php echo('"./roms/'.$romlistfin[$gid].'"'); ?>;
EJS_core = <?php echo("'".$gamedata[$gid]["Core"]."'"); ?>;
function load() {
var script = document.createElement('script');
script.src = 'js/libretro.js'
document.getElementsByTagName('head')[0].appendChild(script);
}
var retroArchCfg = {
}
</script>