Compare commits

..
Author SHA1 Message Date
Rupert Hausberger
582a980c74
Merge pull request #20 from steffest/master
Bugfix in DMS decompression with DEEP Compression
2018-02-19 19:38:43 +01:00
Steffest
9f34fe7a73 Bugfix in DMS decompression with DEEP Compression 2018-02-19 17:44:57 +01:00
Rupert Hausberger
e401b93e22 update 0.9.0 goodies 2017-08-15 00:49:19 +02:00
Rupert Hausberger
d99a5c7185 Merge pull request #15 from Intexk/patch-1
Performance in scaleplay function
2017-04-06 20:22:43 +02:00
Intexk
cffb6c8920 Update audio.js
Improves the perfomance of that function by caching some values that doesn't change during loop.
2017-04-05 11:08:07 +01:00
Rupert Hausberger
f67b42e831 Merge pull request #11 from db48x/dont-unmute-on-reset
update
2016-08-08 03:33:47 +02:00
Daniel Brooks
7b71a91721 make sure we're unmuted during setup, but don't unmute during reset 2016-08-07 18:31:48 -07:00
Rupert Hausberger
f1f8a1e846 update 0.9.0 2016-08-06 02:19:59 +02:00
Rupert Hausberger
470f65cca4 update 0.9.0 2016-08-02 22:03:47 +02:00
Rupert Hausberger
091eda539f update 2016-08-02 00:03:44 +02:00
Rupert Hausberger
8367c0d32e update 2016-08-01 22:32:29 +02:00
Rupert Hausberger
83e9dbd1e6 test 2016-08-01 20:03:07 +02:00
Rupert Hausberger
d964c21903 test 2016-08-01 18:52:17 +02:00
Rupert Hausberger
99eeb532c3 update 2016-08-01 18:10:41 +02:00
Rupert Hausberger
4d6e683ff6 update 2016-08-01 18:04:01 +02:00
Rupert Hausberger
cc08d24dd4 Merge branch 'master' of https://github.com/naTmeg/ScriptedAmigaEmulator 2016-08-01 18:01:48 +02:00
Rupert Hausberger
61f71da4df update 2016-08-01 18:01:43 +02:00
Rupert Hausberger
95a8aeeb5b Merge pull request #10 from naTmeg/revert-9-source-map
Revert "create a source map when compiling the js"
2016-08-01 17:41:05 +02:00
Rupert Hausberger
f06f7c081c update 0.9.0 2016-08-01 17:33:13 +02:00
19 changed files with 664 additions and 140 deletions

9
.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
*.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,2 +1,3 @@
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 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 $@ closure-compiler --language_in=ECMASCRIPT6 --language_out ES5 $^ --js_output_file $@ --create_source_map $@.map
printf "/*\n//@ sourceMappingURL=%b\n*/" $@.map >> $@

View file

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

View file

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

View file

@ -23,6 +23,7 @@ var inf = null; /* Reference to the info-object */
var running = false; /* Is the emualtion currently running? */ var running = false; /* Is the emualtion currently running? */
var paused = false; /* Is the emualtion currently paused? */ var paused = false; /* Is the emualtion currently paused? */
var muted = false; /* Is the audio-output currently muted? */
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
/* Helpers */ /* Helpers */
@ -64,14 +65,27 @@ 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) { function saee2text(err) {
switch (err) { switch (err) {
case SAEE_AlreadyRunning: return "The emulator is already running."; case SAEE_AlreadyRunning: return "The emulator is already running.";
case SAEE_NotRunning: return "The emulator is not running."; case SAEE_NotRunning: return "The emulator is not running.";
case SAEE_NoTimer: return "No timing-functions avail. Please upgrade your browser."; case SAEE_NoTimer: return "No timing-functions avail. Please upgrade your browser.";
case SAEE_NoMemory: return "Out of memory."; case SAEE_NoMemory: return "Out of memory.";
case SAEE_Assert: return "Assertiation failed.";
case SAEE_Internal: return "Internal emulator error."; case SAEE_Internal: return "Internal emulator error.";
case SAEE_Config_Invalid: return "Invalid configuration."; 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_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_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."; case SAEE_CPU_Requires680EC20: return "The selected kickstart-rom does require a 68020.";
@ -327,6 +341,18 @@ function pause(p) {
alert(saee2text(err)); 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() { function romSelect() {
var e = document.getElementById("cfg_rom_file").files[0]; var e = document.getElementById("cfg_rom_file").files[0];
if (e) { if (e) {
@ -441,6 +467,10 @@ function hook_event_stopped() {
paused = false; paused = false;
switchPauseResume(paused); switchPauseResume(paused);
} }
if (muted) {
muted = false;
switchMutePlay(muted);
}
resetLEDs(); resetLEDs();
} }
@ -450,6 +480,10 @@ function hook_event_reseted(hard) {
paused = false; paused = false;
switchPauseResume(paused); switchPauseResume(paused);
} }
if (muted) {
muted = false;
switchMutePlay(muted);
}
} }
/* Get call after the emulator has finished switching between pause-resume. */ /* Get call after the emulator has finished switching between pause-resume. */

View file

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

View file

@ -1219,11 +1219,13 @@
<table> <table>
<tr> <tr>
<td class="arm"><span class="label">Driver</span></td> <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>
<tr> <tr>
<td class="arm">Mode</td> <td class="arm">Mode</td>
<td colspan="3"> <td>
<select id="cfg_video_api" size="1" onchange="videoUpdateAPI()"> <select id="cfg_video_api" size="1" onchange="videoUpdateAPI()">
<option value="1">WebGL</option> <option value="1">WebGL</option>
<option value="0">Canvas</option> <option value="0">Canvas</option>
@ -1233,6 +1235,14 @@
<option value="5">32 bits per pixel (RGBA)</option> <option value="5">32 bits per pixel (RGBA)</option>
</select> </select>
</td> </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>
<tr> <tr>
<td class="arm"><input id="cfg_video_antialias" type="checkbox" /></td> <td class="arm"><input id="cfg_video_antialias" type="checkbox" /></td>
@ -1493,10 +1503,11 @@
<option value="0">Disabled</option> <option value="0">Disabled</option>
<option value="1">Mouse</option> <option value="1">Mouse</option>
<option value="2">Joystick</option> <option value="2">Joystick</option>
<option value="3">Emulated</option>
</select> </select>
</td> </td>
<td> <td>
<div id="cfg_ports_0_grp"> <div id="cfg_ports_0_joyemu_grp">
Move Move
<select id="cfg_ports_0_move" size="1"> <select id="cfg_ports_0_move" size="1">
<option value="1">Arrows</option> <option value="1">Arrows</option>
@ -1556,6 +1567,13 @@
<option value="50">2</option> <option value="50">2</option>
</select> </select>
</div> </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>
<td style="width:100%"></td> <td style="width:100%"></td>
</tr> </tr>
@ -1564,11 +1582,12 @@
<td> <td>
<select id="cfg_ports_1" size="1" onchange="portUpdate(1)"> <select id="cfg_ports_1" size="1" onchange="portUpdate(1)">
<option value="0">Disabled</option> <option value="0">Disabled</option>
<option value="3">Joystick</option> <option value="2">Joystick</option>
<option value="3">Emulated</option>
</select> </select>
</td> </td>
<td> <td>
<div id="cfg_ports_1_grp"> <div id="cfg_ports_1_joyemu_grp">
Move Move
<select id="cfg_ports_1_move" size="1"> <select id="cfg_ports_1_move" size="1">
<option value="1">Arrows</option> <option value="1">Arrows</option>
@ -1628,9 +1647,20 @@
<option value="50">2</option> <option value="50">2</option>
</select> </select>
</div> </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>
<td style="width:100%"></td> <td style="width:100%"></td>
</tr> </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 colspan="4"><div style="height:10px"></div></td></tr>
<tr> <tr>
<td class="arm"><span class="label">Keyboard</span></td> <td class="arm"><span class="label">Keyboard</span></td>
@ -1638,7 +1668,7 @@
</tr> </tr>
<tr> <tr>
<td class="arm"><input id="cfg_keyborad_enabled" type="checkbox" /></td> <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>
<tr><td colspan="4"><div style="height:10px"></div></td></tr> <tr><td colspan="4"><div style="height:10px"></div></td></tr>
<tr> <tr>
@ -1662,7 +1692,7 @@
</div> </div>
<div style="height:5px"></div> <div style="height:5px"></div>
<div id="foot" class="foot" style="line-height:14px"> <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="readme.htm">Description</a> |
<a target="_blank" href="disass.htm">Disassembler</a> | <a target="_blank" href="disass.htm">Disassembler</a> |
<a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a> <a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a>
@ -1678,6 +1708,7 @@
<td><button onclick="reset()">Reset</button></td> <td><button onclick="reset()">Reset</button></td>
<td><button onclick="stop()">Stop</button></td> <td><button onclick="stop()">Stop</button></td>
<td><button onclick="pause(1)" id="controls_pr">Pause</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 id="controls_disk"><button onclick="dskchgOpen()">Disk</button></td>
<!--<td><button onclick="toggleFullScreen()">FS</button></td>--> <!--<td><button onclick="toggleFullScreen()">FS</button></td>-->
</tr> </tr>

183
index.js
View file

@ -199,6 +199,7 @@ var amaxInfo = null; /* amax rom-info */
var floppyNum = -1; /* current floppy-unit if floppy-info is shown */ var floppyNum = -1; /* current floppy-unit if floppy-info is shown */
var mountConfigNum = -1; /* current mount-unit if mount-info is shown */ var mountConfigNum = -1; /* current mount-unit if mount-info is shown */
var paused = false; /* is the emualtion currently paused? */ 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 dskchg = false; /* disk-change requester in database-mode */
var dskchgList = []; /* list of floppies to change, created dynamicaly */ var dskchgList = []; /* list of floppies to change, created dynamicaly */
@ -439,6 +440,17 @@ 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) { function switchBaseEmul(emul) {
if (emul) { if (emul) {
document.body.style.backgroundColor = "#000000"; document.body.style.backgroundColor = "#000000";
@ -489,8 +501,10 @@ function saee2text(err) {
case SAEE_NotRunning: return "The emulator is not running."; case SAEE_NotRunning: return "The emulator is not running.";
case SAEE_NoTimer: return "No timing-functions avail. Please upgrade your browser."; case SAEE_NoTimer: return "No timing-functions avail. Please upgrade your browser.";
case SAEE_NoMemory: return "Out of memory."; case SAEE_NoMemory: return "Out of memory.";
case SAEE_Assert: return "Assertiation failed.";
case SAEE_Internal: return "Internal emulator error."; case SAEE_Internal: return "Internal emulator error.";
case SAEE_Config_Invalid: return "Invalid configuration."; 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_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_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."; case SAEE_CPU_Requires680EC20: return "The selected kickstart-rom does require a 68020.";
@ -509,6 +523,7 @@ function saee2text(err) {
case SAEE_Video_ComphileShader: return "Can not compile the required shader-program."; 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_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_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+")"; default: return "("+err+")";
} }
} }
@ -980,12 +995,22 @@ function fixAdvandedConfig() {
cfg.video.enabled = false; cfg.video.enabled = false;
else if (SAEV_config.video.api == SAEC_Config_Video_API_WebGL && !inf.video.webGL) else if (SAEV_config.video.api == SAEC_Config_Video_API_WebGL && !inf.video.webGL)
SAEV_config.video.api = SAEC_Config_Video_API_Canvas; 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 */ /* audio */
if (cfg.audio.mode >= SAEC_Config_Audio_Mode_On) { if (cfg.audio.mode >= SAEC_Config_Audio_Mode_On) {
if (!inf.audio.webAudio) if (!inf.audio.webAudio)
cfg.audio.mode = SAEC_Config_Audio_Mode_Off_Emul; 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() { function setAdvandedConfig() {
@ -1096,6 +1121,7 @@ function setAdvandedConfig() {
{ {
setSelect("cfg_video_api", cfg.video.api); setSelect("cfg_video_api", cfg.video.api);
setDisabled("cfg_video_api", inf.video.webGL == false); setDisabled("cfg_video_api", inf.video.webGL == false);
setSelect("cfg_video_cursor", cfg.video.cursor);
setSelect("cfg_video_color_mode", cfg.video.colorMode); setSelect("cfg_video_color_mode", cfg.video.colorMode);
setCheckbox("cfg_video_antialias", cfg.video.antialias); setCheckbox("cfg_video_antialias", cfg.video.antialias);
//setRadio("cfg_video_fs", cfg.video.apmode[0].gfx_fullscreen); //setRadio("cfg_video_fs", cfg.video.apmode[0].gfx_fullscreen);
@ -1144,13 +1170,17 @@ function setAdvandedConfig() {
setSelect("cfg_ports_0_move", cfg.ports[0].move); 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_1", cfg.ports[0].fire[0]);
setSelect("cfg_ports_0_fire_2", cfg.ports[0].fire[1]); 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", cfg.ports[1].type);
setSelect("cfg_ports_1_move", cfg.ports[1].move); 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_1", cfg.ports[1].fire[0]);
setSelect("cfg_ports_1_fire_2", cfg.ports[1].fire[1]); 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); setCheckbox("cfg_keyborad_enabled", cfg.keyboard.enabled);
@ -1288,6 +1318,7 @@ function getAdvandedConfig() {
cfg.video.enabled = getCheckbox("cfg_video_enabled"); cfg.video.enabled = getCheckbox("cfg_video_enabled");
if (cfg.video.enabled) { if (cfg.video.enabled) {
cfg.video.api = getSelect("cfg_video_api"); cfg.video.api = getSelect("cfg_video_api");
cfg.video.cursor = getSelect("cfg_video_cursor");
cfg.video.colorMode = getSelect("cfg_video_color_mode"); cfg.video.colorMode = getSelect("cfg_video_color_mode");
cfg.video.antialias = getCheckbox("cfg_video_antialias"); cfg.video.antialias = getCheckbox("cfg_video_antialias");
//cfg.video.apmode[0].gfx_fullscreen = getRadio("cfg_video_fs"); //cfg.video.apmode[0].gfx_fullscreen = getRadio("cfg_video_fs");
@ -1346,26 +1377,49 @@ function getAdvandedConfig() {
/* ports */ /* ports */
cfg.ports[0].type = getSelect("cfg_ports_0"); 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].move = getSelect("cfg_ports_0_move");
cfg.ports[0].fire[0] = getSelect("cfg_ports_0_fire_1"); cfg.ports[0].fire[0] = getSelect("cfg_ports_0_fire_1");
cfg.ports[0].fire[1] = getSelect("cfg_ports_0_fire_2"); 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]) { 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; return false;
} }
} }
cfg.ports[1].type = getSelect("cfg_ports_1"); if (cfg.ports[0].type == SAEC_Config_Ports_Type_Joy) {
if (cfg.ports[1].type == SAEC_Config_Ports_Type_Joy1) { cfg.ports[0].device = getSelect("cfg_ports_0_joy_device");
cfg.ports[1].move = getSelect("cfg_ports_1_move"); if (cfg.ports[0].device == SAEC_Config_Ports_Device_None) {
cfg.ports[1].fire[0] = getSelect("cfg_ports_1_fire_1"); alert("Joystick-device on mouse-port not found.");
cfg.ports[1].fire[1] = getSelect("cfg_ports_1_fire_2"); changePage(PID_Ports);
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.");
return false; 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.keyboard.enabled = getCheckbox("cfg_keyborad_enabled");
cfg.serial.enabled = getCheckbox("cfg_serial_enabled"); cfg.serial.enabled = getCheckbox("cfg_serial_enabled");
@ -1383,7 +1437,7 @@ function start() {
if (s == S_VALID) { /* all files are downloaded or cached, go! */ if (s == S_VALID) { /* all files are downloaded or cached, go! */
freezeButtons(false, true); freezeButtons(false, true);
var err = sae.start(); /* this does start the emulator */ var err = sae.start(); /* send start-request */
if (err != SAEE_None) if (err != SAEE_None)
alert(saee2text(err)); alert(saee2text(err));
} }
@ -1431,6 +1485,13 @@ function reset() {
sae.reset(false, false); sae.reset(false, false);
} }
function mute(m) {
sae.mute(m);
muted = m;
switchMutePlay(muted);
}
/*---------------------------------*/ /*---------------------------------*/
function init() { function init() {
@ -1444,6 +1505,7 @@ function init() {
//console.log(cfg); //console.log(cfg);
initHooks(); initHooks();
initGamepads();
dbInit(); dbInit();
setDatabaseConfig(); setDatabaseConfig();
@ -2440,10 +2502,13 @@ function channelsUpdate() {
function portUpdate(n) { function portUpdate(n) {
var v = getSelect("cfg_ports_" + n); var v = getSelect("cfg_ports_" + n);
if (n == 0) if (n == 0) {
styleDisplayInline("cfg_ports_0_grp", v == SAEC_Config_Ports_Type_Joy0); styleDisplayInline("cfg_ports_0_joyemu_grp", v == SAEC_Config_Ports_Type_JoyEmu);
else styleDisplayInline("cfg_ports_0_joy_grp", v == SAEC_Config_Ports_Type_Joy);
styleDisplayInline("cfg_ports_1_grp", v == SAEC_Config_Ports_Type_Joy1); } 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);
}
} }
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
@ -2466,6 +2531,10 @@ function hook_event_stopped() {
paused = false; paused = false;
switchPauseResume(paused); switchPauseResume(paused);
} }
if (muted) {
muted = false;
switchMutePlay(muted);
}
if (dskchg) if (dskchg)
dskchgClose(); dskchgClose();
@ -2480,6 +2549,10 @@ function hook_event_reseted(hard) {
paused = false; paused = false;
switchPauseResume(paused); switchPauseResume(paused);
} }
if (muted) {
muted = false;
switchMutePlay(muted);
}
if (dskchg) if (dskchg)
dskchgClose(); dskchgClose();
} }
@ -2650,3 +2723,81 @@ function dskchgSelect() {
sae.insert(n); 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,10 +21,12 @@
<li><a href="readme.htm#limits">Limits</a></li> <li><a href="readme.htm#limits">Limits</a></li>
<li style="list-style:none"><div style="height:8px"></div></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#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#safety">Safety</a></li>
<li><a href="readme.htm#privacy">Privacy</a></li> <li><a href="readme.htm#privacy">Privacy</a></li>
<li style="list-style:none"><div style="height:8px"></div></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#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 style="list-style:none"><div style="height:8px"></div></li>
<li><a href="readme.htm#author">Author</a></li> <li><a href="readme.htm#author">Author</a></li>
<li><a href="readme.htm#thanks">Thanks</a></li> <li><a href="readme.htm#thanks">Thanks</a></li>
@ -57,6 +59,8 @@
<ul> <ul>
<li>WegGL/Canvas2D- and WebAudio-extensions.</li> <li>WegGL/Canvas2D- and WebAudio-extensions.</li>
<li>Typed-arrays and FileReader-extension.</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 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>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> <li>Memory-requirements are between 200MB to 1.5GB depending on configuration and browser.</li>
@ -307,6 +311,21 @@
<li>Or, go to &quot;Chipset/Features/Manual&quot; and select &quot;Onboard-IDE&quot; or &quot;PCMCIA-slot&quot; manually.</li> <li>Or, go to &quot;Chipset/Features/Manual&quot; and select &quot;Onboard-IDE&quot; or &quot;PCMCIA-slot&quot; manually.</li>
</ul> </ul>
</li> </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> </ul>
</li> </li>
</ul> </ul>
@ -342,6 +361,14 @@
</ul> </ul>
</li> </li>
</ul> </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> <ul>
<li style="list-style:none"><div class="linehoriz"></div></li> <li style="list-style:none"><div class="linehoriz"></div></li>
</ul> </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://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://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><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> </ul>
</li> </li>
</ul> </ul>
@ -397,6 +424,40 @@
<ul id="history"> <ul id="history">
<li><span class="label">History</span> <li><span class="label">History</span>
<ul> <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> <li><span class="label">0.9.0 (15.07.2016)</span>
<ul> <ul>
<li>CPU <li>CPU
@ -833,7 +894,7 @@
</div> </div>
<div style="height:5px"></div> <div style="height:5px"></div>
<div id="foot" class="foot" style="line-height:14px"> <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> | <span class="gray">Description</span> |
<a target="_blank" href="disass.htm">Disassembler</a> | <a target="_blank" href="disass.htm">Disassembler</a> |
<a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a> <a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">Source-code</a>

View file

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

View file

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

View file

@ -793,8 +793,7 @@ function SAEO_CIA() {
function check_led() { function check_led() {
var v = ciaapra; 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; var led2 = (v & 2) ? 0 : 1;
if (led2 != led) { if (led2 != led) {
calc_led(led); calc_led(led);
@ -824,12 +823,18 @@ function SAEO_CIA() {
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) { if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) {
if (!SAER.input.mouse.button[0]) tmp |= 0x40; if (!SAER.input.mouse.button[0]) tmp |= 0x40;
if (dra & 0x40) tmp = (tmp & ~0x40) | (pra & 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 (!SAER.input.joystick[0].button[0]) tmp |= 0x40;
if (dra & 0x40) tmp = (tmp & ~0x40) | (pra & 0x40); if (dra & 0x40) tmp = (tmp & ~0x40) | (pra & 0x40);
} else tmp |= 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 (!SAER.input.joystick[1].button[0]) tmp |= 0x80;
if (dra & 0x80) tmp = (tmp & ~0x80) | (pra & 0x80); if (dra & 0x80) tmp = (tmp & ~0x80) | (pra & 0x80);
} else tmp |= 0x80; } else tmp |= 0x80;

View file

@ -266,6 +266,10 @@ function SAEO_Config_Mount_Data() { //uaedev_config_data
const SAEC_Config_Video_API_Canvas = 0; const SAEC_Config_Video_API_Canvas = 0;
const SAEC_Config_Video_API_WebGL = 1; 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_LoRes = 0;
const SAEC_Config_Video_HResolution_HiRes = 1; const SAEC_Config_Video_HResolution_HiRes = 1;
const SAEC_Config_Video_HResolution_SuperHiRes = 2; 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_None = 0;
const SAEC_Config_Ports_Type_Mouse = 1; const SAEC_Config_Ports_Type_Mouse = 1;
const SAEC_Config_Ports_Type_Joy0 = 2; const SAEC_Config_Ports_Type_Joy = 2;
const SAEC_Config_Ports_Type_Joy1 = 3; const SAEC_Config_Ports_Type_JoyEmu = 3;
const SAEC_Config_Ports_Move_None = 0; const SAEC_Config_Ports_Move_None = 0;
const SAEC_Config_Ports_Move_Arrows = 1; 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_Fire_None = 0;
const SAEC_Config_Ports_Device_None = -1;
/*---------------------------------*/ /*---------------------------------*/
/* debug */ /* debug */
@ -574,7 +580,7 @@ function SAEO_Config() {
this.video = { this.video = {
id: "", id: "",
enabled: false, enabled: false,
//driver: 0, cursor: 0,
scandoubler: false, //gfx_scandoubler scandoubler: false, //gfx_scandoubler
framerate: 0, //gfx_framerate framerate: 0, //gfx_framerate
@ -672,11 +678,13 @@ function SAEO_Config() {
this.ports = [{ this.ports = [{
type: SAEC_Config_Ports_Type_Mouse, type: SAEC_Config_Ports_Type_Mouse,
move: SAEC_Config_Ports_Move_WASD, 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, move: SAEC_Config_Ports_Move_Arrows,
fire: [16,17] fire: [16,17],
device: SAEC_Config_Ports_Device_None
}]; }];
this.keyboard = { this.keyboard = {
@ -1075,6 +1083,7 @@ function SAEO_Configuration() {
p.video.id = "video"; p.video.id = "video";
p.video.enabled = true; p.video.enabled = true;
p.video.cursor = SAEC_Config_Video_Cursor_Lock;
p.video.scandoubler = false; p.video.scandoubler = false;
p.video.framerate = 1; p.video.framerate = 1;
p.video.hresolution = SAEC_Config_Video_HResolution_HiRes; p.video.hresolution = SAEC_Config_Video_HResolution_HiRes;
@ -1159,9 +1168,11 @@ function SAEO_Configuration() {
p.ports[0].type = SAEC_Config_Ports_Type_Mouse; p.ports[0].type = SAEC_Config_Ports_Type_Mouse;
p.ports[0].move = SAEC_Config_Ports_Move_WASD; p.ports[0].move = SAEC_Config_Ports_Move_WASD;
p.ports[0].fire = [49,50]; 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].move = SAEC_Config_Ports_Move_Arrows;
p.ports[1].fire = [16,17]; 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[0], 0, sizeof (struct jport));
memset (&p.jports[1], 0, sizeof (struct jport)); memset (&p.jports[1], 0, sizeof (struct jport));
memset (&p.jports[2], 0, sizeof (struct jport)); memset (&p.jports[2], 0, sizeof (struct jport));
@ -2398,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; p.chipset.cia.tod = p.chipset.ntsc ? SAEC_Config_Chipset_CIA_TOD_60Hz : SAEC_Config_Chipset_CIA_TOD_50Hz;
built_in_chipset_prefs(p); built_in_chipset_prefs(p);
//inputdevice_fix_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; return true; //err == 0;
} }
} }

View file

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

View file

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

View file

@ -19,56 +19,60 @@ function SAEO_Mouse() {
this.button = [false, false, false]; this.button = [false, false, false];
this.pos = 0; this.pos = 0;
var cx = 0; var cx = 0, cy = 0;
var cy = 0; var mx = 0, my = 0;
var mx = 0; var lx = -1, ly = -1;
var my = 0;
var lx = -1;
var ly = -1;
this.reset = function() { this.reset = function() {
this.button = [0, 0, 0]; this.button = [false, false, false];
cx = cy = 0; cx = cy = 0;
lx = ly = -1; lx = ly = -1;
}; };
this.mousedown = function(e) { this.mousedown = function(e) {
e = e || window.event; e = e || window.event; if (e === undefined) return;
if (!e) return;
this.button[e.button] = true; this.button[e.button] = true;
}; };
this.mouseup = function(e) { this.mouseup = function(e) {
e = e || window.event; e = e || window.event; if (e === undefined) return;
if (!e) return;
this.button[e.button] = false; this.button[e.button] = false;
}; };
this.mouseover = function(e) { this.mouseover = function(e) {
//SAER.video.hideCursor(1); 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); this.mousemove(e);
lx = cx; lx = cx;
ly = cy; ly = cy;
}; };
this.mouseout = function(e) { this.mouseout = function(e) {
//SAER.video.hideCursor(0); e = e || window.event; if (e === undefined) return;
this.mouseup(e); this.mouseup(e);
if (SAEV_config.video.cursor == SAEC_Config_Video_Cursor_Hide)
SAER.video.hideCursor(false);
}; };
this.mousemove = function(e) { this.mousemove = function(e) {
e = e || window.event; e = e || window.event; if (e === undefined) return;
if (!e) return;
if (e.pageX || e.pageY) { if (e.pageX !== undefined) {
cx = e.pageX; cx = e.pageX;
cy = e.pageY; cy = e.pageY;
} else if (e.clientX || e.clientY) { } else if (e.clientX !== undefined) {
cx = e.clientX; cx = e.clientX;
cy = e.clientY; cy = e.clientY;
} } else
cx = cy = 0;
if (lx == -1) { if (lx == -1) {
lx = cx; lx = cx;
ly = cy; ly = cy;
@ -76,6 +80,25 @@ function SAEO_Mouse() {
//SAEF_log("input.mousemove() %d %d", cx, cy); //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() { this.update = function() {
if (lx != -1) { if (lx != -1) {
var dx = cx - lx; var dx = cx - lx;
@ -109,15 +132,80 @@ function SAEO_Mouse() {
} }
} }
function SAEO_Joystick(type) { function SAEO_Joystick(port) {
this.type = type; this.port = port;
this.button = [false, false, false]; this.button = [false, false, false];
this.state = [false, false, false, false]; this.state = [false, false, false, false];
this.dir = 0; this.dir = 0;
this.requestID = null;
this.reset = function() { this.reset = function() {
this.button = [false, false, false]; this.button = [false, false, false];
this.state = [false, 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() { this.update = function() {
@ -142,7 +230,7 @@ function SAEO_Joystick(type) {
var b9 = (l ^ 1) ? 2 : 0; var b9 = (l ^ 1) ? 2 : 0;
this.dir = ((b8 | b9) << 8) | (b0 | b1);*/ this.dir = ((b8 | b9) << 8) | (b0 | b1);*/
} };
} }
function SAEO_Keyboard() { function SAEO_Keyboard() {
@ -571,7 +659,7 @@ function SAEO_Keyboard() {
} }
/* joystick emul */ /* 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; var l, u, r, d, f1, f2;
switch (SAEV_config.ports[0].move) { switch (SAEV_config.ports[0].move) {
case SAEC_Config_Ports_Move_Arrows: case SAEC_Config_Ports_Move_Arrows:
@ -624,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; var l, u, r, d, f1, f2;
switch (SAEV_config.ports[1].move) { switch (SAEV_config.ports[1].move) {
case SAEC_Config_Ports_Move_Arrows: case SAEC_Config_Ports_Move_Arrows:
@ -750,8 +838,8 @@ function SAEO_Keyboard() {
function SAEO_Input() { function SAEO_Input() {
this.mouse = new SAEO_Mouse(); this.mouse = new SAEO_Mouse();
this.joystick = new Array(2); this.joystick = new Array(2);
this.joystick[0] = new SAEO_Joystick(SAEC_Config_Ports_Type_Joy0); this.joystick[0] = new SAEO_Joystick(0);
this.joystick[1] = new SAEO_Joystick(SAEC_Config_Ports_Type_Joy1); this.joystick[1] = new SAEO_Joystick(1);
this.keyboard = new SAEO_Keyboard(); this.keyboard = new SAEO_Keyboard();
var potgo = { var potgo = {
@ -760,10 +848,22 @@ function SAEO_Input() {
}; };
this.setup = function () { this.setup = function () {
var err;
this.keyboard.setup(); 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.cleanup = function () {
this.joystick[1].cleanup();
this.joystick[0].cleanup();
this.keyboard.cleanup(); this.keyboard.cleanup();
}; };
@ -792,11 +892,18 @@ function SAEO_Input() {
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) { if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) {
if (this.mouse.button[2]) v &= 0xfbff; if (this.mouse.button[2]) v &= 0xfbff;
if (this.mouse.button[1]) v &= 0xfeff; 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[1]) v &= 0xfbff;
if (this.joystick[0].button[2]) v &= 0xfeff; 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[1]) v &= 0xbfff;
if (this.joystick[1].button[2]) v &= 0xefff; if (this.joystick[1].button[2]) v &= 0xefff;
} }
@ -822,7 +929,10 @@ function SAEO_Input() {
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) { if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) {
this.mouse.update(); this.mouse.update();
return this.mouse.pos; 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(); this.joystick[0].update();
return this.joystick[0].dir; return this.joystick[0].dir;
} }
@ -833,7 +943,10 @@ function SAEO_Input() {
if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Mouse) { if (SAEV_config.ports[1].type == SAEC_Config_Ports_Type_Mouse) {
this.mouse.update(); this.mouse.update();
return this.mouse.pos; 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(); this.joystick[1].update();
return this.joystick[1].dir; return this.joystick[1].dir;
} }
@ -844,4 +957,3 @@ function SAEO_Input() {
//SAEF_log("Input.JOYTEST() $%04x", v); //SAEF_log("Input.JOYTEST() $%04x", v);
} }
} }

24
sae/prototypes.js vendored
View file

@ -76,3 +76,27 @@ if (!performance.now) {
return Date.now() - this.timing.navigationStart; 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); var l = SAEF_ZFile_create(null, file.name);
l.name = file.name.length ? file.name : ""; l.name = file.name.length ? file.name : "";
if (0) { /* ptr-mode. do not enable */ if (0) { /* reference-mode. do not enable */
l.data = file.data; l.data = file.data;
} else { } else {
l.data = new Uint8Array(file.size); l.data = new Uint8Array(file.size);
@ -493,6 +493,13 @@ function SAEF_ZFile_fopen_file(file) {
l.datasize = file.size; l.datasize = file.size;
l.allocsize = file.size; //OWN 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 (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) { if (SAEF_CompareArray(l.data, SAEF_String2Array("DMS!"), 4) == 0) {
var dms = new SAEO_DMS(); var dms = new SAEO_DMS();

View file

@ -90,6 +90,7 @@ function SAEO_Video() {
this.ctx = null; this.ctx = null;
this.texture = null; this.texture = null;
this.surface = null; this.surface = null;
this.requestPointerLock = null;
this.div = null; this.div = null;
this.shown = false; this.shown = false;
@ -194,6 +195,24 @@ function SAEO_Video() {
return SAEE_None; 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) { function CreateWindow(left, top, width, height) {
var hWnd = new HWND(); var hWnd = new HWND();
@ -237,6 +256,20 @@ function SAEO_Video() {
return false; return false;
}; };
if (SAEV_config.ports[0].type == SAEC_Config_Ports_Type_Mouse) { 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) { hWnd.canvas.onmousedown = function(e) {
SAER.input.mouse.mousedown(e); SAER.input.mouse.mousedown(e);
}; };
@ -251,12 +284,20 @@ function SAEO_Video() {
}; };
hWnd.canvas.onmousemove = function(e) { hWnd.canvas.onmousemove = function(e) {
SAER.input.mouse.mousemove(e); SAER.input.mouse.mousemove(e);
};
} }
} }
return hWnd; return hWnd;
} }
function DestroyWindow(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) if (SAEV_config.video.api == SAEC_Config_Video_API_WebGL)
hWnd.texture = null; hWnd.texture = null;
else if (SAEV_config.video.api == SAEC_Config_Video_API_Canvas) else if (SAEV_config.video.api == SAEC_Config_Video_API_Canvas)
@ -278,16 +319,16 @@ function SAEO_Video() {
hWnd.div.style.width = String(currentmode.native_width)+"px"; hWnd.div.style.width = String(currentmode.native_width)+"px";
hWnd.div.style.height = String(currentmode.native_height)+"px"; hWnd.div.style.height = String(currentmode.native_height)+"px";
hWnd.div.appendChild(hWnd.canvas); hWnd.div.appendChild(hWnd.canvas);
} else } else {
hWnd.div = null; hWnd.div = null;
hWnd.canvas.style.width = String(currentmode.native_width)+"px";
hWnd.canvas.style.height = String(currentmode.native_height)+"px";
}
hWnd.shown = true; hWnd.shown = true;
} }
else if (nCmdShow == SW_HIDE && hWnd.shown) { else if (nCmdShow == SW_HIDE && hWnd.shown) {
if (hWnd.div !== null) { if (hWnd.div !== null)
hWnd.div.removeChild(hWnd.canvas); hWnd.div.removeChild(hWnd.canvas);
hWnd.canvas = null;
}
hWnd.shown = false; hWnd.shown = false;
} }
@ -2015,6 +2056,11 @@ function SAEO_Video() {
DirectDraw_ReleaseDC(hdc); DirectDraw_ReleaseDC(hdc);
}*/ }*/
this.hideCursor = function(hide) {
if (hAmigaWnd !== null && hAmigaWnd.shown)
hAmigaWnd.canvas.style.cursor = hide ? "none" : "auto";
}
/*-----------------------------------------------------------------------*/ /*-----------------------------------------------------------------------*/
//var flushymin = 0, flushymax = 0; //var flushymin = 0, flushymax = 0;