Compare commits

..
19 changed files with 140 additions and 664 deletions

9
.gitignore vendored
View file

@ -1,9 +0,0 @@
*.adf
db/tools/index.htm
db/index.htm
db/games/index.htm
db/demos_aga/index.htm
db/demos/index.htm
*.bin
scriptedamigaemulator.js
scriptedamigaemulator.js.map

View file

@ -1,3 +1,2 @@
scriptedamigaemulator.js: sae/prototypes.js sae/utils.js sae/dms.js sae/config.js sae/roms.js sae/memory.js sae/autoconf.js sae/expansion.js sae/events.js sae/gayle.js sae/ide.js sae/filesys.js sae/hardfile.js sae/input.js sae/serial.js sae/custom.js sae/blitter.js sae/copper.js sae/playfield.js sae/video.js sae/audio.js sae/cia.js sae/disk.js sae/rtc.js sae/m68k.js sae/cpu.js sae/amiga.js
closure-compiler --language_in=ECMASCRIPT6 --language_out ES5 $^ --js_output_file $@ --create_source_map $@.map
printf "/*\n//@ sourceMappingURL=%b\n*/" $@.map >> $@
closure-compiler --language_in=ECMASCRIPT6 --language_out ES5 $^ --js_output_file $@

View file

@ -80,7 +80,7 @@
</div>
<div style="height:5px"></div>
<div id="foot" class="foot" style="line-height:14px">
<span class="gray">2012-2017 Rupert Hausberger</span> |
<span class="gray">2012-2016 Rupert Hausberger</span> |
<a target="_blank" href="readme.htm">Description</a> |
<span class="gray">Disassembler</span> |
<a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a>

View file

@ -133,7 +133,6 @@
<td><button onclick="stop()">Stop</button></td>
<td><button onclick="reset()">Reset</button></td>
<td><button onclick="pause(1)" id="controls_pr">Pause</button></td>
<td><button onclick="mute(1)" id="controls_mp">Mute</button></td>
</tr>
</table>
</td>
@ -145,12 +144,8 @@
<!-- Method 1: SAE will create a canvas and add it into the div-element below -->
<div id="myVideo" style="margin:auto"></div>
<!-- Method 2: The canvas is already defined. SAE will output to the element below.
The size of the canvas is set by SAE according your settings.
See example2.htm -->
The size of the canvas is set by SAE according your settings -->
<!--<canvas id="myVideo" style="margin:auto;background-color:#000"></canvas>-->
</td>
</tr>

View file

@ -23,7 +23,6 @@ var inf = null; /* Reference to the info-object */
var running = false; /* Is the emualtion currently running? */
var paused = false; /* Is the emualtion currently paused? */
var muted = false; /* Is the audio-output currently muted? */
/*-----------------------------------------------------------------------*/
/* Helpers */
@ -65,27 +64,14 @@ function switchPauseResume(p) {
}
}
function switchMutePlay(m) {
var e = document.getElementById("controls_mp");
if (m) {
e.innerHTML = "Play";
e.onclick = function() { mute(false); };
} else {
e.innerHTML = "Mute";
e.onclick = function() { mute(true); };
}
}
function saee2text(err) {
switch (err) {
case SAEE_AlreadyRunning: return "The emulator is already running.";
case SAEE_NotRunning: return "The emulator is not running.";
case SAEE_NoTimer: return "No timing-functions avail. Please upgrade your browser.";
case SAEE_NoMemory: return "Out of memory.";
case SAEE_Assert: return "Assertiation failed.";
case SAEE_Internal: return "Internal emulator error.";
case SAEE_Config_Invalid: return "Invalid configuration.";
case SAEE_Config_Compressed: return "A ZIP file was detected. Compressed files are not yet supported.";
case SAEE_CPU_Internal: return "Internal CPU-error.";
case SAEE_CPU_Requires68020: return "The selected kickstart-rom does require a 68020 and 32bit address-space";
case SAEE_CPU_Requires680EC20: return "The selected kickstart-rom does require a 68020.";
@ -341,18 +327,6 @@ function pause(p) {
alert(saee2text(err));
}
function mute(m) {
/* Mute or play audio.
true == mute, false == play */
var err = sae.mute(m);
if (err == SAEE_None) {
muted = m;
switchMutePlay(muted);
/* ... */
} else
alert(saee2text(err));
}
function romSelect() {
var e = document.getElementById("cfg_rom_file").files[0];
if (e) {
@ -467,10 +441,6 @@ function hook_event_stopped() {
paused = false;
switchPauseResume(paused);
}
if (muted) {
muted = false;
switchMutePlay(muted);
}
resetLEDs();
}
@ -480,10 +450,6 @@ function hook_event_reseted(hard) {
paused = false;
switchPauseResume(paused);
}
if (muted) {
muted = false;
switchMutePlay(muted);
}
}
/* Get call after the emulator has finished switching between pause-resume. */

View file

@ -133,7 +133,6 @@
<td><button onclick="stop()">Stop</button></td>
<td><button onclick="reset()">Reset</button></td>
<td><button onclick="pause(1)" id="controls_pr">Pause</button></td>
<td><button onclick="mute(1)" id="controls_mp">Mute</button></td>
</tr>
</table>
</td>
@ -142,13 +141,9 @@
<tr>
<td class="arm">Output</td>
<td class="alm">
<!-- Method 1: SAE will create a canvas and add it into the div-element below
See example2.htm -->
<!-- Method 1: SAE will create a canvas and add it into the div-element below -->
<!--<div id="myVideo" style="margin:auto"></div>-->
<!-- Method 2: The canvas is already defined. SAE will output to the element below.
The size of the canvas is set by SAE according your settings -->
<canvas id="myVideo" style="margin:auto;background-color:#000"></canvas>

View file

@ -1219,13 +1219,11 @@
<table>
<tr>
<td class="arm"><span class="label">Driver</span></td>
<td></td>
<td class="arm"><span class="label">Cursor</span></td>
<td></td>
<td colspan="3"></td>
</tr>
<tr>
<td class="arm">Mode</td>
<td>
<td colspan="3">
<select id="cfg_video_api" size="1" onchange="videoUpdateAPI()">
<option value="1">WebGL</option>
<option value="0">Canvas</option>
@ -1235,14 +1233,6 @@
<option value="5">32 bits per pixel (RGBA)</option>
</select>
</td>
<td class="arm">Mode</td>
<td class="alm">
<select id="cfg_video_cursor" size="1">
<option value="0">Always shown</option>
<option value="1">Hide over display</option>
<option value="2">Lock to display</option>
</select>
</td>
</tr>
<tr>
<td class="arm"><input id="cfg_video_antialias" type="checkbox" /></td>
@ -1503,11 +1493,10 @@
<option value="0">Disabled</option>
<option value="1">Mouse</option>
<option value="2">Joystick</option>
<option value="3">Emulated</option>
</select>
</td>
<td>
<div id="cfg_ports_0_joyemu_grp">
<div id="cfg_ports_0_grp">
Move
<select id="cfg_ports_0_move" size="1">
<option value="1">Arrows</option>
@ -1567,13 +1556,6 @@
<option value="50">2</option>
</select>
</div>
<div id="cfg_ports_0_joy_grp">
Device
<select id="cfg_ports_0_joy_device" size="1">
<option value="-1" disabled="disabled">- please wait -</option>
<!-- Populated with connected gamepads via HTML5 Gamepad API -->
</select>
</div>
</td>
<td style="width:100%"></td>
</tr>
@ -1582,12 +1564,11 @@
<td>
<select id="cfg_ports_1" size="1" onchange="portUpdate(1)">
<option value="0">Disabled</option>
<option value="2">Joystick</option>
<option value="3">Emulated</option>
<option value="3">Joystick</option>
</select>
</td>
<td>
<div id="cfg_ports_1_joyemu_grp">
<div id="cfg_ports_1_grp">
Move
<select id="cfg_ports_1_move" size="1">
<option value="1">Arrows</option>
@ -1647,20 +1628,9 @@
<option value="50">2</option>
</select>
</div>
<div id="cfg_ports_1_joy_grp">
Device
<select id="cfg_ports_1_joy_device" size="1">
<option value="-1" disabled="disabled">- please wait -</option>
<!-- Populated with connected gamepads via HTML5 Gamepad API -->
</select>
</div>
</td>
<td style="width:100%"></td>
</tr>
<tr>
<td></td>
<td colspan="3"><span class="info">Note: If a joystick-device get not detected, try to press some buttons on it.</span></td>
</tr>
<tr><td colspan="4"><div style="height:10px"></div></td></tr>
<tr>
<td class="arm"><span class="label">Keyboard</span></td>
@ -1668,7 +1638,7 @@
</tr>
<tr>
<td class="arm"><input id="cfg_keyborad_enabled" type="checkbox" /></td>
<td class="alm" colspan="3">Enabled <span class="info">(emulated joysticks do always work)</span></td>
<td class="alm" colspan="3">Enabled <span class="info">(joystick-emulation does always work)</span></td>
</tr>
<tr><td colspan="4"><div style="height:10px"></div></td></tr>
<tr>
@ -1692,7 +1662,7 @@
</div>
<div style="height:5px"></div>
<div id="foot" class="foot" style="line-height:14px">
<span class="gray">2012-2017 Rupert Hausberger</span> |
<span class="gray">2012-2016 Rupert Hausberger</span> |
<a target="_blank" href="readme.htm">Description</a> |
<a target="_blank" href="disass.htm">Disassembler</a> |
<a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a>
@ -1708,7 +1678,6 @@
<td><button onclick="reset()">Reset</button></td>
<td><button onclick="stop()">Stop</button></td>
<td><button onclick="pause(1)" id="controls_pr">Pause</button></td>
<td><button onclick="mute(1)" id="controls_mp">Mute</button></td>
<td id="controls_disk"><button onclick="dskchgOpen()">Disk</button></td>
<!--<td><button onclick="toggleFullScreen()">FS</button></td>-->
</tr>

177
index.js
View file

@ -199,7 +199,6 @@ var amaxInfo = null; /* amax rom-info */
var floppyNum = -1; /* current floppy-unit if floppy-info is shown */
var mountConfigNum = -1; /* current mount-unit if mount-info is shown */
var paused = false; /* is the emualtion currently paused? */
var muted = false; /* is the audio-output currently muted? */
var dskchg = false; /* disk-change requester in database-mode */
var dskchgList = []; /* list of floppies to change, created dynamicaly */
@ -440,17 +439,6 @@ function switchPauseResume(p) {
}
}
function switchMutePlay(m) {
var e = document.getElementById("controls_mp");
if (m) {
e.innerHTML = "Play";
e.onclick = function() { mute(false); };
} else {
e.innerHTML = "Mute";
e.onclick = function() { mute(true); };
}
}
function switchBaseEmul(emul) {
if (emul) {
document.body.style.backgroundColor = "#000000";
@ -501,10 +489,8 @@ function saee2text(err) {
case SAEE_NotRunning: return "The emulator is not running.";
case SAEE_NoTimer: return "No timing-functions avail. Please upgrade your browser.";
case SAEE_NoMemory: return "Out of memory.";
case SAEE_Assert: return "Assertiation failed.";
case SAEE_Internal: return "Internal emulator error.";
case SAEE_Config_Invalid: return "Invalid configuration.";
case SAEE_Config_Compressed: return "A ZIP file was detected. Compressed files are not yet supported.";
case SAEE_CPU_Internal: return "Internal CPU-error.";
case SAEE_CPU_Requires68020: return "The selected kickstart-rom does require a 68020 and 32bit address-space";
case SAEE_CPU_Requires680EC20: return "The selected kickstart-rom does require a 68020.";
@ -523,7 +509,6 @@ function saee2text(err) {
case SAEE_Video_ComphileShader: return "Can not compile the required shader-program.";
case SAEE_Video_LinkShader: return "Can not link the required shader-program.";
case SAEE_Audio_RequiresWebAudio: return "This browser does not support 'WebAudio'. Please upgrade to an actual version.";
case SAEE_Input_GamepadNotReady: return "The selected joystick-/gamepad-device is not ready.\n\nTry to press some buttons after closing this window...";
default: return "("+err+")";
}
}
@ -995,22 +980,12 @@ function fixAdvandedConfig() {
cfg.video.enabled = false;
else if (SAEV_config.video.api == SAEC_Config_Video_API_WebGL && !inf.video.webGL)
SAEV_config.video.api = SAEC_Config_Video_API_Canvas;
if (SAEV_config.video.cursor == SAEC_Config_Video_Cursor_Lock && !inf.video.pointerLock)
SAEV_config.video.cursor = SAEC_Config_Video_Cursor_Show;
}
/* audio */
if (cfg.audio.mode >= SAEC_Config_Audio_Mode_On) {
if (!inf.audio.webAudio)
cfg.audio.mode = SAEC_Config_Audio_Mode_Off_Emul;
}
/* input */
if (!inf.input.gamepad) {
if (cfg.ports[0].type == SAEC_Config_Ports_Type_Joy)
cfg.ports[0].type = SAEC_Config_Ports_Type_JoyEmu;
if (cfg.ports[1].type == SAEC_Config_Ports_Type_Joy)
cfg.ports[1].type = SAEC_Config_Ports_Type_JoyEmu;
}
}
function setAdvandedConfig() {
@ -1121,7 +1096,6 @@ function setAdvandedConfig() {
{
setSelect("cfg_video_api", cfg.video.api);
setDisabled("cfg_video_api", inf.video.webGL == false);
setSelect("cfg_video_cursor", cfg.video.cursor);
setSelect("cfg_video_color_mode", cfg.video.colorMode);
setCheckbox("cfg_video_antialias", cfg.video.antialias);
//setRadio("cfg_video_fs", cfg.video.apmode[0].gfx_fullscreen);
@ -1170,17 +1144,13 @@ function setAdvandedConfig() {
setSelect("cfg_ports_0_move", cfg.ports[0].move);
setSelect("cfg_ports_0_fire_1", cfg.ports[0].fire[0]);
setSelect("cfg_ports_0_fire_2", cfg.ports[0].fire[1]);
styleDisplayInline("cfg_ports_0_joyemu_grp", cfg.ports[0].type == SAEC_Config_Ports_Type_JoyEmu);
styleDisplayInline("cfg_ports_0_joy_grp", cfg.ports[0].type == SAEC_Config_Ports_Type_Joy);
setSelect("cfg_ports_0_joy_device", cfg.ports[0].device);
styleDisplayInline("cfg_ports_0_grp", cfg.ports[0].type == SAEC_Config_Ports_Type_Joy0);
setSelect("cfg_ports_1", cfg.ports[1].type);
setSelect("cfg_ports_1_move", cfg.ports[1].move);
setSelect("cfg_ports_1_fire_1", cfg.ports[1].fire[0]);
setSelect("cfg_ports_1_fire_2", cfg.ports[1].fire[1]);
styleDisplayInline("cfg_ports_1_joyemu_grp", cfg.ports[1].type == SAEC_Config_Ports_Type_JoyEmu);
styleDisplayInline("cfg_ports_1_joy_grp", cfg.ports[1].type == SAEC_Config_Ports_Type_Joy);
setSelect("cfg_ports_1_joy_device", cfg.ports[1].device);
styleDisplayInline("cfg_ports_1_grp", cfg.ports[1].type == SAEC_Config_Ports_Type_Joy1);
setCheckbox("cfg_keyborad_enabled", cfg.keyboard.enabled);
@ -1318,7 +1288,6 @@ function getAdvandedConfig() {
cfg.video.enabled = getCheckbox("cfg_video_enabled");
if (cfg.video.enabled) {
cfg.video.api = getSelect("cfg_video_api");
cfg.video.cursor = getSelect("cfg_video_cursor");
cfg.video.colorMode = getSelect("cfg_video_color_mode");
cfg.video.antialias = getCheckbox("cfg_video_antialias");
//cfg.video.apmode[0].gfx_fullscreen = getRadio("cfg_video_fs");
@ -1377,49 +1346,26 @@ function getAdvandedConfig() {
/* ports */
cfg.ports[0].type = getSelect("cfg_ports_0");
if (cfg.ports[0].type == SAEC_Config_Ports_Type_JoyEmu) {
if (cfg.ports[0].type == SAEC_Config_Ports_Type_Joy0) {
cfg.ports[0].move = getSelect("cfg_ports_0_move");
cfg.ports[0].fire[0] = getSelect("cfg_ports_0_fire_1");
cfg.ports[0].fire[1] = getSelect("cfg_ports_0_fire_2");
if (cfg.ports[0].fire[0] != SAEC_Config_Ports_Fire_None && cfg.ports[0].fire[0] == cfg.ports[0].fire[1]) {
alert("Fire-button 1/2 on mouse-port can't be the same.");
changePage(PID_Ports);
alert("Fire-button 1/2 on port 0 can\"t be the same.");
return false;
}
}
if (cfg.ports[0].type == SAEC_Config_Ports_Type_Joy) {
cfg.ports[0].device = getSelect("cfg_ports_0_joy_device");
if (cfg.ports[0].device == SAEC_Config_Ports_Device_None) {
alert("Joystick-device on mouse-port not found.");
changePage(PID_Ports);
return false;
}
}
cfg.ports[1].type = getSelect("cfg_ports_1");
if (cfg.ports[1].type == SAEC_Config_Ports_Type_JoyEmu) {
if (cfg.ports[1].type == SAEC_Config_Ports_Type_Joy1) {
cfg.ports[1].move = getSelect("cfg_ports_1_move");
cfg.ports[1].fire[0] = getSelect("cfg_ports_1_fire_1");
cfg.ports[1].fire[1] = getSelect("cfg_ports_1_fire_2");
if (cfg.ports[1].fire[0] != SAEC_Config_Ports_Fire_None && cfg.ports[1].fire[0] == cfg.ports[1].fire[1]) {
alert("Fire-button 1/2 on game-port can't be the same.");
changePage(PID_Ports);
return false;
}
}
if (cfg.ports[1].type == SAEC_Config_Ports_Type_Joy) {
cfg.ports[1].device = getSelect("cfg_ports_1_joy_device");
if (cfg.ports[1].device == SAEC_Config_Ports_Device_None) {
alert("Joystick-device on game-port not found.");
changePage(PID_Ports);
return false;
}
if (cfg.ports[0].type == SAEC_Config_Ports_Type_Joy && cfg.ports[1].device == cfg.ports[0].device) {
alert("Joystick device on mouse-port can't be the same as on game-port.");
changePage(PID_Ports);
alert("Fire-button 1/2 on port 1 can\"t be the same.");
return false;
}
}
cfg.keyboard.enabled = getCheckbox("cfg_keyborad_enabled");
cfg.serial.enabled = getCheckbox("cfg_serial_enabled");
@ -1437,7 +1383,7 @@ function start() {
if (s == S_VALID) { /* all files are downloaded or cached, go! */
freezeButtons(false, true);
var err = sae.start(); /* send start-request */
var err = sae.start(); /* this does start the emulator */
if (err != SAEE_None)
alert(saee2text(err));
}
@ -1485,13 +1431,6 @@ function reset() {
sae.reset(false, false);
}
function mute(m) {
sae.mute(m);
muted = m;
switchMutePlay(muted);
}
/*---------------------------------*/
function init() {
@ -1505,7 +1444,6 @@ function init() {
//console.log(cfg);
initHooks();
initGamepads();
dbInit();
setDatabaseConfig();
@ -2501,14 +2439,11 @@ function channelsUpdate() {
/*---------------------------------*/
function portUpdate(n) {
var v = getSelect("cfg_ports_" + n);
if (n == 0) {
styleDisplayInline("cfg_ports_0_joyemu_grp", v == SAEC_Config_Ports_Type_JoyEmu);
styleDisplayInline("cfg_ports_0_joy_grp", v == SAEC_Config_Ports_Type_Joy);
} else {
styleDisplayInline("cfg_ports_1_joyemu_grp", v == SAEC_Config_Ports_Type_JoyEmu);
styleDisplayInline("cfg_ports_1_joy_grp", v == SAEC_Config_Ports_Type_Joy);
}
var v = getSelect("cfg_ports_"+n);
if (n == 0)
styleDisplayInline("cfg_ports_0_grp", v == SAEC_Config_Ports_Type_Joy0);
else
styleDisplayInline("cfg_ports_1_grp", v == SAEC_Config_Ports_Type_Joy1);
}
/*-----------------------------------------------------------------------*/
@ -2531,10 +2466,6 @@ function hook_event_stopped() {
paused = false;
switchPauseResume(paused);
}
if (muted) {
muted = false;
switchMutePlay(muted);
}
if (dskchg)
dskchgClose();
@ -2549,10 +2480,6 @@ function hook_event_reseted(hard) {
paused = false;
switchPauseResume(paused);
}
if (muted) {
muted = false;
switchMutePlay(muted);
}
if (dskchg)
dskchgClose();
}
@ -2723,81 +2650,3 @@ function dskchgSelect() {
sae.insert(n);
}
}
/*-----------------------------------------------------------------------*/
/* Detect changes in connected gamepads/joysticks */
function setAvailableGamepads(select_id, gamepads) {
var sel = document.getElementById(select_id);
if (sel) {
/* Clear list */
for (var i = sel.options.length - 1; i >= 0; i--)
sel.remove(i);
/* Add gamepads */
for (i = 0; i < gamepads.length; i++) {
if (gamepads[i]) {
var id = gamepads[i].id, idx;
if ((idx = id.lastIndexOf(" (")) != -1 && idx >= 4)
id = id.substr(0, idx);
var opt = document.createElement("option");
opt.value = gamepads[i].index;
opt.innerHTML = "#" + i + ": " + id;
sel.appendChild(opt);
}
}
/* Add placeholder if no devices found */
if (sel.options.length == 0) {
var opt = document.createElement("option");
opt.value = "-1";
opt.innerHTML = "- no device detected (try to press a joystick-button) -";
sel.appendChild(opt);
}
}
}
function noGamepadAPI(select_id) {
var sel = document.getElementById(select_id);
if (sel) {
/* Clear list */
for (var i = sel.options.length - 1; i >= 0; i--)
sel.remove(i);
/* Add placeholder if no devices found */
if (sel.options.length == 0) {
var opt = document.createElement("option");
opt.value = "-1";
opt.innerHTML = "- gamepad API not found (browser-update required) -";
sel.appendChild(opt);
}
}
}
function initGamepads() {
if (inf.input.gamepad) {
/* first query */
var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
setAvailableGamepads("cfg_ports_0_joy_device", gamepads);
setAvailableGamepads("cfg_ports_1_joy_device", gamepads);
window.addEventListener("gamepadconnected", function(e) {
var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
setAvailableGamepads("cfg_ports_0_joy_device", gamepads);
setAvailableGamepads("cfg_ports_1_joy_device", gamepads);
SAEF_info("sae.initGamepads() device '" + e.gamepad.id + "' connected.");
});
window.addEventListener("gamepaddisconnected", function(e) {
window.setTimeout(function() {
var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
setAvailableGamepads("cfg_ports_0_joy_device", gamepads);
setAvailableGamepads("cfg_ports_1_joy_device", gamepads);
SAEF_info("sae.initGamepads() device '" + e.gamepad.id + "' disconnected.");
}, 100);
});
} else {
noGamepadAPI("cfg_ports_0_joy_device");
noGamepadAPI("cfg_ports_1_joy_device");
}
}

View file

@ -21,12 +21,10 @@
<li><a href="readme.htm#limits">Limits</a></li>
<li style="list-style:none"><div style="height:8px"></div></li>
<li><a href="readme.htm#usage">Usage</a></li>
<li><a href="readme.htm#api">API</a></li>
<li><a href="readme.htm#safety">Safety</a></li>
<li><a href="readme.htm#privacy">Privacy</a></li>
<li style="list-style:none"><div style="height:8px"></div></li>
<li><a href="readme.htm#support">Your game or demo</a></li>
<li><a href="readme.htm#references">References</a></li>
<li style="list-style:none"><div style="height:8px"></div></li>
<li><a href="readme.htm#author">Author</a></li>
<li><a href="readme.htm#thanks">Thanks</a></li>
@ -59,8 +57,6 @@
<ul>
<li>WegGL/Canvas2D- and WebAudio-extensions.</li>
<li>Typed-arrays and FileReader-extension.</li>
<li>pointerLock-extension. (optional)</li>
<li>gamepad-extension. (optional)</li>
<li>The browser should support compilation of javascript-code to native-code. (JIT)</li>
<li>The browser should be able to use multiple cpu-cores on a single thread/tab.</li>
<li>Memory-requirements are between 200MB to 1.5GB depending on configuration and browser.</li>
@ -311,21 +307,6 @@
<li>Or, go to &quot;Chipset/Features/Manual&quot; and select &quot;Onboard-IDE&quot; or &quot;PCMCIA-slot&quot; manually.</li>
</ul>
</li>
<li>If gamepads/joysticks did not get recognized
<ul>
<li>Try to press buttons on the controller.</li>
<li>Open a new tab and return to the SAE-tab. (Chrome)</li>
</ul>
</li>
</ul>
</li>
</ul>
<ul id="api">
<li><span class="label">API</span>
<ul>
<li>There's no written documentation about the API yet, blame me. At least there's a commented example:</li>
<li><a href="example.htm">example 1</a></li>
<li><a href="example2.htm">example 2</a></li>
</ul>
</li>
</ul>
@ -361,14 +342,6 @@
</ul>
</li>
</ul>
<ul id="references">
<li><span class="label">Some sites using this project</span>
<ul>
<li><a target="_blank" href="https://archive.org/details/softwarelibrary_amiga">archive.org</a></li>
<li><a target="_blank" href="http://retroweb.maclab.org/articles/Amiga-500.html">maclab.org</a></li>
</ul>
</li>
</ul>
<ul>
<li style="list-style:none"><div class="linehoriz"></div></li>
</ul>
@ -387,7 +360,7 @@
<li><a target="_blank" href="http://winuae.net">WinUAE team</a>, especially Toni Wilen.</li>
<li><a target="_blank" href="http://web.archive.org/web/20130812173347/http://www.amigaemulator.org/">Bernd Schmidt</a>, the father of amiga-emulation.</li>
<li><a target="_blank" href="http://aros.org">AROS team</a></li>
<li>All people who contributed their software or helped via github. Thanks for your support!</li>
<li>All people who contributed their games. Thanks for your support!</li>
</ul>
</li>
</ul>
@ -424,40 +397,6 @@
<ul id="history">
<li><span class="label">History</span>
<ul>
<li><span class="label">0.9.0 fixes and updates (2016-2017):</span>
<ul>
<li>Config
<ul>
<li>Added hooks that get called after the emulator has been started, stopped, reseted or paused.</li>
<li>Fixed invalid access of the config-object. Thanks 'db48x'.</li>
</ul>
</li>
<li>Input
<ul>
<li>Added experimental support for the 'Gamepad API'. It is disabled by default.<br />
Go to 'Config/Ports' to enable it. Thanks to 'SpliFF' for the basic implementation.</li>
</ul>
</li>
<li>Video
<ul>
<li>A canvas-element can now used directly as output. See <a href="example2.htm">example2.htm</a></li>
<li>The mouse-pointer can now be hidden or locked via the 'pointerLock API'.<br />
'pointerLock' is enabled by default, all browsers should support that. See 'Config/Video/Cursor'.</li>
</ul>
</li>
<li>Audio
<ul>
<li>Added mute-support over sae.mute()</li>
</ul>
</li>
<li>Common
<ul>
<li>Added an error if a ZIP-file get detected. Compressed files are not yet supported.</li>
</ul>
</li>
</ul>
</li>
<li style="list-style-type:none"><br/></li>
<li><span class="label">0.9.0 (15.07.2016)</span>
<ul>
<li>CPU
@ -894,7 +833,7 @@
</div>
<div style="height:5px"></div>
<div id="foot" class="foot" style="line-height:14px">
<span class="gray">2012-2017 Rupert Hausberger</span> |
<span class="gray">2012-2016 Rupert Hausberger</span> |
<span class="gray">Description</span> |
<a target="_blank" href="disass.htm">Disassembler</a> |
<a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a>

View file

@ -68,7 +68,6 @@ const SAEE_Assert = 5;
const SAEE_Internal = 6;
const SAEE_Config_Invalid = 10;
const SAEE_Config_Compressed = 11;
const SAEE_CPU_Internal = 20;
const SAEE_CPU_Requires68020 = 21;
@ -92,8 +91,6 @@ const SAEE_Video_LinkShader = 44;
const SAEE_Audio_RequiresWebAudio = 50;
const SAEE_Input_GamepadNotReady = 60;
/*-----------------------------------------------------------------------*/
/* global references */
@ -149,11 +146,7 @@ const SAEC_info = (function() {
},
video: {
canvas: false,
webGL: false,
pointerLock: false
},
input: {
gamepad: false
webGL: false
}
};
@ -222,7 +215,6 @@ const SAEC_info = (function() {
var ctx = canvas.getContext("2d");
var imageData = ctx.createImageData(16, 16);
info.video.canvas = true;
try {
const glParams = {
alpha: false,
@ -236,16 +228,9 @@ const SAEC_info = (function() {
ctx = canvas.getContext("webgl", glParams) || canvas.getContext("experimental-webgl", glParams);
info.video.webGL = true;
} catch(e) {}
if (canvas.requestPointerLock || canvas.mozRequestPointerLock)
info.video.pointerLock = true;
} catch(e) {}
}
/* input */
if (navigator.getGamepads || navigator.webkitGetGamepads)
info.input.gamepad = true;
return info;
})();
@ -468,8 +453,9 @@ function ScriptedAmigaEmulator() {
return err;
if ((err = this.audio.obtain()) != SAEE_None)
return err;
if ((err = this.input.setup()) != SAEE_None) //inputdevice_init();
return err;
this.input.setup(); //inputdevice_init();
if ((err = this.gui.setup()) != SAEE_None)
return err;
@ -599,24 +585,9 @@ function ScriptedAmigaEmulator() {
return SAEE_None;
};
this.mute = function(mute) {
if (this.running) {
this.audio.mute(mute);
if (mute)
SAEF_log("sae.mute() audio muted");
else
SAEF_log("sae.mute() playing audio");
return SAEE_None;
} else {
SAEF_warn("sae.mute() emulation not running");
return SAEE_NotRunning;
}
};
this.keyPress = function(e, down) {
this.input.keyPress(e, down);
return SAEE_None;
};
}
/*---------------------------------*/

View file

@ -54,7 +54,6 @@ function SAEO_Audio() {
const SOUND_SYNC_MULTIPLIER = 1.0;
var scaled_sample_evtime_orig = 0.0;
var muted = false;
var paused = false;
var have_sound = false;
var sound_available = false;
@ -211,28 +210,17 @@ function SAEO_Audio() {
/*---------------------------------*/
const INV32768 = 1.0 / 32768; /* mul is always faster than div */
const INV32768 = 1.0 / 32768; /* mul is always fasten than div */
function scaleplay(e, buffer, frames) {
var chn = SAEV_config.audio.channels;
var z = e.outputBuffer.length;
if (muted) {
for (var ch = 0; ch < chn; ch++) {
var data = e.outputBuffer.getChannelData(ch);
for (var i = 0; i < z; i++)
data[i] = 0.0;
}
return;
}
/*if (driver.context.sampleRate != used_freq) {} else*/
{
var step = frames / z;
/*if (driver.context.sampleRate != used_freq) {
} else*/ {
var step = frames / e.outputBuffer.length;
for (var ch = 0; ch < chn; ch++) {
for (var ch = 0; ch < SAEV_config.audio.channels; ch++) {
var data = e.outputBuffer.getChannelData(ch);
var tbuf = buffer[ch];
for (var i = 0, j = 0.0; i < z; i++, j += step)
data[i] = tbuf[j >>> 0] * INV32768;
for (var i = 0, j = 0.0; i < e.outputBuffer.length; i++, j += step)
data[i] = buffer[ch][j >>> 0] * INV32768;
}
}
}
@ -371,7 +359,6 @@ function SAEO_Audio() {
}
function setup_sound() { //init_sound()
muted = paused = false;
//SAER.gui.data.sndbuf_status = 3;
//SAER.gui.data.sndbuf = 0;
if (!have_sound)
@ -392,10 +379,6 @@ function SAEO_Audio() {
paula.average.clr();
}
function mute_sound(mute) { //OWN
muted = mute;
}
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
@ -1474,9 +1457,11 @@ function SAEO_Audio() {
}
this.reset = function() {
var i;
reset_sound();
for (var i = 0; i < sound_filter_state.length; i++)
for (i = 0; i < sound_filter_state.length; i++)
sound_filter_state[i].clr();
for (i = 0; i < AUDIO_CHANNELS_MAX; i++) {
@ -1502,10 +1487,6 @@ function SAEO_Audio() {
resume_sound();
}
this.mute = function(mute) {
mute_sound(mute)
}
/*-----------------------------------------------------------------------*/
var prevcon = -1;

View file

@ -793,7 +793,8 @@ function SAEO_CIA() {
function check_led() {
var v = ciaapra;
v |= ~ciaadra; /* output is high when pin's direction is input */
v |= ~ciaadra; /* output is high when pin"s direction is input */
var led2 = (v & 2) ? 0 : 1;
if (led2 != led) {
calc_led(led);
@ -823,18 +824,12 @@ function SAEO_CIA() {
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) {
if (!SAER.input.mouse.button[0]) tmp |= 0x40;
if (dra & 0x40) tmp = (tmp & ~0x40) | (pra & 0x40);
} else if (
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy ||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_JoyEmu
) {
} else if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy0) {
if (!SAER.input.joystick[0].button[0]) tmp |= 0x40;
if (dra & 0x40) tmp = (tmp & ~0x40) | (pra & 0x40);
} else tmp |= 0x40;
if (
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy ||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_JoyEmu
) {
if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy1) {
if (!SAER.input.joystick[1].button[0]) tmp |= 0x80;
if (dra & 0x80) tmp = (tmp & ~0x80) | (pra & 0x80);
} else tmp |= 0x80;

View file

@ -266,10 +266,6 @@ function SAEO_Config_Mount_Data() { //uaedev_config_data
const SAEC_Config_Video_API_Canvas = 0;
const SAEC_Config_Video_API_WebGL = 1;
const SAEC_Config_Video_Cursor_Show = 0;
const SAEC_Config_Video_Cursor_Hide = 1;
const SAEC_Config_Video_Cursor_Lock = 2;
const SAEC_Config_Video_HResolution_LoRes = 0;
const SAEC_Config_Video_HResolution_HiRes = 1;
const SAEC_Config_Video_HResolution_SuperHiRes = 2;
@ -376,8 +372,8 @@ const SAEC_Config_Audio_Interpol_Crux = 3;
const SAEC_Config_Ports_Type_None = 0;
const SAEC_Config_Ports_Type_Mouse = 1;
const SAEC_Config_Ports_Type_Joy = 2;
const SAEC_Config_Ports_Type_JoyEmu = 3;
const SAEC_Config_Ports_Type_Joy0 = 2;
const SAEC_Config_Ports_Type_Joy1 = 3;
const SAEC_Config_Ports_Move_None = 0;
const SAEC_Config_Ports_Move_Arrows = 1;
@ -386,8 +382,6 @@ const SAEC_Config_Ports_Move_WASD = 3;
const SAEC_Config_Ports_Fire_None = 0;
const SAEC_Config_Ports_Device_None = -1;
/*---------------------------------*/
/* debug */
@ -580,7 +574,7 @@ function SAEO_Config() {
this.video = {
id: "",
enabled: false,
cursor: 0,
//driver: 0,
scandoubler: false, //gfx_scandoubler
framerate: 0, //gfx_framerate
@ -678,13 +672,11 @@ function SAEO_Config() {
this.ports = [{
type: SAEC_Config_Ports_Type_Mouse,
move: SAEC_Config_Ports_Move_WASD,
fire: [49,50],
device: SAEC_Config_Ports_Device_None
fire: [49,50]
}, {
type: SAEC_Config_Ports_Type_JoyEmu,
type: SAEC_Config_Ports_Type_Joy1,
move: SAEC_Config_Ports_Move_Arrows,
fire: [16,17],
device: SAEC_Config_Ports_Device_None
fire: [16,17]
}];
this.keyboard = {
@ -1083,7 +1075,6 @@ function SAEO_Configuration() {
p.video.id = "video";
p.video.enabled = true;
p.video.cursor = SAEC_Config_Video_Cursor_Lock;
p.video.scandoubler = false;
p.video.framerate = 1;
p.video.hresolution = SAEC_Config_Video_HResolution_HiRes;
@ -1168,11 +1159,9 @@ function SAEO_Configuration() {
p.ports[0].type = SAEC_Config_Ports_Type_Mouse;
p.ports[0].move = SAEC_Config_Ports_Move_WASD;
p.ports[0].fire = [49,50];
p.ports[0].device = SAEC_Config_Ports_Device_None;
p.ports[1].type = SAEC_Config_Ports_Type_JoyEmu;
p.ports[1].type = SAEC_Config_Ports_Type_Joy1;
p.ports[1].move = SAEC_Config_Ports_Move_Arrows;
p.ports[1].fire = [16,17];
p.ports[1].device = SAEC_Config_Ports_Device_None;
/*memset (&p.jports[0], 0, sizeof (struct jport));
memset (&p.jports[1], 0, sizeof (struct jport));
memset (&p.jports[2], 0, sizeof (struct jport));
@ -2409,17 +2398,7 @@ function SAEO_Configuration() {
p.chipset.cia.tod = p.chipset.ntsc ? SAEC_Config_Chipset_CIA_TOD_60Hz : SAEC_Config_Chipset_CIA_TOD_50Hz;
built_in_chipset_prefs(p);
//inputdevice_fix_prefs(p);
if (p.ports[0].type == SAEC_Config_Ports_Type_Joy && p.ports[0].device == SAEC_Config_Ports_Device_None) {
p.ports[0].type = SAEC_Config_Ports_Type_JoyEmu;
SAEF_warn("config.fixup_prefs() p.ports[0].device is invalid. (falling back to joystick-emulation)");
}
if (p.ports[1].type == SAEC_Config_Ports_Type_Joy && p.ports[1].device == SAEC_Config_Ports_Device_None) {
p.ports[1].type = SAEC_Config_Ports_Type_JoyEmu;
SAEF_warn("config.fixup_prefs() p.ports[1].device is invalid. (falling back to joystick-emulation)");
}
return true; //err == 0;
}
}

View file

@ -10229,3 +10229,39 @@ function SAEO_CPU() {
return true;
}
}

View file

@ -325,10 +325,10 @@ function SAEO_DMS() {
//l = (j - k) << 1;
l = j - k;
//memmove(&freq[k + 1], &freq[k], (size_t)l);
for (m = l-1; m >= 0; m--) freq[k + m + 1] = freq[k + m];
for (m = l; m >= 0; m--) freq[k + m + 1] = freq[k + m];
freq[k] = f;
//memmove(&son[k + 1], &son[k], (size_t)l);
for (m = l-1; m >= 0; m--) son[k + m + 1] = son[k + m];
for (m = l; m >= 0; m--) son[k + m + 1] = son[k + m];
son[k] = i;
}
/* connect prnt */

View file

@ -19,60 +19,56 @@ function SAEO_Mouse() {
this.button = [false, false, false];
this.pos = 0;
var cx = 0, cy = 0;
var mx = 0, my = 0;
var lx = -1, ly = -1;
var cx = 0;
var cy = 0;
var mx = 0;
var my = 0;
var lx = -1;
var ly = -1;
this.reset = function() {
this.button = [false, false, false];
this.button = [0, 0, 0];
cx = cy = 0;
lx = ly = -1;
};
this.mousedown = function(e) {
e = e || window.event; if (e === undefined) return;
e = e || window.event;
if (!e) return;
this.button[e.button] = true;
};
this.mouseup = function(e) {
e = e || window.event; if (e === undefined) return;
e = e || window.event;
if (!e) return;
this.button[e.button] = false;
};
this.mouseover = function(e) {
e = e || window.event; if (e === undefined) return;
if (SAEV_config.video.cursor == SAEC_Config_Video_Cursor_Hide)
SAER.video.hideCursor(true);
//SAER.video.hideCursor(1);
this.mousemove(e);
lx = cx;
ly = cy;
};
this.mouseout = function(e) {
e = e || window.event; if (e === undefined) return;
//SAER.video.hideCursor(0);
this.mouseup(e);
if (SAEV_config.video.cursor == SAEC_Config_Video_Cursor_Hide)
SAER.video.hideCursor(false);
};
this.mousemove = function(e) {
e = e || window.event; if (e === undefined) return;
e = e || window.event;
if (!e) return;
if (e.pageX !== undefined) {
if (e.pageX || e.pageY) {
cx = e.pageX;
cy = e.pageY;
} else if (e.clientX !== undefined) {
} else if (e.clientX || e.clientY) {
cx = e.clientX;
cy = e.clientY;
} else
cx = cy = 0;
}
if (lx == -1) {
lx = cx;
ly = cy;
@ -80,25 +76,6 @@ function SAEO_Mouse() {
//SAEF_log("input.mousemove() %d %d", cx, cy);
};
this.mousemove_locked = function(e) {
e = e || window.event; if (e === undefined) return;
if (e.movementX !== undefined) {
cx += e.movementX;
cy += e.movementY;
} else if (e.mozMovementX !== undefined) {
cx += e.mozMovementX;
cy += e.mozMovementY;
} else
cx = cy = 0;
if (lx == -1) {
lx = cx;
ly = cy;
}
//SAEF_log("input.mousemove_locked() %d %d", cx, cy);
};
this.update = function() {
if (lx != -1) {
var dx = cx - lx;
@ -132,80 +109,15 @@ function SAEO_Mouse() {
}
}
function SAEO_Joystick(port) {
this.port = port;
function SAEO_Joystick(type) {
this.type = type;
this.button = [false, false, false];
this.state = [false, false, false, false];
this.dir = 0;
this.requestID = null;
this.reset = function() {
this.button = [false, false, false];
this.state = [false, false, false, false];
this.dir = 0;
this.requestID = null;
};
this.setup = function() {
if (SAEV_config.ports[this.port].type == SAEC_Config_Ports_Type_Joy) {
var dev = SAEV_config.ports[this.port].device;
var pad;
if (navigator.getGamepads)
pad = navigator.getGamepads()[dev];
else if (navigator.webkitGetGamepads)
pad = navigator.webkitGetGamepads()[dev];
else
pad = null;
if (pad && pad.connected) {
var joystick = this;
/* the gamepad API only supports polling not events */
function pollGamepad() {
var dev = SAEV_config.ports[joystick.port].device;
var pad;
if (navigator.getGamepads)
pad = navigator.getGamepads()[dev];
else if (navigator.webkitGetGamepads)
pad = navigator.webkitGetGamepads()[dev];
else
pad = null;
if (pad && pad.connected) {
joystick.button = [
pad.buttons[0].pressed,
pad.buttons[1].pressed,
false /* ignore fire2/button3 */
];
joystick.state = [
pad.axes[0] < -0.6, /* l */
pad.axes[1] < -0.6, /* u */
pad.axes[0] > 0.6, /* r */
pad.axes[1] > 0.6 /* d */
];
joystick.requestID = window.requestAnimationFrame(pollGamepad); /* next request */
}
}
this.requestID = window.requestAnimationFrame(pollGamepad); /* initial request */
SAEF_log("Joystick.setup() assigned controller " + pad.id + " #" + pad.index + " to port " + this.port);
} else {
SAEF_error("Joystick.setup() chosen gamepad device with index " + dev + " was not detected.");
return SAEE_Input_GamepadNotReady;
}
}
return SAEE_None;
};
this.cleanup = function() {
if (SAEV_config.ports[this.port].type == SAEC_Config_Ports_Type_Joy) {
if (this.requestID !== null) {
window.cancelAnimationFrame(this.requestID);
this.requestID = null;
}
}
};
this.update = function() {
@ -230,7 +142,7 @@ function SAEO_Joystick(port) {
var b9 = (l ^ 1) ? 2 : 0;
this.dir = ((b8 | b9) << 8) | (b0 | b1);*/
};
}
}
function SAEO_Keyboard() {
@ -659,7 +571,7 @@ function SAEO_Keyboard() {
}
/* joystick emul */
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_JoyEmu) {
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy0) {
var l, u, r, d, f1, f2;
switch (SAEV_config.ports[0].move) {
case SAEC_Config_Ports_Move_Arrows:
@ -712,7 +624,7 @@ function SAEO_Keyboard() {
}
}
}
if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_JoyEmu) {
if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy1) {
var l, u, r, d, f1, f2;
switch (SAEV_config.ports[1].move) {
case SAEC_Config_Ports_Move_Arrows:
@ -838,8 +750,8 @@ function SAEO_Keyboard() {
function SAEO_Input() {
this.mouse = new SAEO_Mouse();
this.joystick = new Array(2);
this.joystick[0] = new SAEO_Joystick(0);
this.joystick[1] = new SAEO_Joystick(1);
this.joystick[0] = new SAEO_Joystick(SAEC_Config_Ports_Type_Joy0);
this.joystick[1] = new SAEO_Joystick(SAEC_Config_Ports_Type_Joy1);
this.keyboard = new SAEO_Keyboard();
var potgo = {
@ -848,22 +760,10 @@ function SAEO_Input() {
};
this.setup = function () {
var err;
this.keyboard.setup();
if ((err = this.joystick[0].setup()) == SAEE_None) {
if ((err = this.joystick[1].setup()) == SAEE_None)
return SAEE_None;
this.joystick[0].cleanup();
}
this.keyboard.cleanup();
return err;
};
this.cleanup = function () {
this.joystick[1].cleanup();
this.joystick[0].cleanup();
this.keyboard.cleanup();
};
@ -892,18 +792,11 @@ function SAEO_Input() {
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) {
if (this.mouse.button[2]) v &= 0xfbff;
if (this.mouse.button[1]) v &= 0xfeff;
} else if (
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy ||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_JoyEmu
){
} else if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy0) {
if (this.joystick[0].button[1]) v &= 0xfbff;
if (this.joystick[0].button[2]) v &= 0xfeff;
}
if (
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy ||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_JoyEmu
){
if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy1) {
if (this.joystick[1].button[1]) v &= 0xbfff;
if (this.joystick[1].button[2]) v &= 0xefff;
}
@ -929,10 +822,7 @@ function SAEO_Input() {
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) {
this.mouse.update();
return this.mouse.pos;
} else if (
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy ||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_JoyEmu
) {
} else if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy0) {
this.joystick[0].update();
return this.joystick[0].dir;
}
@ -943,10 +833,7 @@ function SAEO_Input() {
if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Mouse) {
this.mouse.update();
return this.mouse.pos;
} else if (
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy ||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_JoyEmu
) {
} else if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy1) {
this.joystick[1].update();
return this.joystick[1].dir;
}
@ -957,3 +844,4 @@ function SAEO_Input() {
//SAEF_log("Input.JOYTEST() $%04x", v);
}
}

24
sae/prototypes.js vendored
View file

@ -76,27 +76,3 @@ if (!performance.now) {
return Date.now() - this.timing.navigationStart;
};
}
/*-----------------------------------------------------------------------*/
/* AnimationFrame */
(function() {
var lastTime = 0;
if (!window.requestAnimationFrame) {
console.warn("This browser does not support 'window.requestAnimationFrame'. Falling back to 'setTimeout'...");
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
if (!window.cancelAnimationFrame) {
console.warn("This browser does not support 'window.cancelAnimationFrame'. Falling back to 'clearTimeout'...");
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
}());

View file

@ -479,7 +479,7 @@ function SAEF_ZFile_fopen_file(file) {
var l = SAEF_ZFile_create(null, file.name);
l.name = file.name.length ? file.name : "";
if (0) { /* reference-mode. do not enable */
if (0) { /* ptr-mode. do not enable */
l.data = file.data;
} else {
l.data = new Uint8Array(file.size);
@ -493,13 +493,6 @@ function SAEF_ZFile_fopen_file(file) {
l.datasize = file.size;
l.allocsize = file.size; //OWN
var magic = ((l.data[0] << 24) | (l.data[1] << 16) | (l.data[2] << 8) | (l.data[3])) >>> 0;
//SAEF_log("SAEF_ZFile_fopen_file() opening '%s', %d/%d bytes, crc32 0x%08x, magic %08x", l.name, l.size, l.data.length, file.crc32 !== false ? file.crc32 : 0, magic);
if (magic == 0x504B0304 || magic == 0x04034B50)
SAEF_fatal(SAEE_Config_Compressed, "A ZIP file was detected. Compressed files are not yet supported.");
//if (l.data[0] == 68 && l.data[1] == 77 && l.data[2] == 83 && l.data[3] == 33) { /* DMS! */
if (SAEF_CompareArray(l.data, SAEF_String2Array("DMS!"), 4) == 0) {
var dms = new SAEO_DMS();

View file

@ -90,7 +90,6 @@ function SAEO_Video() {
this.ctx = null;
this.texture = null;
this.surface = null;
this.requestPointerLock = null;
this.div = null;
this.shown = false;
@ -195,24 +194,6 @@ function SAEO_Video() {
return SAEE_None;
}
function pointerLockChange() {
if (document.pointerLockElement === hAmigaWnd.canvas || document.mozPointerLockElement === hAmigaWnd.canvas) {
hAmigaWnd.canvas.onmousedown = function(e) {
SAER.input.mouse.mousedown(e);
};
hAmigaWnd.canvas.onmouseup = function(e) {
SAER.input.mouse.mouseup(e);
};
document.addEventListener("mousemove", SAER.input.mouse.mousemove_locked, false);
//SAEF_log("sae.video() mouse-pointer locked");
} else {
hAmigaWnd.canvas.onmousedown = function(e) {};
hAmigaWnd.canvas.onmouseup = function(e) {};
document.removeEventListener("mousemove", SAER.input.mouse.mousemove_locked, false);
//SAEF_log("sae.video() mouse-pointer unlocked");
}
}
function CreateWindow(left, top, width, height) {
var hWnd = new HWND();
@ -256,48 +237,26 @@ function SAEO_Video() {
return false;
};
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) {
if (SAEV_config.video.cursor == SAEC_Config_Video_Cursor_Lock)
hWnd.canvas.requestPointerLock = hWnd.canvas.requestPointerLock || hWnd.canvas.mozRequestPointerLock;
else
hWnd.canvas.requestPointerLock = null;
if (typeof hWnd.canvas.requestPointerLock == "function") {
document.addEventListener("pointerlockchange", pointerLockChange, false);
document.addEventListener("mozpointerlockchange", pointerLockChange, false);
hWnd.canvas.onclick = function(e) {
if (!(document.pointerLockElement === hAmigaWnd.canvas || document.mozPointerLockElement === hAmigaWnd.canvas))
hWnd.canvas.requestPointerLock();
};
} else {
hWnd.canvas.onmousedown = function(e) {
SAER.input.mouse.mousedown(e);
};
hWnd.canvas.onmouseup = function(e) {
SAER.input.mouse.mouseup(e);
};
hWnd.canvas.onmouseover = function(e) {
SAER.input.mouse.mouseover(e);
};
hWnd.canvas.onmouseout = function(e) {
SAER.input.mouse.mouseout(e);
};
hWnd.canvas.onmousemove = function(e) {
SAER.input.mouse.mousemove(e);
};
hWnd.canvas.onmousedown = function(e) {
SAER.input.mouse.mousedown(e);
};
hWnd.canvas.onmouseup = function(e) {
SAER.input.mouse.mouseup(e);
};
hWnd.canvas.onmouseover = function(e) {
SAER.input.mouse.mouseover(e);
};
hWnd.canvas.onmouseout = function(e) {
SAER.input.mouse.mouseout(e);
};
hWnd.canvas.onmousemove = function(e) {
SAER.input.mouse.mousemove(e);
}
}
return hWnd;
}
function DestroyWindow(hWnd) {
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) {
if (typeof hWnd.canvas.requestPointerLock == "function") {
document.removeEventListener('pointerlockchange', pointerLockChange, false);
document.removeEventListener('mozpointerlockchange', pointerLockChange, false);
}
hWnd.canvas.requestPointerLock = null;
}
if (SAEV_config.video.api == SAEC_Config_Video_API_WebGL)
hWnd.texture = null;
else if (SAEV_config.video.api == SAEC_Config_Video_API_Canvas)
@ -319,16 +278,16 @@ function SAEO_Video() {
hWnd.div.style.width = String(currentmode.native_width)+"px";
hWnd.div.style.height = String(currentmode.native_height)+"px";
hWnd.div.appendChild(hWnd.canvas);
} else {
} else
hWnd.div = null;
hWnd.canvas.style.width = String(currentmode.native_width)+"px";
hWnd.canvas.style.height = String(currentmode.native_height)+"px";
}
hWnd.shown = true;
}
else if (nCmdShow == SW_HIDE && hWnd.shown) {
if (hWnd.div !== null)
if (hWnd.div !== null) {
hWnd.div.removeChild(hWnd.canvas);
hWnd.canvas = null;
}
hWnd.shown = false;
}
@ -2056,11 +2015,6 @@ function SAEO_Video() {
DirectDraw_ReleaseDC(hdc);
}*/
this.hideCursor = function(hide) {
if (hAmigaWnd !== null && hAmigaWnd.shown)
hAmigaWnd.canvas.style.cursor = hide ? "none" : "auto";
}
/*-----------------------------------------------------------------------*/
//var flushymin = 0, flushymax = 0;