| 1 |
<!doctype html> |
| 2 |
<html lang="en-us"> |
| 3 |
<head> |
| 4 |
<meta charset="utf-8"> |
| 5 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 6 |
<title>Play GNU FreeDink</title> |
| 7 |
<style> |
| 8 |
body { |
| 9 |
font-family: sans-serif; |
| 10 |
margin: 0; |
| 11 |
padding: none; |
| 12 |
background-color: #4c653d; |
| 13 |
background-image: url("background.jpg"); |
| 14 |
background-attachment: fixed; |
| 15 |
} |
| 16 |
|
| 17 |
.emscripten { |
| 18 |
padding-right: 0; margin-left: auto; margin-right: auto; display: block; |
| 19 |
width: 640px; |
| 20 |
height: 480px; |
| 21 |
} |
| 22 |
div.emscripten { text-align: center; } |
| 23 |
div.emscripten_border { border: 1px solid black; } |
| 24 |
/* the canvas *must not* have any border or padding, or mouse coords will be wrong */ |
| 25 |
canvas.emscripten { border: 0px none; background-color: black; } |
| 26 |
|
| 27 |
.spinner { |
| 28 |
height: 30px; |
| 29 |
width: 30px; |
| 30 |
margin: 0; |
| 31 |
margin-top: 20px; |
| 32 |
margin-left: 20px; |
| 33 |
display: inline-block; |
| 34 |
vertical-align: top; |
| 35 |
|
| 36 |
-webkit-animation: rotation .8s linear infinite; |
| 37 |
-moz-animation: rotation .8s linear infinite; |
| 38 |
-o-animation: rotation .8s linear infinite; |
| 39 |
animation: rotation 0.8s linear infinite; |
| 40 |
|
| 41 |
border-left: 5px solid rgb(235, 235, 235); |
| 42 |
border-right: 5px solid rgb(235, 235, 235); |
| 43 |
border-bottom: 5px solid rgb(235, 235, 235); |
| 44 |
border-top: 5px solid rgb(120, 120, 120); |
| 45 |
|
| 46 |
border-radius: 100%; |
| 47 |
background-color: rgb(189, 215, 46); |
| 48 |
} |
| 49 |
|
| 50 |
@-webkit-keyframes rotation { |
| 51 |
from {-webkit-transform: rotate(0deg);} |
| 52 |
to {-webkit-transform: rotate(360deg);} |
| 53 |
} |
| 54 |
@-moz-keyframes rotation { |
| 55 |
from {-moz-transform: rotate(0deg);} |
| 56 |
to {-moz-transform: rotate(360deg);} |
| 57 |
} |
| 58 |
@-o-keyframes rotation { |
| 59 |
from {-o-transform: rotate(0deg);} |
| 60 |
to {-o-transform: rotate(360deg);} |
| 61 |
} |
| 62 |
@keyframes rotation { |
| 63 |
from {transform: rotate(0deg);} |
| 64 |
to {transform: rotate(360deg);} |
| 65 |
} |
| 66 |
|
| 67 |
#status { |
| 68 |
display: inline-block; |
| 69 |
vertical-align: top; |
| 70 |
margin-top: 30px; |
| 71 |
margin-left: 20px; |
| 72 |
font-weight: bold; |
| 73 |
color: rgb(255, 255, 2); |
| 74 |
height: 30px; |
| 75 |
} |
| 76 |
|
| 77 |
#progress { |
| 78 |
height: 20px; |
| 79 |
width: 300px; |
| 80 |
} |
| 81 |
|
| 82 |
#controls { |
| 83 |
display: inline-block; |
| 84 |
float: right; |
| 85 |
vertical-align: top; |
| 86 |
margin-top: 30px; |
| 87 |
margin-right: 20px; |
| 88 |
} |
| 89 |
|
| 90 |
#minidfarc { |
| 91 |
display: inline-block; |
| 92 |
float: left; |
| 93 |
vertical-align: top; |
| 94 |
margin-top: 90px; |
| 95 |
margin-left: 20px; |
| 96 |
background-color: seagreen; |
| 97 |
padding: 5px; |
| 98 |
} |
| 99 |
|
| 100 |
#output { |
| 101 |
width: 100%; |
| 102 |
height: 200px; |
| 103 |
margin: 0 auto; |
| 104 |
margin-top: 10px; |
| 105 |
border-left: 0px; |
| 106 |
border-right: 0px; |
| 107 |
padding-left: 0px; |
| 108 |
padding-right: 0px; |
| 109 |
display: block; |
| 110 |
background-color: black; |
| 111 |
color: white; |
| 112 |
font-family: 'Lucida Console', Monaco, monospace; |
| 113 |
outline: none; |
| 114 |
} |
| 115 |
|
| 116 |
a { |
| 117 |
color: gold; |
| 118 |
text-decoration: none; |
| 119 |
} |
| 120 |
a:hover { |
| 121 |
text-decoration: underline; |
| 122 |
} |
| 123 |
a:active { |
| 124 |
color: white; |
| 125 |
} |
| 126 |
</style> |
| 127 |
</head> |
| 128 |
<body> |
| 129 |
<div style="position: absolute;"> |
| 130 |
<span id="minidfarc"> |
| 131 |
<input id="ID_TrueColor" type="checkbox" checked="checked">True Color</input><br /> |
| 132 |
<!--<input id="ID_Windowed" type="checkbox">Windowed</input><br />--> |
| 133 |
<input id="ID_Sound" type="checkbox" checked="checked">Sound</input><br /> |
| 134 |
<input id="ID_Joystick" type="checkbox" checked="checked">Joystick</input><br /> |
| 135 |
<input id="ID_Debug" type="checkbox">Debug</input><br /> |
| 136 |
<input id="ID_V107" type="checkbox">v1.07 mode</input><br /> |
| 137 |
<!--<input id="ID_DinkGL" type="checkbox" checked="checked">OpenGL</input><br />--> |
| 138 |
|
| 139 |
<input id="ID_DmodInstall" type="file" onchange="OnInstall(this)" accept=".dmod" style=display:none></input> |
| 140 |
<button id="ID_DmodInstallDecoy" onclick="document.getElementById('ID_DmodInstall').click()" disabled="disabled">Open D-Mod</button> |
| 141 |
|
| 142 |
<button id="ID_Play" onclick="OnPlay()" disabled="disabled">Play</button> |
| 143 |
<!-- |
| 144 |
Not supported by SDL2: |
| 145 |
<br /> |
| 146 |
<button id="Fullscreen" disabled="disabled" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked, document.getElementById('resize').checked)">Fullscreen</button> |
| 147 |
--> |
| 148 |
|
| 149 |
<br /> |
| 150 |
<br /> |
| 151 |
Language:<br /> |
| 152 |
<select id='language'> |
| 153 |
<option value='ca'>Catalá (ca)</option> |
| 154 |
<option value='da'>Dansk (da)</option> |
| 155 |
<option value='de'>Deutsch (de)</option> |
| 156 |
<option value='en' selected="selected">English (en)</option> |
| 157 |
<option value='eo'>Esperanto (eo)</option> |
| 158 |
<option value='es'>Español (es)</option> |
| 159 |
<option value='fi'>Suomi (fi)</option> |
| 160 |
<option value='fr'>Français (fr)</option> |
| 161 |
<option value='hr'>Hrvatski (hr)</option> |
| 162 |
<option value='hu'>Magyar (hu)</option> |
| 163 |
<option value='mk'>Mакедонски (mk)</option> |
| 164 |
<option value='nl'>Nederlands (nl)</option> |
| 165 |
<option value='sv'>Svenska (sv)</option> |
| 166 |
<option value='tr'>Türkçe (tr)</option> |
| 167 |
</select> |
| 168 |
|
| 169 |
<br /> |
| 170 |
Local files:<br /> |
| 171 |
<input id="ID_SavegamesImport" type="file" onchange="OnSavegamesImport(this)" accept="application/zip" style=display:none> |
| 172 |
<button id="ID_SavegamesImportDecoy" onclick="document.getElementById('ID_SavegamesImport').click()" disabled="disabled">Import saved games</button><br /> |
| 173 |
<button id="ID_SavegamesExport" onclick="OnSavegamesExport()" disabled="disabled">Export saved games</button><br /> |
| 174 |
<input id="ID_ScriptInstall" type="file" onchange="OnScriptInstall()" style=display:none> |
| 175 |
<button id="ID_ScriptInstallDecoy" disabled="disabled" onclick="document.getElementById('ID_ScriptInstall').click()">Install your key-67.c...</button> |
| 176 |
|
| 177 |
|
| 178 |
</span> |
| 179 |
</div> |
| 180 |
<div style="position: absolute; display: none;"> |
| 181 |
<span id="controls"> |
| 182 |
<span><input type="checkbox" id="resize">Resize canvas</span> |
| 183 |
<span><input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer </span> |
| 184 |
<span><input type="button" id="Fullscreen-dist" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked, document.getElementById('resize').checked)"></span> |
| 185 |
</div> |
| 186 |
|
| 187 |
<div class="spinner" id="spinner"></div> |
| 188 |
<div class="emscripten" id="status">Downloading...</div> |
| 189 |
|
| 190 |
<div class="emscripten" style="height: 20px;"> |
| 191 |
<progress value="0" max="100" id="progress" hidden=1></progress> |
| 192 |
</div> |
| 193 |
|
| 194 |
<div class="emscripten_border"> |
| 195 |
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()"></canvas> |
| 196 |
</div> |
| 197 |
|
| 198 |
<textarea id="output" rows="8"></textarea> |
| 199 |
|
| 200 |
<div style="text-align: center;"> |
| 201 |
<a href="https://www.gnu.org/software/freedink/">GNU FreeDink</a> |
| 202 |
- Get D-Mods at <a href="https://dinknetwork.com/">The Dink Network</a> |
| 203 |
- Original game by <a href="https://www.codedojo.com/">RTSoft</a> |
| 204 |
- Brought to the web with <a href="http://emscripten.org/">emscripten</a> |
| 205 |
- <a href="/source/index.html" rel="jslicense" data-jslicense="1">Source Code</a> |
| 206 |
</div> |
| 207 |
|
| 208 |
<script type='text/javascript'> |
| 209 |
/* |
| 210 |
@licstart The following is the entire license notice for the |
| 211 |
JavaScript code in this page. |
| 212 |
|
| 213 |
Copyright (c) 2010-2014 Emscripten authors |
| 214 |
Copyright (C) 2018 Sylvain Beucler |
| 215 |
|
| 216 |
This file is part of GNU FreeDink |
| 217 |
|
| 218 |
GNU FreeDink is free software; you can redistribute it and/or |
| 219 |
modify it under the terms of the GNU General Public License as |
| 220 |
published by the Free Software Foundation; either version 3 of the |
| 221 |
License, or (at your option) any later version. |
| 222 |
|
| 223 |
GNU FreeDink is distributed in the hope that it will be useful, but |
| 224 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 225 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 226 |
General Public License for more details. |
| 227 |
|
| 228 |
You should have received a copy of the GNU General Public License |
| 229 |
along with this program. If not, see |
| 230 |
<http://www.gnu.org/licenses/>. |
| 231 |
|
| 232 |
@licend The above is the entire license notice |
| 233 |
for the JavaScript code in this page. |
| 234 |
*/ |
| 235 |
|
| 236 |
/* Redirect to asmjs version if no WebAssembly support */ |
| 237 |
if (typeof WebAssembly !== 'object' && location.href.search('asmjs/') == -1) |
| 238 |
location.href = 'asmjs/' + location.search; |
| 239 |
|
| 240 |
/* Enforce disabled state on reload (Firefox remembers the disabled state) */ |
| 241 |
function UISetState(can_launch, is_playing) { |
| 242 |
if (can_launch) { |
| 243 |
document.getElementById('ID_Play').disabled = 0; |
| 244 |
document.getElementById('ID_DmodInstall').disabled = 0; |
| 245 |
document.getElementById('ID_DmodInstallDecoy').disabled = 0; |
| 246 |
} else { |
| 247 |
document.getElementById('ID_Play').disabled = 1; |
| 248 |
document.getElementById('ID_DmodInstall').disabled = 1; |
| 249 |
document.getElementById('ID_DmodInstallDecoy').disabled = 1; |
| 250 |
} |
| 251 |
} |
| 252 |
UISetState(false, false); |
| 253 |
document.getElementById('ID_ScriptInstallDecoy').disabled = 1; |
| 254 |
document.getElementById('ID_SavegamesImportDecoy').disabled = 1; |
| 255 |
document.getElementById('ID_SavegamesExport').disabled = 1; |
| 256 |
|
| 257 |
var dmodname = 'dink'; |
| 258 |
function OnPlay() { |
| 259 |
var args = []; |
| 260 |
ENV['LANG'] = document.getElementById('language').value; |
| 261 |
//var args = ['freedink']; |
| 262 |
if (document.getElementById('ID_TrueColor').checked) args.push('--truecolor'); |
| 263 |
//if (document.getElementById('ID_Sound').checked) args.push('--window'); |
| 264 |
args.push('--window'); |
| 265 |
if (!document.getElementById('ID_Sound').checked) args.push('--nosound'); |
| 266 |
if (!document.getElementById('ID_Joystick').checked) args.push('--nojoy'); |
| 267 |
if (document.getElementById('ID_Debug').checked) args.push('--debug'); |
| 268 |
if (document.getElementById('ID_V107').checked) args.push('--v1.07'); |
| 269 |
//if (!document.getElementById('ID_DinkGL').checked) args.push('--software-rendering'); |
| 270 |
args.push('--game'); |
| 271 |
args.push(dmodname); |
| 272 |
|
| 273 |
document.getElementById('ID_Play').blur(); |
| 274 |
UISetState(false, true); |
| 275 |
|
| 276 |
Module.setStatus(''); |
| 277 |
console.log("Running freedink " + args); |
| 278 |
Module.print("Loading, please wait..."); |
| 279 |
|
| 280 |
//Module.run(args); |
| 281 |
//Module.ccall('emMain', 'number', ['number', 'array'], [args.length, args]); |
| 282 |
window.setTimeout(function() { Module.callMain(args); }, 10); |
| 283 |
} |
| 284 |
|
| 285 |
function OnInstall(input) { |
| 286 |
UISetState(false, false); |
| 287 |
Module.print("Extracting, please wait..."); |
| 288 |
|
| 289 |
window.setTimeout(function() { |
| 290 |
reader = new FileReader(); |
| 291 |
reader.onload = function(e) { |
| 292 |
FS.writeFile('mine.dmod', new Uint8Array(e.target.result)); |
| 293 |
DmodExtract(); |
| 294 |
} |
| 295 |
reader.readAsArrayBuffer(input.files[0]) |
| 296 |
}, 10); |
| 297 |
} |
| 298 |
|
| 299 |
function DmodExtract() { |
| 300 |
start = Date.now(); |
| 301 |
ptr_dmoddir = Module.ccall('malloc', 'number', ['number'], [8]); |
| 302 |
Module.ccall('emDmodExtract', 'number', |
| 303 |
['string','string','number'], |
| 304 |
['mine.dmod', '/usr/local/share/dink', ptr_dmoddir]); |
| 305 |
Module.print("Extracted in " + (Date.now()-start)/1000.0 + "s"); |
| 306 |
dmodname = UTF8ToString(getValue(ptr_dmoddir, 'i64'), 256); |
| 307 |
Module.ccall('free', 'number', ['number'], [getValue(ptr_dmoddir, 'i64')]); |
| 308 |
Module.ccall('free', 'number', ['number'], [ptr_dmoddir]); |
| 309 |
UISetState(true, false); |
| 310 |
document.getElementById('ID_Play').textContent = "Play " + dmodname; |
| 311 |
try { |
| 312 |
dmoddiz = new TextDecoder().decode( |
| 313 |
FS.readFile('/usr/local/share/dink/'+dmodname+'/dmod.diz'), |
| 314 |
{encoding:'ISO-8859-1'}); |
| 315 |
// note: -s CASE_INSENSITIVE_FS=1 |
| 316 |
Module.print(dmoddiz); |
| 317 |
Module.print(""); |
| 318 |
} catch(e) { |
| 319 |
Module.print("Note: no D-Mod description file (dmod.diz)"); |
| 320 |
} |
| 321 |
Module.print("D-Mod loaded - adjust options and click Play!"); |
| 322 |
} |
| 323 |
|
| 324 |
function OnScriptInstall() { |
| 325 |
document.getElementById('ID_ScriptInstallDecoy').disabled = 1; |
| 326 |
input = document.getElementById('ID_ScriptInstall') |
| 327 |
reader = new FileReader(); |
| 328 |
reader.onload = function(e) { |
| 329 |
FS.writeFile('/usr/local/share/dink/dink/Story/key-67.c', new Uint8Array(e.target.result)); |
| 330 |
Module.print('key-67.c installed - enjoy!'); |
| 331 |
document.getElementById('ID_ScriptInstallDecoy').disabled = 0; |
| 332 |
document.getElementById('ID_ScriptInstallDecoy').blur(); |
| 333 |
} |
| 334 |
reader.readAsArrayBuffer(input.files[0]) |
| 335 |
} |
| 336 |
|
| 337 |
function OnSavegamesImport(input) { |
| 338 |
reader = new FileReader(); |
| 339 |
reader.onload = function(e) { |
| 340 |
FS.writeFile('savegames.zip', new Uint8Array(e.target.result)); |
| 341 |
Module.ccall('emSavegamesImport', 'void', [], []); |
| 342 |
FS.syncfs(false, function(err) { |
| 343 |
if (err) { console.trace(); console.log(err); } |
| 344 |
}); |
| 345 |
Module.print("Saved games imported."); |
| 346 |
} |
| 347 |
reader.readAsArrayBuffer(input.files[0]) |
| 348 |
} |
| 349 |
|
| 350 |
function OnSavegamesExport() { |
| 351 |
ret = Module.ccall('emSavegamesExport', 'number', [], []); |
| 352 |
if (ret) { |
| 353 |
savegames = FS.readFile('savegames.zip'); |
| 354 |
obj_url = window.URL.createObjectURL(new Blob([savegames])); |
| 355 |
a = document.createElement('a'); |
| 356 |
a.download = 'savegames.zip'; |
| 357 |
a.href = obj_url; |
| 358 |
document.body.appendChild(a); |
| 359 |
a.click(); |
| 360 |
document.body.removeChild(a); |
| 361 |
window.URL.revokeObjectURL(obj_url); |
| 362 |
} |
| 363 |
} |
| 364 |
</script> |
| 365 |
|
| 366 |
<script type='text/javascript'> |
| 367 |
var statusElement = document.getElementById('status'); |
| 368 |
var progressElement = document.getElementById('progress'); |
| 369 |
var spinnerElement = document.getElementById('spinner'); |
| 370 |
|
| 371 |
var Module = { |
| 372 |
preRun: [], |
| 373 |
postRun: [], |
| 374 |
print: (function() { |
| 375 |
var element = document.getElementById('output'); |
| 376 |
if (element) element.value = ''; // clear browser cache |
| 377 |
return function(text) { |
| 378 |
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); |
| 379 |
// These replacements are necessary if you render to raw HTML |
| 380 |
//text = text.replace(/&/g, "&"); |
| 381 |
//text = text.replace(/</g, "<"); |
| 382 |
//text = text.replace(/>/g, ">"); |
| 383 |
//text = text.replace('\n', '<br>', 'g'); |
| 384 |
console.log(text); |
| 385 |
if (element) { |
| 386 |
element.value += text + "\n"; |
| 387 |
element.scrollTop = element.scrollHeight; // focus on bottom |
| 388 |
} |
| 389 |
}; |
| 390 |
})(), |
| 391 |
printErr: function(text) { |
| 392 |
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' '); |
| 393 |
if (0) { // XXX disabled for safety typeof dump == 'function') { |
| 394 |
dump(text + '\n'); // fast, straight to the real console |
| 395 |
} else { |
| 396 |
console.error(text); |
| 397 |
} |
| 398 |
}, |
| 399 |
canvas: (function() { |
| 400 |
var canvas = document.getElementById('canvas'); |
| 401 |
|
| 402 |
// As a default initial behavior, pop up an alert when webgl context is lost. To make your |
| 403 |
// application robust, you may want to override this behavior before shipping! |
| 404 |
// See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 |
| 405 |
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false); |
| 406 |
|
| 407 |
return canvas; |
| 408 |
})(), |
| 409 |
setStatus: function(text) { |
| 410 |
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' }; |
| 411 |
if (text === Module.setStatus.last.text) return; |
| 412 |
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/); |
| 413 |
var now = Date.now(); |
| 414 |
if (m && now - Module.setStatus.last.time < 30) return; // if this is a progress update, skip it if too soon |
| 415 |
Module.setStatus.last.time = now; |
| 416 |
Module.setStatus.last.text = text; |
| 417 |
if (m) { |
| 418 |
text = m[1]; |
| 419 |
progressElement.value = parseInt(m[2])*100; |
| 420 |
progressElement.max = parseInt(m[4])*100; |
| 421 |
progressElement.hidden = false; |
| 422 |
spinnerElement.hidden = false; |
| 423 |
} else { |
| 424 |
progressElement.value = null; |
| 425 |
progressElement.max = null; |
| 426 |
progressElement.hidden = true; |
| 427 |
if (!text) spinnerElement.style.display = 'none'; |
| 428 |
} |
| 429 |
statusElement.innerHTML = text; |
| 430 |
}, |
| 431 |
totalDependencies: 0, |
| 432 |
monitorRunDependencies: function(left) { |
| 433 |
this.totalDependencies = Math.max(this.totalDependencies, left); |
| 434 |
Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.'); |
| 435 |
} |
| 436 |
}; |
| 437 |
Module.setStatus('Downloading...'); |
| 438 |
window.onerror = function(event) { |
| 439 |
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus |
| 440 |
Module.setStatus('Exception thrown, see JavaScript console'); |
| 441 |
spinnerElement.style.display = 'none'; |
| 442 |
Module.setStatus = function(text) { |
| 443 |
if (text) Module.printErr('[post-exception status] ' + text); |
| 444 |
}; |
| 445 |
}; |
| 446 |
</script> |
| 447 |
<script type='text/javascript''> |
| 448 |
// Check parent directory if we're in asmjs/ fallback dir |
| 449 |
// Used by xxx-data.js to locate xxx.data |
| 450 |
Module['locateFile'] = function(url) { |
| 451 |
if (location.href.search('asmjs/') >= 0) { |
| 452 |
if (url.endsWith(".data")) { // e.g. not index.html.mem |
| 453 |
url = '../' + url; |
| 454 |
} |
| 455 |
} |
| 456 |
return url; |
| 457 |
} |
| 458 |
</script> |
| 459 |
<script type='text/javascript' src="/freedink-data-data.js"></script> |
| 460 |
<script type='text/javascript' src="/soundfonts-data.js"></script> |
| 461 |
{{{ SCRIPT }}} |
| 462 |
</body> |
| 463 |
</html> |