Spaces:
No application file
No application file
File size: 5,266 Bytes
bdfa298 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
<!DOCTYPE html>
<html>
<head>
<?php
$settings = parse_ini_file("./settings.ini");
//Write system extension arrays
// Nintendo
$snes = ["smc", "sfc", "fig", "swc", "bs", "st"];
$gba = ["gba"];
$gb = ["gb", "gbc", "dmg"];
$nes = ["fds", "nes", "unif", "unf"];
$vb = ["vb", "vboy"];
$nds = ["nds"];
$n64 = ["n64", "z64", "v64", "u1", "ndd"];
// Sega
$sms = ["sms"];
$smd = ["smd", "md"];
$gg = ["gg"];
// Other
$psx = ["pbp", "chd"];
//Find console
$name = basename($_GET['game']);
$ext = explode(".", $name);
$ext = strtolower(end($ext));
//for zipfile
if ($ext=='zip'){
$zip = new ZipArchive;
if ($zip->open("roms/".$name))
{
$names =$zip->getNameIndex(0);
$ext0 = explode(".", $names);
$ext = strtolower(end($ext));
}
}
if (in_array($ext, $nes)) { $console = 'nes'; }
else if (in_array($ext, $snes)) { $console = 'snes'; }
else if (in_array($ext, $n64)) { $console = 'n64'; }
else if (in_array($ext, $gb)) { $console = 'gb'; }
else if (in_array($ext, $vb)) { $console = 'vb'; }
else if (in_array($ext, $gba)) { $console = 'gba'; }
else if (in_array($ext, $nds)) { $console = 'nds'; }
else if (in_array($ext, $sms)) { $console = 'segaMS'; }
else if (in_array($ext, $smd)) { $console = 'segaMD'; }
else if (in_array($ext, $gg)) { $console = 'segaGG'; }
else if (in_array($ext, $psx)) { $console = 'psx';};
?>
<title><?php echo($name); ?></title>
<style>
body {
background-color: #333;
}
nav {
background-color: #5f5f5f;
border-radius: 5px;
}
nav ul {
margin: 0;
padding: 0;
list-style: none;
display: flex;
justify-content: center;
}
nav a {
display: block;
padding: 1rem;
text-decoration: none;
color: #c5c5c5;
border-radius: 5px;
}
nav a:hover {
background-color: #868686;
color: #fff;
}
</style>
</head>
<body>
<nav>
<ul>
<li><a href="index.php">Arcade</a></li>
<li><a href="upload.php">Upload</a></li>
<li style="width:10%;"></li>
<li><p>Playing: <?php echo($name); ?></p></li>
</ul>
</nav>
<div style='width:640px;height:480px;max-width:100%;margin: auto auto;'>
<div id='game'></div>
</div>
<script type='text/javascript'>
EJS_player = '#game';
<?php
if (file_exists("./bios/$console.zip")) {
$bios = "EJS_biosUrl = './bios/$console.zip';";
} else {
$bios = "";
}
echo("
EJS_core = '$console';
$bios
EJS_gameUrl = './roms/".$_GET['game']."';
EJS_pathtodata = 'data/';");
?>
EJS_onSaveState = function(data) {
const stateBlob = new Blob([data.state], { type: "application/octet-stream" });
const screenshotBlob = new Blob([data.screenshot], { type: "image/png" });
const gameName = "<?php echo($_GET['game']); ?>";
const formData = new FormData();
formData.append("gameName", gameName); // Add gameName to the form data
formData.append("state", stateBlob, `${gameName}.state`); // Construct filename
formData.append("screenshot", screenshotBlob, `${gameName}.img`); // Construct filename
const xhr = new XMLHttpRequest();
xhr.open("POST", "saveState.php", true);
xhr.send(formData);
}
EJS_onLoadState = function() {
const xhr = new XMLHttpRequest();
xhr.open("GET", <?php echo('"./saves/' . $_GET["game"]); ?>.state", true);
xhr.responseType = "arraybuffer"; // Set the response type to arraybuffer
xhr.onload = function() {
if (xhr.status === 200) {
const loadedState = new Uint8Array(xhr.response); // Convert arraybuffer to Uint8Array
EJS_emulator.gameManager.loadState(loadedState);
} else {
console.error("Error loading state");
}
};
xhr.onerror = function() {
console.error("Request failed");
};
xhr.onerror = function() {
console.error("Request failed");
};
xhr.send();
};
</script>
<script src='data/loader.js'></script>
</body>
</html>
|