update 0.8.1

This commit is contained in:
Rupert Hausberger 2013-07-07 16:53:47 +02:00
commit dd3bb23b86
24 changed files with 10461 additions and 9746 deletions

12
ga.js Normal file
View file

@ -0,0 +1,12 @@
/* google analytics */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-37232052-1']);
_gaq.push(['_setDomainName', 'scriptedamigaemulator.net']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

View file

@ -41,7 +41,7 @@ body {
left:0;
margin:0;
padding:0;
font-family:verdana;
font-family:verdana,serif;
font-size:small;
background-color:#fff;
}
@ -81,7 +81,7 @@ body {
background-color:#fcfcfc;
}
.config_simple_hof {
width:480px;
width:380px;
margin:auto;
padding:10px;
border:1px solid #ccc;
@ -114,7 +114,6 @@ body {
width:auto;
}
#config select {
border:0;
border:1px solid #ccc;
}
#config .button {
@ -195,7 +194,7 @@ body {
vertical-align:top;
}
div.float_box {
/*div.float_box {
overflow: hidden;
width: 100%;
}
@ -204,4 +203,4 @@ div.float_item {
}
div.float_clear {
clear: both;
}
}*/

View file

@ -47,22 +47,11 @@
<h3>Welcome!</h3>
This site is the homepage of the project <a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">SAE</a>,
an <i>experimental</i> <a target="_blank" href="http://en.wikipedia.org/wiki/Amiga">Amiga</a> emulator in pure JavaScript and HTML5.<br />
SAE is based on <a target="_blank" href="http://winuae.net')">WinUAE</a> and does use the <a href="javascript:openNewTab('http://aros.org">AROS</a>-kickstart replacement.
SAE is based on <a target="_blank" href="http://winuae.net">WinUAE</a> and does use the <a target="_blank" href="http://aros.org">AROS</a>-kickstart replacement.
For more details, please see the <a target="_blank" href="readme.htm">description</a>.<br />
<br />
Below you find a collection of pre-installed games and demos to play and test. Press the 'Config'-button to use your own roms or file-images, with advanced options.<br />
<br />
<span style="font-size:x-small;color:orange">
Update 22.01.2013: The new game-database is now online. It's quite empty yet and will be filled with freeware and public-domain titles.<br />
<br />
</span>
<span class="info">
<span class="fwb">Your game or demo online</span><br />
If you want to have your game or demo on this site, please <a href="mailto:rupert_hausberger@gmx.net">contact</a> me.
It would be published under a free license, with a link to your homepage and would be free to play for everyone.
This is a non-profit site and an open-source project.<br />
<br />
</span>
<div class="config_simple_hof">
<!--<div class="acm">
<span class="fwb">Browser</span>
@ -89,7 +78,7 @@
</div>-->
<table>
<tr>
<td class="armsb">Game</td>
<td class="armsb"><label for="cfg_game">Game</label></td>
<td>
<select id="cfg_game" size="1" onchange="preSelect(1)">
<option value="0">- select -</option>
@ -97,7 +86,7 @@
</td>
</tr>
<tr>
<td class="armsb">Demo</td>
<td class="armsb"><label for="cfg_demo">Demo</label></td>
<td>
<select id="cfg_demo" size="1" onchange="preSelect(2)">
<option value="0">- select -</option>
@ -155,6 +144,13 @@
<button class="button" onclick="switchCfg(1)">Config</button>
</div>
</div>
<br />
<span class="info">
<span class="fwb">Your game or demo online</span><br />
If you want to have your game or demo on this site, please contact me.
It would be published under a free license, with a link to your homepage and would be free to play for everyone.
This is a non-profit site and an open-source project.
</span>
</div>
<div id="config_advanced">
<div class="acm"><button class="button" onclick="switchCfg(0)">Back</button></div>
@ -533,7 +529,7 @@
<input id="cfg_ports_1_enabled" type="checkbox" onchange="portUpdate(1)" />
Enabled
<span id="cfg_ports_1_grp">
<select id="cfg_ports_1" size="1" onchange="portsUpdate(1)">
<select id="cfg_ports_1" size="1">
<option value="3">Joystick 1</option>
</select>
Move

118
index.js
View file

@ -14,15 +14,45 @@
const URL_TEAM_HOI = '<a href="javascript:openNewTab(\'http://www.sevensheaven.nl\')">Team Hoi</a>';
const URL_RETROGURU = '<a href="javascript:openNewTab(\'http://www.retroguru.com\')">retroguru</a>';
const URL_LOEWENSTEIN = '<a href="javascript:openNewTab(\'http://www.richard-loewenstein.de\')">Richard Löwenstein</a>';
const db = [
/* name company year [disks] [change, turbo] [en,f1,f2,map] load [keys] immediate */
[
['Air Ace II', ['SEUCK', '-', 'Public Domain'], '1989',
['Air Ace II.adf', false, false, false], [false, true],
[true, 16, 17, false], ['...takes very long.'], [], false
],
['Asteroids', ['Vertical Developments', '-', 'Public Domain'], '1979',
['Asteroids.adf', false, false, false], [false, true],
[true, 16, 17, false], [], [], false
],
['Crazy Sue', ['Jumpshoe, Hironymous', '-', 'Public Domain'], '1991',
['Crazy Sue.adf', false, false, false], [false, true],
[true, 16, 17, false], ['...can take some time.'], [], false
],
['Deluxe Galaga 2.4', ['Edgar Vigdal', '-', 'Freeware'], '1994',
['Deluxe Galaga.adf', false, false, false], [false, true],
[true, 16, 17, false], [], [], false
],
['Hoi', [URL_TEAM_HOI, 'Hollyware', 'Freeware'], '1992',
['Hoi (Disk 1).adf',
'Hoi (Disk 2).adf', false, false], [true, true],
[true, 16, 17, false], ['Press the LMB to skip the intro and insert the 2nd disk manually.'], [], false
[true, 16, 17, false], ['Press the LMB to skip the intro and insert the 2nd disk manually.<br /><br />'+
'<span title="After the disk-change, place the \'LVL\'-pointer in the far lower right of the green quarter screen. The bottom \'L\' must be positioned in the corner precisely. Click the LMB, then shift the \'LVL\' pointer to the absolute top left of the screen (as far as it can be moved in that direction). Click the LMB again. Any of the first four levels may now be selected for game play. Press the F4 key during game play for twelve lives. Note: Level 5 can only be accessed by completing level 4.">Cheat (move mouse-over)</span>'], [], false
],
['Norse Gods', [URL_LOEWENSTEIN, '-', 'Freeware'], '1991',
['Norse Gods.adf', false, false, false], [false, true],
[true, 16, 17, false], [], [], false
],
['Pollymorf', ['Andrew Campbell', '-', 'Public Domain'], '1993',
['Pollymorf.adf', false, false, false], [false, true],
[true, 16, 17, false], ['...takes some time, just wait.'], [], false
],
/*['Rectum', ['Mathias Olsson', '-', 'Freeware'], '1992',
['Rectum.adf', false, false, false], [false, true],
[true, 16, 17, false], ['Press the LMB to skip the intro...'], [], false
],*/
['Sqrxz', [URL_RETROGURU, '-', 'Freeware'], '2012',
['sqrxz.adf', false, false, false], [false, true],
[true, 16, 17, false], ['The color-stripes are normal, just wait...'], [], false
@ -31,6 +61,14 @@ const db = [
['sqrxz2.adf', false, false, false], [false, true],
[true, 16, 17, false], ['After the start, click the RMB for the trainer menu.<br />The color-stripes are normal, just wait...'], [], false
],
['Super Obliteration', ['David Papworth', '-', 'Freeware'], '1993',
['Super Obliteration.adf', false, false, false], [false, true],
[true, 16, 17, false], [], [], false
],
['Tanx', ['Robertz Gaz', '-', 'Public Domain'], '1991',
['Tanx.adf', false, false, false], [false, true],
[true, 16, 17, false], [], [], false
]
],
[
['242', 'Virtual Dreams', '1992',
@ -78,6 +116,10 @@ const db = [
[true, 16, 17, false],
['Insert the 2nd disk manually and<br />click the RMB when done.'], [], true
],
['HipHop Hater', 'Mathias Olsson', '1991',
['HipHop Hater.adf',false,false,false], [false, true],
[true, 16, 17, false], [], [], false
],
['Ice', 'Silents', '1991',
['Ice.adf',false,false,false], [false, true],
[true, 16, 17, false], ['Press LMB at the intro-screen'], [], false
@ -134,11 +176,11 @@ var dbNum = 0;
const aros_rom_file = 'aros-amiga-m68k-rom.bin';
const aros_rom_url = 'http://'+window.location.hostname+'/db/'+aros_rom_file;
const aros_rom_size = 0x80000;
const aros_rom_crc = 0xea48b4d1; //0xfc4635e1;
const aros_rom_crc = 0x48dfadd; //0xea48b4d1
const aros_ext_file = 'aros-amiga-m68k-ext.bin';
const aros_ext_url = 'http://'+window.location.hostname+'/db/'+aros_ext_file;
const aros_ext_size = 0x80000;
const aros_ext_crc = 0x60871435; //0xc612f82e;
const aros_ext_crc = 0xaaf211d6; //0x60871435
var mode = 0;
var paused = false;
@ -163,7 +205,7 @@ function Cache() {
var roms = [null,null];
var disks = [];
this.loadRom = function(num) {
this.loadRom = function (num) {
if (roms[num]) {
console.log('loadRom.loadRom() %d is cached', num);
return roms[num];
@ -185,7 +227,7 @@ function Cache() {
}
var data = loadRemoteSync(url);
if (typeof(data) == 'number') {
alert('Can\'t download '+url+' (http status: '+data+')');
alert('Can\'t download ' + url + ' (http status: ' + data + ')');
} else {
if (data.length == size) {
//console.log(dechex(crc32(data)));
@ -193,12 +235,12 @@ function Cache() {
roms[num] = data;
return data;
} else
alert('Wrong checksum for '+url+' (is $'+dechex(crc32(data))+', should $'+dechex(crc)+')');
alert('Wrong checksum for ' + url + ' (is $' + dechex(crc32(data)) + ', should $' + dechex(crc) + ')');
} else
alert('Wrong file-length for '+url+' ('+size+')');
alert('Wrong file-length for ' + url + ' (' + size + ')');
}
return null;
}
};
this.loadDisk = function(url) {
for (var i = 0; i < disks.length; i++) {
@ -230,7 +272,7 @@ function Cache() {
/*-----------------------------------------------------------------------*/
/* utils */
function dump(obj) {
/*function dump(obj) {
var out = '';
if (obj) {
for (var i in obj) {
@ -238,10 +280,7 @@ function dump(obj) {
}
}
alert(out);
/*var pre = document.createElement('pre');
pre.innerHTML = out;
document.body.appendChild(pre);*/
}
}*/
function crc32(str, crc) {
@ -289,11 +328,6 @@ function crc32(str, crc) {
return crc < 0 ? crc + 0x100000000 : crc;
}
function openNewTab(url) {
window.open(url, '_blank');
window.focus();
}
function getSelectValue(e) {
for (var i = 0; i < e.length; i++) {
if (e[i].selected) return e[i].value;
@ -329,7 +363,7 @@ function disabled(id, d) {
document.getElementById(id).disabled = d ? 'disabled' : '';
}
function toggleFullScreen() {
/*function toggleFullScreen() {
if ((document.fullScreenElement && document.fullScreenElement !== null) || // alternative standard method
(!document.mozFullScreenElement && !document.webkitFullScreenElement)) { // current working methods
if (document.documentElement.requestFullScreen) {
@ -348,25 +382,25 @@ function toggleFullScreen() {
document.webkitCancelFullScreen();
}
}
}
}*/
function loadLocalId(id, callback) {
/*function loadLocalId(id, callback) {
var e = document.getElementById(id).files[0];
var reader = new FileReader();
reader.onload = callback;
reader.readAsBinaryString(e);
}
}*/
function loadLocal(e, callback) {
var reader = new FileReader();
reader.onload = callback;
reader.readAsBinaryString(e);
}
function loadRemote(url, size, crc, callback) {
/*function loadRemote(url, size, crc, callback) {
var req = new XMLHttpRequest();
req.open('GET', url, true);
req.overrideMimeType('text\/plain; charset=x-user-defined');
req.onreadystatechange = function(e) {
req.onreadystatechange = function (e) {
if (req.readyState == 4) {
if (req.status == 200) {
if (req.responseText.length == size) {
@ -379,9 +413,9 @@ function loadRemote(url, size, crc, callback) {
} else
callback(3, req.status);
}
}
};
req.send(null);
}
}*/
function loadRemoteSync(url) {
var req = new XMLHttpRequest();
req.open('GET', url, false);
@ -539,7 +573,7 @@ function getSimpleConfig() {
config.chipset.mask = SAEV_Config_Chipset_Mask_OCS;
config.chipset.agnus_dip = false; /* A1000 */
config.chipset.collision_level = SAEV_Config_Chipset_ColLevel_None;
config.chipset.collision_level = (item !== null && item[0] == 'Deluxe Galaga 2.4') ? SAEV_Config_Chipset_ColLevel_Sprite_Playfield : SAEV_Config_Chipset_ColLevel_None;
config.blitter.immediate = (item !== null && item[8]) ? true : false;
config.blitter.waiting = config.blitter.immediate ? 0 : 1;
@ -680,6 +714,7 @@ function fireButtonName(fire) {
case 145: return 'Scroll lock';
case 49: return '1';
case 50: return '2';
default: return 'ERROR';
}
}
@ -721,8 +756,8 @@ function setConfig() {
e = document.getElementById('cfg_chipset_type');
switch (config.chipset.mask) {
case SAEV_Config_Chipset_Mask_OCS: e[0].selected = true; break
case SAEV_Config_Chipset_Mask_ECS_AGNUS: e[1].selected = true; break
case SAEV_Config_Chipset_Mask_OCS: e[0].selected = true; break;
case SAEV_Config_Chipset_Mask_ECS_AGNUS: e[1].selected = true; break;
case SAEV_Config_Chipset_Mask_ECS_DENISE: e[2].selected = true; break
}
document.getElementById('cfg_chipset_cl_enabled').checked = config.chipset.collision_level != SAEV_Config_Chipset_ColLevel_None;
@ -809,7 +844,6 @@ function setConfig() {
styleDisplayBlock('cfg_keyborad_grp', config.keyboard.enabled != 0);
document.getElementById('cfg_ports_0_enabled').checked = config.ports[0].type != SAEV_Config_Ports_Type_None;
e = document.getElementById('cfg_ports_0');
switch (config.ports[0].type) {
case SAEV_Config_Ports_Type_Mouse: document.getElementById('cfg_ports_0')[0].selected = true; break;
case SAEV_Config_Ports_Type_Joy0: document.getElementById('cfg_ports_0')[1].selected = true; break;
@ -824,8 +858,7 @@ function setConfig() {
styleDisplayInline('cfg_ports_0_grp', config.ports[0].type != SAEV_Config_Ports_Type_None);
styleDisplayInline('cfg_ports_0_grp2', config.ports[0].type == SAEV_Config_Ports_Type_Joy0);
e = document.getElementById('cfg_ports_1_enabled').checked = config.ports[1].type != SAEV_Config_Ports_Type_None;
e = document.getElementById('cfg_ports_1');
document.getElementById('cfg_ports_1_enabled').checked = config.ports[1].type != SAEV_Config_Ports_Type_None;
switch (config.ports[1].type) {
case SAEV_Config_Ports_Type_Joy1: document.getElementById('cfg_ports_1')[0].selected = true; break;
}
@ -838,7 +871,7 @@ function setConfig() {
setFireButton('cfg_ports_1_fire_2', config.ports[1].fire[1]);
styleDisplayInline('cfg_ports_1_grp', config.ports[1].type == SAEV_Config_Ports_Type_Joy1);
e = document.getElementById('cfg_serial_enabled').checked = config.serial.enabled != 0;
document.getElementById('cfg_serial_enabled').checked = config.serial.enabled != 0;
styleDisplayInline('dskchg_grp', 1);
}
@ -848,6 +881,7 @@ function getMask(type) {
case SAEV_Config_Chipset_Type_OCS: return SAEV_Config_Chipset_Mask_OCS;
case SAEV_Config_Chipset_Type_ECS_AGNUS: return SAEV_Config_Chipset_Mask_ECS_AGNUS;
case SAEV_Config_Chipset_Type_ECS_DENISE: return SAEV_Config_Chipset_Mask_ECS_DENISE;
default: return SAEV_Config_Chipset_Mask_OCS;
}
}
@ -1059,7 +1093,9 @@ function stop() {
if (paused) {
var e = document.getElementById('status_pr');
e.value = 'pause';
e.onclick = function() { pause(1); }
e.onclick = function () {
pause(1);
};
paused = false;
}
if (dskchg)
@ -1078,14 +1114,16 @@ function stop() {
document.body.style.backgroundColor = '#fff';
}
function reset(p) {
function reset() {
SAE({cmd:'reset'});
}
function pause(p) {
var e = document.getElementById('status_pr');
e.innerHTML = p ? 'Resume' : 'Pause';
e.onclick = function() { pause(1 - p); }
e.onclick = function () {
pause(1 - p);
};
paused = p;
@ -1204,6 +1242,7 @@ function romAROS() {
styleDisplayInline('cfg_ext_remove', 1);
styleDisplayTableRow('cfg_ext_addr_grp', 1);
disabled('cfg_rom_aros', 0);
return true;
}
function romSelect() {
@ -1273,7 +1312,7 @@ function floppyUpdate(n) {
function floppyInsert(n) {
var e = document.getElementById('cfg_df'+n+'_file').files[0];
var ok = false;
var ok = true; //false;
if (!e) return;
/*if (e.size == 0xDC000) {
@ -1290,7 +1329,7 @@ function floppyInsert(n) {
} else
alert('Invalid diskimage-size, 880 or 1460 kb.');
*/
ok = true;
if (ok)
loadLocal(e, function (event) {
config.floppy.drive[n].name = e.name;
@ -1435,7 +1474,7 @@ function dskchgInsert() {
if (!dskchg) return;
var n = getSelectValue(document.getElementById('cfg_dskchg_unit'));
var e = document.getElementById('cfg_dskchg_file').files[0];
var ok = false;
var ok = true; //false;
if (!e) return;
/*if (e.size == 0xDC000) {
@ -1451,7 +1490,6 @@ function dskchgInsert() {
} else
alert('Invalid diskimage-size, 880 or 1460 kb.');
*/
ok = true;
if (ok) {
loadLocal(e, function (event) {
dskchgClose();

View file

@ -5,12 +5,6 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="icon" type="image/x-icon" href="http://scriptedamigaemulator.net/favicon.ico" />
<link rel="stylesheet" type="text/css" href="index.css" />
<script type="text/javascript">
function openNewTab(url) {
window.open(url, '_blank');
window.focus();
}
</script>
</head>
<body>
<div class="head">
@ -101,39 +95,39 @@
<ul>
<li><span class="fwb">Written and ported by</span>
<ul>
<li>Rupert Hausberger &lt;<a href="mailto:rupert_hausberger@gmx.net">rupert_hausberger@gmx.net</a>&gt; (<a href="javascript:openNewTab('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=ZJA3YVT6EP55A')">donate</a>)</li>
<li>Rupert Hausberger &lt;<a href="mailto:rupert_hausberger@gmx.net">rupert_hausberger@gmx.net</a>&gt; (<a target="_blank" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&amp;hosted_button_id=ZJA3YVT6EP55A">donate</a>)</li>
</ul>
</li>
</ul>
<ul>
<li><span class="fwb">Source-code</span>
<ul>
<li><a href="javascript:openNewTab('https://github.com/naTmeg/ScriptedAmigaEmulator')">github.com/naTmeg/ScriptedAmigaEmulator</a></li>
<li><a target="_blank" href="https://github.com/naTmeg/ScriptedAmigaEmulator">github.com/naTmeg/ScriptedAmigaEmulator</a></li>
</ul>
</li>
</ul>
<ul>
<li><span class="fwb">License</span>
<ul>
<li><a href="javascript:openNewTab('gpl.htm')">GPL</a></li>
<li><a target="_blank" href="gpl.htm">GPL</a></li>
</ul>
</li>
</ul>
<ul>
<li><span class="fwb">Thanks</span>
<ul>
<li><a href="javascript:openNewTab('http://www.amigaemulator.org')">Bernd Schmidt</a></li>
<li><a href="javascript:openNewTab('http://winuae.net')">WinUAE team</a></li>
<li><a href="javascript:openNewTab('http://aros.org')">AROS team</a></li>
<li><a target="_blank" href="http://www.amigaemulator.org">Bernd Schmidt</a></li>
<li><a target="_blank" href="http://winuae.net">WinUAE team</a></li>
<li><a target="_blank" href="http://aros.org">AROS team</a></li>
</ul>
</li>
</ul>
<ul>
<li><span class="fwb">Some stats</span>
<ul>
<li>The first public version had ~13.000 lines of code, currently ~23.500</li>
<li>About 5 months development time for the first version.</li>
<li>About the half of the first version was written from scratch, the rest was ported from WinUAE.</li>
<li>About 5 months development time for the first public version. (0.5)</li>
<li>About the half of the first version was written from scratch, the rest was ported from various UAE-sources.</li>
<li>The first version had ~13.000 lines of code, currently ~23.500, most new code is ported from WinUAE.</li>
</ul>
</li>
</ul>
@ -284,7 +278,7 @@
<ul>
<li>Chaned the project-name from 'Janus' to 'SAE' (Scripted Amiga Emulator).<br />
This step is necessary because i did'nt enough research before the initial release.<br />
There is already a project with that name in it. (<a href="javascript:openNewTab('http://janus-uae.sourceforge.net')">janus-uae</a>)
There is already a project with that name in it. (<a target="_blank" href="http://janus-uae.sourceforge.net">janus-uae</a>)
I'm sorry for that, that was kinda stupid :)</li>
<li>Separated the GUI form the core and rewrote most of it.</li>
<li>Simplified the whole code. This means, that functions are called faster.</li>

View file

@ -52,7 +52,7 @@ function Amiga() {
/*---------------------------------*/
this.setup = function() {
this.setup = function () {
this.mem.setup();
this.expansion.setup();
this.events.setup();
@ -65,16 +65,16 @@ function Amiga() {
this.audio.setup();
this.custom.setup();
this.cpu.setup();
}
};
this.cleanup = function() {
this.cleanup = function () {
this.audio.cleanup();
this.video.cleanup();
this.playfield.cleanup();
this.input.cleanup();
}
};
this.reset = function() {
this.reset = function () {
BUG.info('Amiga.reset()');
this.delay = 0;
@ -98,12 +98,12 @@ function Amiga() {
this.audio.reset();
this.custom.reset();
this.cpu.reset(this.mem.rom.lower);
}
};
this.dump = function() {
this.dump = function () {
this.cpu.dump();
//this.cia.dump();
}
};
/*---------------------------------*/
@ -122,28 +122,28 @@ function Amiga() {
}*/
this.start = function() {
this.start = function () {
if (this.state == ST_STOP) {
this.setup();
this.reset();
this.state = ST_CYCLE;
setTimeout('AMIGA.cycle()', 0);
}
}
};
this.stop = function() {
this.stop = function () {
if (this.state != ST_STOP) {
this.state = ST_STOP;
this.cleanup();
}
}
};
this.pause = function(state) {
this.pause = function (state) {
if (this.state != ST_STOP) {
this.state = state ? ST_PAUSE : ST_CYCLE;
this.audio.pauseResume(state);
}
}
};
/*this.insert = function(unit, name, data) {
//this.disk.insert_data(unit, data);
@ -161,28 +161,27 @@ function Amiga() {
}
*/
this.insert = function(unit) {
this.insert = function (unit) {
if (this.state != ST_STOP)
this.disk.insert(unit);
}
};
this.eject = function(unit) {
this.eject = function (unit) {
if (this.state != ST_STOP)
this.disk.eject(unit);
}
};
/*---------------------------------*/
/* mainloop */
this.cycle = function() {
this.cycle = function () {
try {
this.cpu.cycle();
} catch (e) {
if (e instanceof VSync) {
//console.log(e.error, e.message);
this.state = ST_IDLE;
} else
if (e instanceof FatalError) {
} else if (e instanceof FatalError) {
this.state = ST_STOP;
this.stop();
this.config.hooks.error(e.error, e.message);
@ -200,36 +199,36 @@ function Amiga() {
AMIGA.cyclePause();
else
AMIGA.cycleExit();
}
};
this.cyclePause = function() {
this.cyclePause = function () {
if (this.state == ST_CYCLE)
setTimeout('AMIGA.cycle()', 0);
else if (this.state == ST_PAUSE)
setTimeout('AMIGA.cyclePause()', 500);
else
AMIGA.cycleExit();
}
};
this.cycleExit = function() {
this.cycleExit = function () {
this.dump();
//this.cia.dump();
}
};
/*---------------------------------*/
this.dmaen = function (dmamask) {
return ((this.dmacon & DMAF_DMAEN) != 0 && (this.dmacon & dmamask) != 0);
}
};
this.DMACONR = function(hpos) {
this.DMACONR = function (hpos) {
this.playfield.decide_line(hpos);
this.playfield.decide_fetch(hpos);
this.dmacon &= ~(0x4000 | 0x2000);
var iz = this.blitter.getIntZero();
this.dmacon |= ((iz[0] ? 0 : 0x4000) | (iz[1] ? 0x2000 : 0));
return this.dmacon;
}
};
this.DMACON = function (v, hpos) {
var oldcon = this.dmacon;
@ -272,13 +271,13 @@ function Amiga() {
this.playfield.maybe_start_bpl_dma(hpos);
}
this.events.schedule();
}
};
/*---------------------------------*/
this.ADKCONR = function () {
return this.adkcon;
}
};
this.ADKCON = function (v, hpos) {
if (this.config.audio.enabled)
@ -293,15 +292,15 @@ function Amiga() {
this.adkcon &= ~v;
this.audio.update_adkmasks();
}
};
/*---------------------------------*/
this.INTENAR = function () {
return this.intena;
}
};
this.INTENA = function(v) {
this.INTENA = function (v) {
if (v & INTF_SETCLR)
this.intena |= v & ~INTF_SETCLR;
else
@ -309,15 +308,15 @@ function Amiga() {
if (v & INTF_SETCLR)
this.doint();
}
};
/*---------------------------------*/
this.INTREQR = function () {
return this.intreq;
}
};
this.INTREQ_0 = function(v) {
this.INTREQ_0 = function (v) {
var old = this.intreq;
if (v & INTF_SETCLR)
@ -327,16 +326,16 @@ function Amiga() {
if ((v & INTF_SETCLR) && this.intreq != old)
this.doint();
}
};
this.INTREQ = function(v) {
this.INTREQ = function (v) {
this.INTREQ_0(v);
this.cia.rethink();
}
};
/*---------------------------------*/
this.intlev = function() {
this.intlev = function () {
var imask = this.intreq & this.intena;
if (imask && (this.intena & INTF_INTEN)) {
@ -348,7 +347,7 @@ function Amiga() {
if (imask & 0x0007) return 1;
}
return -1;
}
};
this.doint = function() {
if (AMIGA.config.cpu.compatible)
@ -361,6 +360,9 @@ function Amiga() {
/*-----------------------------------------------------------------------*/
/* This API will change in the future. */
var BUG = null;
var AMIGA = null;
function SAE(x) {
try {
switch (x.cmd) {
@ -383,10 +385,6 @@ function SAE(x) {
BUG.info('API.stop()');
AMIGA.stop();
break;
case 'reset':
BUG.info('API.reset()');
AMIGA.reset();
break;
case 'pause':
BUG.info('API.pause() %d', x.state);
AMIGA.pause(x.state);
@ -424,4 +422,5 @@ function SAE(x) {
}
//return SAEE_None;
//return { error:SAEE_None, message:'' };
return 0;
}

View file

@ -51,7 +51,7 @@ function Filter() {
return 1 / (1 + 1 / omega);
}
this.setup = function(on) {
this.setup = function (on) {
this.on = on;
var rate = getRate(AMIGA.config.audio.rate);
filter1_a0 = calc(rate, 6200);
@ -61,16 +61,16 @@ function Filter() {
console.log(filter1_a0);
console.log(filter2_a0);
console.log(filter_a0);*/
}
};
this.reset = function() {
this.reset = function () {
filter_state = [
{ rc1:0,rc2:0,rc3:0,rc4:0,rc5:0 },
{ rc1:0,rc2:0,rc3:0,rc4:0,rc5:0 },
{ rc1:0,rc2:0,rc3:0,rc4:0,rc5:0 },
{ rc1:0,rc2:0,rc3:0,rc4:0,rc5:0 }
{ rc1: 0, rc2: 0, rc3: 0, rc4: 0, rc5: 0 },
{ rc1: 0, rc2: 0, rc3: 0, rc4: 0, rc5: 0 },
{ rc1: 0, rc2: 0, rc3: 0, rc4: 0, rc5: 0 },
{ rc1: 0, rc2: 0, rc3: 0, rc4: 0, rc5: 0 }
];
}
};
this.filter = function(input, state) {
//if (!this.on) return input;
@ -94,7 +94,6 @@ function Filter() {
function Channel(num) {
this.num = num;
this.adk_mask = 0;
this.enabled = false;
this.evtime = 0;
this.dmaenstore = false;
@ -118,8 +117,7 @@ function Channel(num) {
this.ptx_written = false;
this.ptx_tofetch = false;
this.reset = function() {
this.adk_mask = 0;
this.reset = function () {
this.enabled = false;
this.evtime = CYCLE_MAX;
this.dmaenstore = false;
@ -142,44 +140,44 @@ function Channel(num) {
this.ptx = 0;
this.ptx_written = false;
this.ptx_tofetch = false;
}
};
//const audio_channel_mask = 15;
this.newsample = function(sample) {
this.newsample = function (sample) {
//if (debugchannel(this.num)) BUG.info('Audio.channel[%d].newsample() %02x', nr, sample);
//if (!(audio_channel_mask & (1 << this.num))) sample = 0;
if (sample & 0x80) sample -= 0x100;
this.last_sample = this.current_sample;
this.current_sample = sample;
}
};
this.isirq = function() {
this.isirq = function () {
return (AMIGA.INTREQR() & (0x80 << this.num)) != 0;
}
};
this.setirq = function(which) {
this.setirq = function (which) {
//if (debugchannel(this.num) && this.wlen > 1) BUG.info('Audio.channel[%d].setirq() %d, %d', this.num, which, this.isirq() ? 1 : 0);
AMIGA.INTREQ_0(INTF_SETCLR | (0x80 << this.num));
}
};
this.zerostate = function() {
this.zerostate = function () {
//if (debugchannel(this.num)) BUG.info('Audio.channel[%d].zerostate()', this.num);
this.state = 0;
this.evtime = CYCLE_MAX;
this.intreq = false;
this.dmaenstore = false;
}
};
this.setdr = function() {
this.setdr = function () {
//if (debugchannel(this.num) && this.dr) BUG.info('Audio.channel[%d].setdr() DR already active (STATE %d)', this.num, this.state);
this.dr = true;
if (this.wlen == 1) {
this.dsr = true;
//if (debugchannel(this.num) && this.wlen > 1) BUG.info('Audio.channel[%d].setdr() DSR on, pt %08x', this.num, this.pt);
}
}
};
this.loaddat = function(modper) {
this.loaddat = function (modper) {
var audav = (AMIGA.adkcon & (0x01 << this.num)) != 0;
var audap = (AMIGA.adkcon & (0x10 << this.num)) != 0;
if (audav || (modper && audap)) {
@ -202,18 +200,18 @@ function Channel(num) {
//if (debugchannel(this.num)) BUG.info('Audio.channel[%d].loaddat() new %04x, old %04x', this.num, this.dat, this.dat2);
this.dat2 = this.dat;
}
}
};
this.loadper = function() {
this.loadper = function () {
this.evtime = this.per;
if (this.evtime < CYCLE_UNIT)
BUG.info('Audio.channel[%d].loadper() bug %d', this.num, this.evtime);
}
};
this.state_channel = function(perfin) {
this.state_channel = function (perfin) {
this.state_channel2(perfin);
this.dat_written = false;
}
};
this.state_channel2 = function(perfin) {
var chan_ena = ((AMIGA.dmacon & DMAF_DMAEN) && (AMIGA.dmacon & (1 << this.num))) ? true : false;
@ -399,7 +397,7 @@ function Audi0() {
realSize: 0,
data:0,
pos: 0,
rate: new mavg(10)
rate: new MAvg(10)
};
var ringBuffer = {
size: 0,
@ -417,18 +415,19 @@ function Audi0() {
{
var test;
/*try {
try {
test = new AudioContext();
test = null;
if (test && test.createJavaScriptNode)
this.available |= SAEI_Audio_Default;
} catch (e) {}*/
test = null;
} catch (e) {
try {
test = new webkitAudioContext();
if (test && test.createJavaScriptNode)
this.available |= SAEI_Audio_Webkit;
test = null;
} catch (e) {}
}
try {
test = new Audio();
@ -452,7 +451,7 @@ function Audi0() {
}
}
this.calc_sample_evtime = function(freq, longframe, linetoggle) {
this.calc_sample_evtime = function (freq, longframe, linetoggle) {
var lines = 0.0;
var hpos;
@ -469,14 +468,14 @@ function Audi0() {
lines += AMIGA.playfield.maxvpos_nom;
scaled_sample_evtime_orig = Math.floor(hpos * lines * freq * CYCLE_UNIT / getRate(AMIGA.config.audio.rate));
scaled_sample_evtime = scaled_sample_evtime_orig;
/*#if 0
/*#if 0
lines -= AMIGA.playfield.maxvpos_nom;
BUG.info('%d.%d %d.%d %.2f', maxhpos_short, linetoggle ? 5 : 0, maxvpos_nom + (lines == 1.0 ? 1 : 0), lines > 0 && lines < 1 ? 5 : 0, scaled_sample_evtime);
#endif*/
#endif*/
BUG.info('Audio.calc_sample_evtime() scaled_sample_evtime %f (%f) | hpos %d, lines %d', scaled_sample_evtime, scaled_sample_evtime * CYCLE_UNIT_INV, hpos, lines);
}
};
this.setup = function() {
this.setup = function () {
if (channel === null) {
channel = [];
for (var i = 0; i < 4; i++)
@ -486,7 +485,9 @@ function Audi0() {
return;
if (driver.ctx === null) {
if (this.available & SAEI_Audio_Webkit)
if (this.available & SAEI_Audio_Default)
driver.ctx = new AudioContext();
else if (this.available & SAEI_Audio_Webkit)
driver.ctx = new webkitAudioContext();
else if (this.available & SAEI_Audio_Mozilla)
driver.ctx = new Audio();
@ -499,7 +500,8 @@ function Audi0() {
Fatal(SAEE_Audio_WebAudio_Not_Avail, null);
}
this.filter.setup(AMIGA.config.audio.filter); /* A500 lowpass-filter */
this.filter.setup(AMIGA.config.audio.filter);
/* A500 lowpass-filter */
var hz = AMIGA.config.video.ntsc ? 60 : 50;
this.calc_sample_evtime(hz, 1, AMIGA.config.video.ntsc);
@ -511,7 +513,7 @@ function Audi0() {
ringBuffer.size = sampleBuffer.size + (sampleBuffer.size >> 1);
ringBuffer.data = new Float32Array(ringBuffer.size << (AMIGA.config.audio.channels - 1));
if (this.available & SAEI_Audio_Webkit) {
if ((this.available & SAEI_Audio_Default) || (this.available & SAEI_Audio_Webkit)) {
var inputs = BrowserDetect.browser == 'Safari' ? 1 : 0;
//if (inputs == 1) BUG.info('Audio.setup() Safari fix enabled.');
@ -531,11 +533,11 @@ function Audi0() {
BUG.info('Audio.setup() enabled mozilla audio, channels %d, rate %d', AMIGA.config.audio.channels, getRate(AMIGA.config.audio.rate));
}
}
};
this.cleanup = function() {
this.cleanup = function () {
if (driver.ctx !== null) {
if (this.available & SAEI_Audio_Webkit) {
if ((this.available & SAEI_Audio_Default) || (this.available & SAEI_Audio_Webkit)) {
driver.def.node.disconnect(0);
driver.def.node = null;
}
@ -543,13 +545,13 @@ function Audi0() {
clearInterval(driver.moz.interval);
}
}
}
};
this.pauseResume = function(pause) {
this.pauseResume = function (pause) {
if (!AMIGA.config.audio.enabled || AMIGA.config.audio.mode == SAEV_Config_Audio_Mode_Emul) return;
if (driver.ctx !== null) {
if (this.available & SAEI_Audio_Webkit) {
if ((this.available & SAEI_Audio_Default) || (this.available & SAEI_Audio_Webkit)) {
if (driver.def.node) {
if (pause && !driver.paused) {
driver.def.node.disconnect(0);
@ -570,9 +572,9 @@ function Audi0() {
}
}
}
}
};
this.reset = function() {
this.reset = function () {
for (var i = 0; i < 4; i++)
channel[i].reset();
@ -592,11 +594,11 @@ function Audi0() {
ringBuffer.writePos = 0;
this.filter.reset();
}
};
/*---------------------------------*/
this.event_reset = function() {
this.event_reset = function () {
for (var i = 0; i < 4; i++)
channel[i].zerostate();
@ -604,9 +606,9 @@ function Audi0() {
next_sample_evtime = scaled_sample_evtime;
this.schedule();
AMIGA.events.schedule();
}
};
this.activate = function() {
this.activate = function () {
//BUG.info('Audio.activate()');
var ret = 0;
@ -617,26 +619,26 @@ function Audi0() {
}
work_to_do = 4 * AMIGA.playfield.maxvpos_nom * 50;
return ret;
}
};
this.deactivate = function() {
this.deactivate = function () {
//BUG.info('Audio.deactivate()');
this.pauseResume(1);
sampleBuffer.pos = 0;
sampleBuffer.rate.clr();
this.event_reset();
}
};
this.state_machine = function() {
this.state_machine = function () {
this.update();
for (var i = 0; i < 4; i++)
channel[i].state_channel(false);
this.schedule();
AMIGA.events.schedule();
}
};
this.schedule = function() {
this.schedule = function () {
var best = CYCLE_MAX;
AMIGA.events.eventtab[EV_AUDIO].active = false;
@ -651,9 +653,9 @@ function Audi0() {
}
}
AMIGA.events.eventtab[EV_AUDIO].evtime = AMIGA.events.currcycle + best;
}
};
this.update = function() {
this.update = function () {
if (!AMIGA.config.audio.enabled || !work_to_do) {
last_cycles = AMIGA.events.currcycle;
return;
@ -713,15 +715,11 @@ function Audi0() {
}
}
last_cycles = AMIGA.events.currcycle - n_cycles;
}
};
this.update_adkmasks = function() {
this.update_adkmasks = function () {
var t = AMIGA.adkcon | (AMIGA.adkcon >> 4);
channel[0].adk_mask = ((t >> 0) & 1) == 0 ? 0xffffffff : 0;
channel[1].adk_mask = ((t >> 1) & 1) == 0 ? 0xffffffff : 0;
channel[2].adk_mask = ((t >> 2) & 1) == 0 ? 0xffffffff : 0;
channel[3].adk_mask = ((t >> 3) & 1) == 0 ? 0xffffffff : 0;
channel[0].enabled = ((t >> 0) & 1) == 0;
channel[1].enabled = ((t >> 1) & 1) == 0;
channel[2].enabled = ((t >> 2) & 1) == 0;
@ -731,27 +729,28 @@ function Audi0() {
this.activate();
prevcon = AMIGA.adkcon;
}
}
};
this.handler = function() {
this.handler = function () {
this.update();
this.schedule();
}
};
this.hsync = function() {
this.hsync = function () {
if (work_to_do > 0) {
//work_to_do--;
if (--work_to_do == 0)
this.deactivate();
}
this.update();
}
};
this.vsync = function() { }
this.vsync = function () {
};
/*---------------------------------*/
this.AUDxDAT = function(nr, v) {
this.AUDxDAT = function (nr, v) {
//BUG.info('AUD%dDAT %x', nr, v);
channel[nr].dat = v;
channel[nr].dat_written = true;
@ -774,9 +773,9 @@ function Audi0() {
AMIGA.events.schedule();
}
channel[nr].dat_written = false;
}
};
this.AUDxPER = function(nr, v) {
this.AUDxPER = function (nr, v) {
this.activate();
this.update();
@ -798,25 +797,25 @@ function Audi0() {
}
channel[nr].per = per;
//if (debugchannel(nr)) BUG.info('AUD%dPER() %x', nr, v);
}
};
this.AUDxLEN = function(nr, v) {
this.AUDxLEN = function (nr, v) {
this.activate();
this.update();
channel[nr].len = v;
//if (debugchannel(nr)) BUG.info('AUD%dLEN() %x', nr, v);
}
};
this.AUDxVOL = function(nr, v) {
this.AUDxVOL = function (nr, v) {
v &= 127;
if (v > 64) v = 64;
this.activate();
this.update();
channel[nr].vol = v;
//if (debugchannel(nr)) BUG.info('AUD%dVOL() %x', nr, v);
}
};
this.AUDxLCH = function(nr, v) {
this.AUDxLCH = function (nr, v) {
this.activate();
this.update();
@ -825,9 +824,9 @@ function Audi0() {
channel[nr].ptx_written = true;
} else
channel[nr].lc = ((channel[nr].lc & 0xffff) | (v << 16)) >>> 0;
}
};
this.AUDxLCL = function(nr, v) {
this.AUDxLCL = function (nr, v) {
this.activate();
this.update();
@ -836,20 +835,20 @@ function Audi0() {
channel[nr].ptx_written = true;
} else
channel[nr].lc = ((channel[nr].lc & ~0xffff) | (v & 0xfffe)) >>> 0;
}
};
/*---------------------------------*/
this.getpt = function(nr, reset) {
this.getpt = function (nr, reset) {
var p = channel[nr].pt;
channel[nr].pt += 2;
if (reset)
channel[nr].pt = channel[nr].lc;
channel[nr].ptx_tofetch = false;
return p;
}
};
this.dmal = function() {
this.dmal = function () {
var dmal = 0;
for (var nr = 0; nr < 4; nr++) {
if (channel[nr].dr)
@ -860,13 +859,13 @@ function Audi0() {
}
//if (dmal) BUG.info('Audio.dmal() %d', dmal);
return dmal;
}
};
/*---------------------------------*/
const inv32768 = 1.0 / 32768;
this.sample_handler_def = function() {
this.sample_handler_def = function () {
var data0 = channel[0].enabled ? (channel[0].current_sample * channel[0].vol) : 0;
var data1 = channel[1].enabled ? (channel[1].current_sample * channel[1].vol) : 0;
var data2 = channel[2].enabled ? (channel[2].current_sample * channel[2].vol) : 0;
@ -890,9 +889,9 @@ function Audi0() {
sampleBuffer.data[sampleBuffer.pos++] = inv32768 * ((data2 + data3) * 0.5);
} else
BUG.info('Audio.sample_handler() audio buffer over-run!');
}
};
this.sample_handler_crux = function() {
this.sample_handler_crux = function () {
var data0 = channel[0].enabled ? (channel[0].current_sample * channel[0].vol) : 0;
var data1 = channel[1].enabled ? (channel[1].current_sample * channel[1].vol) : 0;
var data2 = channel[2].enabled ? (channel[2].current_sample * channel[2].vol) : 0;
@ -949,9 +948,9 @@ function Audi0() {
sampleBuffer.data[sampleBuffer.pos++] = inv32768 * ((data2 + data3) * 0.5);
} else
BUG.info('Audio.sample_handler_crux() audio buffer over-run!');
}
};
this.sample_handler_rh = function() {
this.sample_handler_rh = function () {
var data0 = channel[0].enabled ? (channel[0].current_sample * channel[0].vol) : 0;
var data1 = channel[1].enabled ? (channel[1].current_sample * channel[1].vol) : 0;
var data2 = channel[2].enabled ? (channel[2].current_sample * channel[2].vol) : 0;
@ -994,7 +993,7 @@ function Audi0() {
sampleBuffer.data[sampleBuffer.pos++] = inv32768 * ((data2 + data3) * 0.5);
} else
BUG.info('Audio.sample_handler_rh() audio buffer over-run!');
}
};
/*---------------------------------*/
@ -1125,7 +1124,7 @@ function Audi0() {
driver.ctx.mozWriteAudio(soundData);
}
function mozHandler_full() {
/*function mozHandler_full() {
var written;
if (driver.moz.tail) {
@ -1149,5 +1148,5 @@ function Audi0() {
}
driver.moz.currentWritePosition += written;
}
}
}*/
}

View file

@ -52,8 +52,8 @@ function Blitter() {
[0 ] /* F */
];
const blit_cycle_diagram_line = [4, 0,3,5,4, 0,3,5,4];
const blit_cycle_diagram_finald = [2, 0,4, 0,4];
const blit_cycle_diagram_finalld = [2, 0,0, 0,0];
//const blit_cycle_diagram_finald = [2, 0,4, 0,4];
//const blit_cycle_diagram_finalld = [2, 0,0, 0,0];
var blit_filltable = [];
var blit_masktable = [];
@ -85,7 +85,6 @@ function Blitter() {
var blitline = 0, blitfc = 0, blitfill = 0, blitife = 0, blitsing = 0, blitdesc = 0;
var blitonedot = 0, blitsign = 0, blitlinepixel = 0;
var ddat1 = 0, ddat2 = 0;
var ddat1use = 0, ddat2use = 0;
var last_blitter_hpos = 0;
@ -101,7 +100,7 @@ function Blitter() {
//function build_blitfilltable()
{
var blit_masktable = new Uint16Array(BLITTER_MAX_WORDS);
blit_masktable = new Uint16Array(BLITTER_MAX_WORDS);
for (var i = 0; i < BLITTER_MAX_WORDS; i++)
blit_masktable[i] = 0xffff;
@ -130,18 +129,18 @@ function Blitter() {
/*---------------------------------*/
this.reset = function() {
this.reset = function () {
bltstate = BLT_done;
blit_interrupt = true;
blit_stuck = 0;
}
};
function blitter_dump() {
/*function blitter_dump() {
BUG.info('PT A=%08X B=%08X C=%08X D=%08X', bltapt, bltbpt, bltcpt, bltdpt);
BUG.info('CON0=%04X CON1=%04X DAT A=%04X B=%04X C=%04X', bltcon0, bltcon1, blt_info.bltadat, blt_info.bltbdat, blt_info.bltcdat);
//BUG.info('AFWM=%04X ALWM=%04X MOD A=%04X B=%04X C=%04X D=%04X', blt_info.bltafwm, blt_info.bltalwm, blt_info.bltamod & 0xffff, blt_info.bltbmod & 0xffff, blt_info.bltcmod & 0xffff, blt_info.bltdmod & 0xffff);
BUG.info('AFWM=%04X ALWM=%04X MOD A=%04X B=%04X C=%04X D=%04X', blt_info.bltafwm, blt_info.bltalwm, blt_info.bltamod, blt_info.bltbmod, blt_info.bltcmod, blt_info.bltdmod);
}
}*/
function castWord(v) {
return (v & 0x8000) ? (v - 0x10000) : v;
@ -167,7 +166,7 @@ function Blitter() {
return diag[1 + diag[0] + cycles];
}
function channel_pos(cycles) {
/*function channel_pos(cycles) {
if (cycles < 0)
return 0;
var diag = get_ch();
@ -176,7 +175,7 @@ function Blitter() {
cycles -= diag[0];
cycles %= diag[0];
return cycles;
}
}*/
function blitter_interrupt() {
if (blit_interrupt)
@ -2012,6 +2011,7 @@ function Blitter() {
case 0xfd: return (~c) | (b) | (a);
case 0xfe: return (c) | (b) | (a);
case 0xff: return 0xffff;
default: return 0;
}
}
@ -2217,7 +2217,7 @@ function Blitter() {
if (bltcon0 & 0x200) {
if (AMIGA.dmaen(DMAF_BLTEN))
//blt_info.bltcdat = AMIGA.mem.load16_chip(bltcpt);
blt_info.bltcdat = dat = AMIGA.mem.chip.data[bltcpt >>> 1];
blt_info.bltcdat = AMIGA.mem.chip.data[bltcpt >>> 1];
}
bltstate = BLT_work;
}
@ -2382,7 +2382,7 @@ function Blitter() {
if (blt_info.vblitsize <= 0)
bltstate = BLT_done;
} while (bltstate != BLT_done);
bltapt_line = null;
//bltapt_line = null;
bltdpt = bltcpt;
} else {
if (blitdesc)
@ -2400,7 +2400,7 @@ function Blitter() {
/*---------------------------------*/
this.handler = function(data) {
this.handler = function (data) {
if (!AMIGA.dmaen(DMAF_BLTEN)) {
AMIGA.events.newevent(EV2_BLITTER, 10, 0);
if (++blit_stuck < 20000 || !AMIGA.config.blitter.immediate)
@ -2416,10 +2416,10 @@ function Blitter() {
return;
}
blitter_do();
}
};
var changetable = new Uint8Array(32 * 32); for (var i = 0; i < changetable.length; i++) changetable[i] = 0;
var freezes = 10;
//var freezes = 10;
function blit_bltset(con) {
if (con & 2) {
blitdesc = bltcon1 & 2;
@ -2518,9 +2518,8 @@ function Blitter() {
warned1--;
BUG.info('waiting_blits detected');
}
if (bltstate == BLT_done)
return true;
return false;
return bltstate == BLT_done;
}
function do_blitter(hpos, copper) {
@ -2533,17 +2532,12 @@ function Blitter() {
cleanstart = 1;
}
bltstate = BLT_done;
blt_info.blitzero = 1;
preva = 0;
prevb = 0;
blt_info.got_cycle = 0;
blit_firstline_cycles = blit_first_cycle = AMIGA.events.currcycle;
blit_last_cycle = 0;
last_blitter_hpos = hpos + 1;
blit_cyclecounter = 0;
blit_bltset(1 | 2);
ddat1use = ddat2use = 0;
@ -2615,7 +2609,7 @@ function Blitter() {
}
var warned2 = 10;
this.maybe_blit = function(hpos, hack) {
this.maybe_blit = function (hpos, hack) {
if (bltstate == BLT_done)
return;
@ -2647,9 +2641,9 @@ function Blitter() {
return;
AMIGA.blitter.handler(0);
}
};
this.blitnasty = function() {
this.blitnasty = function () {
if (bltstate == BLT_done || !AMIGA.dmaen(DMAF_BLTEN))
return 0;
if (blit_last_cycle >= blit_diag[0] && blit_dmacount == blit_diag[0])
@ -2662,12 +2656,12 @@ function Blitter() {
ccnt++;
}
return ccnt;
}
};
/*---------------------------------*/
var oddfstrt = 0, oddfstop = 0, ototal = 0, ofree = 0, slow = 0;
this.slowdown = function() {
this.slowdown = function () {
var data = AMIGA.playfield.getData();
var ddfstrt = data[0];
var ddfstop = data[1];
@ -2693,12 +2687,15 @@ function Blitter() {
return;
blit_slowdown += slow;
}
};
/*---------------------------------*/
this.BLTADAT = function(hpos, v) { this.maybe_blit(hpos, 0); blt_info.bltadat = v; }
this.BLTBDAT = function(hpos, v) {
this.BLTADAT = function (hpos, v) {
this.maybe_blit(hpos, 0);
blt_info.bltadat = v;
};
this.BLTBDAT = function (hpos, v) {
this.maybe_blit(hpos, 0);
if (bltcon1 & 2)
blt_info.bltbhold = (v << (bltcon1 >> 12)) & 0xffff;
@ -2706,35 +2703,96 @@ function Blitter() {
blt_info.bltbhold = (v >> (bltcon1 >> 12)) & 0xffff;
blt_info.bltbdat = v;
}
this.BLTCDAT = function(hpos, v) { this.maybe_blit(hpos, 0); blt_info.bltcdat = v; reset_blit(0); }
};
this.BLTCDAT = function (hpos, v) {
this.maybe_blit(hpos, 0);
blt_info.bltcdat = v;
reset_blit(0);
};
this.BLTAMOD = function(hpos, v) { this.maybe_blit(hpos, 1); blt_info.bltamod = castWord(v & 0xfffe); reset_blit(0); }
this.BLTBMOD = function(hpos, v) { this.maybe_blit(hpos, 1); blt_info.bltbmod = castWord(v & 0xfffe); reset_blit(0); }
this.BLTCMOD = function(hpos, v) { this.maybe_blit(hpos, 1); blt_info.bltcmod = castWord(v & 0xfffe); reset_blit(0); }
this.BLTDMOD = function(hpos, v) { this.maybe_blit(hpos, 1); blt_info.bltdmod = castWord(v & 0xfffe); reset_blit(0); }
this.BLTAMOD = function (hpos, v) {
this.maybe_blit(hpos, 1);
blt_info.bltamod = castWord(v & 0xfffe);
reset_blit(0);
};
this.BLTBMOD = function (hpos, v) {
this.maybe_blit(hpos, 1);
blt_info.bltbmod = castWord(v & 0xfffe);
reset_blit(0);
};
this.BLTCMOD = function (hpos, v) {
this.maybe_blit(hpos, 1);
blt_info.bltcmod = castWord(v & 0xfffe);
reset_blit(0);
};
this.BLTDMOD = function (hpos, v) {
this.maybe_blit(hpos, 1);
blt_info.bltdmod = castWord(v & 0xfffe);
reset_blit(0);
};
this.BLTCON0 = function(hpos, v) { this.maybe_blit(hpos, 2); bltcon0 = v; reset_blit(1); }
this.BLTCON0L = function( hpos, v) {
if (!(AMIGA.config.chipset.mask & CSMASK_ECS_AGNUS)) return;
this.maybe_blit(hpos, 2); bltcon0 = (bltcon0 & 0xFF00) | (v & 0xFF);
this.BLTCON0 = function (hpos, v) {
this.maybe_blit(hpos, 2);
bltcon0 = v;
reset_blit(1);
}
this.BLTCON1 = function(hpos, v) { this.maybe_blit(hpos, 2); bltcon1 = v; reset_blit(2); }
};
this.BLTCON0L = function (hpos, v) {
if (!(AMIGA.config.chipset.mask & CSMASK_ECS_AGNUS)) return;
this.maybe_blit(hpos, 2);
bltcon0 = (bltcon0 & 0xFF00) | (v & 0xFF);
reset_blit(1);
};
this.BLTCON1 = function (hpos, v) {
this.maybe_blit(hpos, 2);
bltcon1 = v;
reset_blit(2);
};
this.BLTAFWM = function(hpos, v) { this.maybe_blit(hpos, 2); blt_info.bltafwm = v; reset_blit(0); }
this.BLTALWM = function(hpos, v) { this.maybe_blit(hpos, 2); blt_info.bltalwm = v; reset_blit(0); }
this.BLTAFWM = function (hpos, v) {
this.maybe_blit(hpos, 2);
blt_info.bltafwm = v;
reset_blit(0);
};
this.BLTALWM = function (hpos, v) {
this.maybe_blit(hpos, 2);
blt_info.bltalwm = v;
reset_blit(0);
};
this.BLTAPTH = function(hpos, v) { this.maybe_blit(hpos, 0); bltapt = ((bltapt & 0xffff) | (v << 16)) >>> 0; }
this.BLTAPTL = function(hpos, v) { this.maybe_blit(hpos, 0); bltapt = ((bltapt & ~0xffff) | (v & 0xfffe)) >>> 0; }
this.BLTBPTH = function(hpos, v) { this.maybe_blit(hpos, 0); bltbpt = ((bltbpt & 0xffff) | (v << 16)) >>> 0; }
this.BLTBPTL = function(hpos, v) { this.maybe_blit(hpos, 0); bltbpt = ((bltbpt & ~0xffff) | (v & 0xfffe)) >>> 0; }
this.BLTCPTH = function(hpos, v) { this.maybe_blit(hpos, 0); bltcpt = ((bltcpt & 0xffff) | (v << 16)) >>> 0; }
this.BLTCPTL = function(hpos, v) { this.maybe_blit(hpos, 0); bltcpt = ((bltcpt & ~0xffff) | (v & 0xfffe)) >>> 0; }
this.BLTDPTH = function(hpos, v) { this.maybe_blit(hpos, 0); bltdpt = ((bltdpt & 0xffff) | (v << 16)) >>> 0; }
this.BLTDPTL = function(hpos, v) { this.maybe_blit(hpos, 0); bltdpt = ((bltdpt & ~0xffff) | (v & 0xfffe)) >>> 0; }
this.BLTAPTH = function (hpos, v) {
this.maybe_blit(hpos, 0);
bltapt = ((bltapt & 0xffff) | (v << 16)) >>> 0;
};
this.BLTAPTL = function (hpos, v) {
this.maybe_blit(hpos, 0);
bltapt = ((bltapt & ~0xffff) | (v & 0xfffe)) >>> 0;
};
this.BLTBPTH = function (hpos, v) {
this.maybe_blit(hpos, 0);
bltbpt = ((bltbpt & 0xffff) | (v << 16)) >>> 0;
};
this.BLTBPTL = function (hpos, v) {
this.maybe_blit(hpos, 0);
bltbpt = ((bltbpt & ~0xffff) | (v & 0xfffe)) >>> 0;
};
this.BLTCPTH = function (hpos, v) {
this.maybe_blit(hpos, 0);
bltcpt = ((bltcpt & 0xffff) | (v << 16)) >>> 0;
};
this.BLTCPTL = function (hpos, v) {
this.maybe_blit(hpos, 0);
bltcpt = ((bltcpt & ~0xffff) | (v & 0xfffe)) >>> 0;
};
this.BLTDPTH = function (hpos, v) {
this.maybe_blit(hpos, 0);
bltdpt = ((bltdpt & 0xffff) | (v << 16)) >>> 0;
};
this.BLTDPTL = function (hpos, v) {
this.maybe_blit(hpos, 0);
bltdpt = ((bltdpt & ~0xffff) | (v & 0xfffe)) >>> 0;
};
this.BLTSIZE = function(hpos, v) {
this.BLTSIZE = function (hpos, v) {
this.maybe_blit(hpos, 0);
blt_info.vblitsize = v >> 6;
@ -2745,15 +2803,15 @@ function Blitter() {
blt_info.hblitsize = 64;
do_blitter(hpos, AMIGA.copper.access);
}
};
this.BLTSIZV = function(hpos, v) {
this.BLTSIZV = function (hpos, v) {
if (!(AMIGA.config.chipset.mask & CSMASK_ECS_AGNUS)) return;
this.maybe_blit(hpos, 0);
blt_info.vblitsize = v & 0x7FFF;
}
};
this.BLTSIZH = function(hpos, v) {
this.BLTSIZH = function (hpos, v) {
if (!(AMIGA.config.chipset.mask & CSMASK_ECS_AGNUS)) return;
this.maybe_blit(hpos, 0);
blt_info.hblitsize = v & 0x7FF;
@ -2763,16 +2821,16 @@ function Blitter() {
blt_info.hblitsize = 0x0800;
do_blitter(hpos, AMIGA.copper.access);
}
};
/*---------------------------------*/
this.getState = function() {
this.getState = function () {
return bltstate;
}
this.setState = function(s) {
};
this.setState = function (s) {
bltstate = s;
}
};
this.getIntZero = function() {
return [blit_interrupt, blt_info.blitzero];
}

View file

@ -11,13 +11,13 @@
*
**************************************************************************/
const CIAA_DEBUG_R = 0;
/*const CIAA_DEBUG_R = 0;
const CIAA_DEBUG_W = 0;
const CIAB_DEBUG_R = 0;
const CIAB_DEBUG_W = 0;
const DONGLE_DEBUG = 0;
const KB_DEBUG = 0;
const CLOCK_DEBUG = 0;
const CLOCK_DEBUG = 0;*/
const TOD_HACK = 1;
@ -54,7 +54,7 @@ function CIA() {
var div10 = 0;
//var kbstate = 0, kblostsynccnt = 0, kbcode = 0;
var serbits = 0;
//var serbits = 0;
var warned = 10;
//var rtc_delayed_write = 0;
@ -101,23 +101,23 @@ function CIA() {
}
}
this.SetICRA = function(icr, sdr) {
this.SetICRA = function (icr, sdr) {
ciaaicr |= icr;
ciaasdr = sdr;
RethinkICRA();
}
};
this.SetICRB = function(icr, sdr) {
this.SetICRB = function (icr, sdr) {
ciabicr |= icr;
if (sdr !== null)
ciabsdr = sdr;
RethinkICRB();
}
};
this.rethink = function() {
this.rethink = function () {
RethinkICRA();
RethinkICRB();
}
};
/* Figure out how many CIA timer cycles have passed for each timer since the last call of CIA_calctimers. */
function compute_passed_time() {
@ -343,10 +343,10 @@ function CIA() {
AMIGA.events.schedule();
}
this.handler = function() {
this.handler = function () {
CIA_update();
CIA_calctimers();
}
};
/*this.diskindex = function() {
ciabicr |= 0x10;
@ -476,7 +476,7 @@ function CIA() {
//this.hsync_prehandler = function() {}
this.hsync_posthandler = function(dotod) {
this.hsync_posthandler = function (dotod) {
if (ciabtodon && dotod) {
ciabtod++;
ciabtod &= 0xFFFFFF;
@ -510,7 +510,7 @@ function CIA() {
keyreq();
}*/
AMIGA.input.keyboard.hsync();
}
};
function calc_led(old_led) {
var c = AMIGA.events.currcycle;
@ -560,7 +560,7 @@ function CIA() {
led_cycles_off = 0;
}
this.vsync_prehandler = function() {
this.vsync_prehandler = function () {
/*if (rtc_delayed_write < 0) {
rtc_delayed_write = 50;
} else if (rtc_delayed_write > 0) {
@ -579,9 +579,9 @@ function CIA() {
}
}*/
AMIGA.input.keyboard.vsync();
}
};
this.vsync_posthandler = function(dotod) {
this.vsync_posthandler = function (dotod) {
//if (heartbeat_cnt > 0) heartbeat_cnt--;
if (TOD_HACK) {
if (AMIGA.config.cia.tod_hack && tod_hack_enabled == 1)
@ -590,13 +590,13 @@ function CIA() {
if (ciaatodon && dotod) {
ciaatod++;
ciaatod &= 0xFFFFFF;
ciaa_checkalarm (1);
ciaa_checkalarm(1);
}
/*if (vpos == 0) {
write_log ('%d', vsync_counter);
this.dump();
}*/
}
};
function bfe001_change() {
var v = ciaapra;
@ -782,7 +782,7 @@ function CIA() {
}
return tmp;
case 1:
if (DONGLE_DEBUG && notinrom()) write_log (_T('BFD100 R %02X %s\n'), ciabprb, debuginfo(0));
//if (DONGLE_DEBUG && notinrom()) write_log (_T('BFD100 R %02X %s\n'), ciabprb, debuginfo(0));
tmp = ciabprb;
//tmp = dongle_cia_read(1, reg, tmp);
if (ciabcrb & 2) {
@ -790,14 +790,14 @@ function CIA() {
if (ciabcrb & 4)
pb7 = ciabcrb & 1;
tmp &= ~0x80;
tmp |= pb7 ? 0x80 : 00;
tmp |= pb7 ? 0x80 : 0;
}
if (ciabcra & 2) {
var pb6 = 0;
if (ciabcra & 4)
pb6 = ciabcra & 1;
tmp &= ~0x40;
tmp |= pb6 ? 0x40 : 00;
tmp |= pb6 ? 0x40 : 0;
}
return tmp;
case 2:
@ -993,7 +993,7 @@ function CIA() {
//if ((addr >= 8 && addr <= 10) || CIAB_DEBUG_W > 1) write_log (_T('W_CIAB: bfd%x00 %02X %08X\n'), reg, val, M68K_GETPC);
switch (reg) {
case 0:
if (DONGLE_DEBUG && notinrom()) write_log (_T('BFD000 W %02X %s\n'), val, debuginfo(0));
//if (DONGLE_DEBUG && notinrom()) write_log (_T('BFD000 W %02X %s\n'), val, debuginfo(0));
//dongle_cia_write (1, reg, val);
ciabpra = val;
//if (currprefs.use_serial)
@ -1117,9 +1117,10 @@ function CIA() {
}
}
this.setup = function() {}
this.setup = function () {
};
this.reset = function() {
this.reset = function () {
if (TOD_HACK) {
tod_hack_tv = 0;
tod_hack_tod = 0;
@ -1137,16 +1138,22 @@ function CIA() {
//oldovl = true;
//kbstate = 0;
ciaatlatch = ciabtlatch = 0;
ciaapra = 0; ciaadra = 0;
ciaatod = ciabtod = 0; ciaatodon = ciabtodon = 0;
ciaapra = 0;
ciaadra = 0;
ciaatod = ciabtod = 0;
ciaatodon = ciabtodon = 0;
ciaaicr = ciabicr = ciaaimask = ciabimask = 0;
ciaacra = ciaacrb = ciabcra = ciabcrb = 0x4; /* outmode = toggle; */
ciaacra = ciaacrb = ciabcra = ciabcrb = 0x4;
/* outmode = toggle; */
ciaala = ciaalb = ciabla = ciablb = ciaata = ciaatb = ciabta = ciabtb = 0xFFFF;
ciaaalarm = ciabalarm = 0;
ciabpra = 0x8C; ciabdra = 0;
ciabpra = 0x8C;
ciabdra = 0;
div10 = 0;
ciaasdr_cnt = 0; ciaasdr = 0;
ciabsdr_cnt = 0; ciabsdr = 0;
ciaasdr_cnt = 0;
ciaasdr = 0;
ciabsdr_cnt = 0;
ciabsdr = 0;
ciaata_passed = ciaatb_passed = ciabta_passed = ciabtb_passed = 0;
CIA_calctimers();
@ -1155,14 +1162,14 @@ function CIA() {
//map_overlay (0);
//if (currprefs.use_serial) serial_dtr_off (); NI /* Drop DTR at reset */
}
};
this.dump = function() {
this.dump = function () {
BUG.info('A: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)', ciaacra, ciaacrb, ciaaicr, ciaaimask, ciaata, ciaala, ciaatb, ciaalb);
BUG.info('TOD %06x (%06x) ALARM %06x %s%s CYC=%.1f', ciaatod, ciaatol, ciaaalarm, ciaatlatch ? 'L' : ' ', ciaatodon ? ' ' : 'S', AMIGA.events.currcycle * CYCLE_UNIT_INV);
BUG.info('B: CRA %02x CRB %02x ICR %02x IM %02x TA %04x (%04x) TB %04x (%04x)', ciabcra, ciabcrb, ciabicr, ciabimask, ciabta, ciabla, ciabtb, ciablb);
BUG.info('TOD %06x (%06x) ALARM %06x %s%s CLK=%.1f', ciabtod, ciabtol, ciabalarm, ciabtlatch ? 'L' : ' ', ciabtodon ? ' ' : 'S', div10 * CYCLE_UNIT_INV);
}
};
// Gayle or Fat Gary does not enable CIA /CS lines if both CIAs are selected
// Old Gary based Amigas enable both CIAs in this situation
@ -1203,7 +1210,7 @@ function CIA() {
return mask == 0xe000 || mask == 0xd000;
}
this.load8 = function(addr) {
this.load8 = function (addr) {
var r = (addr & 0xf00) >> 8;
var v = 0xff;
@ -1222,7 +1229,8 @@ function CIA() {
case 2:
v = (addr & 1) ? ReadCIAA(r) : 0xff;
break;
case 3: {
case 3:
{
//if (AMIGA.config.cpu.model == 68000 && AMIGA.config.cpu.compatible) v = (addr & 1) ? regs.irc : regs.irc >> 8;
if (warned > 0) {
BUG.info('cia_bget: unknown CIA address %x', addr);
@ -1233,9 +1241,9 @@ function CIA() {
}
cia_wait_post(v);
return v;
}
};
this.load16 = function(addr) {
this.load16 = function (addr) {
var r = (addr & 0xf00) >> 8;
var v = 0xffff;
@ -1254,7 +1262,8 @@ function CIA() {
case 2:
v = (0xff << 8) | ReadCIAA(r);
break;
case 3: {
case 3:
{
//if (AMIGA.config.cpu.model == 68000 && AMIGA.config.cpu.compatible) v = regs.irc;
if (warned > 0) {
BUG.info('cia_wget: unknown CIA address %x', addr);
@ -1265,13 +1274,13 @@ function CIA() {
}
cia_wait_post(v);
return v;
}
};
this.load32 = function(addr) {
this.load32 = function (addr) {
var v = this.load16(addr) << 16;
v |= this.load16(addr + 2);
return v >>> 0;
}
};
this.store8 = function (addr, value) {
var r = (addr & 0xf00) >> 8;
@ -1291,7 +1300,7 @@ function CIA() {
}
}
cia_wait_post(value);
}
};
this.store16 = function (addr, value) {
var r = (addr & 0xf00) >> 8;
@ -1311,7 +1320,7 @@ function CIA() {
}
}
cia_wait_post(value);
}
};
this.store32 = function (addr, value) {
this.store16(addr, value >> 16);

View file

@ -34,10 +34,10 @@ function Config() {
size: 0
},
slow: {
size: 0,
size: 0
},
fast: {
size: 0,
size: 0
}
};
this.rom = {
@ -177,7 +177,7 @@ function Config() {
c.video.scanlines = 0 ? true : false;
c.video.extrawidth = 0;
c.video.xcenter = 0;
c.video.ycenter = 0
c.video.ycenter = 0;
c.audio.enabled = true;
//c.audio.mode = SAEV_Config_Audio_Mode_Play_Best;
@ -203,11 +203,16 @@ function Config() {
c.cia.tod = 0;
c.cia.tod_hack = true;
c.hooks.error = function(err, msg) {}
c.hooks.power_led = function(on) {}
c.hooks.floppy_motor = function(unit, on) {}
c.hooks.floppy_step = function(unit, cyl) {}
c.hooks.fps = function(fps) {}
c.hooks.error = function (err, msg) {
};
c.hooks.power_led = function (on) {
};
c.hooks.floppy_motor = function (unit, on) {
};
c.hooks.floppy_step = function (unit, cyl) {
};
c.hooks.fps = function (fps) {
};
c.hooks.cpu = function(usage) {}
}
configSetDefaults(this);

View file

@ -10,20 +10,14 @@
const SAEV_Version = 0;
const SAEV_Revision = 8;
const SAEV_Revision_Sub = 0;
/*-----------------------------------------------------------------------*/
const SAEV_Null = null;
const SAEV_True = true;
const SAEV_False = false;
const SAEV_Revision_Sub = 1;
/*-----------------------------------------------------------------------*/
/* info */
const SAEI_Audio_Webkit = 1;
const SAEI_Audio_Mozilla = 2;
const SAEI_Audio_Default = 1;
const SAEI_Audio_Webkit = 2;
const SAEI_Audio_Mozilla = 4;
const SAEI_Video_Canvas2D = 1;
const SAEI_Video_WebGL = 2;
@ -83,7 +77,7 @@ const SAEV_Config_EXT_Size_None = 0;
const SAEV_Config_EXT_Size_256K = 1;
const SAEV_Config_EXT_Size_512K = 2;
const SAEV_Config_EXT_Addr_A0 = 1;
//const SAEV_Config_EXT_Addr_A0 = 1;
const SAEV_Config_EXT_Addr_E0 = 2;
const SAEV_Config_EXT_Addr_F0 = 3;
@ -138,7 +132,7 @@ const SAEV_Config_RTC_Type_RF5C01A = 2;
/*-----------------------------------------------------------------------*/
/* erros */
const SAEE_None = 0;
//const SAEE_None = 0;
const SAEE_CPU_Internal = 1;
const SAEE_CPU_68020_Required = 2;
@ -148,32 +142,25 @@ const SAEE_Disk_File_Too_Big = 3;
const SAEE_Video_Shader_Error = 4;
const SAEE_Video_ID_Not_Found = 5;
const SAEE_Video_Canvas_Not_Supported = 6;
const SAEE_Video_WebGL_Not_Avail = 7;
//const SAEE_Video_WebGL_Not_Avail = 7;
const SAEE_Audio_WebAudio_Not_Avail = 8;
/*-----------------------------------------------------------------------*/
/* methods */
const SAEM_Init = 1;
/*const SAEM_Init = 1;
const SAEM_Start = 2;
const SAEM_Stop = 3;
const SAEM_Pause = 4;
const SAEM_Reset = 5;
const SAEM_Insert = 6;
const SAEM_Eject = 7;
const SAEM_Eject = 7;*/
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
/* debug */
var BUG = null;
/*-----------------------------------------------------------------------*/
/* amiga */
var AMIGA = null;
const ST_STOP = 0;
const ST_CYCLE = 1;
const ST_PAUSE = 2;
@ -251,8 +238,6 @@ const DMAF_BZERO = 1 << 13;
const DMAF_BBUSY = 1 << 14;
const DMAF_SETCLR = 1 << 15;
const INT_PROCESSING_DELAY = 3 * CYCLE_UNIT;
/*-----------------------------------------------------------------------*/
/* blitter */
@ -301,7 +286,7 @@ const EQU_ENDLINE_NTSC = 10;
const CSMASK_ECS_AGNUS = 1;
const CSMASK_ECS_DENISE = 2;
const CSMASK_AGA = 4;
const CSMASK_MASK = (CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA);
//const CSMASK_MASK = (CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA);
const CHIPSET_CLOCK_PAL = 3546895;
const CHIPSET_CLOCK_NTSC = 3579545;
@ -338,7 +323,7 @@ const HARD_DDF_START = 0x18;
const MAX_PLANES = 6; /* 8 = AGA */
const AMIGA_WIDTH_MAX = 752 / 2;
const AMIGA_HEIGHT_MAX = 574 / 2;
//const AMIGA_HEIGHT_MAX = 574 / 2;
const DIW_DDF_OFFSET = 1;
const HBLANK_OFFSET = 9;
@ -366,13 +351,13 @@ const COLOR_CHANGE_BRDBLANK = 0x80000000;
const BPLCON_DENISE_DELAY = 1;
const SPRITE_DEBUG = 0;
const SPRITE_DEBUG_MINY = 0x0;
const SPRITE_DEBUG_MAXY = 0x100;
const SPR0_HPOS = 0x15;
const MAX_SPRITES = 8;
//const SPRITE_DEBUG = 0;
//const SPRITE_DEBUG_MINY = 0x0;
//const SPRITE_DEBUG_MAXY = 0x100;
//const AUTOSCALE_SPRITES = 1;
//const SPRBORDER = 0;
const SPR0_HPOS = 0x15;
const MAX_SPRITES = 8;
const MAX_PIXELS_PER_LINE = 1760;
@ -382,8 +367,6 @@ const MAX_REG_CHANGE = ((MAXVPOS + 1) * 2 * MAXHPOS);
const MAX_STOP = 30000;
const NO_BLOCK = -3;
const FRAMES_UNTIL_RES_SWITCH = 1;
const MAX_WORDS_PER_LINE = 100;
const DO_SPRITES = 1;

View file

@ -50,7 +50,7 @@ function Copper() {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
];
this.cop1lc = 0;
this.cop2lc = 0,
this.cop2lc = 0;
this.copcon = 0;
this.enabled_thisline = false;
this.access = false;
@ -75,29 +75,29 @@ function Copper() {
this.reset = function () {
this.copcon = 0;
cop_state.state = COP_stop;
}
};
this.reset2 = function () {
cop_state.hpos = 0;
cop_state.last_write = 0;
this.compute_spcflag_copper(AMIGA.playfield.maxhpos);
}
};
this.COPCON = function (v) {
this.copcon = v;
}
};
this.COP1LCH = function (v) {
this.cop1lc = ((v << 16) | (this.cop1lc & 0xffff)) >>> 0;
}
};
this.COP1LCL = function (v) {
this.cop1lc = ((this.cop1lc & 0xffff0000) | (v & 0xfffe)) >>> 0;
}
};
this.COP2LCH = function (v) {
this.cop2lc = ((v << 16) | (this.cop2lc & 0xffff)) >>> 0;
}
};
this.COP2LCL = function (v) {
this.cop2lc = ((this.cop2lc & 0xffff0000) | (v & 0xfffe)) >>> 0;
}
};
this.COPJMP = function (num, vblank) {
var oldstrobe = cop_state.strobe;
@ -134,7 +134,7 @@ function Copper() {
cop_state.state = COP_stop;
//BUG.info('COPJMP(%d) COP_stop');
}
}
};
/*function get_copper_address(copno) {
switch (copno) {
@ -154,7 +154,7 @@ function Copper() {
return true;
}
return false;
}
};
this.immediate_copper = function (num) {
var pos = 0;
@ -202,7 +202,7 @@ function Copper() {
}
cop_state.state = COP_stop;
clr_special(SPCFLAG_COPPER);
}
};
this.copper_cant_read = function (hpos, alloc) {
//BUG.info('copper_cant_read2() hpos %d / %d', hpos, AMIGA.playfield.maxhpos);
@ -212,7 +212,7 @@ function Copper() {
return -1;
}
return AMIGA.playfield.is_bitplane_dma(hpos);
}
};
this.custom_store16_copper = function (hpos, addr, value, noget) {
//if (addr == 0x88 || addr == 0x8a)
@ -222,15 +222,15 @@ function Copper() {
var v = AMIGA.custom.store16_real(hpos, addr, value, noget);
this.access = false;
return v;
}
};
this.dump_copper = function (error, until_hpos) {
BUG.info('\n');
BUG.info('%s: vpos=%d until_hpos=%d vp=%d', error, AMIGA.playfield.vpos, until_hpos, AMIGA.playfield.vpos & (((cop_state.saved_i2 >> 8) & 0x7f) | 0x80));
BUG.info('cvcmp=%d chcmp=%d chpos=%d cvpos=%d ci1=%04X ci2=%04X', cop_state.vcmp, cop_state.hcmp, cop_state.hpos, cop_state.vpos, cop_state.saved_i1, cop_state.saved_i2);
BUG.info('cstate=%d ip=%x SPCFLAGS=%x iscline=%d', cop_state.state, cop_state.ip, AMIGA.spcflags, this.enabled_thisline?1:0);
BUG.info('cstate=%d ip=%x SPCFLAGS=%x iscline=%d', cop_state.state, cop_state.ip, AMIGA.spcflags, this.enabled_thisline ? 1 : 0);
BUG.info('\n');
}
};
this.update = function (until_hpos) {
var vp = AMIGA.playfield.vpos & (((cop_state.saved_i2 >> 8) & 0x7f) | 0x80);
@ -252,7 +252,7 @@ function Copper() {
if (until_hpos > (AMIGA.playfield.maxhpos & ~1))
until_hpos = AMIGA.playfield.maxhpos & ~1;
for (;;) {
for (; ;) {
var old_hpos = c_hpos;
var hp;
@ -276,24 +276,28 @@ function Copper() {
c_hpos += 2;
switch (cop_state.state) {
case COP_wait_in2: {
case COP_wait_in2:
{
if (this.copper_cant_read(old_hpos, 0))
continue;
cop_state.state = COP_wait1;
break;
}
case COP_skip_in2: {
case COP_skip_in2:
{
if (this.copper_cant_read(old_hpos, 0))
continue;
cop_state.state = COP_skip1;
break;
}
case COP_strobe_extra: {
case COP_strobe_extra:
{
// Wait 1 copper cycle doing nothing
cop_state.state = COP_strobe_delay1;
break;
}
case COP_strobe_delay1: {
case COP_strobe_delay1:
{
// First cycle after COPJMP is just like normal first read cycle
// Cycle is used and needs to be free.
if (this.copper_cant_read(old_hpos, 1))
@ -302,7 +306,8 @@ function Copper() {
cop_state.ip += 2;
break;
}
case COP_strobe_delay2: {
case COP_strobe_delay2:
{
// Second cycle after COPJMP. This is the strange one.
// This cycle does not need to be free
// But it still gets allocated by copper if it is free = CPU and blitter can't use it.
@ -315,14 +320,16 @@ function Copper() {
cop_state.strobe = 0;
break;
}
case COP_strobe_delay1x: {
case COP_strobe_delay1x:
{
// First cycle after COPJMP and Copper was waiting. This is the buggy one.
// Cycle can be free and copper won't allocate it.
// If Blitter uses this cycle = Copper's address gets copied blitter DMA pointer..
cop_state.state = COP_strobe_delay2x;
break;
}
case COP_strobe_delay2x: {
case COP_strobe_delay2x:
{
// Second cycle fetches following word and tosses it away. Must be free cycle
// but is not allocated, blitter or cpu can still use it.
if (this.copper_cant_read(old_hpos, 1))
@ -336,14 +343,16 @@ function Copper() {
cop_state.strobe = 0;
break;
}
case COP_start_delay: {
case COP_start_delay:
{
if (this.copper_cant_read(old_hpos, 1))
continue;
cop_state.state = COP_read1;
cop_state.ip = this.cop1lc;
break;
}
case COP_read1: {
case COP_read1:
{
if (this.copper_cant_read(old_hpos, 1))
continue;
/* workaround for a bug in kick 1.x */
@ -360,7 +369,8 @@ function Copper() {
cop_state.state = COP_read2;
break;
}
case COP_read2: {
case COP_read2:
{
if (this.copper_cant_read(old_hpos, 1))
continue;
//cop_state.i2 = AMIGA.mem.load16_chip(cop_state.ip);
@ -425,10 +435,11 @@ function Copper() {
}
break;
}
case COP_wait1: {
/*#if 0
case COP_wait1:
{
/*#if 0
if (c_hpos >= (AMIGA.playfield.maxhpos & ~1) || (c_hpos & 1)) break;
#endif*/
#endif*/
cop_state.state = COP_wait;
cop_state.vcmp = (cop_state.saved_i1 & (cop_state.saved_i2 | 0x8000)) >> 8;
@ -455,7 +466,8 @@ function Copper() {
}
}
/* fall through */
case COP_wait: {
case COP_wait:
{
var ch_comp = c_hpos;
if (ch_comp & 1)
ch_comp = 0;
@ -483,7 +495,8 @@ function Copper() {
cop_state.state = COP_read1;
break;
}
case COP_skip1: {
case COP_skip1:
{
var vcmp, hcmp, vp1, hp1;
if (c_hpos >= (AMIGA.playfield.maxhpos & ~1) || (c_hpos & 1))
@ -509,7 +522,7 @@ function Copper() {
//out:
cop_state.hpos = c_hpos;
this.last_copper_hpos = until_hpos;
}
};
this.compute_spcflag_copper = function (hpos) {
//BUG.info('compute_spcflag_copper() hpos %d', hpos);
@ -544,7 +557,7 @@ function Copper() {
this.enabled_thisline = true;
set_special(SPCFLAG_COPPER);
}
};
this.blitter_done_notify = function (hpos) {
if (cop_state.state != COP_bltwait)
@ -567,19 +580,19 @@ function Copper() {
this.enabled_thisline = true;
set_special(SPCFLAG_COPPER);
}
}
};
this.cycle = function () {
this.update(AMIGA.playfield.hpos());
}
};
this.sync_copper_with_cpu = function (hpos, do_schedule) {
/* Need to let the copper advance to the current position. */
if (this.enabled_thisline)
this.update(hpos);
}
};
this.check = function (n) {
/*this.check = function (n) {
if (cop_state.state == COP_wait) {
var vp = AMIGA.playfield.vpos & (((cop_state.saved_i2 >> 8) & 0x7f) | 0x80);
if (vp < cop_state.vcmp) {
@ -587,5 +600,5 @@ function Copper() {
BUG.info('COPPER BUG %d: vp=%d vpos=%d vcmp=%d thisline=%d', n, vp, AMIGA.playfield.vpos, cop_state.vcmp, this.enabled_thisline?1:0);
}
}
}
}*/
}

View file

@ -40,7 +40,7 @@ function CPU() {
const ccNames = ['T', 'F', 'HI', 'LS', 'CC', 'CS', 'NE', 'EQ', 'VC', 'VS', 'PL', 'MI', 'GE', 'LT', 'GT', 'LE'];
/* Effective Address */
function effAddr(m, r) {
function EffAddr(m, r) {
this.m = m; /* Mode M_ */
this.t = 0; /* Type T_ */
this.r = r; /* Register An/Dn */
@ -49,31 +49,31 @@ function CPU() {
}
/* Instruction Condition */
function iCon(cc, dp, dr) {
function ICon(cc, dp, dr) {
this.cc = cc; /* Condition Code */
this.dp = dp; /* Displacement */
this.dr = dr; /* Data Register for DBcc */
}
/* Instruction Paramenter */
function iPar() {
this.z; /* size B,W,L */
function IPar() {
this.z = 0; /* size B,W,L */
/* Filled on demand
this.s = new effAddr();
this.d = new effAddr();
this.c = new iCon();
this.s = new EffAddr();
this.d = new EffAddr();
this.c = new ICon();
this.ms = 0;
this.mz = 0;
this.cyc = 0;*/
}
/* Instruction Definition */
function iDef() {
this.op; /* OP-code */
this.pr; /* Privileged */
this.mn; /* Mnemonic */
this.f; /* Function */
this.p = new iPar();
function IDef() {
this.op = 0; /* OP-code */
//this.pr = false; /* Privileged */
this.mn = ''; /* Mnemonic */
this.f = null; /* Function */
this.p = new IPar();
}
/* Exception 2/3 error */
@ -118,14 +118,14 @@ function CPU() {
/*-----------------------------------------------------------------------*/
this.setup = function() {
this.setup = function () {
if (iTab === null) {
BUG.say('cpu.setup() no instruction table, generating...');
if (!mkiTab())
Fatal(SAEE_CPU_Internal, 'cpu.setup() error generating function table');
} else
BUG.say('cpu.setup() instruction table is cached');
}
};
this.reset = function (addr) {
for (var i = 0; i < 8; i++)
@ -142,7 +142,7 @@ function CPU() {
regs.stopped = false;
BUG.say(sprintf('cpu.reset() addr 0x%08x, A7 0x%08x, PC 0x%08x', addr, regs.a[7], regs.pc));
}
};
/*-----------------------------------------------------------------------*/
@ -154,6 +154,7 @@ function CPU() {
case 4: return 'L';
default:
Fatal(SAEE_CPU_Internal, 'cpu.szChr() invalid size');
return '';
}
}
@ -203,6 +204,7 @@ function CPU() {
case 4: return r > 0xffffffff ? r - 0x100000000 : r;
default:
Fatal(SAEE_CPU_Internal, 'cpu.addAuto() invalid size');
return 0;
}
}
function sub32(a, b) {
@ -217,6 +219,7 @@ function CPU() {
case 4: return r < 0 ? r + 0x100000000 : r;
default:
Fatal(SAEE_CPU_Internal, 'cpu.subAuto() invalid size');
return 0;
}
}
@ -241,9 +244,10 @@ function CPU() {
//var scale = 1 << ((ext & 0x600) >> 9); if (scale != 1) alert('exII() scale '+scale);
function exII(base) {
var ext = nextIWord();
if (ext & 0x100)
if (ext & 0x100) {
Fatal(SAEE_CPU_68020_Required, 'cpu.exII() Full extension index (not a 68000 program)');
else {
return 0;
} else {
var disp = extByte(ext & 0xff);
var r = (ext & 0x7000) >> 12;
var reg = (ext & 0x8000) ? regs.a[r] : regs.d[r];
@ -394,6 +398,7 @@ function CPU() {
case 4: return regs.d[ea.a];
default:
Fatal(SAEE_CPU_Internal, 'cpu.ldEA() T_RD invalid size');
return 0;
}
}
case T_RA: {
@ -402,6 +407,7 @@ function CPU() {
case 4: return regs.a[ea.a];
default:
Fatal(SAEE_CPU_Internal, 'cpu.ldEA() T_RA invalid size');
return 0;
}
}
case T_AD: {
@ -427,12 +433,14 @@ function CPU() {
case 4: return AMIGA.mem.load32(ea.a);
default:
Fatal(SAEE_CPU_Internal, 'cpu.ldEA() T_AD invalid size');
return 0;
}
}
case T_IM:
return ea.a;
default:
Fatal(SAEE_CPU_Internal, 'cpu.ldEA() invalid type (' + ea.t + ')');
return 0;
}
}
@ -501,6 +509,7 @@ function CPU() {
case 15: return regs.z || (regs.n != regs.v); //LE
default:
Fatal(SAEE_CPU_Internal, 'cpu.ccTrue() invalid condition code (' + cc + ')');
return false;
}
}
@ -698,7 +707,7 @@ function CPU() {
function I_PEA(p) {
var sea = exEA(p.s, p.z);
var dea = exEA(new effAddr(M_ripr, 7), p.z);
var dea = exEA(new EffAddr(M_ripr, 7), p.z);
stEA(dea, p.z, sea.a);
//ccna
return p.cyc;
@ -710,7 +719,7 @@ function CPU() {
var dea = exEA(p.d, p.z);
var dp = ldEA(dea, p.z); if (p.z == 2) dp = extWord(dp);
stEA(exEA(new effAddr(M_ripr, 7), 4), 4, regs.a[An]);
stEA(exEA(new EffAddr(M_ripr, 7), 4), 4, regs.a[An]);
regs.a[An] = regs.a[7];
regs.a[7] = add32(regs.a[7], dp);
//ccna
@ -726,7 +735,7 @@ function CPU() {
var sea = exEA(p.s, p.z);
var An = sea.a;
regs.a[7] = regs.a[An];
regs.a[An] = ldEA(exEA(new effAddr(M_ripo, 7), 4), 4);
regs.a[An] = ldEA(exEA(new EffAddr(M_ripo, 7), 4), 4);
//ccna
//BUG.say(sprintf('I_UNLK.%s A%d', szChr(p.z), An));
return p.cyc;
@ -987,7 +996,7 @@ function CPU() {
function I_CLR(p) {
var dea = exEA(p.d, p.z);
var foo = ldEA(dea, p.z); /* In the MC68000 and MC68008 a memory location is read before it is cleared. */
//var foo = ldEA(dea, p.z); /* In the MC68000 and MC68008 a memory location is read before it is cleared. */
stEA(dea, p.z, 0);
regs.n = false;
@ -1812,7 +1821,7 @@ function CPU() {
var cyc;
if (!ccTrue(cc)) {
var ea = exEA(new effAddr(M_rdd, p.c.dr), p.z);
var ea = exEA(new EffAddr(M_rdd, p.c.dr), p.z);
var dr = ldEA(ea, p.z);
if (dr--) {
@ -1833,7 +1842,7 @@ function CPU() {
//var cc = p.s.r;
var cc = p.c.cc;
var dea = exEA(p.d, p.z);
var foo = ldEA(dea, p.z); /* In the MC68000 and MC68008 a memory location is read before it is cleared. */
//var foo = ldEA(dea, p.z); /* In the MC68000 and MC68008 a memory location is read before it is cleared. */
var isTrue = ccTrue(cc);
stEA(dea, p.z, isTrue ? 0xff : 0);
//ccna
@ -1868,7 +1877,7 @@ function CPU() {
//else if (dp == 255) Fatal(SAEE_CPU_68020_Required, 'cpu.I_BSR() Full extension index detected (not a 68000 programm)');
else pc = add32(regs.pc, extByte(dp));
stEA(exEA(new effAddr(M_ripr, 7), 4), 4, regs.pc);
stEA(exEA(new EffAddr(M_ripr, 7), 4), 4, regs.pc);
setPC(pc);
//ccna
return p.cycTaken;
@ -1884,7 +1893,7 @@ function CPU() {
function I_JSR(p) {
var dea = exEA(p.d, p.z);
stEA(exEA(new effAddr(M_ripr, 7), 4), 4, regs.pc);
stEA(exEA(new EffAddr(M_ripr, 7), 4), 4, regs.pc);
setPC(dea.a);
//ccna
//BUG.say(sprintf('I_JSR $%08x', dea.a));
@ -1892,8 +1901,8 @@ function CPU() {
}
function I_RTR(p) {
var ccr = ldEA(exEA(new effAddr(M_ripo, 7), 2), 2) & 0xff;
var pc = ldEA(exEA(new effAddr(M_ripo, 7), 4), 4);
var ccr = ldEA(exEA(new EffAddr(M_ripo, 7), 2), 2) & 0xff;
var pc = ldEA(exEA(new EffAddr(M_ripo, 7), 4), 4);
setCCR(ccr);
setPC(pc);
//BUG.say(sprintf('I_RTR crr $%04x pc $%08x', crr, pc));
@ -1901,7 +1910,7 @@ function CPU() {
}
function I_RTS(p) {
var pc = ldEA(exEA(new effAddr(M_ripo, 7), 4), 4);
var pc = ldEA(exEA(new EffAddr(M_ripo, 7), 4), 4);
//BUG.say(sprintf('I_RTS() regs.pc $%08x newpc $%08x', regs.pc, pc));
setPC(pc);
//ccna
@ -2039,7 +2048,7 @@ function CPU() {
function I_MOVE_SR2(p) {
var sr = getSR();
var dea = exEA(p.d, p.z);
var foo = ldEA(dea, p.z); /* Memory destination is read before it is written to. */
//var foo = ldEA(dea, p.z); /* Memory destination is read before it is written to. */
stEA(dea, p.z, sr);
//ccna
//BUG.say(sprintf('I_MOVE_SR2.%s sr $%04x', szChr(p.z), sr));
@ -2144,8 +2153,8 @@ function CPU() {
function I_RTE(p) {
if (regs.s) {
var sr = ldEA(exEA(new effAddr(M_ripo, 7), 2), 2);
var pc = ldEA(exEA(new effAddr(M_ripo, 7), 4), 4);
var sr = ldEA(exEA(new EffAddr(M_ripo, 7), 2), 2);
var pc = ldEA(exEA(new EffAddr(M_ripo, 7), 4), 4);
setSR(sr);
//BUG.say(sprintf('I_RTE sr $%04x newpc $%08x oldpc $%08x', sr, pc, regs.pc));
setPC(pc);
@ -2239,11 +2248,12 @@ function CPU() {
case M_absl: return z == 4 ? [16,4,0] : [12,3,0];
case M_imm:
case M_list: return z == 4 ? [ 8,2,0] : [ 4,1,0];
default: return [0,0,0];
}
}
function mkN(op, mn, cyc) {
var i = new iDef();
var i = new IDef();
i.op = op;
i.pr = false;
i.mn = mn;
@ -2254,14 +2264,14 @@ function CPU() {
}
function mkS(op, mn, z, s, r, cyc, add) {
var i = new iDef();
var i = new IDef();
i.op = op;
i.pr = false;
i.mn = mn;
i.f = null;
i.p = {};
i.p.z = z;
i.p.s = new effAddr(s, r);
i.p.s = new EffAddr(s, r);
i.p.s.c = mkCyc(z, s);
i.p.cyc = cyc;
if (add) i.p.cyc[0] += i.p.s.c[0];
@ -2271,14 +2281,14 @@ function CPU() {
}
function mkD(op, mn, z, d, r, cyc, add) {
var i = new iDef();
var i = new IDef();
i.op = op;
i.pr = false;
i.mn = mn;
i.f = null;
i.p = {};
i.p.z = z;
i.p.d = new effAddr(d, r);
i.p.d = new EffAddr(d, r);
i.p.d.c = mkCyc(z, d);
i.p.cyc = cyc;
if (add) i.p.cyc[0] += i.p.d.c[0];
@ -2288,7 +2298,7 @@ function CPU() {
}
function mkSD(op, mn, z, sm, sr, dm, dr, cyc, sa, da) {
var i = new iDef();
var i = new IDef();
i.op = op;
i.pr = false;
i.mn = mn;
@ -2297,8 +2307,8 @@ function CPU() {
i.p.z = z;
i.p.ms = z == 1 ? 0x80 : (z == 2 ? 0x8000 : 0x80000000);
i.p.mz = z == 1 ? 0xff : (z == 2 ? 0xffff : 0xffffffff);
i.p.s = new effAddr(sm, sr);
i.p.d = new effAddr(dm, dr);
i.p.s = new EffAddr(sm, sr);
i.p.d = new EffAddr(dm, dr);
i.p.s.c = mkCyc(z, sm);
i.p.d.c = mkCyc(z, dm);
i.p.cyc = cyc;
@ -2312,28 +2322,28 @@ function CPU() {
}
function mkC(op, mn, sz, cc, dp, dr, cycTaken, cyc) {
var i = new iDef();
var i = new IDef();
i.op = op;
i.pr = false;
i.mn = mn;
i.f = null;
i.p = {};
i.p.z = sz;
i.p.c = new iCon(cc, dp, dr);
i.p.c = new ICon(cc, dp, dr);
if (cycTaken !== null) i.p.cycTaken = cycTaken;
if (cyc !== null) i.p.cyc = cyc;
return i;
}
function mkDBcc(op, mn, sz, cc, dp, dr, cycTrue, cycFalseTaken, cycFalse) {
var i = new iDef();
var i = new IDef();
i.op = op;
i.pr = false;
i.mn = mn;
i.f = null;
i.p = {};
i.p.z = sz;
i.p.c = new iCon(cc, dp, dr);
i.p.c = new ICon(cc, dp, dr);
i.p.cycTrue = cycTrue;
i.p.cycFalseTaken = cycFalseTaken;
i.p.cycFalse = cycFalse;
@ -2341,15 +2351,15 @@ function CPU() {
}
function mkCD(op, mn, z, cc, dp, dr, m, r, cycTrue, cycFalse, add) {
var i = new iDef();
var i = new IDef();
i.op = op;
i.pr = false;
i.mn = mn;
i.f = null;
i.p = {};
i.p.z = z;
i.p.c = new iCon(cc, dp, dr);
i.p.d = new effAddr(m, r);
i.p.c = new ICon(cc, dp, dr);
i.p.d = new EffAddr(m, r);
i.p.d.c = mkCyc(z, m);
i.p.cycTrue = cycTrue;
i.p.cycFalse = cycFalse;
@ -2395,7 +2405,7 @@ function CPU() {
iTab = new Array(0x10000);
for (op = 0; op < 0x10000; op++) {
iTab[op] = new iDef();
iTab[op] = new IDef();
iTab[op].op = -1;
iTab[op].pr = false;
iTab[op].mn = 'ILLEGAL';
@ -3590,7 +3600,7 @@ function CPU() {
op = (275 << 6) | ea[0];
if (iTab[op].op === -1) {
iTab[op] = mkS(op, 'MOVE_2CCR', 2, ea[1], ea[2], [12,1,0], ea[1] == M_rdd ? false : true);
iTab[op] = mkS(op, 'MOVE_2CCR', 2, ea[1], ea[2], [12,1,0], ea[1] != M_rdd);
iTab[op].f = I_MOVE_2CCR;
cnt++;
} else {
@ -3632,7 +3642,7 @@ function CPU() {
op = (283 << 6) | ea[0];
if (iTab[op].op === -1) {
iTab[op] = mkS(op, 'MOVE_2SR', 2, ea[1], ea[2], [12,1,0], ea[1] == M_rdd ? false : true);
iTab[op] = mkS(op, 'MOVE_2SR', 2, ea[1], ea[2], [12,1,0], ea[1] != M_rdd);
iTab[op].pr = true;
iTab[op].f = I_MOVE_2SR;
cnt++;
@ -4687,10 +4697,10 @@ function CPU() {
BUG.say(o);
}
}
this.dissFault = function (limit) {
};
/*this.dissFault = function (limit) {
this.diss(fault.pc, limit);
}
};*/
/*function nextIWordData(data, pc) {
return (data[pc] << 8) | data[pc + 1];
@ -4866,7 +4876,7 @@ function CPU() {
return getName(AMIGA.mem.load32(task + 10));
}
this.getThisTaskName = function() {
this.getThisTaskName = function () {
var tn = '';
/* Extract current task-name form SysBase */
var sysBase = AMIGA.mem.load32(4);
@ -4876,9 +4886,9 @@ function CPU() {
tn = getTaskName(thisTask);
}
return tn;
}
};
this.dump = function() {
this.dump = function () {
var i, out = '', tn = 1 ? this.getThisTaskName() : '';
for (i = 0; i < 8; i++) {
@ -4896,7 +4906,7 @@ function CPU() {
out += "\n";
out += "\n";
BUG.say(out);
}
};
/*-----------------------------------------------------------------------*/
/*-----------------------------------------------------------------------*/
@ -5025,7 +5035,7 @@ function CPU() {
regs.t = 0;
}
function exception_cycles(n) {
/*function exception_cycles(n) {
var c;
if (n < 16)
switch (n) {
@ -5051,7 +5061,7 @@ function CPU() {
c = [4,0,0];
}
return c;
}
}*/
function exception(n) {
//BUG.say(sprintf('cpu.exception() nr %d', n));
@ -5076,8 +5086,8 @@ function CPU() {
if (n == 2) {
BUG.say(sprintf('cpu.exception() %d, regs.pc $%08x, fault.pc $%08x, fault.op $%04x, fault.ad $%08x, fault.ia %d', n, regs.pc, fault.pc, fault.op, fault.ad, fault.ia ? 1 : 0));
stEA(exEA(new effAddr(M_ripr, 7), 4), 4, regs.pc);
stEA(exEA(new effAddr(M_ripr, 7), 2), 2, sr);
stEA(exEA(new EffAddr(M_ripr, 7), 4), 4, regs.pc);
stEA(exEA(new EffAddr(M_ripr, 7), 2), 2, sr);
} else if (n == 3) {
BUG.say(sprintf('cpu.exception() %d, regs.pc $%08x, fault.pc $%08x, fault.op $%04x, fault.ad $%08x, fault.ia %d', n, regs.pc, fault.pc, fault.op, fault.ad, fault.ia ? 1 : 0));
@ -5085,14 +5095,14 @@ function CPU() {
var wa = 0;
var cd = (wa ? 0 : 16) | (olds ? 4 : 0) | (ia ? 2 : 1);
stEA(exEA(new effAddr(M_ripr, 7), 4), 4, fault.pc);
stEA(exEA(new effAddr(M_ripr, 7), 2), 2, sr);
stEA(exEA(new effAddr(M_ripr, 7), 2), 2, fault.op);
stEA(exEA(new effAddr(M_ripr, 7), 4), 4, fault.ad);
stEA(exEA(new effAddr(M_ripr, 7), 2), 2, cd);
stEA(exEA(new EffAddr(M_ripr, 7), 4), 4, fault.pc);
stEA(exEA(new EffAddr(M_ripr, 7), 2), 2, sr);
stEA(exEA(new EffAddr(M_ripr, 7), 2), 2, fault.op);
stEA(exEA(new EffAddr(M_ripr, 7), 4), 4, fault.ad);
stEA(exEA(new EffAddr(M_ripr, 7), 2), 2, cd);
} else {
stEA(exEA(new effAddr(M_ripr, 7), 4), 4, regs.pc);
stEA(exEA(new effAddr(M_ripr, 7), 2), 2, sr);
stEA(exEA(new EffAddr(M_ripr, 7), 4), 4, regs.pc);
stEA(exEA(new EffAddr(M_ripr, 7), 2), 2, sr);
}
var pc = AMIGA.mem.load32(n * 4);
@ -5113,14 +5123,14 @@ function CPU() {
regs.pc = pc;
exception_trace(n);
return exception_cycles(n);
return [4,0,0];//exception_cycles(n);
}
function exception2(ad) {
/*function exception2(ad) {
fault.ad = ad;
fault.ia = 0;
throw new Exception23(2);
}
}*/
function exception3(ad, ia) {
fault.ad = ad;
@ -5139,19 +5149,13 @@ function CPU() {
AMIGA.doint();
}
function trace() {
if (regs.t) {
clr_special(SPCFLAG_TRACE);
set_special(SPCFLAG_DOTRACE);
}
}
function cycle_spc(cycles) {
if (AMIGA.spcflags & SPCFLAG_COPPER)
AMIGA.copper.cycle();
while ((AMIGA.spcflags & SPCFLAG_BLTNASTY) && AMIGA.dmaen(DMAF_BLTEN) && cycles > 0) {
var c = AMIGA.blitter.blitnasty();
//console.log('nasty', cycles, c);
if (c > 0) {
cycles -= c * CYCLE_UNIT * 2;
if (cycles < CYCLE_UNIT)
@ -5166,6 +5170,7 @@ function CPU() {
if (AMIGA.spcflags & SPCFLAG_DOTRACE)
exception(9);
if (AMIGA.spcflags & SPCFLAG_TRAP) {
clr_special(SPCFLAG_TRAP);
exception(3);
@ -5183,21 +5188,26 @@ function CPU() {
if (intr > 0 && intr > regs.intmask)
interrupt(intr);
}
/*if (AMIGA.spcflags & SPCFLAG_BRK) {
clr_special(SPCFLAG_BRK);
//if (AMIGA.spcflags & SPCFLAG_BRK) {
if (AMIGA.state != ST_CYCLE) {
//clr_special(SPCFLAG_BRK);
clr_special(SPCFLAG_STOP);
regs.stopped = false;
return true;
}*/
}
}
if (AMIGA.spcflags & SPCFLAG_TRACE)
trace();
if (AMIGA.spcflags & SPCFLAG_TRACE) {
if (regs.t) {
clr_special(SPCFLAG_TRACE);
set_special(SPCFLAG_DOTRACE);
}
}
if (AMIGA.spcflags & SPCFLAG_INT) {
clr_special(SPCFLAG_INT | SPCFLAG_DOINT);
var intr = AMIGA.intlev();
if (intr > 0 && (intr > regs.intmask || intr == 7))
if (intr > 0 && intr > regs.intmask)
interrupt(intr);
}
if (AMIGA.spcflags & SPCFLAG_DOINT) {

View file

@ -11,8 +11,10 @@
function Custom() {
this.last_value = 0;
this.setup = function() {}
this.reset = function() {}
this.setup = function () {
};
this.reset = function () {
};
/*---------------------------------*/
@ -23,23 +25,52 @@ function Custom() {
addr &= 0xfff;
switch (addr & 0x1fe) {
case 0x002: v = AMIGA.DMACONR(hpos); break;
case 0x004: v = AMIGA.playfield.VPOSR(); break;
case 0x006: v = AMIGA.playfield.VHPOSR(); break;
case 0x002:
v = AMIGA.DMACONR(hpos);
break;
case 0x004:
v = AMIGA.playfield.VPOSR();
break;
case 0x006:
v = AMIGA.playfield.VHPOSR();
break;
case 0x00A: v = AMIGA.input.JOY0DAT(); break;
case 0x00C: v = AMIGA.input.JOY1DAT(); break;
case 0x00E: v = AMIGA.playfield.CLXDAT(); break;
case 0x010: v = AMIGA.ADKCONR(); break;
case 0x00A:
v = AMIGA.input.JOY0DAT();
break;
case 0x00C:
v = AMIGA.input.JOY1DAT();
break;
case 0x00E:
v = AMIGA.playfield.CLXDAT();
break;
case 0x010:
v = AMIGA.ADKCONR();
break;
case 0x012: v = AMIGA.input.POT0DAT(); break;
case 0x014: v = AMIGA.input.POT1DAT(); break;
case 0x016: v = AMIGA.input.POTGOR(); break;
case 0x018: v = AMIGA.serial.SERDATR(); break;
case 0x01A: v = AMIGA.disk.DSKBYTR(hpos); break;
case 0x01C: v = AMIGA.INTENAR(); break;
case 0x01E: v = AMIGA.INTREQR(); break;
case 0x07C: {
case 0x012:
v = AMIGA.input.POT0DAT();
break;
case 0x014:
v = AMIGA.input.POT1DAT();
break;
case 0x016:
v = AMIGA.input.POTGOR();
break;
case 0x018:
v = AMIGA.serial.SERDATR();
break;
case 0x01A:
v = AMIGA.disk.DSKBYTR(hpos);
break;
case 0x01C:
v = AMIGA.INTENAR();
break;
case 0x01E:
v = AMIGA.INTREQR();
break;
case 0x07C:
{
var result = AMIGA.playfield.DENISEID();
if (result[0])
writeonly = true;
@ -48,7 +79,7 @@ function Custom() {
break;
}
/*#ifdef AGA
/*#ifdef AGA
case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A:
case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196:
case 0x198: case 0x19A: case 0x19C: case 0x19E: case 0x1A0: case 0x1A2:
@ -59,7 +90,7 @@ function Custom() {
writeonly = true;
v = COLOR_READ ((addr & 0x3E) >> 1);
break;
#endif*/
#endif*/
default:
writeonly = true;
@ -97,14 +128,14 @@ function Custom() {
this.last_value = v;
return v;
}
};
this.load16_2 = function (addr) {
var hpos = AMIGA.playfield.hpos();
AMIGA.copper.sync_copper_with_cpu (hpos, 1);
AMIGA.copper.sync_copper_with_cpu(hpos, 1);
return this.load16_real(hpos, addr, 0);
}
};
this.load16 = function (addr) {
if (addr & 1) {
@ -112,15 +143,15 @@ function Custom() {
return (this.load16_2(addr) << 8) | (this.load16_2(addr + 2) >> 8);
}
return this.load16_2(addr);
}
};
this.load8 = function (addr) {
return this.load16_2(addr & ~1) >> ((addr & 1) ? 0 : 8);
}
};
this.load32 = function (addr) {
return ((this.load16(addr) << 16) | this.load16(addr + 2)) >>> 0;
}
};
/*---------------------------------*/
@ -131,190 +162,522 @@ function Custom() {
value &= 0xffff;
switch (addr) {
case 0x00E: AMIGA.playfield.CLXDAT(); break;
case 0x00E:
AMIGA.playfield.CLXDAT();
break;
case 0x020: AMIGA.disk.DSKPTH(value); break;
case 0x022: AMIGA.disk.DSKPTL(value); break;
case 0x024: AMIGA.disk.DSKLEN(value, hpos); break;
case 0x026: /* AMIGA.disk.DSKDAT(value). Writing to DMA write registers won't do anything */; break;
case 0x020:
AMIGA.disk.DSKPTH(value);
break;
case 0x022:
AMIGA.disk.DSKPTL(value);
break;
case 0x024:
AMIGA.disk.DSKLEN(value, hpos);
break;
case 0x026: /* AMIGA.disk.DSKDAT(value). Writing to DMA write registers won't do anything */
break;
case 0x02A: AMIGA.playfield.VPOSW(value); break;
case 0x02C: AMIGA.playfield.VHPOSW(value); break;
case 0x02E: AMIGA.copper.COPCON(value); break;
case 0x030: AMIGA.serial.SERDAT(value); break;
case 0x032: AMIGA.serial.SERPER(value); break;
case 0x034: AMIGA.input.POTGO(value); break;
case 0x02A:
AMIGA.playfield.VPOSW(value);
break;
case 0x02C:
AMIGA.playfield.VHPOSW(value);
break;
case 0x02E:
AMIGA.copper.COPCON(value);
break;
case 0x030:
AMIGA.serial.SERDAT(value);
break;
case 0x032:
AMIGA.serial.SERPER(value);
break;
case 0x034:
AMIGA.input.POTGO(value);
break;
case 0x040: AMIGA.blitter.BLTCON0(hpos, value); break;
case 0x042: AMIGA.blitter.BLTCON1(hpos, value); break;
case 0x040:
AMIGA.blitter.BLTCON0(hpos, value);
break;
case 0x042:
AMIGA.blitter.BLTCON1(hpos, value);
break;
case 0x044: AMIGA.blitter.BLTAFWM(hpos, value); break;
case 0x046: AMIGA.blitter.BLTALWM(hpos, value); break;
case 0x044:
AMIGA.blitter.BLTAFWM(hpos, value);
break;
case 0x046:
AMIGA.blitter.BLTALWM(hpos, value);
break;
case 0x050: AMIGA.blitter.BLTAPTH(hpos, value); break;
case 0x052: AMIGA.blitter.BLTAPTL(hpos, value); break;
case 0x04C: AMIGA.blitter.BLTBPTH(hpos, value); break;
case 0x04E: AMIGA.blitter.BLTBPTL(hpos, value); break;
case 0x048: AMIGA.blitter.BLTCPTH(hpos, value); break;
case 0x04A: AMIGA.blitter.BLTCPTL(hpos, value); break;
case 0x054: AMIGA.blitter.BLTDPTH(hpos, value); break;
case 0x056: AMIGA.blitter.BLTDPTL(hpos, value); break;
case 0x050:
AMIGA.blitter.BLTAPTH(hpos, value);
break;
case 0x052:
AMIGA.blitter.BLTAPTL(hpos, value);
break;
case 0x04C:
AMIGA.blitter.BLTBPTH(hpos, value);
break;
case 0x04E:
AMIGA.blitter.BLTBPTL(hpos, value);
break;
case 0x048:
AMIGA.blitter.BLTCPTH(hpos, value);
break;
case 0x04A:
AMIGA.blitter.BLTCPTL(hpos, value);
break;
case 0x054:
AMIGA.blitter.BLTDPTH(hpos, value);
break;
case 0x056:
AMIGA.blitter.BLTDPTL(hpos, value);
break;
case 0x058: AMIGA.blitter.BLTSIZE(hpos, value); break;
case 0x058:
AMIGA.blitter.BLTSIZE(hpos, value);
break;
case 0x064: AMIGA.blitter.BLTAMOD(hpos, value); break;
case 0x062: AMIGA.blitter.BLTBMOD(hpos, value); break;
case 0x060: AMIGA.blitter.BLTCMOD(hpos, value); break;
case 0x066: AMIGA.blitter.BLTDMOD(hpos, value); break;
case 0x064:
AMIGA.blitter.BLTAMOD(hpos, value);
break;
case 0x062:
AMIGA.blitter.BLTBMOD(hpos, value);
break;
case 0x060:
AMIGA.blitter.BLTCMOD(hpos, value);
break;
case 0x066:
AMIGA.blitter.BLTDMOD(hpos, value);
break;
case 0x070: AMIGA.blitter.BLTCDAT(hpos, value); break;
case 0x072: AMIGA.blitter.BLTBDAT(hpos, value); break;
case 0x074: AMIGA.blitter.BLTADAT(hpos, value); break;
case 0x070:
AMIGA.blitter.BLTCDAT(hpos, value);
break;
case 0x072:
AMIGA.blitter.BLTBDAT(hpos, value);
break;
case 0x074:
AMIGA.blitter.BLTADAT(hpos, value);
break;
case 0x07E: AMIGA.disk.DSKSYNC(value, hpos); break;
case 0x07E:
AMIGA.disk.DSKSYNC(value, hpos);
break;
case 0x080: AMIGA.copper.COP1LCH(value); break;
case 0x082: AMIGA.copper.COP1LCL(value); break;
case 0x084: AMIGA.copper.COP2LCH(value); break;
case 0x086: AMIGA.copper.COP2LCL(value); break;
case 0x080:
AMIGA.copper.COP1LCH(value);
break;
case 0x082:
AMIGA.copper.COP1LCL(value);
break;
case 0x084:
AMIGA.copper.COP2LCH(value);
break;
case 0x086:
AMIGA.copper.COP2LCL(value);
break;
case 0x088: AMIGA.copper.COPJMP(1, 0); break;
case 0x08A: AMIGA.copper.COPJMP(2, 0); break;
case 0x088:
AMIGA.copper.COPJMP(1, 0);
break;
case 0x08A:
AMIGA.copper.COPJMP(2, 0);
break;
case 0x08E: AMIGA.playfield.DIWSTRT(hpos, value); break;
case 0x090: AMIGA.playfield.DIWSTOP(hpos, value); break;
case 0x092: AMIGA.playfield.DDFSTRT(hpos, value); break;
case 0x094: AMIGA.playfield.DDFSTOP(hpos, value); break;
case 0x08E:
AMIGA.playfield.DIWSTRT(hpos, value);
break;
case 0x090:
AMIGA.playfield.DIWSTOP(hpos, value);
break;
case 0x092:
AMIGA.playfield.DDFSTRT(hpos, value);
break;
case 0x094:
AMIGA.playfield.DDFSTOP(hpos, value);
break;
case 0x096: AMIGA.DMACON(value, hpos); break;
case 0x098: AMIGA.playfield.CLXCON(value); break;
case 0x09A: AMIGA.INTENA(value); break;
case 0x09C: AMIGA.INTREQ(value); break;
case 0x09E: AMIGA.ADKCON(value, hpos); break;
case 0x096:
AMIGA.DMACON(value, hpos);
break;
case 0x098:
AMIGA.playfield.CLXCON(value);
break;
case 0x09A:
AMIGA.INTENA(value);
break;
case 0x09C:
AMIGA.INTREQ(value);
break;
case 0x09E:
AMIGA.ADKCON(value, hpos);
break;
case 0x0A0: AMIGA.audio.AUDxLCH(0, value); break;
case 0x0A2: AMIGA.audio.AUDxLCL(0, value); break;
case 0x0A4: AMIGA.audio.AUDxLEN(0, value); break;
case 0x0A6: AMIGA.audio.AUDxPER(0, value); break;
case 0x0A8: AMIGA.audio.AUDxVOL(0, value); break;
case 0x0AA: AMIGA.audio.AUDxDAT(0, value); break;
case 0x0A0:
AMIGA.audio.AUDxLCH(0, value);
break;
case 0x0A2:
AMIGA.audio.AUDxLCL(0, value);
break;
case 0x0A4:
AMIGA.audio.AUDxLEN(0, value);
break;
case 0x0A6:
AMIGA.audio.AUDxPER(0, value);
break;
case 0x0A8:
AMIGA.audio.AUDxVOL(0, value);
break;
case 0x0AA:
AMIGA.audio.AUDxDAT(0, value);
break;
case 0x0B0: AMIGA.audio.AUDxLCH(1, value); break;
case 0x0B2: AMIGA.audio.AUDxLCL(1, value); break;
case 0x0B4: AMIGA.audio.AUDxLEN(1, value); break;
case 0x0B6: AMIGA.audio.AUDxPER(1, value); break;
case 0x0B8: AMIGA.audio.AUDxVOL(1, value); break;
case 0x0BA: AMIGA.audio.AUDxDAT(1, value); break;
case 0x0B0:
AMIGA.audio.AUDxLCH(1, value);
break;
case 0x0B2:
AMIGA.audio.AUDxLCL(1, value);
break;
case 0x0B4:
AMIGA.audio.AUDxLEN(1, value);
break;
case 0x0B6:
AMIGA.audio.AUDxPER(1, value);
break;
case 0x0B8:
AMIGA.audio.AUDxVOL(1, value);
break;
case 0x0BA:
AMIGA.audio.AUDxDAT(1, value);
break;
case 0x0C0: AMIGA.audio.AUDxLCH(2, value); break;
case 0x0C2: AMIGA.audio.AUDxLCL(2, value); break;
case 0x0C4: AMIGA.audio.AUDxLEN(2, value); break;
case 0x0C6: AMIGA.audio.AUDxPER(2, value); break;
case 0x0C8: AMIGA.audio.AUDxVOL(2, value); break;
case 0x0CA: AMIGA.audio.AUDxDAT(2, value); break;
case 0x0C0:
AMIGA.audio.AUDxLCH(2, value);
break;
case 0x0C2:
AMIGA.audio.AUDxLCL(2, value);
break;
case 0x0C4:
AMIGA.audio.AUDxLEN(2, value);
break;
case 0x0C6:
AMIGA.audio.AUDxPER(2, value);
break;
case 0x0C8:
AMIGA.audio.AUDxVOL(2, value);
break;
case 0x0CA:
AMIGA.audio.AUDxDAT(2, value);
break;
case 0x0D0: AMIGA.audio.AUDxLCH(3, value); break;
case 0x0D2: AMIGA.audio.AUDxLCL(3, value); break;
case 0x0D4: AMIGA.audio.AUDxLEN(3, value); break;
case 0x0D6: AMIGA.audio.AUDxPER(3, value); break;
case 0x0D8: AMIGA.audio.AUDxVOL(3, value); break;
case 0x0DA: AMIGA.audio.AUDxDAT(3, value); break;
case 0x0D0:
AMIGA.audio.AUDxLCH(3, value);
break;
case 0x0D2:
AMIGA.audio.AUDxLCL(3, value);
break;
case 0x0D4:
AMIGA.audio.AUDxLEN(3, value);
break;
case 0x0D6:
AMIGA.audio.AUDxPER(3, value);
break;
case 0x0D8:
AMIGA.audio.AUDxVOL(3, value);
break;
case 0x0DA:
AMIGA.audio.AUDxDAT(3, value);
break;
case 0x0E0: AMIGA.playfield.BPLxPTH(hpos, value, 0); break;
case 0x0E2: AMIGA.playfield.BPLxPTL(hpos, value, 0); break;
case 0x0E4: AMIGA.playfield.BPLxPTH(hpos, value, 1); break;
case 0x0E6: AMIGA.playfield.BPLxPTL(hpos, value, 1); break;
case 0x0E8: AMIGA.playfield.BPLxPTH(hpos, value, 2); break;
case 0x0EA: AMIGA.playfield.BPLxPTL(hpos, value, 2); break;
case 0x0EC: AMIGA.playfield.BPLxPTH(hpos, value, 3); break;
case 0x0EE: AMIGA.playfield.BPLxPTL(hpos, value, 3); break;
case 0x0F0: AMIGA.playfield.BPLxPTH(hpos, value, 4); break;
case 0x0F2: AMIGA.playfield.BPLxPTL(hpos, value, 4); break;
case 0x0F4: AMIGA.playfield.BPLxPTH(hpos, value, 5); break;
case 0x0F6: AMIGA.playfield.BPLxPTL(hpos, value, 5); break;
case 0x0F8: AMIGA.playfield.BPLxPTH(hpos, value, 6); break;
case 0x0FA: AMIGA.playfield.BPLxPTL(hpos, value, 6); break;
case 0x0FC: AMIGA.playfield.BPLxPTH(hpos, value, 7); break;
case 0x0FE: AMIGA.playfield.BPLxPTL(hpos, value, 7); break;
case 0x0E0:
AMIGA.playfield.BPLxPTH(hpos, value, 0);
break;
case 0x0E2:
AMIGA.playfield.BPLxPTL(hpos, value, 0);
break;
case 0x0E4:
AMIGA.playfield.BPLxPTH(hpos, value, 1);
break;
case 0x0E6:
AMIGA.playfield.BPLxPTL(hpos, value, 1);
break;
case 0x0E8:
AMIGA.playfield.BPLxPTH(hpos, value, 2);
break;
case 0x0EA:
AMIGA.playfield.BPLxPTL(hpos, value, 2);
break;
case 0x0EC:
AMIGA.playfield.BPLxPTH(hpos, value, 3);
break;
case 0x0EE:
AMIGA.playfield.BPLxPTL(hpos, value, 3);
break;
case 0x0F0:
AMIGA.playfield.BPLxPTH(hpos, value, 4);
break;
case 0x0F2:
AMIGA.playfield.BPLxPTL(hpos, value, 4);
break;
case 0x0F4:
AMIGA.playfield.BPLxPTH(hpos, value, 5);
break;
case 0x0F6:
AMIGA.playfield.BPLxPTL(hpos, value, 5);
break;
case 0x0F8:
AMIGA.playfield.BPLxPTH(hpos, value, 6);
break;
case 0x0FA:
AMIGA.playfield.BPLxPTL(hpos, value, 6);
break;
case 0x0FC:
AMIGA.playfield.BPLxPTH(hpos, value, 7);
break;
case 0x0FE:
AMIGA.playfield.BPLxPTL(hpos, value, 7);
break;
case 0x100: AMIGA.playfield.BPLCON0(hpos, value); break;
case 0x102: AMIGA.playfield.BPLCON1(hpos, value); break;
case 0x104: AMIGA.playfield.BPLCON2(hpos, value); break;
case 0x106: AMIGA.playfield.BPLCON3(hpos, value); break;
case 0x100:
AMIGA.playfield.BPLCON0(hpos, value);
break;
case 0x102:
AMIGA.playfield.BPLCON1(hpos, value);
break;
case 0x104:
AMIGA.playfield.BPLCON2(hpos, value);
break;
case 0x106:
AMIGA.playfield.BPLCON3(hpos, value);
break;
case 0x108: AMIGA.playfield.BPL1MOD(hpos, value); break;
case 0x10A: AMIGA.playfield.BPL2MOD(hpos, value); break;
case 0x108:
AMIGA.playfield.BPL1MOD(hpos, value);
break;
case 0x10A:
AMIGA.playfield.BPL2MOD(hpos, value);
break;
//case 0x10E: AMIGA.playfield.CLXCON2(value); break; //AGA
case 0x110: AMIGA.playfield.BPLxDAT(hpos, value, 0); break;
case 0x112: AMIGA.playfield.BPLxDAT(hpos, value, 1); break;
case 0x114: AMIGA.playfield.BPLxDAT(hpos, value, 2); break;
case 0x116: AMIGA.playfield.BPLxDAT(hpos, value, 3); break;
case 0x118: AMIGA.playfield.BPLxDAT(hpos, value, 4); break;
case 0x11A: AMIGA.playfield.BPLxDAT(hpos, value, 5); break;
case 0x11C: AMIGA.playfield.BPLxDAT(hpos, value, 6); break;
case 0x11E: AMIGA.playfield.BPLxDAT(hpos, value, 7); break;
case 0x110:
AMIGA.playfield.BPLxDAT(hpos, value, 0);
break;
case 0x112:
AMIGA.playfield.BPLxDAT(hpos, value, 1);
break;
case 0x114:
AMIGA.playfield.BPLxDAT(hpos, value, 2);
break;
case 0x116:
AMIGA.playfield.BPLxDAT(hpos, value, 3);
break;
case 0x118:
AMIGA.playfield.BPLxDAT(hpos, value, 4);
break;
case 0x11A:
AMIGA.playfield.BPLxDAT(hpos, value, 5);
break;
case 0x11C:
AMIGA.playfield.BPLxDAT(hpos, value, 6);
break;
case 0x11E:
AMIGA.playfield.BPLxDAT(hpos, value, 7);
break;
case 0x180: case 0x182: case 0x184: case 0x186: case 0x188: case 0x18A:
case 0x18C: case 0x18E: case 0x190: case 0x192: case 0x194: case 0x196:
case 0x198: case 0x19A: case 0x19C: case 0x19E: case 0x1A0: case 0x1A2:
case 0x1A4: case 0x1A6: case 0x1A8: case 0x1AA: case 0x1AC: case 0x1AE:
case 0x1B0: case 0x1B2: case 0x1B4: case 0x1B6: case 0x1B8: case 0x1BA:
case 0x1BC: case 0x1BE:
case 0x180:
case 0x182:
case 0x184:
case 0x186:
case 0x188:
case 0x18A:
case 0x18C:
case 0x18E:
case 0x190:
case 0x192:
case 0x194:
case 0x196:
case 0x198:
case 0x19A:
case 0x19C:
case 0x19E:
case 0x1A0:
case 0x1A2:
case 0x1A4:
case 0x1A6:
case 0x1A8:
case 0x1AA:
case 0x1AC:
case 0x1AE:
case 0x1B0:
case 0x1B2:
case 0x1B4:
case 0x1B6:
case 0x1B8:
case 0x1BA:
case 0x1BC:
case 0x1BE:
AMIGA.playfield.COLOR_WRITE(hpos, value & 0xFFF, (addr & 0x3E) >> 1);
break;
case 0x120: case 0x124: case 0x128: case 0x12C:
case 0x130: case 0x134: case 0x138: case 0x13C:
case 0x120:
case 0x124:
case 0x128:
case 0x12C:
case 0x130:
case 0x134:
case 0x138:
case 0x13C:
AMIGA.playfield.SPRxPTH(hpos, value, (addr - 0x120) >> 2);
break;
case 0x122: case 0x126: case 0x12A: case 0x12E:
case 0x132: case 0x136: case 0x13A: case 0x13E:
case 0x122:
case 0x126:
case 0x12A:
case 0x12E:
case 0x132:
case 0x136:
case 0x13A:
case 0x13E:
AMIGA.playfield.SPRxPTL(hpos, value, (addr - 0x122) >> 2);
break;
case 0x140: case 0x148: case 0x150: case 0x158:
case 0x160: case 0x168: case 0x170: case 0x178:
case 0x140:
case 0x148:
case 0x150:
case 0x158:
case 0x160:
case 0x168:
case 0x170:
case 0x178:
AMIGA.playfield.SPRxPOS(hpos, value, (addr - 0x140) >> 3);
break;
case 0x142: case 0x14A: case 0x152: case 0x15A:
case 0x162: case 0x16A: case 0x172: case 0x17A:
case 0x142:
case 0x14A:
case 0x152:
case 0x15A:
case 0x162:
case 0x16A:
case 0x172:
case 0x17A:
AMIGA.playfield.SPRxCTL(hpos, value, (addr - 0x142) >> 3);
break;
case 0x144: case 0x14C: case 0x154: case 0x15C:
case 0x164: case 0x16C: case 0x174: case 0x17C:
case 0x144:
case 0x14C:
case 0x154:
case 0x15C:
case 0x164:
case 0x16C:
case 0x174:
case 0x17C:
AMIGA.playfield.SPRxDATA(hpos, value, (addr - 0x144) >> 3);
break;
case 0x146: case 0x14E: case 0x156: case 0x15E:
case 0x166: case 0x16E: case 0x176: case 0x17E:
case 0x146:
case 0x14E:
case 0x156:
case 0x15E:
case 0x166:
case 0x16E:
case 0x176:
case 0x17E:
AMIGA.playfield.SPRxDATB(hpos, value, (addr - 0x146) >> 3);
break;
case 0x36: AMIGA.input.JOYTEST(value); break;
case 0x5A: AMIGA.blitter.BLTCON0L(hpos, value); break;
case 0x5C: AMIGA.blitter.BLTSIZV(hpos, value); break;
case 0x5E: AMIGA.blitter.BLTSIZH(hpos, value); break;
case 0x1E4: AMIGA.playfield.DIWHIGH(hpos, value); break;
case 0x36:
AMIGA.input.JOYTEST(value);
break;
case 0x5A:
AMIGA.blitter.BLTCON0L(hpos, value);
break;
case 0x5C:
AMIGA.blitter.BLTSIZV(hpos, value);
break;
case 0x5E:
AMIGA.blitter.BLTSIZH(hpos, value);
break;
case 0x1E4:
AMIGA.playfield.DIWHIGH(hpos, value);
break;
//case 0x10C: AMIGA.playfield.BPLCON4(hpos, value); break; //AGA
case 0x1DC: AMIGA.playfield.BEAMCON0(value); break;
case 0x1C0: if (AMIGA.playfield.htotal != value) { AMIGA.playfield.htotal = value; AMIGA.playfield.varsync(); } break;
case 0x1C2: if (AMIGA.playfield.hsstop != value) { AMIGA.playfield.hsstop = value; AMIGA.playfield.varsync(); } break;
case 0x1C4: if (AMIGA.playfield.hbstrt != value) { AMIGA.playfield.hbstrt = value; AMIGA.playfield.varsync(); } break;
case 0x1C6: if (AMIGA.playfield.hbstop != value) { AMIGA.playfield.hbstop = value; AMIGA.playfield.varsync(); } break;
case 0x1C8: if (AMIGA.playfield.vtotal != value) { AMIGA.playfield.vtotal = value; AMIGA.playfield.varsync(); } break;
case 0x1CA: if (AMIGA.playfield.vsstop != value) { AMIGA.playfield.vsstop = value; AMIGA.playfield.varsync(); } break;
case 0x1CC: if (AMIGA.playfield.vbstrt < value || AMIGA.playfield.vbstrt > value + 1) { AMIGA.playfield.vbstrt = value; AMIGA.playfield.varsync(); } break;
case 0x1CE: if (AMIGA.playfield.vbstop < value || AMIGA.playfield.vbstop > value + 1) { AMIGA.playfield.vbstop = value; AMIGA.playfield.varsync(); } break;
case 0x1DE: if (AMIGA.playfield.hsstrt != value) { AMIGA.playfield.hsstrt = value; AMIGA.playfield.varsync(); } break;
case 0x1E0: if (AMIGA.playfield.vsstrt != value) { AMIGA.playfield.vsstrt = value; AMIGA.playfield.varsync(); } break;
case 0x1E2: if (AMIGA.playfield.hcenter != value) { AMIGA.playfield.hcenter = value; AMIGA.playfield.varsync(); } break;
case 0x1DC:
AMIGA.playfield.BEAMCON0(value);
break;
case 0x1C0:
if (AMIGA.playfield.htotal != value) {
AMIGA.playfield.htotal = value;
AMIGA.playfield.varsync();
}
break;
case 0x1C2:
if (AMIGA.playfield.hsstop != value) {
AMIGA.playfield.hsstop = value;
AMIGA.playfield.varsync();
}
break;
case 0x1C4:
if (AMIGA.playfield.hbstrt != value) {
AMIGA.playfield.hbstrt = value;
AMIGA.playfield.varsync();
}
break;
case 0x1C6:
if (AMIGA.playfield.hbstop != value) {
AMIGA.playfield.hbstop = value;
AMIGA.playfield.varsync();
}
break;
case 0x1C8:
if (AMIGA.playfield.vtotal != value) {
AMIGA.playfield.vtotal = value;
AMIGA.playfield.varsync();
}
break;
case 0x1CA:
if (AMIGA.playfield.vsstop != value) {
AMIGA.playfield.vsstop = value;
AMIGA.playfield.varsync();
}
break;
case 0x1CC:
if (AMIGA.playfield.vbstrt < value || AMIGA.playfield.vbstrt > value + 1) {
AMIGA.playfield.vbstrt = value;
AMIGA.playfield.varsync();
}
break;
case 0x1CE:
if (AMIGA.playfield.vbstop < value || AMIGA.playfield.vbstop > value + 1) {
AMIGA.playfield.vbstop = value;
AMIGA.playfield.varsync();
}
break;
case 0x1DE:
if (AMIGA.playfield.hsstrt != value) {
AMIGA.playfield.hsstrt = value;
AMIGA.playfield.varsync();
}
break;
case 0x1E0:
if (AMIGA.playfield.vsstrt != value) {
AMIGA.playfield.vsstrt = value;
AMIGA.playfield.varsync();
}
break;
case 0x1E2:
if (AMIGA.playfield.hcenter != value) {
AMIGA.playfield.hcenter = value;
AMIGA.playfield.varsync();
}
break;
//case 0x1FC: AMIGA.playfield.FMODE(hpos, value); break; //AGA
//case 0x1FE: FNULL (value); break;
case 0x1FE: break;
case 0x1FE:
break;
/* writing to read-only register causes read access */
default: {
default:
{
if (!noget) {
//BUG.info('Custom.store16_real() %04x written', addr);
this.load16_real(hpos, addr, 1);
@ -323,7 +686,7 @@ function Custom() {
}
}
return false;
}
};
this.store16 = function (addr, value) {
var hpos = AMIGA.playfield.hpos();
@ -335,7 +698,7 @@ function Custom() {
return;
}
this.store16_real(hpos, addr, value, 0);
}
};
this.store8 = function (addr, value) {
var rval;
@ -356,7 +719,7 @@ function Custom() {
this.store16(addr, value << 8);
} else*/
this.store16(addr & ~1, rval);
}
};
this.store32 = function (addr, value) {
this.store16(addr & 0xfffe, value >>> 16);

View file

@ -33,9 +33,8 @@ const DSKREADY_DOWN_TIME = 50;
const WORDSYNC_TIME = 11;
const DSKDMA_OFF = 0;
const DSKDMA_INIT = 1;
const DSKDMA_READ = 2;
const DSKDMA_WRITE = 3;
const DSKDMA_READ = 1;
const DSKDMA_WRITE = 2;
const DRIVE_ID_NONE = 0x00000000;
const DRIVE_ID_35DD = 0xFFFFFFFF;
@ -53,18 +52,16 @@ const ADF_NONE = -1;
const ADF_NORMAL = 0;
const ADF_EXT1 = 1;
const ADF_EXT2 = 2;
const ADF_FDI = 3;
/*const ADF_FDI = 3;
const ADF_IPF = 4;
const ADF_PCDOS = 5;
const ADF_PCDOS = 5;*/
function trackid() {
var len = 0;
var offs = 0;
var bitlen = 0;
var track = 0;
var sync = 0;
var type = TRACK_NONE;
var revolutions = 0;
function Track() {
this.len = 0;
this.offs = 0;
this.bitlen = 0;
this.sync = 0;
this.type = TRACK_NONE;
}
function get_floppy_speed() {
@ -83,8 +80,8 @@ function Drive(number) {
this.diskfile = null;
//this.writediskfile = null;
this.filetype = 0; //drive_filetype
this.trackdata = new Array(MAX_TRACKS); for (var i = 0; i < MAX_TRACKS; i++) this.trackdata[i] = new trackid();
//this.writetrackdata = new Array(MAX_TRACKS); for (var i = 0; i < MAX_TRACKS; i++) this.trackdata[i] = new trackid();
this.trackdata = new Array(MAX_TRACKS); for (var i = 0; i < MAX_TRACKS; i++) this.trackdata[i] = new Track();
//this.writetrackdata = new Array(MAX_TRACKS); for (var i = 0; i < MAX_TRACKS; i++) this.trackdata[i] = new Track();
this.writebuffer = new Uint8Array(544 * MAX_SECTORS); for (var i = 0; i < 544 * MAX_SECTORS; i++) this.writebuffer[i] = 0;
this.buffered_cyl = 0;
this.buffered_side = 0;
@ -95,16 +92,13 @@ function Drive(number) {
this.wrprot = false;
this.bigmfmbuf = new Uint16Array(0x4000 * DDHDMULT); for (var i = 0; i < 0x4000 * DDHDMULT; i++) this.bigmfmbuf[i] = 0;
this.tracktiming = new Uint16Array(0x4000 * DDHDMULT); for (var i = 0; i < 0x4000 * DDHDMULT; i++) this.tracktiming[i] = 0;
this.multi_revolution = 0;
this.skipoffset = 0;
this.mfmpos = 0;
this.indexoffset = 0;
this.tracklen = 0;
this.revolutions = 0;
this.prevtracklen = 0;
this.trackspeed = 0;
this.num_tracks = 0;
this.write_num_tracks = 0;
this.num_secs = 0;
this.hard_num_cyls = 0;
this.dskchange = false;
@ -124,19 +118,24 @@ function Drive(number) {
this.useturbo = false;
this.floppybitcounter = 0;
this.id_name = function() {
/*this.id_name = function () {
switch (this.drive_id) {
case DRIVE_ID_35HD : return '3.5HD';
case DRIVE_ID_525SD: return '5.25SD';
case DRIVE_ID_35DD : return '3.5DD';
case DRIVE_ID_NONE : return 'NONE';
case DRIVE_ID_35HD :
return '3.5HD';
case DRIVE_ID_525SD:
return '5.25SD';
case DRIVE_ID_35DD :
return '3.5DD';
case DRIVE_ID_NONE :
return 'NONE';
}
return 'UNKNOWN';
}
};*/
this.set_id = function() {
this.set_id = function () {
switch (AMIGA.config.floppy.drive[this.num].type) {
case SAEV_Config_Floppy_Type_35_HD: {
case SAEV_Config_Floppy_Type_35_HD:
{
if (FLOPPY_DRIVE_HD) {
if (!this.diskfile || this.ddhd <= 1)
this.drive_id = DRIVE_ID_35DD;
@ -160,15 +159,15 @@ function Drive(number) {
this.drive_id = DRIVE_ID_35DD;
}
//BUG.info('Drive.set_id() DF%d set to %s', this.num, this.id_name());
}
};
this.get_floppy_speed2 = function() {
this.get_floppy_speed2 = function () {
var m = Math.floor(get_floppy_speed() * this.tracklen / (2 * 8 * (AMIGA.config.video.ntsc ? 6399 : 6334) * this.ddhd));
if (m <= 0) m = 1;
return m;
}
};
this.reset = function() {
this.reset = function () {
//BUG.info('Drive.reset() DF%d', this.num);
this.filetype = ADF_NONE;
this.diskfile = null;
@ -187,26 +186,25 @@ function Drive(number) {
if (this.num == 0 && AMIGA.config.floppy.drive[this.num].type == SAEV_Config_Floppy_Type_35_DD)
this.indexhackmode = 1;
this.set_id();
}
};
this.updatemfmpos = function() {
this.updatemfmpos = function () {
if (this.prevtracklen)
this.mfmpos = this.mfmpos * Math.floor(Math.floor(this.tracklen * 1000 / this.prevtracklen) / 1000);
this.mfmpos %= this.tracklen;
this.prevtracklen = this.tracklen;
}
};
this.reset_track = function() {
this.reset_track = function () {
//BUG.info('Drive.reset_track() DF%d', this.num);
this.tracklen = (AMIGA.config.video.ntsc ? 6399 : 6334) * this.ddhd * 2 * 8;
this.revolutions = 1;
this.trackspeed = get_floppy_speed();
this.buffered_side = -1;
this.skipoffset = -1;
this.tracktiming[0] = 0;
for (var i = 0; i < (AMIGA.config.video.ntsc ? 6399 : 6334) * this.ddhd; i++) this.bigmfmbuf[i] = 0xaaaa; //memset (this.bigmfmbuf, 0xaa, (AMIGA.config.video.ntsc ? 6399 : 6334) * 2 * this.ddhd);
this.updatemfmpos();
}
};
function strncmp_as(str1, str2, n) {
for (var i = 0; i < n; i++) {
@ -215,14 +213,14 @@ function Drive(number) {
}
return 0;
}
function strncmp_aa(str1, str2, n) {
/*function strncmp_aa(str1, str2, n) {
for (var i = 0; i < n; i++) {
if (str1[i] != str2[i])
return 1;
}
return 0;
}
this.insert = function() {
}*/
this.insert = function () {
//BUG.info('DF%d.insert()', this.num);
//const exeheader = [0x00,0x00,0x03,0xf3,0x00,0x00,0x00,0x00];
@ -279,7 +277,6 @@ function Drive(number) {
this.trackdata[i].sync = buffer[0] * 256 + buffer[1];
this.trackdata[i].len = buffer[2] * 256 + buffer[3];
this.trackdata[i].offs = offs;
this.trackdata[i].revolutions = 1;
if (this.trackdata[i].sync == 0) {
this.trackdata[i].type = TRACK_AMIGADOS;
@ -307,7 +304,6 @@ function Drive(number) {
this.trackdata[i].len = 512 * this.num_secs;
this.trackdata[i].bitlen = 0;
this.trackdata[i].offs = i * 512 * this.num_secs;
this.trackdata[i].revolutions = 1;
}
this.useturbo = true;
}*/
@ -355,7 +351,6 @@ function Drive(number) {
this.trackdata[i].len = 512 * this.num_secs;
this.trackdata[i].bitlen = 0;
this.trackdata[i].offs = i * 512 * this.num_secs;
this.trackdata[i].revolutions = 1;
}
}
this.set_id();
@ -366,9 +361,9 @@ function Drive(number) {
this.mfmpos %= this.tracklen;
this.prevtracklen = 0;
return 1;
}
};
this.eject = function() {
this.eject = function () {
//BUG.info('DF%d.eject()', this.num);
this.filetype = ADF_NONE;
this.diskfile = null;
@ -380,18 +375,18 @@ function Drive(number) {
this.dskready_down_time = 0;
this.ddhd = 1;
this.set_id();
}
};
this.is_empty = function() {
this.is_empty = function () {
return this.diskfile === null;
}
};
this.set_steplimit = function() {
this.set_steplimit = function () {
this.steplimit = 10;
this.steplimitcycle = AMIGA.events.currcycle;
}
};
this.step = function() {
this.step = function () {
if (!this.is_empty())
this.dskchange = 0;
@ -414,32 +409,35 @@ function Drive(number) {
}
AMIGA.disk.rand_shifter();
AMIGA.config.hooks.floppy_step(this.num, this.cyl);
}
};
this.is_track0 = function() {
this.is_track0 = function () {
return this.cyl == 0;
}
};
this.is_writeprotected = function() {
this.is_writeprotected = function () {
return this.wrprot || this.diskfile === null;
}
};
this.is_running = function() {
this.is_running = function () {
return !this.motoroff;
}
};
this.set_motor = function(off) {
this.set_motor = function (off) {
if (this.motoroff && !off) {
this.dskready_up_time = DSKREADY_UP_TIME;
AMIGA.disk.rand_shifter();
}
if (!this.motoroff && off) {
this.drive_id_scnt = 0; /* Reset id shift reg counter */
this.drive_id_scnt = 0;
/* Reset id shift reg counter */
this.dskready_down_time = DSKREADY_DOWN_TIME;
if (AMIGA.config.cpu.model <= 68010 && AMIGA.config.cpu.speed == SAEV_Config_CPU_Speed_Original) {
this.motordelay = true;
AMIGA.events.newevent2(30, this.num, function(v) { AMIGA.disk.motordelay_func(v); });
AMIGA.events.newevent2(30, this.num, function (v) {
AMIGA.disk.motordelay_func(v);
});
}
}
this.motoroff = off;
@ -449,13 +447,13 @@ function Drive(number) {
} else {
this.dskready_down_time = 0;
}
}
};
/* get one bit from MFM bit stream */
this.getonebit = function(mfmpos) {
this.getonebit = function (mfmpos) {
return (this.bigmfmbuf[mfmpos >> 4] & (1 << (15 - (mfmpos & 15)))) ? 1 : 0;
}
this.decode_amigados = function() {
};
this.decode_amigados = function () {
var gap_len = AMIGA.config.video.ntsc ? 415 : 350;
var tr = this.cyl * 2 + AMIGA.disk.side;
var len = this.num_secs * 544 + gap_len;
@ -554,12 +552,13 @@ function Drive(number) {
}
for (i = 0; i < 544; i++) {
this.bigmfmbuf[bigmfmpos % len] = mfmbuf[i]; bigmfmpos++;
}
this.bigmfmbuf[bigmfmpos % len] = mfmbuf[i];
bigmfmpos++;
}
}
};
this.decode_raw = function() {
this.decode_raw = function () {
var tr = this.cyl * 2 + AMIGA.disk.side;
var base_offset = this.trackdata[tr].type == TRACK_RAW ? 0 : 1;
@ -579,9 +578,9 @@ function Drive(number) {
this.bigmfmbuf[i] = 256 * buf[(i - base_offset) << 1] + buf[((i - base_offset) << 1) + 1];
//BUG.info('DF%d.decode_raw() rawtrack %d, offset %d', this.num, tr, this.trackdata[tr].offs);
}
};
this.fill_bigbuf = function(force) {
this.fill_bigbuf = function (force) {
var tr = this.cyl * 2 + AMIGA.disk.side;
if (!this.diskfile || tr >= this.num_tracks) {
@ -592,16 +591,13 @@ function Drive(number) {
return;
this.indexoffset = 0;
this.multi_revolution = 0;
this.tracktiming[0] = 0;
this.skipoffset = -1;
this.revolutions = 1;
/*if (this.writediskfile && this.writetrackdata[tr].bitlen > 0) {
var i;
trackid *wti = &this.writetrackdata[tr];
Track *wti = &this.writetrackdata[tr];
this.tracklen = wti->bitlen;
this.revolutions = wti->revolutions;
read_floppy_data (this.writediskfile, wti, 0, (var*)this.bigmfmbuf, Math.floor((wti->bitlen + 7) / 8));
for (i = 0; i < Math.floor((this.tracklen + 15) / 16); i++) {
var *mfm = this.bigmfmbuf + i;
@ -619,7 +615,7 @@ function Drive(number) {
else if (this.trackdata[tr].type == TRACK_PCDOS)
this.decode_pcdos();
else
this.decode_raw()
this.decode_raw();
this.buffered_side = AMIGA.disk.side;
this.buffered_cyl = this.cyl;
@ -630,15 +626,15 @@ function Drive(number) {
this.trackspeed = this.get_floppy_speed2();
this.updatemfmpos();
}
};
this.getmfmword = function(mbuf, shift) {
this.getmfmword = function (mbuf, shift) {
return (((this.bigmfmbuf[mbuf] << shift) | (this.bigmfmbuf[mbuf + 1] >>> (16 - shift))) >>> 0) & 0xffff;
}
this.getmfmlong = function(mbuf, shift) {
};
this.getmfmlong = function (mbuf, shift) {
return (((this.getmfmword(mbuf, shift) << 16) | this.getmfmword(mbuf + 1, shift)) >>> 0) & 0x55555555;
}
this.decode_buffer = function(checkmode) {
};
this.decode_buffer = function (checkmode) {
var mbuf = 0;
var cyl = this.cyl;
var drvsec = this.num_secs;
@ -738,9 +734,9 @@ function Drive(number) {
if (secwritten < 0) BUG.info('DF%d.decode_buffer() sector labels ignored', this.num);
return 0;
}
};
this.write_adf_amigados = function() {
this.write_adf_amigados = function () {
//var drvsec, i;
//var sectable[MAX_SECTORS];
@ -758,10 +754,9 @@ function Drive(number) {
this.diskfile[offset + j] = this.diskdata[offset + j] = this.writebuffer[i * 512 + j];
}
return 0;
}
};
this.write_data = function() {
var ret = -1;
this.write_data = function () {
var tr = this.cyl * 2 + AMIGA.disk.side;
if (this.is_writeprotected() || this.trackdata[tr].type == TRACK_NONE) {
@ -771,7 +766,8 @@ function Drive(number) {
//if (this.writediskfile) drive_write_ext2 (this.bigmfmbuf, this.writediskfile, &this.writetrackdata[tr], LONGWRITEMODE ? dsklength2 * 8 : this.tracklen);
switch (this.filetype) {
case ADF_NORMAL: {
case ADF_NORMAL:
{
if (this.write_adf_amigados()) {
//notify_user (NUMSG_NEEDEXT2);
}
@ -779,17 +775,16 @@ function Drive(number) {
}
}
this.tracktiming[0] = 0;
}
};
this.is_unformatted = function() {
this.is_unformatted = function () {
var tr = this.cyl * 2 + AMIGA.disk.side;
if (tr >= this.num_tracks) return true;
if (this.filetype == ADF_EXT2 && this.trackdata[tr].bitlen == 0 && this.trackdata[tr].type != TRACK_AMIGADOS)
return true;
if (this.trackdata[tr].type == TRACK_NONE)
return true;
return false;
}
return this.trackdata[tr].type == TRACK_NONE;
};
this.vsync = function() {
if (this.dskready_down_time > 0)
@ -808,7 +803,7 @@ function Drive(number) {
}
function Disk() {
this.side = 0
this.side = 0;
this.direction = 0;
var selected = 15;
var disabled = 0;
@ -823,7 +818,6 @@ function Disk() {
var fifo_filled = false;
var dma_enable = false;
var bitoffset = 0;
var syncoffset = 0;
var word = 0;
var dsksync = 0;
var dsksync_cycles = 0;
@ -838,9 +832,10 @@ function Disk() {
var ledstate = new Array(MAX_FLOPPY_DRIVES); for (var i = 0; i < MAX_FLOPPY_DRIVES; i++) ledstate[i] = false;
var floppy = new Array(MAX_FLOPPY_DRIVES); for (var i = 0; i < MAX_FLOPPY_DRIVES; i++) floppy[i] = new Drive(i);
this.setup = function() {}
this.setup = function () {
};
this.reset = function() {
this.reset = function () {
disk_hpos = 0;
dskdmaen = DSKDMA_OFF;
disabled = 0;
@ -855,19 +850,19 @@ function Disk() {
this.eject(i);
this.insert(i);
}
}
};
this.rand_shifter = function() {
var r = ((uaerand () >>> 4) & 7) + 1;
this.rand_shifter = function () {
var r = ((uaerand() >>> 4) & 7) + 1;
while (r-- > 0) {
word <<= 1;
word |= (uaerand () & 0x1000) ? 1 : 0;
word |= (uaerand() & 0x1000) ? 1 : 0;
bitoffset++;
bitoffset &= 15;
}
}
};
this.setdskchangetime = function(num, dsktime) {
this.setdskchangetime = function (num, dsktime) {
if (floppy[num].dskchange_time > 0)
return;
@ -877,9 +872,9 @@ function Disk() {
}
floppy[num].dskchange_time = dsktime;
//BUG.info('Disk.setdskchangetime() delayed insert enable %d', dsktime);
}
};
this.insert2 = function(num, forced) {
this.insert2 = function (num, forced) {
//BUG.info('Disk.insert() DF%d', num);
if (AMIGA.config.floppy.drive[num].name && AMIGA.config.floppy.drive[num].data) {
@ -900,34 +895,34 @@ function Disk() {
this.setdskchangetime(num, 100);
} else
this.setdskchangetime(num, 1);
}
this.insert = function(num) {
};
this.insert = function (num) {
this.insert2(num, false);
}
};
this.eject = function(num) {
this.eject = function (num) {
floppy[num].eject();
floppy[num].diskdata = null;
}
};
this.is_empty = function(num) {
this.is_empty = function (num) {
return floppy[num].is_empty();
}
};
this.select_fetch = function(data) {
this.select_fetch = function (data) {
selected = (data >> 3) & 15;
this.side = 1 - ((data >> 2) & 1);
this.direction = (data >> 1) & 1;
}
};
this.select_set = function(data) {
this.select_set = function (data) {
prev_data = data;
prev_step = data & 1;
this.select_fetch(data);
}
};
this.select = function(data) {
this.select = function (data) {
//BUG.info('Disk.select() $%02x', data);
var step_pulse, prev_selected, dr;
@ -956,7 +951,7 @@ function Disk() {
}
}
for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
if (!(selected & (1 << dr)) && (prev_selected & (1 << dr)) ) {
if (!(selected & (1 << dr)) && (prev_selected & (1 << dr))) {
floppy[dr].drive_id_scnt++;
floppy[dr].drive_id_scnt &= 31;
floppy[dr].idbit = (floppy[dr].drive_id & (1 << (31 - floppy[dr].drive_id_scnt))) ? 1 : 0;
@ -965,7 +960,8 @@ function Disk() {
if ((prev_data & 0x80) == 0 || (data & 0x80) == 0)
floppy[dr].set_motor(0); /* motor off: if motor bit = 0 in prevdata or data -> turn motor on */
else if (prev_data & 0x80)
floppy[dr].set_motor(1); /* motor on: if motor bit = 1 in prevdata only (motor flag state in data has no effect) -> turn motor off */
floppy[dr].set_motor(1);
/* motor on: if motor bit = 1 in prevdata only (motor flag state in data has no effect) -> turn motor off */
}
if (dr == 0)
floppy[dr].idbit = 0;
@ -979,9 +975,9 @@ function Disk() {
}
}
prev_data = data;
}
};
this.status = function() {
this.status = function () {
var st = 0x3c;
for (var dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
@ -1015,13 +1011,13 @@ function Disk() {
}
//BUG.info('Disk.status() $%02x', st);
return st;
}
};
this.fetchnextrevolution = function(num) {
this.fetchnextrevolution = function (num) {
floppy[num].trackspeed = floppy[num].get_floppy_speed2();
}
};
this.handler = function(data) {
this.handler = function (data) {
var flag = data & 255;
var disk_sync_cycle = data >> 8;
//BUG.info('Disk.handler() data $%x, flag %d, disk_sync_cycle %d', data, flag, disk_sync_cycle);
@ -1044,16 +1040,16 @@ function Disk() {
AMIGA.cia.SetICRB(0x10, null);
}
}
}
};
this.update_jitter = function() {
this.update_jitter = function () {
if (random_bits_max > 0)
disk_jitter = ((uaerand() >>> 4) % (random_bits_max - random_bits_min + 1)) + random_bits_min;
else
disk_jitter = 0;
}
};
this.updatetrackspeed = function(num, mfmpos) {
this.updatetrackspeed = function (num, mfmpos) {
if (dskdmaen < DSKDMA_WRITE) {
var t = floppy[num].tracktiming[Math.floor(mfmpos / 8)];
floppy[num].trackspeed = Math.floor(floppy[num].get_floppy_speed2() * t / 1000);
@ -1062,25 +1058,25 @@ function Disk() {
floppy[num].trackspeed = 1000;
}
}
}
};
this.fifostatus = function() {
this.fifostatus = function () {
if (fifo_inuse[0] && fifo_inuse[1] && fifo_inuse[2])
return 1;
else if (!fifo_inuse[0] && !fifo_inuse[1] && !fifo_inuse[2])
return -1;
return 0;
}
};
this.dmafinished = function() {
this.dmafinished = function () {
//BUG.info('Disk.dmafinished()');
AMIGA.INTREQ(INT_DSKBLK);
//LONGWRITEMODE = 0;
dskdmaen = DSKDMA_OFF;
dsklength = 0;
}
};
this.readdma = function() {
this.readdma = function () {
if (AMIGA.dmaen(DMAF_DSKEN) && bitoffset == 15 && dma_enable && dskdmaen == DSKDMA_READ && dsklength >= 0) {
if (dsklength > 0) {
if (dsklength == 1 && dsklength2 == 1) {
@ -1106,9 +1102,9 @@ function Disk() {
return 1;
}
return 0;
}
};
this.update_read_nothing = function(floppybits) {
this.update_read_nothing = function (floppybits) {
//BUG.info('Disk.update_read_nothing() floppybits %d', floppybits);
while (floppybits >= get_floppy_speed()) {
@ -1123,16 +1119,16 @@ function Disk() {
bitoffset &= 15;
floppybits -= get_floppy_speed();
}
}
};
/*static this.read_floppy_data (struct zfile *diskfile, trackid *tid, var offset, var *dst, var len) {
/*static this.read_floppy_data (struct zfile *diskfile, Track *tid, var offset, var *dst, var len) {
if (len == 0)
return;
zfile_fseek (diskfile, tid->offs + offset, SEEK_SET);
zfile_fread (dst, 1, len, diskfile);
}*/
this.update_read = function(num, floppybits) {
this.update_read = function (num, floppybits) {
//BUG.info('Disk.update_read() DF%d, floppybits %d', num, floppybits);
while (floppybits >= floppy[num].trackspeed) {
@ -1182,10 +1178,10 @@ function Disk() {
bitoffset &= 15;
floppybits -= floppy[num].trackspeed;
}
}
};
this.update_write = function(num, floppybits) {
var dr, drives = [0,0,0,0];
this.update_write = function (num, floppybits) {
var dr, drives = [0, 0, 0, 0];
for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
drives[dr] = 0;
@ -1216,7 +1212,7 @@ function Disk() {
}
if (this.fifostatus() >= 0) {
var w = this.DSKDATR();
for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) {
for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
if (drives[dr]) {
floppy[dr].bigmfmbuf[floppy[dr].mfmpos >> 4] = w;
floppy[dr].bigmfmbuf[(floppy[dr].mfmpos >> 4) + 1] = 0x5555;
@ -1226,7 +1222,7 @@ function Disk() {
dsklength--;
if (dsklength <= 0) {
this.dmafinished();
for (dr = 0; dr < MAX_FLOPPY_DRIVES ; dr++) {
for (dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
floppy[dr].writtento = 0;
if (floppy[dr].motoroff)
continue;
@ -1240,9 +1236,9 @@ function Disk() {
}
floppybits -= floppy[num].trackspeed;
}
}
};
this.doupdate_predict = function(startcycle) {
this.doupdate_predict = function (startcycle) {
//BUG.info('Disk.doupdate_predict() startcycle %d', startcycle);
var finaleventcycle = AMIGA.playfield.maxhpos << 8;
var finaleventflag = 0;
@ -1304,13 +1300,12 @@ function Disk() {
if (finaleventflag && (finaleventcycle >>> 8) < AMIGA.playfield.maxhpos)
AMIGA.events.newevent(EV2_DISK, (finaleventcycle - startcycle) >>> 8, ((finaleventcycle >>> 8) << 8) | finaleventflag);
}
};
this.update = function(tohpos) {
this.update = function (tohpos) {
//if (tohpos != 227) BUG.info('Disk.update() disk_hpos %f, to hpos %d', disk_hpos / CYCLE_UNIT, tohpos);
var dr;
var cycles;
var startcycle = disk_hpos;
if (disk_hpos < 0) {
disk_hpos = -disk_hpos;
@ -1362,13 +1357,13 @@ function Disk() {
this.dmafinished();
this.doupdate_predict(disk_hpos);
}
};
this.dma_debugmsg = function() {
this.dma_debugmsg = function () {
BUG.info('Disk.dma_debugmsg() LEN=%04x (%d) SYNC=%04x PT=%08x ADKCON=%04x', dsklength, dsklength, (AMIGA.adkcon & 0x400) ? dsksync : 0xffff, dskpt, AMIGA.adkcon);
}
};
this.start = function() {
this.start = function () {
fifo_filled = false;
for (var i = 0; i < 3; i++)
fifo_inuse[i] = 0;
@ -1391,9 +1386,9 @@ function Disk() {
floppy[dr].floppybitcounter = 0;
}
dma_enable = (AMIGA.adkcon & 0x400) ? false : true;
}
};
this.check_change = function() {
this.check_change = function () {
//if (currprefs.floppy_speed != changed_prefs.floppy_speed) currprefs.floppy_speed = changed_prefs.floppy_speed;
/*for (var i = 0; i < MAX_FLOPPY_DRIVES; i++) {
if (currprefs.floppyslots[i].dfxtype != changed_prefs.floppyslots[i].dfxtype) {
@ -1401,18 +1396,18 @@ function Disk() {
floppy[i].reset();
}
}*/
}
};
this.vsync = function() {
this.vsync = function () {
this.check_change();
for (var i = 0; i < MAX_FLOPPY_DRIVES; i++) {
//if (drv->dskchange_time == 0 && _tcscmp (currprefs.floppyslots[i].df, changed_prefs.floppyslots[i].df)) this.insert(i, changed_prefs.floppyslots[i].df);
floppy[i].vsync();
}
}
};
this.hsync = function() {
this.hsync = function () {
for (var dr = 0; dr < MAX_FLOPPY_DRIVES; dr++) {
if (floppy[dr].steplimit)
floppy[dr].steplimit--;
@ -1425,9 +1420,9 @@ function Disk() {
return;
}
this.update(AMIGA.playfield.maxhpos);
}
};
this.update_adkcon = function(v) {
this.update_adkcon = function (v) {
var vold = AMIGA.adkcon;
var vnew = AMIGA.adkcon;
if (v & 0x8000)
@ -1437,15 +1432,14 @@ function Disk() {
if ((vnew & 0x400) && !(vold & 0x400))
bitoffset = 0;
}
};
this.motordelay_func = function(unit) {
this.motordelay_func = function (unit) {
//BUG.info('Disk.motordelay_func(%d)', unit);
floppy[unit].motordelay = false;
}
};
this.DSKLEN = function(v, hpos)
{
this.DSKLEN = function (v, hpos) {
//BUG.info('Disk.DSKLEN() $%04x', v);
var dr, prev = dsklen;
@ -1552,8 +1546,7 @@ function Disk() {
done = true;
} else if (dskdmaen == DSKDMA_WRITE) { //TURBO write
for (i = 0; i < dsklength; i++) {
var w = AMIGA.mem.load16(dskpt + i * 2);
floppy[dr].bigmfmbuf[pos >> 4] = w;
floppy[dr].bigmfmbuf[pos >> 4] = AMIGA.mem.load16(dskpt + i * 2);
pos += 16;
pos %= floppy[dr].tracklen;
}
@ -1577,9 +1570,9 @@ function Disk() {
dskdmaen = DSKDMA_OFF;
}
}
}
};
this.DSKBYTR = function(hpos) {
this.DSKBYTR = function (hpos) {
this.update(hpos);
var v = dskbytr_val;
@ -1593,17 +1586,17 @@ function Disk() {
//BUG.info('Disk.DSKBYTR() %x', v);
return v;
}
};
this.DSKSYNC = function(v, hpos) {
this.DSKSYNC = function (v, hpos) {
if (v == dsksync)
return;
this.update(hpos);
dsksync = v;
}
};
this.DSKDAT = function(v) {
this.DSKDAT = function (v) {
if (fifo_inuse[2]) {
BUG.info('Disk.DSKDAT() FIFO overflow!');
return;
@ -1615,9 +1608,9 @@ function Disk() {
fifo_inuse[0] = dskdmaen == DSKDMA_WRITE ? 2 : 1;
fifo[0] = v;
fifo_filled = true;
}
};
this.DSKDATR = function() {
this.DSKDATR = function () {
var i, v = 0;
for (i = 2; i >= 0; i--) {
@ -1634,21 +1627,21 @@ function Disk() {
//BUG.info('Disk.DSKDATR() %x', v);
return v;
}
};
this.DSKPTH = function(v) {
this.DSKPTH = function (v) {
dskpt = ((v << 16) | (dskpt & 0xffff)) >>> 0;
}
};
this.DSKPTL = function(v) {
this.DSKPTL = function (v) {
dskpt = ((dskpt & 0xffff0000) | v) >>> 0;
}
};
this.getpt = function() {
this.getpt = function () {
var pt = dskpt;
dskpt += 2;
return pt;
}
};
this.dmal = function() {
var dmal = 0;
@ -1661,7 +1654,7 @@ function Disk() {
if (dsklength == 1)
dmal &= ~(16 + 32 + 4 + 8);
} else {
dmal = 16 * (fifo_inuse[0] ? 1 : 0) + 4 * (fifo_inuse[1] ? 1 : 0) + 1 * (fifo_inuse[2] ? 1 : 0);
dmal = 16 * (fifo_inuse[0] ? 1 : 0) + 4 * (fifo_inuse[1] ? 1 : 0) + (fifo_inuse[2] ? 1 : 0);
}
}
return dmal;

View file

@ -8,7 +8,7 @@
*
**************************************************************************/
function Event() {
function Event1() {
this.active = false;
this.evtime = 0;
this.oldcycles = 0;
@ -31,7 +31,7 @@ function Events() {
var nextevent = 0;
var nextevent2 = 0;
var dmal = 0
var dmal = 0;
var dmal_hpos = 0;
var vsynctimebase = 0;
@ -45,11 +45,11 @@ function Events() {
//var vsync_counter = 0;
const MAVG_VSYNC_SIZE = 128;
var ma_frameskipt = new mavg(MAVG_VSYNC_SIZE);
var ma_frameskipt = new MAvg(MAVG_VSYNC_SIZE);
const FPSCOUNTER_MAVG_SIZE = 10;
var fps_mavg = new mavg(FPSCOUNTER_MAVG_SIZE);
var idle_mavg = new mavg(FPSCOUNTER_MAVG_SIZE);
var fps_mavg = new MAvg(FPSCOUNTER_MAVG_SIZE);
var idle_mavg = new MAvg(FPSCOUNTER_MAVG_SIZE);
var timeframes = 0;
var lastframetime = 0;
var idletime = 0;
@ -65,32 +65,46 @@ function Events() {
/*---------------------------------*/
this.setup = function() {
this.setup = function () {
if (this.eventtab === null) {
this.eventtab = new Array(EV_MAX);
for (var i = 0; i < EV_MAX; i++)
this.eventtab[i] = new Event();
this.eventtab[i] = new Event1();
this.eventtab[EV_CIA].handler = function() { AMIGA.cia.handler(); }
this.eventtab[EV_AUDIO].handler = function() { AMIGA.audio.handler(); }
this.eventtab[EV_MISC].handler = function() { AMIGA.events.misc_handler(); }
this.eventtab[EV_HSYNC].handler = function() { AMIGA.events.hsync_handler(); }
this.eventtab[EV_CIA].handler = function () {
AMIGA.cia.handler();
};
this.eventtab[EV_AUDIO].handler = function () {
AMIGA.audio.handler();
};
this.eventtab[EV_MISC].handler = function () {
AMIGA.events.misc_handler();
};
this.eventtab[EV_HSYNC].handler = function () {
AMIGA.events.hsync_handler();
}
}
if (this.eventtab2 === null) {
this.eventtab2 = new Array(EV2_MAX);
for (var i = 0; i < EV2_MAX; i++)
this.eventtab2[i] = new Event2();
this.eventtab2[EV2_BLITTER].handler = function(data) { AMIGA.blitter.handler(data); }
this.eventtab2[EV2_DISK].handler = function(data) { AMIGA.disk.handler(data); }
this.eventtab2[EV2_DMAL].handler = function(data) { AMIGA.events.dmal_handler(data); }
this.eventtab2[EV2_BLITTER].handler = function (data) {
AMIGA.blitter.handler(data);
};
this.eventtab2[EV2_DISK].handler = function (data) {
AMIGA.disk.handler(data);
};
this.eventtab2[EV2_DMAL].handler = function (data) {
AMIGA.events.dmal_handler(data);
}
}
this.calc_vsynctimebase(AMIGA.config.video.ntsc ? 60 : 50);
}
};
this.reset = function() {
dmal = 0
this.reset = function () {
dmal = 0;
dmal_hpos = 0;
this.currcycle = 0;
@ -116,30 +130,31 @@ function Events() {
this.eventtab2[i].active = false;
this.eventtab2[i].evtime = 0;
}
this.eventtab[EV_HSYNC].evtime = 227 * CYCLE_UNIT; /* 0xe3 */
this.eventtab[EV_HSYNC].evtime = 227 * CYCLE_UNIT;
/* 0xe3 */
this.eventtab[EV_HSYNC].active = true;
this.schedule();
}
};
this.calc_vsynctimebase = function(hz) {
this.calc_vsynctimebase = function (hz) {
vsynctimebase = Math.floor(SYNCBASE / hz);
//vsynctimebase >>= 1;//(AMIGA.config.video.framerate > 1 ? 1 : 0);
}
};
/*---------------------------------*/
this.hpos = function() {
this.hpos = function () {
return Math.floor((this.currcycle - this.eventtab[EV_HSYNC].oldcycles) * CYCLE_UNIT_INV);
}
};
this.cycles_in_range = function(endcycles) {
this.cycles_in_range = function (endcycles) {
return (endcycles - this.currcycle > 0);
}
};
/*---------------------------------*/
this.schedule = function() {
this.schedule = function () {
var mintime = CYCLE_MAX;
for (var i = 0; i < EV_MAX; i++) {
@ -149,9 +164,9 @@ function Events() {
}
}
nextevent = this.currcycle + mintime;
}
};
this.cycle = function(cycles) {
this.cycle = function (cycles) {
if (vsyncresume) {
vsyncresume = false;
this.hsync_handler_post(1);
@ -182,13 +197,13 @@ function Events() {
this.schedule();
}
this.currcycle += cycles;
}
};
/*---------------------------------*/
var stack = { recursive:0, dorecheck:false };
this.misc_handler = function() {
this.misc_handler = function () {
//if (stack.recursive > 1) BUG.info('misc_handler() recursive %d', stack.recursive);
var mintime;
var ct = this.currcycle;
@ -230,12 +245,12 @@ function Events() {
this.schedule();
}
stack.recursive--;
}
};
this.newevent2_x = function(t, data, func) {
this.newevent2_x = function (t, data, func) {
var et = this.currcycle + t;
var no = nextevent2;
for (;;) {
for (; ;) {
if (!this.eventtab2[no].active)
break;
@ -254,65 +269,66 @@ function Events() {
this.eventtab2[no].handler = func;
this.eventtab2[no].data = data;
this.misc_handler();
}
};
this.newevent2 = function(t, data, func) {
this.newevent2 = function (t, data, func) {
if (t <= 0)
func(data);
else
this.newevent2_x(t * CYCLE_UNIT, data, func);
}
};
this.newevent = function(id, t, data) {
this.newevent = function (id, t, data) {
this.eventtab2[id].active = true;
this.eventtab2[id].evtime = this.currcycle + t * CYCLE_UNIT;
this.eventtab2[id].data = data;
this.misc_handler();
}
};
this.remevent = function(no) {
this.remevent = function (no) {
if (this.eventtab2[no].active) {
this.eventtab2[no].active = false;
//BUG.info('remevent() %d', no);
}
}
};
/*---------------------------------*/
this.dmal_emu = function(v) {
this.dmal_emu = function (v) {
if (!(AMIGA.dmacon & DMAF_DMAEN))
return;
var hpos = this.hpos();
//var hpos = this.hpos();
var dat, pt;
if (v >= 6) {
v -= 6;
var nr = v >> 1;
var pt = AMIGA.audio.getpt(nr, (v & 1) != 0);
pt = AMIGA.audio.getpt(nr, (v & 1) != 0);
//var dat = AMIGA.mem.load16_chip(pt);
var dat = AMIGA.mem.chip.data[pt >>> 1];
dat = AMIGA.mem.chip.data[pt >>> 1];
AMIGA.custom.last_value = dat;
AMIGA.audio.AUDxDAT(nr, dat);
} else {
var w = v & 1;
var pt = AMIGA.disk.getpt();
pt = AMIGA.disk.getpt();
if (w) {
if (AMIGA.disk.fifostatus() <= 0) {
//var dat = AMIGA.mem.load16_chip(pt);
var dat = AMIGA.mem.chip.data[pt >>> 1];
dat = AMIGA.mem.chip.data[pt >>> 1];
AMIGA.custom.last_value = dat;
AMIGA.disk.DSKDAT(dat);
}
} else {
if (AMIGA.disk.fifostatus() >= 0) {
var dat = AMIGA.disk.DSKDATR();
dat = AMIGA.disk.DSKDATR();
//AMIGA.mem.store16_chip(pt, dat);
AMIGA.mem.chip.data[pt >>> 1] = dat;
}
}
}
}
};
this.dmal_handler = function(v) {
this.dmal_handler = function (v) {
while (dmal) {
if (dmal & 3)
this.dmal_emu(dmal_hpos + ((dmal & 2) ? 1 : 0));
@ -320,9 +336,9 @@ function Events() {
dmal >>>= 2;
}
this.remevent(EV2_DMAL);
}
};
this.dmal_hsync = function() {
this.dmal_hsync = function () {
if (dmal) BUG.info('dmal_hsync() DMAL error!? %04x', dmal);
dmal = AMIGA.audio.dmal();
dmal <<= 6;
@ -331,13 +347,13 @@ function Events() {
dmal_hpos = 0;
this.newevent(EV2_DMAL, 7, 13);
}
}
};
/*---------------------------------*/
function sleep(ms) {
var start = new Date().getTime();
while ((new Date().getTime() - start) < ms);
while ((new Date().getTime() - start) < ms) {}
}
function read_processor_time() {
@ -356,9 +372,9 @@ function Events() {
return v;
}
this.framewait = function() {
this.framewait = function () {
var clockadjust = 0;
var vstb = vsynctimebase;
var curr_time;
var frameskipt_avg = ma_frameskipt.set(frameskiptime);
frameskiptime = 0;
@ -369,19 +385,19 @@ function Events() {
if (!frame_rendered)
frame_rendered = AMIGA.playfield.render_screen(false);
var curr_time = read_processor_time();
curr_time = read_processor_time();
var adjust = 0;
if (Math.floor(curr_time - vsyncwaittime) > 0 && Math.floor(curr_time - vsyncwaittime) < (vstb >> 1))
if (Math.floor(curr_time - vsyncwaittime) > 0 && Math.floor(curr_time - vsyncwaittime) < (vsynctimebase >> 1))
adjust += curr_time - vsyncwaittime;
adjust += clockadjust;
console.log(adjust);
vsyncwaittime = curr_time + vstb - adjust;
vsyncwaittime = curr_time + vsynctimebase - adjust;
vsyncmintime = curr_time;
var max = Math.floor(vstb - adjust);
var max = Math.floor(vsynctimebase - adjust);
if (max < 0) {
max = 0;
vsynctimeperline = 1;
@ -402,32 +418,35 @@ function Events() {
sleep(2);
start = read_processor_time();
while (rpt_vsync(clockadjust) < 0);
while (rpt_vsync(clockadjust) < 0) {
}
idletime += read_processor_time() - start;
var curr_time = read_processor_time();
curr_time = read_processor_time();
vsyncmintime = curr_time;
vsyncmaxtime = vsyncwaittime = curr_time + vstb;
vsyncmaxtime = vsyncwaittime = curr_time + vsynctimebase;
if (frame_rendered) {
frame_shown = AMIGA.playfield.show_screen();
t += read_processor_time() - curr_time;
}
t += frameskipt_avg;
vsynctimeperline = Math.floor((vstb - t) / 3);
vsynctimeperline = Math.floor((vsynctimebase - t) / 3);
if (vsynctimeperline < 0)
vsynctimeperline = 0;
else if (vsynctimeperline > Math.floor(vstb / 3))
vsynctimeperline = Math.floor(vstb / 3);
}
else if (vsynctimeperline > Math.floor(vsynctimebase / 3))
vsynctimeperline = Math.floor(vsynctimebase / 3);
}
};
this.framewait2 = function() {
this.framewait2 = function () {
if (AMIGA.config.cpu.speed < 0) {
if (AMIGA.playfield.is_last_line()) {
/* really last line, just run the cpu emulation until whole vsync time has been used */
vsyncmintime = vsyncmaxtime; /* emulate if still time left */
is_syncline_end = read_processor_time() + vsynctimebase; /* far enough in future, we never wait that long */
vsyncmintime = vsyncmaxtime;
/* emulate if still time left */
is_syncline_end = read_processor_time() + vsynctimebase;
/* far enough in future, we never wait that long */
is_syncline = 1;
} else {
/* end of scanline, run cpu emulation as long as we still have time */
@ -465,17 +484,17 @@ function Events() {
}
}
}
}
};
this.fpscounter_reset = function() {
this.fpscounter_reset = function () {
timeframes = 0;
fps_mavg.clr();
idle_mavg.clr();
lastframetime = read_processor_time();
idletime = 0;
}
};
this.fpscounter = function() {
this.fpscounter = function () {
var hz = AMIGA.playfield.vblank_hz;
var now = read_processor_time();
@ -507,12 +526,12 @@ function Events() {
AMIGA.config.hooks.cpu(Math.round(idle * 0.1));
}
}
}
};
/*---------------------------------*/
this.hsync_handler_pre = function(onvsync) {
var hpos = this.hpos();
this.hsync_handler_pre = function (onvsync) {
//var hpos = this.hpos();
AMIGA.copper.sync_copper_with_cpu(AMIGA.playfield.maxhpos, 0);
AMIGA.playfield.hsync_handler_pre();
AMIGA.disk.hsync();
@ -524,9 +543,9 @@ function Events() {
this.eventtab[EV_HSYNC].evtime = this.currcycle + AMIGA.playfield.maxhpos * CYCLE_UNIT;
this.eventtab[EV_HSYNC].oldcycles = this.currcycle;
}
};
this.vsync_handler_pre = function() {
this.vsync_handler_pre = function () {
//AMIGA.audio.vsync(); //empty
AMIGA.cia.vsync_prehandler();
@ -534,13 +553,14 @@ function Events() {
var start = read_processor_time();
AMIGA.playfield.vsync_handle_redraw();
frameskiptime += read_processor_time() - start;
vsync_rendered = true;
//vsync_rendered = true;
}
this.framewait();
if (!frame_rendered)
frame_rendered = AMIGA.playfield.render_screen(false);
if (frame_rendered && !frame_shown)
frame_shown = AMIGA.playfield.show_screen();
//frame_shown = AMIGA.playfield.show_screen();
AMIGA.playfield.show_screen();
this.fpscounter();
vsync_rendered = false;
@ -548,10 +568,10 @@ function Events() {
frame_rendered = false;
AMIGA.playfield.checklacecount(null);
}
};
var cia_hsync = 256;
this.hsync_handler_post = function(onvsync) {
this.hsync_handler_post = function (onvsync) {
AMIGA.copper.last_copper_hpos = 0;
var ciasyncs = !(AMIGA.playfield.bplcon0 & 2) || ((AMIGA.playfield.bplcon0 & 2) && AMIGA.config.chipset.genlock);
@ -599,13 +619,13 @@ function Events() {
//AMIGA.copper.check(2);
AMIGA.playfield.hsync_handler_post_diw_change();
}
};
this.vsync_handler_post = function() {
this.vsync_handler_post = function () {
//if ((AMIGA.intreq & 0x0020) && (AMIGA.intena & 0x0020)) BUG.info('vblank interrupt not cleared');
AMIGA.disk.vsync();
AMIGA.playfield.vsync_handler_post();
}
};
this.hsync_handler = function() {
var vs = AMIGA.playfield.is_custom_vsync();

View file

@ -14,7 +14,7 @@ function Board_A2058() {
const MEM_2MB = 0x06;
const MEM_1MB = 0x05;
const MEM_512KB = 0x04;
const MEM_256KB = 0x03;
//const MEM_256KB = 0x03;
//const MEM_128KB = 0x02;
//const MEM_64KB = 0x01;
@ -80,7 +80,7 @@ function Expansion() {
var boards = [];
var board = 0;
this.setup = function() {
this.setup = function () {
mem.data = new Uint16Array(0x8000);
boards = [];
if (AMIGA.mem.fast.size > 0)
@ -90,22 +90,22 @@ function Expansion() {
for (var i = 1; i < MAX_EXPANSION_BOARDS; i++)
boards[i] = new Board_Dummy();
}
};
this.reset = function() {
this.reset = function () {
board = 0;
this.config(board);
}
};
this.clear = function() {
this.clear = function () {
for (var i = 0; i < mem.data.length; i++)
mem.data[i] = 0;
}
};
this.write = function (addr, value) {
mem.data[(addr >> 1)] = (value & 0xf0) << 8;
mem.data[(addr >> 1) + 1] = (value & 0x0f) << 12;
}
};
this.load8 = function (addr) {
addr &= 0xffff;
@ -113,7 +113,7 @@ function Expansion() {
if (addr == 0 || addr == 2 || addr == 0x40 || addr == 0x42)
return value;
return ~value & 0xff;
}
};
this.store8 = function (addr, value) {
switch (addr & 0xff) {
@ -147,7 +147,7 @@ function Expansion() {
this.clear();
break;
}
}
};
this.config = function(board) {
var info = boards[board].info();

View file

@ -19,37 +19,37 @@ function Mouse() {
var lx = -1;
var ly = -1;
this.reset = function() {
this.reset = function () {
this.button = [0, 0, 0];
cx = cy = 0;
lx = ly = -1;
}
};
this.mousedown = function (e) {
e = e || window.event;
if (!e) return;
this.button[e.button] = true;
}
};
this.mouseup = function (e) {
e = e || window.event;
if (!e) return;
this.button[e.button] = false;
}
};
this.mouseover = function (e) {
//AMIGA.video.hideCursor(1);
this.mousemove(e);
lx = cx;
ly = cy;
}
};
this.mouseout = function (e) {
//AMIGA.video.hideCursor(0);
this.mouseup(e);
}
};
this.mousemove = function (e) {
e = e || window.event;
@ -67,7 +67,7 @@ function Mouse() {
ly = cy;
}
//BUG.info('USER() mousemove %d %d', cx, cy);
}
};
this.update = function() {
if (lx != -1) {
@ -97,13 +97,11 @@ function Joystick(type) {
this.button = [false, false, false];
this.state = [false, false, false, false];
this.dir = 0;
var x = 0;
var y = 0;
this.reset = function() {
this.reset = function () {
this.button = [false, false, false];
this.state = [false, false, false, false];
}
};
this.update = function() {
var u = this.state[1];
@ -144,7 +142,7 @@ function Keyboard() {
const RAWKEY_0 = 0x0A;
const RAWKEY_MINUS = 0x0B;
const RAWKEY_EQUAL = 0x0C;
const RAWKEY_BACKSLASH = 0x0D;
//const RAWKEY_BACKSLASH = 0x0D;
const RAWKEY_KP_0 = 0x0F;
const RAWKEY_Q = 0x10;
const RAWKEY_W = 0x11;
@ -194,7 +192,7 @@ function Keyboard() {
const RAWKEY_SPACE = 0x40;
const RAWKEY_BACKSPACE = 0x41;
const RAWKEY_TAB = 0x42;
const RAWKEY_KP_ENTER = 0x43;
//const RAWKEY_KP_ENTER = 0x43;
const RAWKEY_RETURN = 0x44;
const RAWKEY_ESCAPE = 0x45;
const RAWKEY_DELETE = 0x46;
@ -226,7 +224,7 @@ function Keyboard() {
const RAWKEY_CAPSLOCK = 0x62;
const RAWKEY_CONTROL = 0x63;
const RAWKEY_LALT = 0x64;
const RAWKEY_RALT = 0x65;
//const RAWKEY_RALT = 0x65;
const RAWKEY_LAMIGA = 0x66;
const RAWKEY_RAMIGA = 0x67;
/*const RAWKEY_SCRLOCK = 0x6B;
@ -247,9 +245,9 @@ function Keyboard() {
const RAWKEY_NM_WHEEL_LEFT = 0x7C;
const RAWKEY_NM_WHEEL_RIGHT = 0x7D;
const RAWKEY_NM_BUTTON_FOURTH = 0x7E;*/
const RAWKEY_BAD_CODE = 0xF9;
/*const RAWKEY_BAD_CODE = 0xF9;
const RAWKEY_BUFFER_OVERFLOW = 0xFA;
const RAWKEY_SELFTEST_FAILED = 0xFC;
const RAWKEY_SELFTEST_FAILED = 0xFC;*/
const RAWKEY_INIT_POWER_UP = 0xFD;
const RAWKEY_TERM_POWER_UP = 0xFE;
@ -486,7 +484,7 @@ function Keyboard() {
function _onkeydown(e) { AMIGA.input.keyboard.handleKey(e, true); }
function _onkeyup(e) { AMIGA.input.keyboard.handleKey(e, false); }
this.setup = function() {
this.setup = function () {
/*document.onkeydown = function (e) {
AMIGA.input.keyboard.keydownup(e, true);
}
@ -495,35 +493,35 @@ function Keyboard() {
}*/
window.document.addEventListener('keydown', _onkeydown, false);
window.document.addEventListener('keyup', _onkeyup, false);
}
};
this.cleanup = function() {
this.cleanup = function () {
//BUG.info('Keyboard.cleanup()');
//document.onkeydown = null;
//document.onkeyup = null;
window.document.removeEventListener('keydown', _onkeydown, false);
window.document.removeEventListener('keyup', _onkeyup, false);
}
};
this.reset = function() {
this.reset = function () {
for (var i = 0; i < MAXKEYS; i++) keyState[i] = false;
state = 0;
code = 0;
first = last = 0;
hsynccnt = 0;
this.lostsynccnt = 0;
}
};
this.keysAvail = function() {
this.keysAvail = function () {
return first != last;
}
};
this.nextKey = function() {
this.nextKey = function () {
//assert (first != last);
var key = keyBuf[last];
if (++last == KEYBUFSIZE) last = 0;
return key;
}
};
this.recordKey = function (kc) {
var next = first + 1;
@ -536,7 +534,7 @@ function Keyboard() {
keyBuf[first] = kc;
first = next;
return true;
}
};
this.processKey = function (code, down) {
/* Caps-lock */
@ -551,39 +549,137 @@ function Keyboard() {
/* joystick emul */
if (AMIGA.config.ports[0].type == SAEV_Config_Ports_Type_Joy0) {
var l,u,r,d,f1,f2;
var l, u, r, d, f1, f2;
switch (AMIGA.config.ports[0].move) {
case SAEV_Config_Ports_Move_Arrows: { l = 37; u = 38; r = 39; d = 40; break; }
case SAEV_Config_Ports_Move_Numpad: { l = 100; u = 104; r = 102; d = 101; break; }
case SAEV_Config_Ports_Move_WASD: { l = 65; u = 87; r = 68; d = 83; break; }
case SAEV_Config_Ports_Move_Arrows:
{
l = 37;
u = 38;
r = 39;
d = 40;
break;
}
case SAEV_Config_Ports_Move_Numpad:
{
l = 100;
u = 104;
r = 102;
d = 101;
break;
}
case SAEV_Config_Ports_Move_WASD:
{
l = 65;
u = 87;
r = 68;
d = 83;
break;
}
}
f1 = AMIGA.config.ports[0].fire[0];
f2 = AMIGA.config.ports[0].fire[1];
switch (code) {
case f1: { AMIGA.input.joystick[0].button[0] = down; break; }
case f2: { AMIGA.input.joystick[0].button[1] = down; break; }
case l: { AMIGA.input.joystick[0].state[0] = down; if (down && AMIGA.input.joystick[0].state[2]) AMIGA.input.joystick[0].state[2] = false; break; }
case u: { AMIGA.input.joystick[0].state[1] = down; if (down && AMIGA.input.joystick[0].state[3]) AMIGA.input.joystick[0].state[3] = false; break; }
case r: { AMIGA.input.joystick[0].state[2] = down; if (down && AMIGA.input.joystick[0].state[0]) AMIGA.input.joystick[0].state[0] = false; break; }
case d: { AMIGA.input.joystick[0].state[3] = down; if (down && AMIGA.input.joystick[0].state[1]) AMIGA.input.joystick[0].state[1] = false; break; }
case f1:
{
AMIGA.input.joystick[0].button[0] = down;
break;
}
case f2:
{
AMIGA.input.joystick[0].button[1] = down;
break;
}
case l:
{
AMIGA.input.joystick[0].state[0] = down;
if (down && AMIGA.input.joystick[0].state[2]) AMIGA.input.joystick[0].state[2] = false;
break;
}
case u:
{
AMIGA.input.joystick[0].state[1] = down;
if (down && AMIGA.input.joystick[0].state[3]) AMIGA.input.joystick[0].state[3] = false;
break;
}
case r:
{
AMIGA.input.joystick[0].state[2] = down;
if (down && AMIGA.input.joystick[0].state[0]) AMIGA.input.joystick[0].state[0] = false;
break;
}
case d:
{
AMIGA.input.joystick[0].state[3] = down;
if (down && AMIGA.input.joystick[0].state[1]) AMIGA.input.joystick[0].state[1] = false;
break;
}
}
}
if (AMIGA.config.ports[1].type == SAEV_Config_Ports_Type_Joy1) {
var l,u,r,d,f1,f2;
var l, u, r, d, f1, f2;
switch (AMIGA.config.ports[1].move) {
case SAEV_Config_Ports_Move_Arrows: { l = 37; u = 38; r = 39; d = 40; break; }
case SAEV_Config_Ports_Move_Numpad: { l = 100; u = 104; r = 102; d = 101; break; }
case SAEV_Config_Ports_Move_WASD: { l = 65; u = 87; r = 68; d = 83; break; }
case SAEV_Config_Ports_Move_Arrows:
{
l = 37;
u = 38;
r = 39;
d = 40;
break;
}
case SAEV_Config_Ports_Move_Numpad:
{
l = 100;
u = 104;
r = 102;
d = 101;
break;
}
case SAEV_Config_Ports_Move_WASD:
{
l = 65;
u = 87;
r = 68;
d = 83;
break;
}
}
f1 = AMIGA.config.ports[1].fire[0];
f2 = AMIGA.config.ports[1].fire[1];
switch (code) {
case f1: { AMIGA.input.joystick[1].button[0] = down; break; }
case f2: { AMIGA.input.joystick[1].button[1] = down; break; }
case l: { AMIGA.input.joystick[1].state[0] = down; if (down && AMIGA.input.joystick[1].state[2]) AMIGA.input.joystick[1].state[2] = false; break; }
case u: { AMIGA.input.joystick[1].state[1] = down; if (down && AMIGA.input.joystick[1].state[3]) AMIGA.input.joystick[1].state[3] = false; break; }
case r: { AMIGA.input.joystick[1].state[2] = down; if (down && AMIGA.input.joystick[1].state[0]) AMIGA.input.joystick[1].state[0] = false; break; }
case d: { AMIGA.input.joystick[1].state[3] = down; if (down && AMIGA.input.joystick[1].state[1]) AMIGA.input.joystick[1].state[1] = false; break; }
case f1:
{
AMIGA.input.joystick[1].button[0] = down;
break;
}
case f2:
{
AMIGA.input.joystick[1].button[1] = down;
break;
}
case l:
{
AMIGA.input.joystick[1].state[0] = down;
if (down && AMIGA.input.joystick[1].state[2]) AMIGA.input.joystick[1].state[2] = false;
break;
}
case u:
{
AMIGA.input.joystick[1].state[1] = down;
if (down && AMIGA.input.joystick[1].state[3]) AMIGA.input.joystick[1].state[3] = false;
break;
}
case r:
{
AMIGA.input.joystick[1].state[2] = down;
if (down && AMIGA.input.joystick[1].state[0]) AMIGA.input.joystick[1].state[0] = false;
break;
}
case d:
{
AMIGA.input.joystick[1].state[3] = down;
if (down && AMIGA.input.joystick[1].state[1]) AMIGA.input.joystick[1].state[1] = false;
break;
}
}
}
@ -593,22 +689,22 @@ function Keyboard() {
/* map shift-keys (team17 pinball games) */
if (AMIGA.config.keyboard.mapShift) {
switch (code) {
case 37: { //left arrow
var rawkey = RAWKEY_LSHIFT;
case 37:
{ //left arrow
if (!down) {
this.recordKey((rawkey << 1) | 1);
this.recordKey((RAWKEY_LSHIFT << 1) | 1);
} else {
this.recordKey(rawkey << 1);
this.recordKey(RAWKEY_LSHIFT << 1);
}
//break;
return;
}
case 39: { //right arrow
var rawkey = RAWKEY_RSHIFT;
case 39:
{ //right arrow
if (!down) {
this.recordKey((rawkey << 1) | 1);
this.recordKey((RAWKEY_RSHIFT << 1) | 1);
} else {
this.recordKey(rawkey << 1);
this.recordKey(RAWKEY_RSHIFT << 1);
}
//break;
return;
@ -632,7 +728,7 @@ function Keyboard() {
else
this.recordKey((rawkey << 1) | 1);
}
}
};
this.handleKey = function (e, down) {
e = e || window.event;
@ -659,20 +755,21 @@ function Keyboard() {
if (keyState[code] != oldstate) {
this.processKey(code, keyState[code]);
}
}
};
this.setCode = function (keycode) {
code = ~((keycode << 1) | (keycode >> 7)) & 0xff;
}
};
this.keyReq = function() {
this.lostsynccnt = 8 * AMIGA.playfield.maxvpos * 8; /* 8 frames * 8 bits */
this.keyReq = function () {
this.lostsynccnt = 8 * AMIGA.playfield.maxvpos * 8;
/* 8 frames * 8 bits */
//AMIGA.cia.setICR(CIA_A, 8, code);
AMIGA.cia.SetICRA(8, code);
}
};
this.hsync = function() {
this.hsync = function () {
if ((this.keysAvail() || state < 3) && !this.lostsynccnt && ((++hsynccnt) & 15) == 0) {
switch (state) {
case 0:
@ -693,7 +790,7 @@ function Keyboard() {
}
this.keyReq();
}
}
};
this.vsync = function() {
if (this.lostsynccnt > 0) {
@ -719,29 +816,29 @@ function Input() {
count: 0
};
this.setup = function() {
this.setup = function () {
this.keyboard.setup();
}
};
this.cleanup = function() {
this.cleanup = function () {
this.keyboard.cleanup();
}
};
this.reset = function() {
this.reset = function () {
this.mouse.reset();
this.joystick[0].reset();
this.joystick[1].reset();
this.keyboard.reset();
potgo.data = 0;
potgo.count = 0;
}
};
this.POTGO = function (v) {
//BUG.info('Input.POTGO() $%04x', v);
potgo.data = v;
}
};
this.POTGOR = function() {
this.POTGOR = function () {
var v = (potgo.data | (potgo.data << 1)) & 0xaa00;
v |= v >> 1;
@ -758,23 +855,23 @@ function Input() {
}
//BUG.info('Input.POTGOR() $%04x', v);
return v;
}
};
this.POT0DAT = function() {
this.POT0DAT = function () {
if (AMIGA.config.ports[0].type == SAEV_Config_Ports_Type_Mouse) {
if (this.mouse.button[2]) potgo.count = (potgo.count & 0xff00) | ((potgo.count + 1) & 0xff);
if (this.mouse.button[1]) potgo.count = (potgo.count + 0x100) & 0xffff;
}
//BUG.info('Input.POT0DAT() $%04x', v);
return potgo.count;
}
};
this.POT1DAT = function() {
this.POT1DAT = function () {
//BUG.info('Input.POT1DAT() NOT IMPLEMENTED');
return 0xffff;
}
};
this.JOY0DAT = function() {
this.JOY0DAT = function () {
if (AMIGA.config.ports[0].type == SAEV_Config_Ports_Type_Mouse) {
this.mouse.update();
return this.mouse.pos;
@ -783,9 +880,9 @@ function Input() {
return this.joystick[0].dir;
}
return 0xffff;
}
};
this.JOY1DAT = function() {
this.JOY1DAT = function () {
if (AMIGA.config.ports[1].type == SAEV_Config_Ports_Type_Mouse) {
this.mouse.update();
return this.mouse.pos;
@ -794,7 +891,7 @@ function Input() {
return this.joystick[1].dir;
}
return 0xffff;
}
};
this.JOYTEST = function (v) {
//BUG.info('Input.JOYTEST() $%04x', v);

View file

@ -40,7 +40,7 @@ function Memory() {
align: 0,
data: null,
lower: 0,
upper: 0,
upper: 0
};
this.slow = {
enabled: false,
@ -91,11 +91,11 @@ function Memory() {
lower: 0x00E80000,
upper: 0x00E90000
};
this.aros = {
/*this.aros = {
cached: false,
rom: '',
ext: ''
};
};*/
function getChipSize(v) {
switch (v) {
@ -154,10 +154,11 @@ function Memory() {
}
}*/
this.setup = function() {
this.setup = function () {
this.chip.size = getChipSize(AMIGA.config.ram.chip.size);
this.chip.align = this.chip.size >>> 1;
this.chip.data = new Uint16Array(this.chip.align); for (var i = 0; i < this.chip.align; i++) this.chip.data[i] = 0;
this.chip.data = new Uint16Array(this.chip.align);
for (var i = 0; i < this.chip.align; i++) this.chip.data[i] = 0;
this.chip.lower = 0;
this.chip.upper = this.chip.size;
@ -165,7 +166,8 @@ function Memory() {
this.slow.enabled = true;
this.slow.size = getSlowSize(AMIGA.config.ram.slow.size);
this.slow.align = this.slow.size >>> 1;
this.slow.data = new Uint16Array(this.slow.align); for (var i = 0; i < this.slow.align; i++) this.slow.data[i] = 0;
this.slow.data = new Uint16Array(this.slow.align);
for (var i = 0; i < this.slow.align; i++) this.slow.data[i] = 0;
this.slow.upper = this.slow.lower + this.slow.size;
} else {
this.slow.enabled = false;
@ -178,7 +180,8 @@ function Memory() {
this.fast.enabled = true;
this.fast.size = getFastSize(AMIGA.config.ram.fast.size);
this.fast.align = this.fast.size >>> 1;
this.fast.data = new Uint16Array(this.fast.align); for (var i = 0; i < this.fast.align; i++) this.fast.data[i] = 0;
this.fast.data = new Uint16Array(this.fast.align);
for (var i = 0; i < this.fast.align; i++) this.fast.data[i] = 0;
this.fast.upper = this.fast.lower + this.fast.size;
} else {
this.fast.enabled = false;
@ -191,11 +194,15 @@ function Memory() {
this.rom.size = getROMSize(AMIGA.config.rom.size);
this.rom.align = this.rom.size >>> 1;
this.rom.data = new Uint16Array(this.rom.align); for (var i = 0; i < this.rom.align; i++) this.rom.data[i] = 0;
this.rom.data = new Uint16Array(this.rom.align);
for (var i = 0; i < this.rom.align; i++) this.rom.data[i] = 0;
this.res_d8.data = new Uint16Array(this.res_d8.align); for (var i = 0; i < this.res_d8.align; i++) this.res_d8.data[i] = 0;
this.res_e0.data = new Uint16Array(this.res_e0.align); for (var i = 0; i < this.res_e0.align; i++) this.res_e0.data[i] = 0;
this.res_f0.data = new Uint16Array(this.res_f0.align); for (var i = 0; i < this.res_f0.align; i++) this.res_f0.data[i] = 0;
this.res_d8.data = new Uint16Array(this.res_d8.align);
for (var i = 0; i < this.res_d8.align; i++) this.res_d8.data[i] = 0;
this.res_e0.data = new Uint16Array(this.res_e0.align);
for (var i = 0; i < this.res_e0.align; i++) this.res_e0.data[i] = 0;
this.res_f0.data = new Uint16Array(this.res_f0.align);
for (var i = 0; i < this.res_f0.align; i++) this.res_f0.data[i] = 0;
this.copy_rom(AMIGA.config.rom.data);
@ -246,7 +253,7 @@ function Memory() {
});
}
}*/
}
};
this.load8 = function (addr) {
//BUG.info('Memory.load8() addr $%08x', addr);
@ -290,7 +297,7 @@ function Memory() {
//else BUG.info('Memory.load8() ILLEGAL MEMORY ACCESS addr $%08x', addr);
return NULL8;
}
};
this.load16 = function (addr) {
//BUG.info('Memory.load16() addr $%08x', addr);
@ -331,7 +338,7 @@ function Memory() {
//else BUG.info('Memory.load16() ILLEGAL MEMORY ACCESS addr $%08x', addr);
return NULL16;
}
};
this.load32 = function (addr) {
//BUG.info('Memory.load32() addr $%08x', addr);
@ -379,7 +386,7 @@ function Memory() {
//else BUG.info('Memory.load32() ILLEGAL MEMORY ACCESS addr $%08x', addr);
return NULL32;
}
};
this.store8 = function (addr, value) {
//BUG.info('Memory.store8() addr $%08x, val $%02x', addr, value);
@ -454,7 +461,7 @@ function Memory() {
AMIGA.expansion.store8(addr, value);
}
//else BUG.info('Memory.store8() ILLEGAL MEMORY ACCESS addr $%08x, val %02x', addr, value);
}
};
this.store16 = function (addr, value) {
//BUG.info('Memory.store16() addr $%08x, val $%04x', addr, value);
@ -490,7 +497,7 @@ function Memory() {
this.res_d8.data[(addr - this.res_d8.lower) >>> 1] = value;
}
//else BUG.info('Memory.store16() ILLEGAL MEMORY ACCESS addr $%08x, val %04x', addr, value);
}
};
this.store32 = function (addr, value) {
//BUG.info('Memory.store32() addr $%08x, val $%08x', addr, value);
@ -538,11 +545,11 @@ function Memory() {
this.res_d8.data[addr + 1] = value & 0xffff;
}
//else if (!(addr & 0xc80000)) BUG.info('Memory.store32() ILLEGAL MEMORY ACCESS addr $%08x, val %08x', addr, value);
}
};
this.check16_chip = function (addr, size) {
/*this.check16_chip = function (addr, size) {
return (addr >= 0 && addr + size < this.chip.size - 1);
}
};*/
/*this.load16_chip = function (addr) {
if (this.check16_chip(addr, 1)) {
var v = this.chip.data[addr >>> 1];
@ -572,7 +579,7 @@ function Memory() {
AMIGA.custom.last_value = 0xffff;
}*/
this.copy_rom = function(data) {
this.copy_rom = function (data) {
//BUG.info('copyrom() size %d', data.length);
//BUG.info('copyrom() crc32 $%08x', crc32(data));
@ -610,9 +617,9 @@ function Memory() {
}
this.rom.lower = 0xfc0000;
}
}
};
this.copy_e0 = function(data) {
this.copy_e0 = function (data) {
if (data.length <= 0x80000) {
for (var i = 0; i < data.length; i++) {
var v = data.charCodeAt(i) & 0xff;
@ -625,8 +632,8 @@ function Memory() {
}
}
}
}
this.copy_f0 = function(data) {
};
this.copy_f0 = function (data) {
if (data.length <= 0x80000) {
for (var i = 0; i < data.length; i++) {
var v = data.charCodeAt(i) & 0xff;
@ -639,15 +646,10 @@ function Memory() {
}
}
}
}
};
this.mirror_rom_to_chipram = function() {
/*this.mirror_rom_to_chipram = function() {
for (var i = 0; i < this.rom.size; i++)
this.chip.data[i] = this.rom.data[i];
/*if (this.ext.size > 0) {
for (var i = 0; i < this.ext.size; i++)
this.chip.data[this.rom.size + i] = this.ext.data[i];
}*/
}
}

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@ function RTC() {
var rtc_memory = null;
var rtc_alarm = null;
this.read = function() {
this.read = function () {
/*struct zfile *f;
f = zfile_fopen (currprefs.flashfile, "rb", ZFD_NORMAL);
if (f) {
@ -26,8 +26,8 @@ function RTC() {
zfile_fread (rtc_alarm, RF5C01A_RAM_SIZE, 1, f);
zfile_fclose (f);
}*/
}
this.write = function() {
};
this.write = function () {
/*struct zfile *f = zfile_fopen (currprefs.flashfile, L"rb+", ZFD_NORMAL);
if (!f) {
f = zfile_fopen (currprefs.flashfile, L"wb", 0);
@ -45,17 +45,19 @@ function RTC() {
zfile_fwrite (rtc_alarm, RF5C01A_RAM_SIZE, 1, f);
}
zfile_fclose (f);*/
}
};
this.setup = function() {
this.setup = function () {
BUG.info('RTC.setup() type ' + (AMIGA.config.rtc.type == SAEV_Config_RTC_Type_MSM6242B ? 'MSM6242B' : 'RF5C01A'));
if (AMIGA.config.rtc.type == SAEV_Config_RTC_Type_MSM6242B) {
clock_control_d = 0x1;
clock_control_e = 0;
clock_control_f = 0x4; /* 24/12 */
clock_control_f = 0x4;
/* 24/12 */
} else if (AMIGA.config.rtc.type == SAEV_Config_RTC_Type_RF5C01A) {
clock_control_d = 0x4; /* Timer EN */
clock_control_d = 0x4;
/* Timer EN */
clock_control_e = 0;
clock_control_f = 0;
@ -67,7 +69,7 @@ function RTC() {
this.read();
}
}
};
this.load8 = function (addr) {
addr &= 0x3f;
@ -81,22 +83,38 @@ function RTC() {
addr >>= 2;
if (AMIGA.config.rtc.type == SAEV_Config_RTC_Type_MSM6242B) {
switch (addr) {
case 0x0: return t.getSeconds() % 10;
case 0x1: return Math.floor(t.getSeconds() / 10);
case 0x2: return t.getMinutes() % 10;
case 0x3: return Math.floor(t.getMinutes() / 10);
case 0x4: return t.getHours() % 10;
case 0x5: return Math.floor(t.getHours() / 10);
case 0x6: return t.getDate() % 10;
case 0x7: return Math.floor(t.getDate() / 10);
case 0x8: return (t.getMonth() + 1) % 10;
case 0x9: return Math.floor((t.getMonth() + 1) / 10);
case 0xA: return (t.getFullYear() - 1900) % 10;
case 0xB: return Math.floor((t.getFullYear() - 1900) / 10);
case 0xC: return t.getDay();
case 0xD: return clock_control_d;
case 0xE: return clock_control_e;
case 0xF: return clock_control_f;
case 0x0:
return t.getSeconds() % 10;
case 0x1:
return Math.floor(t.getSeconds() / 10);
case 0x2:
return t.getMinutes() % 10;
case 0x3:
return Math.floor(t.getMinutes() / 10);
case 0x4:
return t.getHours() % 10;
case 0x5:
return Math.floor(t.getHours() / 10);
case 0x6:
return t.getDate() % 10;
case 0x7:
return Math.floor(t.getDate() / 10);
case 0x8:
return (t.getMonth() + 1) % 10;
case 0x9:
return Math.floor((t.getMonth() + 1) / 10);
case 0xA:
return (t.getFullYear() - 1900) % 10;
case 0xB:
return Math.floor((t.getFullYear() - 1900) / 10);
case 0xC:
return t.getDay();
case 0xD:
return clock_control_d;
case 0xE:
return clock_control_e;
case 0xF:
return clock_control_f;
}
} else if (AMIGA.config.rtc.type == SAEV_Config_RTC_Type_RF5C01A) {
var bank = clock_control_d & 3;
@ -105,33 +123,47 @@ function RTC() {
if (bank == 1 && addr < 0x0d) return rtc_alarm[addr];
switch (addr) {
case 0x0: return t.getSeconds() % 10;
case 0x1: return Math.floor(t.getSeconds() / 10);
case 0x2: return t.getMinutes() % 10;
case 0x3: return Math.floor(t.getMinutes() / 10);
case 0x4: return t.getHours() % 10;
case 0x5: return Math.floor(t.getHours() / 10);
case 0x6: return t.getDate() % 10;
case 0x7: return Math.floor(t.getDate() / 10);
case 0x8: return (t.getMonth() + 1) % 10;
case 0x9: return Math.floor((t.getMonth() + 1) / 10);
case 0xA: return (t.getFullYear() - 1900) % 10;
case 0xB: return Math.floor((t.getFullYear() - 1900) / 10);
case 0xC: return t.getDay();
case 0xD: return clock_control_d;
case 0x0:
return t.getSeconds() % 10;
case 0x1:
return Math.floor(t.getSeconds() / 10);
case 0x2:
return t.getMinutes() % 10;
case 0x3:
return Math.floor(t.getMinutes() / 10);
case 0x4:
return t.getHours() % 10;
case 0x5:
return Math.floor(t.getHours() / 10);
case 0x6:
return t.getDate() % 10;
case 0x7:
return Math.floor(t.getDate() / 10);
case 0x8:
return (t.getMonth() + 1) % 10;
case 0x9:
return Math.floor((t.getMonth() + 1) / 10);
case 0xA:
return (t.getFullYear() - 1900) % 10;
case 0xB:
return Math.floor((t.getFullYear() - 1900) / 10);
case 0xC:
return t.getDay();
case 0xD:
return clock_control_d;
/* E and F = write-only */
}
}
return 0;
}
};
this.load16 = function (addr) {
return (this.load8(addr) << 8) | this.load8(addr + 1);
}
};
this.load32 = function (addr) {
return ((this.load16(addr) << 16) | this.load16(addr + 2)) >>> 0;
}
};
this.store8 = function (addr, value) {
addr &= 0x3f;
@ -141,9 +173,15 @@ function RTC() {
value &= 0x0f;
if (AMIGA.config.rtc.type == SAEV_Config_RTC_Type_MSM6242B) {
switch (addr) {
case 0xD: clock_control_d = value & (1 | 8); break;
case 0xE: clock_control_e = value; break;
case 0xF: clock_control_f = value; break;
case 0xD:
clock_control_d = value & (1 | 8);
break;
case 0xE:
clock_control_e = value;
break;
case 0xF:
clock_control_f = value;
break;
}
} else if (AMIGA.config.rtc.type == SAEV_Config_RTC_Type_RF5C01A) {
var bank = clock_control_d & 3;
@ -152,7 +190,7 @@ function RTC() {
rtc_memory[addr] &= ((bank == 2) ? 0xf0 : 0x0f);
rtc_memory[addr] |= value << ((bank == 2) ? 0 : 4);
var ov = rtc_memory[addr];
//var ov = rtc_memory[addr];
if (rtc_memory[addr] != value) this.write();
return;
}
@ -166,23 +204,29 @@ function RTC() {
rtc_alarm[10] &= ~0xe;
rtc_alarm[11] &= ~0xc;
var ov = rtc_alarm[addr];
//var ov = rtc_alarm[addr];
if (rtc_alarm[addr] != value) this.write();
return;
}
switch (addr) {
case 0xD: clock_control_d = value; break;
case 0xE: clock_control_e = value; break;
case 0xF: clock_control_f = value; break;
case 0xD:
clock_control_d = value;
break;
case 0xE:
clock_control_e = value;
break;
case 0xF:
clock_control_f = value;
break;
}
}
}
};
this.store16 = function (addr, value) {
this.store8(addr, (value >> 8) & 0xff);
this.store8(addr + 1, value & 0xff);
}
};
this.store32 = function (addr, value) {
this.store16(addr, (value >>> 16) & 0xffff);

View file

@ -14,20 +14,18 @@ function Serial()
var pos = 0, dtr = false;
var serper = 0, serdat = 0x2000;
this.reset = function()
{
this.reset = function () {
this.flushBuffer();
pos = 0;
dtr = false;
serper = 0;
serdat = 0x2000;
}
};
this.flushBuffer = function()
{
this.flushBuffer = function () {
if (pos > 0) {
var str = ''
var str = '';
for (var i = 0; i < pos; i++) {
/*if (buf[i] == 13)
str += '<br/>';
@ -41,32 +39,28 @@ function Serial()
BUG.info(str);
BUG.col = 1;
}
}
};
this.readStatus = function()
{
this.readStatus = function () {
//ciabpra |= 0x20; //Push up Carrier Detect line
//ciabpra |= 0x08; //DSR ON
return 0;
}
};
this.writeStatus = function(old, nw)
{
this.writeStatus = function (old, nw) {
if ((old & 0x80) == 0x80 && (nw & 0x80) == 0x00) dtr = true;
if ((old & 0x80) == 0x00 && (nw & 0x80) == 0x80) dtr = false;
//if ((old & 0x40) != (nw & 0x40)) BUG.info('RTS %s.', (nw & 0x40) == 0x40 ? 'set' : 'clr');
//if ((old & 0x10) != (nw & 0x10)) BUG.info('CTS %s.', (nw & 0x10) == 0x10 ? 'set' : 'clr');
return nw;
}
};
this.SERPER = function(v)
{
this.SERPER = function (v) {
if (serper != v)
serper = v;
}
};
this.SERDAT = function(v)
{
this.SERDAT = function (v) {
//BUG.info('SERDAT $%04x', v);
if (AMIGA.config.serial.enabled) {
@ -74,9 +68,11 @@ function Serial()
if (pos == 1024)
this.flushBuffer();
}
serdat |= 0x2000; /* Set TBE in the SERDATR ... */
AMIGA.intreq |= 1; /* ... and in INTREQ register */
}
serdat |= 0x2000;
/* Set TBE in the SERDATR ... */
AMIGA.intreq |= 1;
/* ... and in INTREQ register */
};
this.SERDATR = function()
{

View file

@ -10,18 +10,18 @@
/* moving average algorithm */
function mavg(size) {
function MAvg(size) {
this.values = new Array(size);
this.size = size;
this.usage = 0;
this.offset = 0;
this.average = 0;
this.clr = function() {
this.clr = function () {
this.usage = 0;
this.offset = 0;
this.average = 0;
}
};
this.set = function(newval) {
if (this.usage < this.size) {
@ -108,14 +108,14 @@ sprintfWrapper = {
var string = arguments[0];
var exp = new RegExp(/(%([%]|(\-)?(\+|\x20)?(0)?(\d+)?(\.(\d)?)?([bcdfosxX])))/g);
var matches = new Array();
var strings = new Array();
var matches = [];
var strings = [];
var convCount = 0;
var stringPosStart = 0;
var stringPosEnd = 0;
var matchPosEnd = 0;
var newString = '';
var match = null;
var match;
while (match = exp.exec(string)) {
if (match[9]) {
@ -135,7 +135,7 @@ sprintfWrapper = {
min: match[6] || 0,
precision: match[8],
code: match[9] || '%',
negative: parseInt(arguments[convCount]) < 0 ? true : false,
negative: !!(parseInt(arguments[convCount]) < 0),
argument: String(arguments[convCount])
};
}
@ -148,11 +148,8 @@ sprintfWrapper = {
return null;
}
var code = null;
var match = null;
var i = null;
for (i = 0; i < matches.length; i++) {
for (var i = 0; i < matches.length; i++) {
var substitution;
if (matches[i].code == '%') {
substitution = '%'
@ -172,7 +169,7 @@ sprintfWrapper = {
matches[i].argument = String(Math.abs(parseInt(matches[i].argument)).toString(8));
substitution = sprintfWrapper.convert(matches[i]);
} else if (matches[i].code == 's') {
matches[i].argument = matches[i].argument.substring(0, matches[i].precision ? matches[i].precision : matches[i].argument.length)
matches[i].argument = matches[i].argument.substring(0, matches[i].precision ? matches[i].precision : matches[i].argument.length);
substitution = sprintfWrapper.convert(matches[i], true);
} else if (matches[i].code == 'x') {
matches[i].argument = String(Math.abs(parseInt(matches[i].argument)).toString(16));
@ -183,7 +180,6 @@ sprintfWrapper = {
} else {
substitution = matches[i].match;
}
newString += strings[i];
newString += substitution;
@ -216,7 +212,7 @@ sprintfWrapper = {
}
}
}
}
};
sprintf = sprintfWrapper.init;
@ -240,10 +236,11 @@ var BrowserDetect = {
if (dataString.indexOf(data[i].subString) != -1) return data[i].identity;
} else if (dataProp) return data[i].identity;
}
return '';
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
if (index == -1) return 0.0;
return parseFloat(dataString.substring(index + this.versionSearchString.length + 1));
},
dataBrowser: [{
@ -323,7 +320,7 @@ BrowserDetect.init();
/*-----------------------------------------------------------------------*/
function dump(obj) {
/*function dump(obj) {
var out = '';
if (obj) {
for (var i in obj) {
@ -333,7 +330,7 @@ function dump(obj) {
out = 'undefined';
alert(out);
}
}*/
/*-----------------------------------------------------------------------*/
@ -396,7 +393,7 @@ function loadRemote(file, crc, callback) {
/*-----------------------------------------------------------------------*/
function Debug() {
this.col = 1;
//this.col = 1;
this.on = 1;
this.say = function (str) {
@ -414,7 +411,7 @@ function Debug() {
console.error(str);
console.assert(str);*/
}
}
};
this.info = function () {
if (this.on) {
@ -426,16 +423,16 @@ function Debug() {
/*-----------------------------------------------------------------------*/
function Uint64(hi, lo) {
/*function Uint64(hi, lo) {
this.hi = hi;
this.lo = lo;
this.or = function(v) {
this.or = function (v) {
this.hi = (this.hi | v.hi) >>> 0;
this.lo = (this.lo | v.lo) >>> 0;
}
};
this.lshift = function(n) {
this.lshift = function (n) {
if (n) {
if (n < 32) {
var m = Math.pow(2, n) - 1;
@ -446,15 +443,15 @@ function Uint64(hi, lo) {
//BUG.info('lshift %d %x', n, m, t);
} else {
var t = this.lo;
this.hi = (t << (n-32)) >>> 0;
this.hi = (t << (n - 32)) >>> 0;
this.lo = 0;
//BUG.info('lshift %d %x', n, t);
}
}
}
};
this.rshift = function(n) {
this.rshift = function (n) {
if (n) {
if (n < 32) {
var m = Math.pow(2, n) - 1;
@ -466,16 +463,16 @@ function Uint64(hi, lo) {
} else {
var t = this.hi;
this.hi = 0;
this.lo = (t >>> (n-32)) >>> 0;
this.lo = (t >>> (n - 32)) >>> 0;
//BUG.info('rshift %d %x %x', n, t);
}
}
}
};
this.print = function() {
BUG.info('$%08x%08x', this.hi, this.lo);
}
}
}*/

View file

@ -60,7 +60,6 @@ function Vide0() {
this.available |= SAEI_Video_Canvas2D;
test2 = null;
}
test = null;
}
test = document.createElement('canvas');
if (test && test.getContext) {
@ -143,13 +142,13 @@ function Vide0() {
ctx.colorMask(true, true, true, false);
}
this.setup = function() {
this.setup = function () {
if (!AMIGA.config.video.enabled) return;
if (open) this.cleanup();
div = document.getElementById(AMIGA.config.video.id);
if (!div)
Fatal(SAEE_Video_ID_Not_Found, 'Video DIV-element not found. Check your code. (Malformed-DIV-name: '+AMIGA.config.video.id+')');
Fatal(SAEE_Video_ID_Not_Found, 'Video DIV-element not found. Check your code. (Malformed-DIV-name: ' + AMIGA.config.video.id + ')');
scale = (this.available & SAEI_Video_WebGL) ? AMIGA.config.video.scale : false;
width = VIDEO_WIDTH << (scale ? 1 : 0);
@ -161,13 +160,25 @@ function Vide0() {
canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
canvas.oncontextmenu = function() { return false; }
canvas.oncontextmenu = function () {
return false;
};
if (AMIGA.config.ports[0].type == SAEV_Config_Ports_Type_Mouse) {
canvas.onmousedown = function(e) { AMIGA.input.mouse.mousedown(e); }
canvas.onmouseup = function(e) { AMIGA.input.mouse.mouseup(e); }
canvas.onmouseover = function(e) { AMIGA.input.mouse.mouseover(e); }
canvas.onmouseout = function(e) { AMIGA.input.mouse.mouseout(e); }
canvas.onmousemove = function(e) { AMIGA.input.mouse.mousemove(e); }
canvas.onmousedown = function (e) {
AMIGA.input.mouse.mousedown(e);
};
canvas.onmouseup = function (e) {
AMIGA.input.mouse.mouseup(e);
};
canvas.onmouseover = function (e) {
AMIGA.input.mouse.mouseover(e);
};
canvas.onmouseout = function (e) {
AMIGA.input.mouse.mouseout(e);
};
canvas.onmousemove = function (e) {
AMIGA.input.mouse.mousemove(e);
}
}
if (this.available & SAEI_Video_WebGL) {
ctx = canvas.getContext('experimental-webgl', glParams) || canvas.getContext('webgl', glParams);
@ -175,7 +186,7 @@ function Vide0() {
pixels = new Uint16Array(size);
for (var i = 0; i < size; i++) pixels[i] = 0;
this.drawpixel = drawpixel_gl;
//this.drawpixel = drawpixel_gl;
this.drawline = drawline_gl;
this.render = render_gl;
this.show = show_gl;
@ -184,7 +195,7 @@ function Vide0() {
imagedata = ctx.createImageData(width, height);
pixels = imagedata.data;
this.drawpixel = drawpixel_2d;
//this.drawpixel = drawpixel_2d;
this.drawline = drawline_2d;
this.render = render_2d;
this.show = show_2d;
@ -211,9 +222,9 @@ function Vide0() {
div.appendChild(video);
open = true;
}
};
this.cleanup = function() {
this.cleanup = function () {
if (open) {
div.removeChild(video);
canvas = null;
@ -222,13 +233,13 @@ function Vide0() {
video = null;
open = false;
}
}
};
/*---------------------------------*/
this.hideCursor = function(hide) {
/*this.hideCursor = function (hide) {
canvas.style.cursor = hide ? 'none' : 'auto';
}
};*/
/*this.clear_pixels = function () {
for (var i = 0; i < size; i++)
@ -238,9 +249,9 @@ function Vide0() {
/*---------------------------------*/
/* Canvas 2D */
function drawpixel_2d(x, y, rgb) {
/*function drawpixel_2d(x, y, rgb) {
pixels[y * width + x] = rgb;
}
}*/
function drawline_2d(y, data, offs) {
var yoffs = (y * width) << 2;
@ -261,9 +272,9 @@ function Vide0() {
/*---------------------------------*/
/* WebGL */
function drawpixel_gl(x, y, rgb) {
/*function drawpixel_gl(x, y, rgb) {
pixels[y * width + x] = rgb;
}
}*/
function drawline_gl(y, data, offs) {
var yoffs = y * width;