forked from lesleyrs/Client3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell.html
More file actions
116 lines (103 loc) · 3.51 KB
/
shell.html
File metadata and controls
116 lines (103 loc) · 3.51 KB
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
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>RuneScape Game</title>
<style>
body {
margin: 0;
padding: 0;
color: white;
background-color: black;
}
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */
canvas.emscripten {
padding-right: 0;
margin-left: auto;
margin-right: auto;
display: block;
border: 0px none;
background-color: black;
}
</style>
</head>
<body>
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas>
<script type='text/javascript'>
window.AudioContext = window.AudioContext || window.webkitAudioContext;
if (window.AudioContext) {
window.audioContext = new window.AudioContext();
}
let waveGain;
function setWaveVolume(vol) {
if (!waveGain) {
waveGain = window.audioContext.createGain();
waveGain.connect(window.audioContext.destination);
}
waveGain.gain.value = vol / 128;
}
async function playWave(data) {
try {
const audioBuffer = await window.audioContext.decodeAudioData(Uint8Array.from(data).buffer);
let bufferSource = window.audioContext.createBufferSource();
bufferSource.buffer = audioBuffer;
bufferSource.connect(waveGain);
bufferSource.start();
} catch (err) {
console.log(err);
}
}
function bytesToBigInt(bytes) {
let result = 0n;
for (let index = 0; index < bytes.length; index++) {
result = (result << 8n) | BigInt(bytes[index]);
}
return result;
}
function bigIntToBytes(bigInt) {
const bytes = [];
while (bigInt > 0n) {
bytes.unshift(Number(bigInt & 0xffn));
bigInt >>= 8n;
}
if (bytes[0] & 0x80) {
bytes.unshift(0);
}
return new Uint8Array(bytes);
}
function bigIntModPow(base, exponent, modulus) {
let result = 1n;
while (exponent > 0n) {
if (exponent % 2n === 1n) {
result = (result * base) % modulus;
}
base = (base * base) % modulus;
exponent >>= 1n;
}
return result;
}
function getParameter(name) {
const urlParams = new URLSearchParams(window.location.search);
return urlParams.get(name) ?? '';
}
function setParameter(name, value) {
const url = new URL(window.location.toString());
url.searchParams.set(name, value);
window.history.pushState(null, '', url.toString());
}
var Module = {
arguments: [],
canvas: (() => {
var canvas = document.getElementById('canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
// application robust, you may want to override this behavior before shipping!
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
canvas.addEventListener("webglcontextlost", (e) => { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas;
})(),
};
</script>
{{{ SCRIPT }}}
</body>
</html>