update 0.9.0 goodies
This commit is contained in:
parent
d99a5c7185
commit
e401b93e22
11 changed files with 514 additions and 93 deletions
|
|
@ -80,7 +80,7 @@
|
|||
</div>
|
||||
<div style="height:5px"></div>
|
||||
<div id="foot" class="foot" style="line-height:14px">
|
||||
<span class="gray">2012-2016 Rupert Hausberger</span> |
|
||||
<span class="gray">2012-2017 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>
|
||||
|
|
|
|||
44
index.htm
44
index.htm
|
|
@ -1219,11 +1219,13 @@
|
|||
<table>
|
||||
<tr>
|
||||
<td class="arm"><span class="label">Driver</span></td>
|
||||
<td colspan="3"></td>
|
||||
<td></td>
|
||||
<td class="arm"><span class="label">Cursor</span></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="arm">Mode</td>
|
||||
<td colspan="3">
|
||||
<td>
|
||||
<select id="cfg_video_api" size="1" onchange="videoUpdateAPI()">
|
||||
<option value="1">WebGL</option>
|
||||
<option value="0">Canvas</option>
|
||||
|
|
@ -1233,6 +1235,14 @@
|
|||
<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>
|
||||
|
|
@ -1493,10 +1503,11 @@
|
|||
<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_grp">
|
||||
<div id="cfg_ports_0_joyemu_grp">
|
||||
Move
|
||||
<select id="cfg_ports_0_move" size="1">
|
||||
<option value="1">Arrows</option>
|
||||
|
|
@ -1556,6 +1567,13 @@
|
|||
<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>
|
||||
|
|
@ -1564,11 +1582,12 @@
|
|||
<td>
|
||||
<select id="cfg_ports_1" size="1" onchange="portUpdate(1)">
|
||||
<option value="0">Disabled</option>
|
||||
<option value="3">Joystick</option>
|
||||
<option value="2">Joystick</option>
|
||||
<option value="3">Emulated</option>
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<div id="cfg_ports_1_grp">
|
||||
<div id="cfg_ports_1_joyemu_grp">
|
||||
Move
|
||||
<select id="cfg_ports_1_move" size="1">
|
||||
<option value="1">Arrows</option>
|
||||
|
|
@ -1628,9 +1647,20 @@
|
|||
<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>
|
||||
|
|
@ -1638,7 +1668,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<td class="arm"><input id="cfg_keyborad_enabled" type="checkbox" /></td>
|
||||
<td class="alm" colspan="3">Enabled <span class="info">(joystick-emulation does always work)</span></td>
|
||||
<td class="alm" colspan="3">Enabled <span class="info">(emulated joysticks do always work)</span></td>
|
||||
</tr>
|
||||
<tr><td colspan="4"><div style="height:10px"></div></td></tr>
|
||||
<tr>
|
||||
|
|
@ -1662,7 +1692,7 @@
|
|||
</div>
|
||||
<div style="height:5px"></div>
|
||||
<div id="foot" class="foot" style="line-height:14px">
|
||||
<span class="gray">2012-2016 Rupert Hausberger</span> |
|
||||
<span class="gray">2012-2017 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>
|
||||
|
|
|
|||
156
index.js
156
index.js
|
|
@ -523,6 +523,7 @@ 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+")";
|
||||
}
|
||||
}
|
||||
|
|
@ -994,12 +995,22 @@ 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() {
|
||||
|
|
@ -1110,6 +1121,7 @@ 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);
|
||||
|
|
@ -1158,13 +1170,17 @@ 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_grp", cfg.ports[0].type == SAEC_Config_Ports_Type_Joy0);
|
||||
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);
|
||||
|
||||
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_grp", cfg.ports[1].type == SAEC_Config_Ports_Type_Joy1);
|
||||
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);
|
||||
|
||||
setCheckbox("cfg_keyborad_enabled", cfg.keyboard.enabled);
|
||||
|
||||
|
|
@ -1302,6 +1318,7 @@ 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");
|
||||
|
|
@ -1360,26 +1377,49 @@ function getAdvandedConfig() {
|
|||
|
||||
/* ports */
|
||||
cfg.ports[0].type = getSelect("cfg_ports_0");
|
||||
if (cfg.ports[0].type == SAEC_Config_Ports_Type_Joy0) {
|
||||
if (cfg.ports[0].type == SAEC_Config_Ports_Type_JoyEmu) {
|
||||
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 port 0 can\"t be the same.");
|
||||
alert("Fire-button 1/2 on mouse-port can't be the same.");
|
||||
changePage(PID_Ports);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
cfg.ports[1].type = getSelect("cfg_ports_1");
|
||||
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 port 1 can\"t be the same.");
|
||||
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) {
|
||||
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);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
cfg.keyboard.enabled = getCheckbox("cfg_keyborad_enabled");
|
||||
|
||||
cfg.serial.enabled = getCheckbox("cfg_serial_enabled");
|
||||
|
|
@ -1397,7 +1437,7 @@ function start() {
|
|||
if (s == S_VALID) { /* all files are downloaded or cached, go! */
|
||||
freezeButtons(false, true);
|
||||
|
||||
var err = sae.start(); /* this does start the emulator */
|
||||
var err = sae.start(); /* send start-request */
|
||||
if (err != SAEE_None)
|
||||
alert(saee2text(err));
|
||||
}
|
||||
|
|
@ -1465,6 +1505,7 @@ function init() {
|
|||
//console.log(cfg);
|
||||
|
||||
initHooks();
|
||||
initGamepads();
|
||||
|
||||
dbInit();
|
||||
setDatabaseConfig();
|
||||
|
|
@ -2460,11 +2501,14 @@ function channelsUpdate() {
|
|||
/*---------------------------------*/
|
||||
|
||||
function portUpdate(n) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
|
@ -2679,3 +2723,81 @@ 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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
65
readme.htm
65
readme.htm
|
|
@ -21,10 +21,12 @@
|
|||
<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>
|
||||
|
|
@ -57,6 +59,8 @@
|
|||
<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>
|
||||
|
|
@ -307,6 +311,21 @@
|
|||
<li>Or, go to "Chipset/Features/Manual" and select "Onboard-IDE" or "PCMCIA-slot" 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>
|
||||
|
|
@ -342,6 +361,14 @@
|
|||
</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>
|
||||
|
|
@ -360,7 +387,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 games. Thanks for your support!</li>
|
||||
<li>All people who contributed their software or helped via github. Thanks for your support!</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
@ -397,6 +424,40 @@
|
|||
<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
|
||||
|
|
@ -833,7 +894,7 @@
|
|||
</div>
|
||||
<div style="height:5px"></div>
|
||||
<div id="foot" class="foot" style="line-height:14px">
|
||||
<span class="gray">2012-2016 Rupert Hausberger</span> |
|
||||
<span class="gray">2012-2017 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>
|
||||
|
|
|
|||
21
sae/amiga.js
21
sae/amiga.js
|
|
@ -92,6 +92,8 @@ const SAEE_Video_LinkShader = 44;
|
|||
|
||||
const SAEE_Audio_RequiresWebAudio = 50;
|
||||
|
||||
const SAEE_Input_GamepadNotReady = 60;
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* global references */
|
||||
|
||||
|
|
@ -147,7 +149,11 @@ const SAEC_info = (function() {
|
|||
},
|
||||
video: {
|
||||
canvas: false,
|
||||
webGL: false
|
||||
webGL: false,
|
||||
pointerLock: false
|
||||
},
|
||||
input: {
|
||||
gamepad: false
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -216,6 +222,7 @@ const SAEC_info = (function() {
|
|||
var ctx = canvas.getContext("2d");
|
||||
var imageData = ctx.createImageData(16, 16);
|
||||
info.video.canvas = true;
|
||||
|
||||
try {
|
||||
const glParams = {
|
||||
alpha: false,
|
||||
|
|
@ -229,9 +236,16 @@ 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;
|
||||
})();
|
||||
|
||||
|
|
@ -454,9 +468,8 @@ function ScriptedAmigaEmulator() {
|
|||
return err;
|
||||
if ((err = this.audio.obtain()) != SAEE_None)
|
||||
return err;
|
||||
|
||||
this.input.setup(); //inputdevice_init();
|
||||
|
||||
if ((err = this.input.setup()) != SAEE_None) //inputdevice_init();
|
||||
return err;
|
||||
if ((err = this.gui.setup()) != SAEE_None)
|
||||
return err;
|
||||
|
||||
|
|
|
|||
12
sae/audio.js
12
sae/audio.js
|
|
@ -211,11 +211,11 @@ function SAEO_Audio() {
|
|||
|
||||
/*---------------------------------*/
|
||||
|
||||
const INV32768 = 1.0 / 32768; /* mul is always fasten than div */
|
||||
const INV32768 = 1.0 / 32768; /* mul is always faster than div */
|
||||
|
||||
function scaleplay(e, buffer, frames) {
|
||||
var chn=SAEV_config.audio.channels;
|
||||
var z=e.outputBuffer.length;
|
||||
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);
|
||||
|
|
@ -224,13 +224,13 @@ function SAEO_Audio() {
|
|||
}
|
||||
return;
|
||||
}
|
||||
/*if (driver.context.sampleRate != used_freq) {
|
||||
} else*/ {
|
||||
/*if (driver.context.sampleRate != used_freq) {} else*/
|
||||
{
|
||||
var step = frames / z;
|
||||
|
||||
for (var ch = 0; ch < chn; ch++) {
|
||||
var data = e.outputBuffer.getChannelData(ch);
|
||||
var tbuf=buffer[ch];
|
||||
var tbuf = buffer[ch];
|
||||
for (var i = 0, j = 0.0; i < z; i++, j += step)
|
||||
data[i] = tbuf[j >>> 0] * INV32768;
|
||||
}
|
||||
|
|
|
|||
13
sae/cia.js
13
sae/cia.js
|
|
@ -793,8 +793,7 @@ 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);
|
||||
|
|
@ -824,12 +823,18 @@ 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_Joy0) {
|
||||
} else if (
|
||||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy ||
|
||||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_JoyEmu
|
||||
) {
|
||||
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_Joy1) {
|
||||
if (
|
||||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy ||
|
||||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_JoyEmu
|
||||
) {
|
||||
if (!SAER.input.joystick[1].button[0]) tmp |= 0x80;
|
||||
if (dra & 0x80) tmp = (tmp & ~0x80) | (pra & 0x80);
|
||||
} else tmp |= 0x80;
|
||||
|
|
|
|||
|
|
@ -266,6 +266,10 @@ 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;
|
||||
|
|
@ -372,8 +376,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_Joy0 = 2;
|
||||
const SAEC_Config_Ports_Type_Joy1 = 3;
|
||||
const SAEC_Config_Ports_Type_Joy = 2;
|
||||
const SAEC_Config_Ports_Type_JoyEmu = 3;
|
||||
|
||||
const SAEC_Config_Ports_Move_None = 0;
|
||||
const SAEC_Config_Ports_Move_Arrows = 1;
|
||||
|
|
@ -382,6 +386,8 @@ const SAEC_Config_Ports_Move_WASD = 3;
|
|||
|
||||
const SAEC_Config_Ports_Fire_None = 0;
|
||||
|
||||
const SAEC_Config_Ports_Device_None = -1;
|
||||
|
||||
/*---------------------------------*/
|
||||
/* debug */
|
||||
|
||||
|
|
@ -574,8 +580,7 @@ function SAEO_Config() {
|
|||
this.video = {
|
||||
id: "",
|
||||
enabled: false,
|
||||
//driver: 0,
|
||||
hideCursor: false,
|
||||
cursor: 0,
|
||||
|
||||
scandoubler: false, //gfx_scandoubler
|
||||
framerate: 0, //gfx_framerate
|
||||
|
|
@ -673,11 +678,13 @@ function SAEO_Config() {
|
|||
this.ports = [{
|
||||
type: SAEC_Config_Ports_Type_Mouse,
|
||||
move: SAEC_Config_Ports_Move_WASD,
|
||||
fire: [49,50]
|
||||
fire: [49,50],
|
||||
device: SAEC_Config_Ports_Device_None
|
||||
}, {
|
||||
type: SAEC_Config_Ports_Type_Joy1,
|
||||
type: SAEC_Config_Ports_Type_JoyEmu,
|
||||
move: SAEC_Config_Ports_Move_Arrows,
|
||||
fire: [16,17]
|
||||
fire: [16,17],
|
||||
device: SAEC_Config_Ports_Device_None
|
||||
}];
|
||||
|
||||
this.keyboard = {
|
||||
|
|
@ -1076,7 +1083,7 @@ function SAEO_Configuration() {
|
|||
|
||||
p.video.id = "video";
|
||||
p.video.enabled = true;
|
||||
p.video.hideCursor = 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;
|
||||
|
|
@ -1161,9 +1168,11 @@ 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[1].type = SAEC_Config_Ports_Type_Joy1;
|
||||
p.ports[0].device = SAEC_Config_Ports_Device_None;
|
||||
p.ports[1].type = SAEC_Config_Ports_Type_JoyEmu;
|
||||
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));
|
||||
|
|
@ -2400,7 +2409,17 @@ 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
168
sae/input.js
168
sae/input.js
|
|
@ -19,35 +19,32 @@ function SAEO_Mouse() {
|
|||
this.button = [false, false, false];
|
||||
this.pos = 0;
|
||||
|
||||
var cx = 0;
|
||||
var cy = 0;
|
||||
var mx = 0;
|
||||
var my = 0;
|
||||
var lx = -1;
|
||||
var ly = -1;
|
||||
var cx = 0, cy = 0;
|
||||
var mx = 0, my = 0;
|
||||
var lx = -1, ly = -1;
|
||||
|
||||
this.reset = function() {
|
||||
this.button = [0, 0, 0];
|
||||
this.button = [false, false, false];
|
||||
cx = cy = 0;
|
||||
lx = ly = -1;
|
||||
};
|
||||
|
||||
this.mousedown = function(e) {
|
||||
e = e || window.event;
|
||||
if (!e) return;
|
||||
e = e || window.event; if (e === undefined) return;
|
||||
|
||||
this.button[e.button] = true;
|
||||
};
|
||||
|
||||
this.mouseup = function(e) {
|
||||
e = e || window.event;
|
||||
if (!e) return;
|
||||
e = e || window.event; if (e === undefined) return;
|
||||
|
||||
this.button[e.button] = false;
|
||||
};
|
||||
|
||||
this.mouseover = function(e) {
|
||||
if (SAEV_config.video.hideCursor)
|
||||
e = e || window.event; if (e === undefined) return;
|
||||
|
||||
if (SAEV_config.video.cursor == SAEC_Config_Video_Cursor_Hide)
|
||||
SAER.video.hideCursor(true);
|
||||
|
||||
this.mousemove(e);
|
||||
|
|
@ -56,23 +53,26 @@ function SAEO_Mouse() {
|
|||
};
|
||||
|
||||
this.mouseout = function(e) {
|
||||
e = e || window.event; if (e === undefined) return;
|
||||
|
||||
this.mouseup(e);
|
||||
|
||||
if (SAEV_config.video.hideCursor)
|
||||
if (SAEV_config.video.cursor == SAEC_Config_Video_Cursor_Hide)
|
||||
SAER.video.hideCursor(false);
|
||||
};
|
||||
|
||||
this.mousemove = function(e) {
|
||||
e = e || window.event;
|
||||
if (!e) return;
|
||||
e = e || window.event; if (e === undefined) return;
|
||||
|
||||
if (e.pageX || e.pageY) {
|
||||
if (e.pageX !== undefined) {
|
||||
cx = e.pageX;
|
||||
cy = e.pageY;
|
||||
} else if (e.clientX || e.clientY) {
|
||||
} else if (e.clientX !== undefined) {
|
||||
cx = e.clientX;
|
||||
cy = e.clientY;
|
||||
}
|
||||
} else
|
||||
cx = cy = 0;
|
||||
|
||||
if (lx == -1) {
|
||||
lx = cx;
|
||||
ly = cy;
|
||||
|
|
@ -80,6 +80,25 @@ 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;
|
||||
|
|
@ -113,15 +132,80 @@ function SAEO_Mouse() {
|
|||
}
|
||||
}
|
||||
|
||||
function SAEO_Joystick(type) {
|
||||
this.type = type;
|
||||
function SAEO_Joystick(port) {
|
||||
this.port = port;
|
||||
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() {
|
||||
|
|
@ -146,7 +230,7 @@ function SAEO_Joystick(type) {
|
|||
var b9 = (l ^ 1) ? 2 : 0;
|
||||
|
||||
this.dir = ((b8 | b9) << 8) | (b0 | b1);*/
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function SAEO_Keyboard() {
|
||||
|
|
@ -575,7 +659,7 @@ function SAEO_Keyboard() {
|
|||
}
|
||||
|
||||
/* joystick emul */
|
||||
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy0) {
|
||||
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_JoyEmu) {
|
||||
var l, u, r, d, f1, f2;
|
||||
switch (SAEV_config.ports[0].move) {
|
||||
case SAEC_Config_Ports_Move_Arrows:
|
||||
|
|
@ -628,7 +712,7 @@ function SAEO_Keyboard() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy1) {
|
||||
if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_JoyEmu) {
|
||||
var l, u, r, d, f1, f2;
|
||||
switch (SAEV_config.ports[1].move) {
|
||||
case SAEC_Config_Ports_Move_Arrows:
|
||||
|
|
@ -754,8 +838,8 @@ function SAEO_Keyboard() {
|
|||
function SAEO_Input() {
|
||||
this.mouse = new SAEO_Mouse();
|
||||
this.joystick = new Array(2);
|
||||
this.joystick[0] = new SAEO_Joystick(SAEC_Config_Ports_Type_Joy0);
|
||||
this.joystick[1] = new SAEO_Joystick(SAEC_Config_Ports_Type_Joy1);
|
||||
this.joystick[0] = new SAEO_Joystick(0);
|
||||
this.joystick[1] = new SAEO_Joystick(1);
|
||||
this.keyboard = new SAEO_Keyboard();
|
||||
|
||||
var potgo = {
|
||||
|
|
@ -764,10 +848,22 @@ 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();
|
||||
};
|
||||
|
||||
|
|
@ -796,11 +892,18 @@ 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_Joy0) {
|
||||
} else if (
|
||||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy ||
|
||||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_JoyEmu
|
||||
){
|
||||
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_Joy1) {
|
||||
|
||||
if (
|
||||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy ||
|
||||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_JoyEmu
|
||||
){
|
||||
if (this.joystick[1].button[1]) v &= 0xbfff;
|
||||
if (this.joystick[1].button[2]) v &= 0xefff;
|
||||
}
|
||||
|
|
@ -826,7 +929,10 @@ 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_Joy0) {
|
||||
} else if (
|
||||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Joy ||
|
||||
SAEV_config.ports[0].type == SAEC_Config_Ports_Type_JoyEmu
|
||||
) {
|
||||
this.joystick[0].update();
|
||||
return this.joystick[0].dir;
|
||||
}
|
||||
|
|
@ -837,7 +943,10 @@ 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_Joy1) {
|
||||
} else if (
|
||||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Joy ||
|
||||
SAEV_config.ports[1].type == SAEC_Config_Ports_Type_JoyEmu
|
||||
) {
|
||||
this.joystick[1].update();
|
||||
return this.joystick[1].dir;
|
||||
}
|
||||
|
|
@ -848,4 +957,3 @@ function SAEO_Input() {
|
|||
//SAEF_log("Input.JOYTEST() $%04x", v);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
24
sae/prototypes.js
vendored
24
sae/prototypes.js
vendored
|
|
@ -76,3 +76,27 @@ 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);
|
||||
};
|
||||
}
|
||||
}());
|
||||
|
|
|
|||
45
sae/video.js
45
sae/video.js
|
|
@ -90,6 +90,7 @@ function SAEO_Video() {
|
|||
this.ctx = null;
|
||||
this.texture = null;
|
||||
this.surface = null;
|
||||
this.requestPointerLock = null;
|
||||
|
||||
this.div = null;
|
||||
this.shown = false;
|
||||
|
|
@ -194,6 +195,24 @@ 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();
|
||||
|
||||
|
|
@ -237,6 +256,20 @@ 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);
|
||||
};
|
||||
|
|
@ -251,12 +284,20 @@ function SAEO_Video() {
|
|||
};
|
||||
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)
|
||||
|
|
@ -286,10 +327,8 @@ function SAEO_Video() {
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue