Refactoring.

This commit is contained in:
Will Scullin 2017-09-22 21:42:57 -07:00
parent 8a8db4015c
commit 37a3fb9bcd
18 changed files with 1734 additions and 681 deletions

View File

@ -47,15 +47,16 @@
<script type="text/javascript" src="js/util.js"></script>
<script type="text/javascript" src="js/prefs.js"></script>
<script type="text/javascript" src="js/ram.js"></script>
<script type="text/javascript" src="js/langcard.js"></script>
<script type="text/javascript" src="js/applesoft/decompiler.js"></script>
<script type="text/javascript" src="js/intbasic/decompiler.js"></script>
<script type="text/javascript" src="js/canvas2.js"></script>
<script type="text/javascript" src="js/apple2io.js"></script>
<script type="text/javascript" src="js/parallel.js"></script>
<script type="text/javascript" src="js/disk2.js"></script>
<script type="text/javascript" src="js/ramfactor.js"></script>
<script type="text/javascript" src="js/thunderclock.js"></script>
<script type="text/javascript" src="js/cards/langcard.js"></script>
<script type="text/javascript" src="js/cards/parallel.js"></script>
<script type="text/javascript" src="js/cards/videoterm.js"></script>
<script type="text/javascript" src="js/cards/disk2.js"></script>
<script type="text/javascript" src="js/cards/ramfactor.js"></script>
<script type="text/javascript" src="js/cards/thunderclock.js"></script>
<script type="text/javascript" src="js/cpu6502.js"></script>
<script type="text/javascript" src="js/base64.js"></script>
<script type="text/javascript" src="js/roms/fpbasic.js"></script>
@ -63,32 +64,28 @@
<script type="text/javascript" src="js/roms/original.js"></script>
<script type="text/javascript" src="js/roms/apple2_char.js"></script>
<script type="text/javascript" src="js/ui/audio.js"></script>
<script type="text/javascript" src="js/ui/keyboard2.js"></script>
<script type="text/javascript" src="js/ui/keyboard.js"></script>
<script type="text/javascript" src="js/ui/gamepad.js"></script>
<script type="text/javascript" src="js/ui/printer.js"></script>
<!-- Disk Index -->
<script type="text/javascript" src="json/disks/index.js"></script>
<script type="text/javascript" src="js/main2.js"></script>
</head>
<body>
<div style="margin: auto; width: 604px">
<a href="http://www.w3.org/html/logo/"><img src="http://www.w3.org/html/logo/badge/html5-badge-h-solo.png" width="63" height="64" alt="HTML5 Powered" title="HTML5 Powered" style="float: right"></a>
<a href="about.html" target="_blank">
<img src="img/badge.png" id="badge" />
</a>
<h1 id="subtitle">An Apple ][ Emulator in JavaScript</h1>
<table id="display">
<tr>
<td style="vertical-align: top">
<div class="overscan">
<canvas id="screen" width="560" height="384"></canvas>
</div>
</td>
</tr>
</table>
<div id="header">
<a href="http://www.w3.org/html/logo/"><img src="http://www.w3.org/html/logo/badge/html5-badge-h-solo.png" width="63" height="64" alt="HTML5 Powered" title="HTML5 Powered" style="float: right"></a>
<a href="about.html" target="_blank">
<img src="img/badge.png" id="badge" />
</a>
<h1 id="subtitle">An Apple ][ Emulator in JavaScript</h1>
</div>
<div id="display">
<div class="overscan">
<canvas id="screen" width="560" height="384"></canvas>
</div>
</div>
<div class="inset">
<div style="float: left; width: 50%">
<div class="disk" id="disk1">&nbsp;</div>
@ -128,12 +125,38 @@
</div>
<div class="inset">
<div id="keyboard"></div>
<div id="textarea" style="display: none">
<button onclick="io.keyDown(0x1b)">
ESC
</button>
<button onclick="reset()" style="float: right; margin-left: 10px">
Reset
</button>
<button onclick="io.keyDown(0x15)" style="float: right">
&rarr;
</button>
<button onclick="io.keyDown(0x08)" style="float: right">
&larr;
</button>
<label for="text_input">Text Input</label>
<textarea rows="10" style="width: 99%" id="text_input"></textarea>
<br />
<button onclick="io.setKeyBuffer($('#text_input').val())">
Send
</button>
<input type="checkbox" id="buffering" />
<label for="buffering">Buffer</label>
<button style="float: right"
onclick="$('#keyboard').show(); $('#textarea').hide()">
Keyboard
</button>
</div>
</div>
</div>
<div id="loading" title="Loading">
<div id="loading" title="Loading" style="display: none">
Loading...
</div>
<div id="options" title="Options">
<div id="options" title="Options" style="display: none">
<h3>CPU</h3>
<ul>
<li>
@ -141,7 +164,7 @@
<option value="apple2plus">Apple ][+</option>
<option value="apple2">Autostart Apple ][</option>
<option value="original">Apple ][</option>
<select>
</select>
<label for="computer_type">
Type
</label>
@ -212,9 +235,9 @@
</li>
</ul>
</div>
<div id="save" title="Save Disk">
<div id="save" title="Save Disk" style="display: none">
<form action="#" onsubmit="return false;">
<b>Save to Browser</a>
<b>Save to Browser</b>
<br /><br />
Save Name: <input type="text" name="name" id="save_name"
style="width: 200px" />
@ -226,14 +249,14 @@
<a id="local_save_link" class="button">Download</a>
</div>
</div>
<div id="manage" title="Manage Disks">
<div id="manage" title="Manage Disks" style="display: none">
</div>
<div id="http_load" title="Load URL">
<div id="http_load" title="Load URL" style="display: none">
<form action="#">
<input type="text" id="http_url" style="width: 500px"/>
</form>
</div>
<div id="load" title="Load Disk">
<div id="load" title="Load Disk" style="display: none">
<table>
<tr>
<td>
@ -255,5 +278,6 @@
<input type="file" id="local_file" />
</form>
</div>
<script type="text/javascript" src="js/main2.js"></script>
</body>
</html>

View File

@ -52,43 +52,41 @@
<script type="text/javascript" src="js/intbasic/decompiler.js"></script>
<script type="text/javascript" src="js/canvas2e.js"></script>
<script type="text/javascript" src="js/apple2io.js"></script>
<script type="text/javascript" src="js/parallel.js"></script>
<script type="text/javascript" src="js/disk2.js"></script>
<script type="text/javascript" src="js/ramfactor.js"></script>
<script type="text/javascript" src="js/thunderclock.js"></script>
<script type="text/javascript" src="js/cards/parallel.js"></script>
<script type="text/javascript" src="js/cards/disk2.js"></script>
<script type="text/javascript" src="js/cards/ramfactor.js"></script>
<script type="text/javascript" src="js/cards/thunderclock.js"></script>
<script type="text/javascript" src="js/cpu6502.js"></script>
<script type="text/javascript" src="js/base64.js"></script>
<script type="text/javascript" src="js/roms/apple2e.js"></script>
<script type="text/javascript" src="js/roms/apple2enh.js"></script>
<script type="text/javascript" src="js/roms/apple2e_char.js"></script>
<script type="text/javascript" src="js/roms/apple2enh_char.js"></script>
<script type="text/javascript" src="js/ui/audio.js"></script>
<script type="text/javascript" src="js/ui/keyboard2e.js"></script>
<script type="text/javascript" src="js/ui/keyboard.js"></script>
<script type="text/javascript" src="js/ui/gamepad.js"></script>
<script type="text/javascript" src="js/ui/printer.js"></script>
<!-- Disk Index -->
<script type="text/javascript" src="json/disks/index.js"></script>
<script type="text/javascript" src="js/main2e.js"></script>
</head>
<body class="apple2e">
<div style="margin: auto; width: 604px">
<a href="http://www.w3.org/html/logo/"><img src="http://www.w3.org/html/logo/badge/html5-badge-h-solo.png" width="63" height="64" alt="HTML5 Powered" title="HTML5 Powered" style="float: right"></a>
<a href="about.html" target="_blank">
<img src="img/badge.png" id="badge" />
</a>
<h1 id="subtitle">An Apple //e Emulator in JavaScript</h1>
<table id="display">
<tr>
<td style="vertical-align: top">
<div role="textbox" class="overscan"
onKeyDown="_keydown(event);"
onKeyUp="_keyup(event);">
<canvas id="screen" width="560" height="384"></canvas>
</div>
</td>
</tr>
</table>
<div id="header">
<a href="http://www.w3.org/html/logo/"><img src="http://www.w3.org/html/logo/badge/html5-badge-h-solo.png" width="63" height="64" alt="HTML5 Powered" title="HTML5 Powered" style="float: right"></a>
<a href="about.html" target="_blank">
<img src="img/badge.png" id="badge" />
</a>
<h1 id="subtitle">An Apple //e Emulator in JavaScript</h1>
</div>
<div id="display">
<div class="overscan"
onkeydown="_keydown(event);"
onkeyup="_keyup(event);">
<canvas id="screen" width="560" height="384"></canvas>
</div>
</div>
<div class="inset">
<div style="float: left; width: 50%">
<div class="disk" id="disk1">&nbsp;</div>
@ -143,7 +141,7 @@
<select id="computer_type" value="apple2enh" onchange="updateCPU()">
<option value="apple2enh">Enhanced Apple //e</option>
<option value="apple2e">Apple //e</option>
<select>
</select>
<label for="computer_type">
Type
</label>
@ -216,7 +214,7 @@
</div>
<div id="save" title="Save Disk">
<form action="#" onsubmit="return false;">
<b>Save to Browser</a>
<b>Save to Browser</b>
<br /><br />
Save Name: <input type="text" name="name" id="save_name"
style="width: 200px" />
@ -257,5 +255,6 @@
<input type="file" id="local_file" />
</form>
</div>
<script type="text/javascript" src="js/main2e.js"></script>
</body>
</html>

View File

@ -1,22 +1,36 @@
/* Copyright 2010-2016 Will Scullin */
#header {
width: 580px;
margin: auto;
}
.motter {
font-family: "Motter Tektura";
}
.clear {
clear: both
}
.disklabel {
color: #000;
font-weight: bold;
vertical-align: middle;
margin-right: 0.5em;
}
img {
border: none;
}
img#badge {
padding: 0px 12px;
#badge {
cursor: pointer;
}
h1#subtitle {
margin: 0px;
padding: 3px 0px 0px 10px;
#subtitle {
margin: 0;
padding: 3px 0 0 10;
color: black;
font-family: "Adobe Garamond Pro",Garamond,Times;
font-size: 13px;
@ -37,10 +51,19 @@ input[type="text"] {
}
body {
margin: 16px 0px;
margin: 16px 0;
font-size: 10px;
background-color: #c4c1a0; /* Pantone 453 */
color: #fff;
font-family: sans-serif;
}
.outer {
margin: auto;
width: 620px;
}
label {
font-weight: bold;
}
#display {
@ -86,8 +109,8 @@ body {
white-space: pre;
}
table.debug_page {
padding: 0px;
.debug_page {
padding: 0;
font-family: Courier;
font-size: 10px;
border-collapse: collapse;
@ -102,16 +125,12 @@ th {
border-radius: 6px;
border: 3px inset #f0edd0;
padding: 6px;
margin: 10px 0px;
}
#speed {
margin: 9px 0px;
width: 200px;
margin: 10px 0;
}
#khz {
margin-right: 4px;
overflow: hidden;
padding: 4px;
float: left;
font-family: Courier;
@ -126,78 +145,27 @@ th {
}
canvas {
position: absolute;
top: 16px;
left: 16px;
display: block;
float: left;
}
#screen {
cursor: crosshair;
width: 560px;
height: 384px;
image-rendering: -moz-crisp-edges;
image-rendering: -webkit-optimize-contrast;
image-rendering: optimize-contrast;
-moz-image-rendering: -moz-crisp-edges;
-webkit-image-rendering: -webkit-optimize-contrast;
image-rendering: optimizeSpeed;
}
@media all and (device-width: 320px) {
canvas {
width: 537px;
height: 368px;
left: 30px;
top: 24px;
}
}
@media all and (device-width: 768px) {
canvas {
width: 564px;
height: 386px;
left: 14px;
top: 15px;
}
}
:-webkit-full-screen {
#screen:-webkit-full-screen {
top: 0;
left: 0;
width: 100%;
height: 100%;
}
/*
@media screen and (min-device-width:1120px) {
:-webkit-full-screen {
background: #000;
}
:-moz-full-screen .overscan {
border: 0px none !important;
width: 1120px;
height: 768px;
margin: auto;
}
:-webkit-full-screen .overscan {
border: 0px none !important;
width: 1120px;
height: 768px;
}
:-moz-full-screen canvas {
width: 1120px;
height: 768px;
}
:-webkit-full-screen canvas {
width: 1120px;
height: 768px;
}
}
*/
#about iframe {
border: 1px inset #666;
width: 99%;
height: 99%;
}
#about {
padding: 16px;
margin: 0px;
margin: 0;
font-family: "Adobe Garamond Pro",Garamond,Times;
font-size: 14px;
background-color: #fff;
@ -214,37 +182,10 @@ canvas {
height: 300px;
}
.apple2e #controls {
width: calc(100% - 70px)
}
.apple2e #reset {
position: absolute;
right: 0; top: 0;
background: #44372C;
border: 3px outset #66594E;
border-radius: 3px;
color: white;
font: 9px Helvetica;
height: 42px;
padding: 0;
width: 42px;
}
.apple2e #reset:hover {
background: #44372C;
border: 3px outset #66594E;
}
.apple2e #reset:active {
background: #22150A;
border: 5px outset #44372C;
}
#keyboard .row {
display: block;
margin: 0px;
padding: 0px;
margin: 0;
padding: 0;
height: 42px;
font-family: Helvetica;
width: 570px;
@ -254,14 +195,6 @@ canvas {
width: 610px;
}
#keyboard {
margin: 0px 10px;
}
.apple2e #keyboard {
margin: 0px;
}
#keyboard .row0 {
margin-left: 20px;
}
@ -279,31 +212,30 @@ canvas {
}
.apple2e #keyboard .row0 {
margin-left: 0px;
margin-left: 0;
}
.apple2e #keyboard .row2 {
margin-left: 0px;
margin-left: 0;
}
.apple2e #keyboard .row3 {
margin-left: 0px;
margin-left: 0;
}
.apple2e #keyboard .row4 {
margin-left: 0px;
margin-left: 0;
}
#keyboard .key {
display: block;
float: left;
margin: 0px;
padding: 0px;
margin: 0;
padding: 0;
width: 32px;
height: 32px;
background-color: #44372C;
color: white;
vertical-align: bottom;
text-align: center;
position: relative;
border: 5px outset #66594E;
@ -319,7 +251,7 @@ canvas {
#keyboard .key div {
border-radius: 3px;
position: absolute;
bottom: 0px;
bottom: 0;
width: 100%;
text-align: center;
}
@ -333,10 +265,10 @@ canvas {
}
#keyboard .key span {
font-size: 14px;
font-size: 13px;
}
#keyboard .key span.small {
#keyboard .key .small {
font-size: 7px;
}
@ -378,7 +310,7 @@ canvas {
width: 330px;
}
.apple2e table#display {
.apple2e #display {
margin: 5px;
}
@ -399,7 +331,7 @@ canvas {
}
.apple2e #keyboard .key-nbsp {
margin-left: 0px;
margin-left: 0;
width: 215px;
}
@ -433,6 +365,41 @@ canvas {
display: none;
}
#keyboard .key-M div span:first-child {
display: none;
}
.apple2e #keyboard .key-M div span:first-child {
display: inline;
}
.apple2e #controls {
width: calc(100% - 70px)
}
.apple2e #reset {
position: absolute;
right: 0; top: 0;
background: #44372C;
border: 3px outset #66594E;
border-radius: 3px;
color: white;
font: 9px Helvetica;
height: 42px;
padding: 0;
width: 42px;
}
.apple2e #reset:hover {
background: #44372C;
border: 3px outset #66594E;
}
.apple2e #reset:active {
background: #22150A;
border: 5px outset #44372C;
}
#keyboard .key-OPEN_APPLE.active div {
background-image: url(../img/open-apple24-green.png);
}
@ -452,3 +419,25 @@ canvas {
#keyboard .key-CLOSED_APPLE span {
display: none;
}
.standalone {
position: fixed;
width: 100%;
}
.standalone #header, .standalone #social {
display: none;
}
#textarea textarea {
font-family: courier;
}
#options {
line-height: 1.75em;
height: auto !important;
}
#options li {
list-style-type: none;
}

View File

@ -41,6 +41,7 @@ function Apple2IO(cpu, callbacks)
var _audioListener = null;
var _trigger = 0;
var _annunciators = [false, false, false, false];
var _tape = [];
var _tapeOffset = 0;
@ -91,7 +92,8 @@ function Apple2IO(cpu, callbacks)
PDLTRIG: 0x70, // trigger paddles
BANK: 0x73, // Back switched RAM card bank
SETIOUDIS:0x7E, // Enable double hires
CLRIOUDIS:0x7F // Disable double hires
CLRIOUDIS:0x7F, // Disable double hires
RDDHIRES: 0x7F // Read double hires status
};
function _debug() {
@ -198,36 +200,36 @@ function Apple2IO(cpu, callbacks)
break;
case LOC.SETAN0:
_debug('Annunciator 0 on');
if ('annunciator' in callbacks) callbacks.annunicator(0, true);
_annunciators[0] = true;
break;
case LOC.SETAN1:
_debug('Annunciator 1 on');
if ('annunciator' in callbacks) callbacks.annunicator(1, true);
_annunciators[1] = true;
break;
case LOC.SETAN2:
_debug('Annunciator 2 on');
if ('annunciator' in callbacks) callbacks.annunicator(2, true);
_annunciators[2] = true;
break;
case LOC.SETAN3:
_debug('Annunciator 3 on');
if ('annunciator' in callbacks) callbacks.annunicator(3, true);
_annunciators[3] = true;
if ('doublehires' in callbacks) callbacks.doublehires(false);
break;
case LOC.CLRAN0:
_debug('Annunciator 0 off');
if ('annunciator' in callbacks) callbacks.annunicator(0, false);
_annunciators[0] = false;
break;
case LOC.CLRAN1:
_debug('Annunciator 1 off');
if ('annunciator' in callbacks) callbacks.annunicator(1, false);
_annunciators[1] = false;
break;
case LOC.CLRAN2:
_debug('Annunciator 2 off');
if ('annunciator' in callbacks) callbacks.annunicator(2, false);
_annunciators[2] = false;
break;
case LOC.CLRAN3:
_debug('Annunciator 3 off');
if ('annunciator' in callbacks) callbacks.annunicator(3, false);
_annunciators[3] = false;
if ('doublehires' in callbacks) callbacks.doublehires(true);
break;
case LOC.SPEAKER:
@ -273,6 +275,11 @@ function Apple2IO(cpu, callbacks)
case LOC.PDLTRIG:
_trigger = cpu.cycles();
break;
case LOC.RDDHIRES:
if ('isDoubleHires' in callbacks) {
result = callbacks.isDoubleHires() ? 0x80 : 0x0;
}
break;
case LOC.TAPEIN:
// var flipped = false;
if (_tapeOffset == -1) {
@ -474,6 +481,10 @@ function Apple2IO(cpu, callbacks)
addSampleListener: function addSampleListener(cb) {
_audioListener = cb;
},
annunciator: function annunciator(idx) {
return _annunciators[idx];
}
};
}

View File

@ -17,9 +17,8 @@ var textMode = true;
var mixedMode = true;
var hiresMode = false;
var pageMode = 1;
var pages = [];
var context = null;
var scanlines = false;
var multiScreen = false;
/****************************************************************************
*
@ -27,7 +26,7 @@ var scanlines = false;
*
***************************************************************************/
function LoresPage(page, charset)
function LoresPage(page, charset, context)
{
'use strict';
@ -36,6 +35,7 @@ function LoresPage(page, charset)
// $80-$FF normal
var _page = page;
var _imageData;
var _buffer = [];
var _refreshing = false;
var _greenMode = false;
@ -65,11 +65,12 @@ function LoresPage(page, charset)
];
function _init() {
_buffer = allocMemPages(0x4);
for (var idx = 0; idx < 0x400; idx++) {
_buffer[idx] = 0;
var idx;
_imageData = context.createImageData(560, 384);
for (idx = 0; idx < 560 * 384 * 4; idx++) {
_imageData.data[idx] = 0xff;
}
_buffer = allocMemPages(0x4);
}
function _drawPixel(data, off, color) {
@ -139,13 +140,10 @@ function LoresPage(page, charset)
var row = ab | cd | e, color, idx, jdx, b;
if ((row < 24) && (col < 40)) {
if (!textMode && hiresMode && !(mixedMode && row > 19))
return;
var data = pages[_page].data, fore, back;
var data = _imageData.data, fore, back;
off = (col * 14 + row * 560 * 8 * 2) * 4;
if (textMode || (mixedMode && row > 19)) {
if (textMode || hiresMode || (mixedMode && row > 19)) {
if (val & 0x80 || ((val & 0x40) && _blink)) {
fore = _greenMode ? _green : _white;
back = _black;
@ -221,8 +219,12 @@ function LoresPage(page, charset)
_greenMode = on;
this.refresh();
},
blit: function() {
context.putImageData(pages[_page], 0, 0);
blit: function(mixed) {
if (mixed) {
context.putImageData(_imageData, 0, 0, 0, 320, 560, 64);
} else {
context.putImageData(_imageData, 0, 0, 0, 0, 560, 384);
}
},
getState: function() {
return {
@ -241,9 +243,10 @@ function LoresPage(page, charset)
};
}
function HiresPage(page)
function HiresPage(page, context)
{
var _page = page;
var _imageData;
var orangeCol = [0xff, 0x65, 0x00];
var greenCol = [0x00, 0xff, 0x00];
@ -259,10 +262,12 @@ function HiresPage(page)
var _greenMode = false;
function _init() {
var idx;
_imageData = context.createImageData(560, 384);
for (idx = 0; idx < 560 * 384 * 4; idx++) {
_imageData.data[idx] = 0xff;
}
_buffer = allocMemPages(0x20);
for (var idx = 0; idx < 0x2000; idx++)
_buffer[idx] = 0; // Math.floor(Math.random()*256);
}
function _drawPixel(data, off, color) {
@ -317,10 +322,7 @@ function HiresPage(page)
rowb = base >> 10;
if ((rowa < 24) && (col < 40)) {
if (textMode || !hiresMode || (mixedMode && rowa > 19))
return;
var data = pages[_page].data,
var data = _imageData.data,
dy = rowa * 8 + rowb,
dx = col * 14 - 2,
b0 = col > 0 ? _buffer[base - 1] : 0,
@ -380,8 +382,12 @@ function HiresPage(page)
_greenMode = on;
this.refresh();
},
blit: function() {
context.putImageData(pages[_page], 0, 0);
blit: function(mixed) {
if (mixed) {
context.putImageData(_imageData, 0, 0, 0, 0, 560, 320);
} else {
context.putImageData(_imageData, 0, 0, 0, 0, 560, 384);
}
},
getState: function() {
return {
@ -439,21 +445,23 @@ function VideoModes(gr,hgr,gr2,hgr2) {
page: function(pageNo) {
pageMode = pageNo;
},
setContext: function(c) {
context = c;
pages[1] = context.createImageData(560, 384);
pages[2] = context.createImageData(560, 384);
for (var idx = 0; idx < 560 * 384 * 4; idx++) {
pages[1].data[idx] = 0xff;
pages[2].data[idx] = 0xff;
}
},
blit: function() {
if (hiresMode && !textMode) {
_hgrs[pageMode - 1].blit();
if (multiScreen) {
_grs[0].blit();
_grs[1].blit();
_hgrs[0].blit();
_hgrs[1].blit();
} else {
_grs[pageMode - 1].blit();
if (hiresMode && !textMode) {
if (mixedMode) {
_grs[pageMode - 1].blit(true);
_hgrs[pageMode - 1].blit(true);
} else {
_hgrs[pageMode - 1].blit();
}
} else {
_grs[pageMode - 1].blit();
}
}
},
getState: function() {

View File

@ -12,8 +12,9 @@
/*globals allocMemPages: false, debug: false,
base64_encode: false, base64_decode: false,
enhanced: false */
/*exported LoresPage, HiresPage, VideoModes */
/*exported LoresPage, HiresPage, VideoModes, scanlines, multiScreen */
var multiScreen = false;
var textMode = true;
var mixedMode = false;
var hiresMode = false;
@ -27,8 +28,6 @@ var mixedDHRMode = false;
var highColorHGRMode = false;
var highColorTextMode = false;
var pages = [];
var context = null;
var scanlines = false;
/****************************************************************************
@ -37,7 +36,7 @@ var scanlines = false;
*
***************************************************************************/
function LoresPage(page, charset)
function LoresPage(page, charset, context)
{
'use strict';
@ -46,6 +45,7 @@ function LoresPage(page, charset)
// $80-$FF normal
var _page = page;
var _imageData;
var _buffer = [];
var _refreshing = false;
var _greenMode = false;
@ -75,13 +75,13 @@ function LoresPage(page, charset)
];
function _init() {
var idx;
_imageData = context.createImageData(560, 384);
for (idx = 0; idx < 560 * 384 * 4; idx++) {
_imageData.data[idx] = 0xff;
}
_buffer[0] = allocMemPages(0x4);
_buffer[1] = allocMemPages(0x4);
for (var idx = 0; idx < 0x400; idx++) {
_buffer[0][idx] = 0; // idx & 0x2 ? 0xff : 0x00;
_buffer[1][idx] = 0; // idx & 0x2 ? 0xff : 0x00;
}
}
function _drawPixel(data, off, color) {
@ -178,8 +178,9 @@ function LoresPage(page, charset)
base = addr - 0x400 * _page,
fore, back;
if (_buffer[bank][base] == val && !_refreshing)
if (_buffer[bank][base] == val && !_refreshing) {
return;
}
_buffer[bank][base] = val;
var col = (base % 0x80) % 0x28,
@ -193,13 +194,10 @@ function LoresPage(page, charset)
var row = ab | cd | e;
var b;
var data = pages[_page].data;
var data = _imageData.data;
if ((row < 24) && (col < 40)) {
if (!textMode && hiresMode && !(mixedMode && row > 19))
return;
var color;
if (textMode || (mixedMode && row > 19)) {
if (textMode || hiresMode || (mixedMode && row > 19)) {
var flash = ((val & 0xc0) == 0x40) &&
_blink && !_80colMode && !altCharMode;
fore = flash ? _black : (_greenMode ? _green : _white);
@ -236,8 +234,8 @@ function LoresPage(page, charset)
off = (col * 14 + row * 560 * 8 * 2) * 4;
if (highColorTextMode) {
fore = _colors[_buffer[0][base] >> 4];
back = _colors[_buffer[0][base] & 0x0f];
fore = _colors[_buffer[1][base] >> 4];
back = _colors[_buffer[1][base] & 0x0f];
}
for (jdx = 0; jdx < 8; jdx++) {
@ -327,8 +325,9 @@ function LoresPage(page, charset)
_refreshing = true;
for (var idx = 0; idx < 0x400; idx++, addr++) {
this._write(addr >> 8, addr & 0xff, _buffer[0][idx], 0);
if (_80colMode)
if (_80colMode) {
this._write(addr >> 8, addr & 0xff, _buffer[1][idx], 1);
}
}
_refreshing = false;
},
@ -349,15 +348,21 @@ function LoresPage(page, charset)
_greenMode = on;
this.refresh();
},
blit: function() {
context.putImageData(pages[_page], 0, 0);
blit: function(mixed) {
if (mixed) {
context.putImageData(_imageData, 0, 0, 0, 320, 560, 64);
} else {
context.putImageData(_imageData, 0, 0, 0, 0, 560, 384);
}
},
getState: function() {
return {
page: _page,
green: _greenMode,
buffer: [base64_encode(_buffer[0]),
base64_encode(_buffer[1])]
buffer: [
base64_encode(_buffer[0]),
base64_encode(_buffer[1])
]
};
},
setState: function(state) {
@ -377,31 +382,34 @@ function LoresPage(page, charset)
*
***************************************************************************/
function HiresPage(page)
function HiresPage(page, context)
{
'use strict';
var _page = page;
var _imageData;
var r4 = [0, // Black
2, // Dark Blue
4, // Dark Green
6, // Medium Blue
var r4 = [
0, // Black
2, // Dark Blue
4, // Dark Green
6, // Medium Blue
8, // Brown
5, // Gray 1
12, // Light Green
14, // Aqua
8, // Brown
5, // Gray 1
12, // Light Green
14, // Aqua
1, // Red
3, // Purple
10, // Gray 2
7, // Pink
1, // Red
3, // Purple
10, // Gray 2
7, // Pink
9, // Orange
11, // Light Blue
13, // Yellow
15]; // White
9, // Orange
11, // Light Blue
13, // Yellow
15 // White
];
var dcolors = [
[0x00,0x00,0x00], // black
@ -437,12 +445,13 @@ function HiresPage(page)
var _green = [0x00, 0xff, 0x80];
function _init() {
var idx;
_imageData = context.createImageData(560, 384);
for (idx = 0; idx < 560 * 384 * 4; idx++) {
_imageData.data[idx] = 0xff;
}
_buffer[0] = allocMemPages(0x20);
_buffer[1] = allocMemPages(0x20);
for (var idx = 0; idx < 0x2000; idx++) {
_buffer[0][idx] = 0; // idx & 0x2 ? 0xff : 0x00;
_buffer[1][idx] = 0; // idx & 0x2 ? 0xff : 0x00;
}
}
function _drawPixel(data, off, color) {
@ -528,12 +537,22 @@ function HiresPage(page)
_write: function(page, off, val, bank) {
function dim(c) {
return [c[0] * 0.75, c[1] * 0.75, c[2] * 0.75];
return [
c[0] * 0.75 & 0xff,
c[1] * 0.75 & 0xff,
c[2] * 0.75 & 0xff
];
}
var addr = (page << 8) | off, base = addr - 0x2000 * _page,
idx, jdx;
if (_buffer[bank][base] == val && !_refreshing)
if (addr < (0x2000 * _page) || addr >= (0x2000 * _page + 0x2000)) {
return;
}
if (_buffer[bank][base] == val && !_refreshing) {
return;
}
_buffer[bank][base] = val;
var hbs = val & 0x80;
@ -550,16 +569,23 @@ function HiresPage(page)
var rowa = ab | cd | e,
rowb = base >> 10;
var dx, dy, data = pages[_page].data;
var dx, dy, data = _imageData.data;
if ((rowa < 24) && (col < 40)) {
if (textMode || !hiresMode || (mixedMode && rowa > 19))
if (!multiScreen && !hiresMode) {
return;
}
dy = rowa * 16 + rowb * 2;
var bz, b0, b1, b2, b3, b4, c, hb;
if (doubleHiresMode) {
// Every 4 bytes is 7 pixels
// 2 bytes per bank
// b0 b1 b2 b3
// c0 c1 c2 c3 c4 c5 c6
// 76543210 76543210 76543210 76543210
// 1111222 2333344 4455556 6667777
var mod = col % 2, mcol = col - mod;
bz = _buffer[0][base - mod - 1];
b0 = _buffer[1][base - mod];
@ -567,24 +593,28 @@ function HiresPage(page)
b2 = _buffer[1][base - mod + 1];
b3 = _buffer[0][base - mod + 1];
b4 = _buffer[1][base - mod + 2];
c = [0,
((b0 & 0x0f) >> 0), // 0
((b0 & 0x70) >> 4) | ((b1 & 0x01) << 3), // 1
((b1 & 0x1e) >> 1), // 2
((b1 & 0x60) >> 5) | ((b2 & 0x03) << 2), // 3
((b2 & 0x3c) >> 2), // 4
((b2 & 0x40) >> 6) | ((b3 & 0x07) << 1), // 5
((b3 & 0x78) >> 3), // 6
0], // 7
hb = [0,
b0 & 0x80, // 0
b0 & 0x80, // 1
b1 & 0x80, // 2
b2 & 0x80, // 3
b2 & 0x80, // 4
b3 & 0x80, // 5
b3 & 0x80, // 6
0]; // 7
c = [
0,
((b0 & 0x0f) >> 0), // 0
((b0 & 0x70) >> 4) | ((b1 & 0x01) << 3), // 1
((b1 & 0x1e) >> 1), // 2
((b1 & 0x60) >> 5) | ((b2 & 0x03) << 2), // 3
((b2 & 0x3c) >> 2), // 4
((b2 & 0x40) >> 6) | ((b3 & 0x07) << 1), // 5
((b3 & 0x78) >> 3), // 6
0
], // 7
hb = [
0,
b0 & 0x80, // 0
b0 & 0x80, // 1
b1 & 0x80, // 2
b2 & 0x80, // 3
b2 & 0x80, // 4
b3 & 0x80, // 5
b3 & 0x80, // 6
0
]; // 7
if (col > 0) {
c[0] = (bz & 0x78) >> 3;
hb[0] = bz & 0x80;
@ -626,19 +656,21 @@ function HiresPage(page)
}
} else if (colorDHRMode) {
_drawHalfPixel(data, off, dcolor);
} else if (((bits & 0x3c) == 0x3c) ||
((bits & 0xf0) == 0xf0) ||
((bits & 0x1e) == 0x1e) ||
((bits & 0x78) == 0x78)) {
} else if (
((c[idx] != c[idx - 1]) && (c[idx] != c[idx + 1])) &&
(((bits & 0x1c) == 0x1c) ||
((bits & 0x70) == 0x70) ||
((bits & 0x38) == 0x38))
) {
_drawHalfPixel(data, off, whiteCol);
} else if (((c[idx] == c[idx + 1]) &&
(bits & 0xf0)) ||
((c[idx] == c[idx - 1]) &&
(bits & 0x01e)) ||
(bits & 0x10)) {
_drawHalfPixel(data, off, dcolor);
} else if ((bits & 0x28) == 0x28) {
} else if (
(bits & 0x38) ||
(c[idx] == c[idx + 1]) ||
(c[idx] == c[idx - 1])
) {
_drawHalfPixel(data, off, dcolor);
} else if (bits & 0x28) {
_drawHalfPixel(data, off, dim(dcolor));
} else {
_drawHalfPixel(data, off, blackCol);
}
@ -668,12 +700,15 @@ function HiresPage(page)
evenCol = (hbs ? blueCol : violetCol);
off = dx * 4 + dy * 280 * 4 * 2;
monoColor = _greenMode ? _green : null;
for (idx = 0; idx < 9; idx++, off += 8) {
val >>= 1;
if (v1) {
if (_greenMode) {
color = _green;
if (monoColor) {
color = monoColor;
} else if (highColorHGRMode) {
color = dcolors[_buffer[1][base] >> 4];
} else if (v0 || v2) {
@ -682,7 +717,7 @@ function HiresPage(page)
color = odd ? oddCol : evenCol;
}
} else {
if (_greenMode) {
if (monoColor) {
color = blackCol;
} else if (highColorHGRMode) {
color = dcolors[_buffer[1][base] & 0x0f];
@ -715,8 +750,9 @@ function HiresPage(page)
page = addr >> 8;
off = addr & 0xff;
this._write(page, off, _buffer[0][idx], 0);
if (_80colMode)
if (_80colMode) {
this._write(page, off, _buffer[1][idx], 1);
}
}
_refreshing = false;
},
@ -724,15 +760,21 @@ function HiresPage(page)
_greenMode = on;
this.refresh();
},
blit: function() {
context.putImageData(pages[_page], 0, 0);
blit: function(mixed) {
if (mixed) {
context.putImageData(_imageData, 0, 0, 0, 0, 560, 320);
} else {
context.putImageData(_imageData, 0, 0, 0, 0, 560, 384);
}
},
getState: function() {
return {
page: _page,
green: _greenMode,
buffer: [base64_encode(_buffer[0]),
base64_encode(_buffer[1])]
buffer: [
base64_encode(_buffer[0]),
base64_encode(_buffer[1])
]
};
},
setState: function(state) {
@ -746,7 +788,7 @@ function HiresPage(page)
};
}
function VideoModes(gr,hgr,gr2,hgr2) {
function VideoModes(gr, hgr, gr2, hgr2) {
var _grs = [gr, gr2];
var _hgrs = [hgr, hgr2];
var _seq = '';
@ -817,7 +859,7 @@ function VideoModes(gr,hgr,gr2,hgr2) {
hiresMode = on;
highColorHGRMode = false;
_seq = (on ? 'H+' : 'H-');
_seq = on ? 'H+' : 'H-';
// debug('_seq=', _seq);
if (old != on) {
@ -897,21 +939,23 @@ function VideoModes(gr,hgr,gr2,hgr2) {
isAltChar: function() {
return altCharMode;
},
setContext: function(c) {
context = c;
pages[1] = c.createImageData(560, 384);
pages[2] = c.createImageData(560, 384);
for (var idx = 0; idx < 560 * 384 * 4; idx++) {
pages[1].data[idx] = 0xff;
pages[2].data[idx] = 0xff;
}
},
blit: function() {
if (hiresMode && !textMode) {
_hgrs[pageMode - 1].blit();
if (multiScreen) {
_grs[0].blit();
_grs[1].blit();
_hgrs[0].blit();
_hgrs[1].blit();
} else {
_grs[pageMode - 1].blit();
if (hiresMode && !textMode) {
if (mixedMode) {
_grs[pageMode - 1].blit(true);
_hgrs[pageMode - 1].blit(true);
} else {
_hgrs[pageMode - 1].blit();
}
} else {
_grs[pageMode - 1].blit();
}
}
},
getState: function() {

647
js/cards/videoterm.js Normal file
View File

@ -0,0 +1,647 @@
/* Copyright 2017 Will Scullin <scullin@scullinsteel.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
/*exported Videoterm */
/*globals debug: false, allocMemPages: false */
function Videoterm(io, slot, context) {
'use strict';
slot = slot || 3;
debug('Videx Videoterm card in slot', slot);
var LOC = {
IOREG: 0x80,
IOVAL: 0x81
};
var ROM = [
0xad,0x7b,0x07,0x29,0xf8,0xc9,0x30,0xf0,
0x21,0xa9,0x30,0x8d,0x7b,0x07,0x8d,0xfb,
0x07,0xa9,0x00,0x8d,0xfb,0x06,0x20,0x61,
0xc9,0xa2,0x00,0x8a,0x8d,0xb0,0xc0,0xbd,
0xa1,0xc8,0x8d,0xb1,0xc0,0xe8,0xe0,0x10,
0xd0,0xf1,0x8d,0x59,0xc0,0x60,0xad,0xfb,
0x07,0x29,0x08,0xf0,0x09,0x20,0x93,0xfe,
0x20,0x22,0xfc,0x20,0x89,0xfe,0x68,0xa8,
0x68,0xaa,0x68,0x60,0x20,0xd1,0xc8,0xe6,
0x4e,0xd0,0x02,0xe6,0x4f,0xad,0x00,0xc0,
0x10,0xf5,0x20,0x5c,0xc8,0x90,0xf0,0x2c,
0x10,0xc0,0x18,0x60,0xc9,0x8b,0xd0,0x02,
0xa9,0xdb,0xc9,0x81,0xd0,0x0a,0xad,0xfb,
0x07,0x49,0x40,0x8d,0xfb,0x07,0xb0,0xe7,
0x48,0xad,0xfb,0x07,0x0a,0x0a,0x68,0x90,
0x1f,0xc9,0xb0,0x90,0x1b,0x2c,0x63,0xc0,
0x30,0x14,0xc9,0xb0,0xf0,0x0e,0xc9,0xc0,
0xd0,0x02,0xa9,0xd0,0xc9,0xdb,0x90,0x08,
0x29,0xcf,0xd0,0x04,0xa9,0xdd,0x09,0x20,
0x48,0x29,0x7f,0x8d,0x7b,0x06,0x68,0x38,
0x60,0x7b,0x50,0x5e,0x29,0x1b,0x08,0x18,
0x19,0x00,0x08,0xe0,0x08,0x00,0x00,0x00,
0x00,0x8d,0x7b,0x06,0xa5,0x25,0xcd,0xfb,
0x05,0xf0,0x06,0x8d,0xfb,0x05,0x20,0x04,
0xca,0xa5,0x24,0xcd,0x7b,0x05,0x90,0x03,
0x8d,0x7b,0x05,0xad,0x7b,0x06,0x20,0x89,
0xca,0xa9,0x0f,0x8d,0xb0,0xc0,0xad,0x7b,
0x05,0xc9,0x50,0xb0,0x13,0x6d,0x7b,0x04,
0x8d,0xb1,0xc0,0xa9,0x0e,0x8d,0xb0,0xc0,
0xa9,0x00,0x6d,0xfb,0x04,0x8d,0xb1,0xc0,
0x60,0x49,0xc0,0xc9,0x08,0xb0,0x1d,0xa8,
0xa9,0xc9,0x48,0xb9,0xf2,0xcb,0x48,0x60,
0xea,0xac,0x7b,0x05,0xa9,0xa0,0x20,0x71,
0xca,0xc8,0xc0,0x50,0x90,0xf8,0x60,0xa9,
0x34,0x8d,0x7b,0x07,0x60,0xa9,0x32,0xd0,
0xf8,0xa0,0xc0,0xa2,0x80,0xca,0xd0,0xfd,
0xad,0x30,0xc0,0x88,0xd0,0xf5,0x60,0xac,
0x7b,0x05,0xc0,0x50,0x90,0x05,0x48,0x20,
0xb0,0xc9,0x68,0xac,0x7b,0x05,0x20,0x71,
0xca,0xee,0x7b,0x05,0x2c,0x78,0x04,0x10,
0x07,0xad,0x7b,0x05,0xc9,0x50,0xb0,0x68,
0x60,0xac,0x7b,0x05,0xad,0xfb,0x05,0x48,
0x20,0x07,0xca,0x20,0x04,0xc9,0x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0xa0,0xb0,0xce,0xc9,0x87,0x90,0x08,0xa8,
0xa9,0xc9,0x48,0xb9,0xb9,0xc9,0x48,0x60,
0x18,0x71,0x13,0xb2,0x48,0x60,0xaf,0x9d,
0xf2,0x13,0x13,0x13,0x13,0x13,0x13,0x13,
0x13,0x13,0x66,0x0e,0x13,0x38,0x00,0x14,
0x7b,0x18,0x98,0x6d,0x7b,0x04,0x48,0xa9,
0x00,0x6d,0xfb,0x04,0x48,0x0a,0x29,0x0c,
0xaa,0xbd,0xb0,0xc0,0x68,0x4a,0x68,0xaa,
0x60,0x0a,0x48,0xad,0xfb,0x07,0x4a,0x68,
0x6a,0x48,0x20,0x59,0xca,0x68,0xb0,0x05,
0x9d,0x00,0xcc,0x90,0x03,0x9d,0x00,0xcd,
0x60,0x48,0xa9,0xf7,0x20,0xa0,0xc9,0x8d,
0x59,0xc0,0xad,0x7b,0x07,0x29,0x07,0xd0,
0x04,0x68,0x4c,0x23,0xca,0x29,0x04,0xf0,
0x03,0x4c,0x87,0xc9,0x68,0x38,0xe9,0x20,
0x29,0x7f,0x48,0xce,0x7b,0x07,0xad,0x7b,
0x07,0x29,0x03,0xd0,0x15,0x68,0xc9,0x18,
0xb0,0x03,0x8d,0xfb,0x05,0xad,0xf8,0x05,
0xc9,0x50,0xb0,0x03,0x8d,0x7b,0x05,0x4c,
0x04,0xca,0x68,0x8d,0xf8,0x05,0x60,0xad,
0x00,0xc0,0xc9,0x93,0xd0,0x0f,0x2c,0x10,
0xc0,0xad,0x00,0xc0,0x10,0xfb,0xc9,0x83,
0xf0,0x03,0x2c,0x10,0xc0,0x60,0xa8,0xb9,
0x31,0xcb,0x20,0xf1,0xc8,0x20,0x44,0xc8,
0xc9,0xce,0xb0,0x08,0xc9,0xc9,0x90,0x04,
0xc9,0xcc,0xd0,0xea,0x4c,0xf1,0xc8,0xea,
0x2c,0xcb,0xff,0x70,0x31,0x38,0x90,0x18,
0xb8,0x50,0x2b,0x01,0x82,0x11,0x14,0x1c,
0x22,0x4c,0x00,0xc8,0x20,0x44,0xc8,0x29,
0x7f,0xa2,0x00,0x60,0x20,0xa7,0xc9,0xa2,
0x00,0x60,0xc9,0x00,0xf0,0x09,0xad,0x00,
0xc0,0x0a,0x90,0x03,0x20,0x5c,0xc8,0xa2,
0x00,0x60,0x91,0x28,0x38,0xb8,0x8d,0xff,
0xcf,0x48,0x85,0x35,0x8a,0x48,0x98,0x48,
0xa5,0x35,0x86,0x35,0xa2,0xc3,0x8e,0x78,
0x04,0x48,0x50,0x10,0xa9,0x32,0x85,0x38,
0x86,0x39,0xa9,0x07,0x85,0x36,0x86,0x37,
0x20,0x00,0xc8,0x18,0x90,0x6f,0x68,0xa4,
0x35,0xf0,0x1f,0x88,0xad,0x78,0x06,0xc9,
0x88,0xf0,0x17,0xd9,0x00,0x02,0xf0,0x12,
0x49,0x20,0xd9,0x00,0x02,0xd0,0x3b,0xad,
0x78,0x06,0x99,0x00,0x02,0xb0,0x03,0x20,
0xed,0xca,0xa9,0x80,0x20,0xf5,0xc9,0x20,
0x44,0xc8,0xc9,0x9b,0xf0,0xf1,0xc9,0x8d,
0xd0,0x05,0x48,0x20,0x01,0xc9,0x68,0xc9,
0x95,0xd0,0x12,0xac,0x7b,0x05,0x20,0x59,
0xca,0xb0,0x05,0xbd,0x00,0xcc,0x90,0x03,
0xbd,0x00,0xcd,0x09,0x80,0x8d,0x78,0x06,
0xd0,0x08,0x20,0x44,0xc8,0xa0,0x00,0x8c,
0x78,0x06,0xba,0xe8,0xe8,0xe8,0x9d,0x00,
0x01,0xa9,0x00,0x85,0x24,0xad,0xfb,0x05,
0x85,0x25,0x4c,0x2e,0xc8,0x68,0xac,0xfb,
0x07,0x10,0x08,0xac,0x78,0x06,0xc0,0xe0,
0x90,0x01,0x98,0x20,0xb1,0xc8,0x20,0xcf,
0xca,0xa9,0x7f,0x20,0xa0,0xc9,0xad,0x7b,
0x05,0xe9,0x47,0x90,0xd4,0x69,0x1f,0x18,
0x90,0xd1,0x60,0x38,0x71,0xb2,0x7b,0x00,
0x48,0x66,0xc4,0xc2,0xc1,0xff,0xc3,0xea,
];
var VIDEO_ROM = [
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,
0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0x00,0x00,0x00,0xff,0xff,
0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,
0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xe0,0x90,0xe0,0x9e,0xf0,0x0c,0x02,0x1c,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x90,0x90,0xf0,0x90,0xbe,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x80,0x80,0x9e,0xf0,0x18,0x10,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x88,0x88,0x50,0x20,0x3e,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xf0,0x80,0xc0,0x9e,0x90,0x18,0x10,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x70,0x80,0x80,0x7c,0x12,0x1c,0x14,0x12,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x70,0x80,0x60,0x10,0xec,0x12,0x12,0x0c,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x70,0x80,0x60,0x1e,0xe4,0x04,0x04,0x0e,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0f,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x08,0x08,0x08,0x0f,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0x0f,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x0f,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0xf8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x08,0x08,0x08,0xf8,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x08,0x08,0x08,0xff,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xf8,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0xf8,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0xff,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0xff,0x08,0x08,0x08,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x18,0x18,0x18,0x00,0x18,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x36,0x36,0x12,0x24,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x24,0x24,0x7e,0x24,0x7e,0x24,0x24,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x3e,0x48,0x3c,0x12,0x7c,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x62,0x94,0x68,0x10,0x2c,0x52,0x8c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x20,0x50,0x50,0x62,0x94,0x88,0x76,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x08,0x10,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0c,0x10,0x20,0x20,0x20,0x10,0x0c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x30,0x08,0x04,0x04,0x04,0x08,0x30,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x10,0x92,0x54,0x38,0x54,0x92,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x10,0xfe,0x10,0x10,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x18,0x18,0x08,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x38,0x44,0x8a,0x92,0xa2,0x44,0x38,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x38,0x08,0x08,0x08,0x08,0x3e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3c,0x42,0x02,0x1c,0x20,0x40,0x7e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7e,0x04,0x08,0x1c,0x02,0x42,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x0c,0x14,0x24,0x7e,0x04,0x04,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7e,0x40,0x7c,0x02,0x02,0x42,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1e,0x20,0x40,0x7c,0x42,0x42,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7e,0x02,0x04,0x08,0x10,0x20,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3c,0x42,0x42,0x3c,0x42,0x42,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3c,0x42,0x42,0x3e,0x02,0x04,0x78,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x18,0x18,0x00,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x18,0x18,0x00,0x18,0x18,0x08,0x10,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x06,0x18,0x60,0x18,0x06,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7e,0x00,0x7e,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x60,0x18,0x06,0x18,0x60,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3c,0x42,0x02,0x0c,0x10,0x00,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3c,0x42,0x9a,0xaa,0x94,0x40,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x24,0x42,0x42,0x7e,0x42,0x42,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7c,0x42,0x42,0x7c,0x42,0x42,0x7c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1c,0x22,0x40,0x40,0x40,0x22,0x1c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x78,0x44,0x42,0x42,0x42,0x44,0x78,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7e,0x40,0x40,0x78,0x40,0x40,0x7e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7e,0x40,0x40,0x78,0x40,0x40,0x40,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1c,0x22,0x40,0x4e,0x42,0x22,0x1e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x42,0x42,0x42,0x7e,0x42,0x42,0x42,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1c,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0e,0x04,0x04,0x04,0x04,0x44,0x38,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x42,0x44,0x48,0x50,0x68,0x44,0x42,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x40,0x40,0x40,0x40,0x40,0x7e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x82,0xc6,0xaa,0x92,0x82,0x82,0x82,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x42,0x62,0x52,0x4a,0x46,0x42,0x42,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x38,0x44,0x82,0x82,0x82,0x44,0x38,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7c,0x42,0x42,0x7c,0x40,0x40,0x40,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x38,0x44,0x82,0x82,0x8a,0x44,0x3a,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x7c,0x42,0x42,0x7c,0x48,0x44,0x42,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3c,0x42,0x40,0x3c,0x02,0x42,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xfe,0x10,0x10,0x10,0x10,0x10,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x42,0x42,0x42,0x42,0x42,0x42,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x82,0x82,0x44,0x44,0x28,0x28,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x82,0x82,0x82,0x82,0x92,0xaa,0x44,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x82,0x44,0x28,0x10,0x28,0x44,0x82,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x82,0x44,0x28,0x10,0x10,0x10,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0xfe,0x04,0x08,0x10,0x20,0x40,0xfe,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3e,0x30,0x30,0x30,0x30,0x30,0x3e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x3e,0x06,0x06,0x06,0x06,0x06,0x3e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x1c,0x2a,0x08,0x08,0x08,0x08,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfe,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x18,0x10,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xf8,0x04,0x7c,0x84,0x7a,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x40,0x7c,0x42,0x42,0x42,0x7c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x42,0x40,0x40,0x3e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x02,0x02,0x3e,0x42,0x42,0x42,0x3e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x42,0x7e,0x40,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1c,0x22,0x20,0x78,0x20,0x20,0x20,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x02,0x3c,0x42,0x42,0x3e,0x02,0x42,
0x3c,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x40,0x5c,0x62,0x42,0x42,0x42,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x00,0x08,0x08,0x08,0x08,0x08,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x04,0x00,0x04,0x04,0x04,0x04,0x04,0x24,
0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x40,0x46,0x58,0x60,0x58,0x46,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x18,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0xec,0x92,0x92,0x92,0x92,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x5c,0x22,0x22,0x22,0x22,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3c,0x42,0x42,0x42,0x3c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7c,0x42,0x42,0x42,0x7c,0x40,
0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3e,0x42,0x42,0x42,0x3e,0x02,
0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x5c,0x62,0x40,0x40,0x40,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x3e,0x40,0x3c,0x02,0x7c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x10,0x3e,0x10,0x10,0x10,0x0e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x44,0x44,0x44,0x44,0x3a,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x82,0x82,0x44,0x28,0x10,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x82,0x82,0x92,0xaa,0x44,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x42,0x24,0x18,0x24,0x42,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x82,0x82,0x44,0x28,0x10,0x20,
0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x7e,0x04,0x18,0x20,0x7e,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x0c,0x10,0x08,0x30,0x08,0x10,0x0c,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x08,0x08,0x00,0x08,0x08,0x08,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x30,0x08,0x10,0x0c,0x10,0x08,0x30,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x60,0x92,0x0c,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x24,0x48,0x92,0x24,0x48,0x92,0x24,0x48,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
];
var REGS = {
CURSOR_UPPER: 0x0A,
CURSOR_LOWER: 0x0B,
STARTPOS_HI: 0x0C,
STARTPOS_LO: 0x0D,
CURSOR_HI: 0x0E,
CURSOR_LO: 0x0F,
LIGHTPEN_HI: 0x10,
LIGHTPEN_LO: 0x11
};
var CURSOR_MODES = {
SOLID: 0x00,
HIDDEN: 0x01,
BLINK: 0x10,
FAST_BLINK: 0x11
};
var _regs = [
0x7b, // 00 - Horiz. total
0x50, // 01 - Horiz. displayed
0x62, // 02 - Horiz. sync pos
0x29, // 03 - Horiz. sync width
0x1b, // 04 - Vert. total
0x08, // 05 - Vert. adjust
0x18, // 06 - Vert. displayed
0x19, // 07 - Vert. sync pos
0x00, // 08 - Interlaced
0x08, // 09 - Max. scan line
0xc0, // 0A - Cursor upper
0x08, // 0B - Cursor lower
0x00, // 0C - Startpos Hi
0x00, // 0D - Startpos Lo
0x00, // 0E - Cursor Hi
0x00, // 0F - Cursor Lo
0x00, // 10 - Lightpen Hi
0x00 // 11 - Lightpen Lo
];
var _blink = false;
var _curReg = 0;
var _startPos;
var _cursorPos;
var _shouldRefresh;
// var _cursor = 0;
var _bank = 0;
var _buffer = allocMemPages(8);
var _imageData;
var _black = [0x00, 0x00, 0x00];
var _white = [0xff, 0xff, 0xff];
function _init() {
var idx;
_imageData = context.createImageData(560, 384);
for (idx = 0; idx < 560 * 384 * 4; idx++) {
_imageData.data[idx] = 0xff;
}
for (idx = 0; idx < 0x800; idx++) {
_buffer[idx] = idx & 0xff;
}
_refresh();
setInterval(function() {
_blink = !_blink;
_refreshCursor();
}, 300);
}
function _updateBuffer(addr, val) {
_buffer[addr] = val;
val &= 0x7f; // XXX temp
var saddr = (0x800 + addr - _startPos) & 0x7ff;
var data = _imageData.data;
var row = (saddr / 80) & 0xff;
var col = saddr % 80;
var x = col * 7;
var y = row * 16;
var c = val * 16;
var color;
if (row < 25) {
for (var idx = 0; idx < 8; idx++) {
var cdata = VIDEO_ROM[c + idx];
for (var jdx = 0; jdx < 7; jdx++) {
if (cdata & 0x80) {
color = _white;
} else {
color = _black;
}
data[(y + idx * 2) * 560 * 4 + (x + jdx) * 4] = color[0];
data[(y + idx * 2) * 560 * 4 + (x + jdx) * 4 + 1] = color[1];
data[(y + idx * 2) * 560 * 4 + (x + jdx) * 4 + 2] = color[2];
data[(y + idx * 2 + 1) * 560 * 4 + (x + jdx) * 4] = color[0];
data[(y + idx * 2 + 1) * 560 * 4 + (x + jdx) * 4 + 1] = color[1];
data[(y + idx * 2 + 1) * 560 * 4 + (x + jdx) * 4 + 2] = color[2];
cdata <<= 1;
}
}
}
}
function _refreshCursor(fromRegs) {
var addr = _regs[REGS.CURSOR_HI] << 8 | _regs[REGS.CURSOR_LO];
var saddr = (0x800 + addr - _startPos) & 0x7ff;
var data = _imageData.data;
var row = (saddr / 80) & 0xff;
var col = saddr % 80;
var x = col * 7;
var y = row * 16;
var blinkmode = (_regs[REGS.CURSOR_UPPER] & 0x60) >> 5;
if (fromRegs) {
if (addr !== _cursorPos) {
var caddr = (0x800 + _cursorPos - _startPos) & 0x7ff;
_updateBuffer(caddr, _buffer[caddr]);
_cursorPos = addr;
}
}
_updateBuffer(addr, _buffer[addr]);
if (blinkmode === CURSOR_MODES.HIDDEN) {
return;
}
if (_blink || (blinkmode === CURSOR_MODES.SOLID)) {
for (var idx = 0; idx < 8; idx++) {
var color = _white;
if (idx >= (_regs[REGS.CURSOR_UPPER] & 0x1f) &&
idx <= (_regs[REGS.CURSOR_LOWER] & 0x1f)) {
for (var jdx = 0; jdx < 7; jdx++) {
data[(y + idx * 2) * 560 * 4 + (x + jdx) * 4] = color[0];
data[(y + idx * 2) * 560 * 4 + (x + jdx) * 4 + 1] = color[1];
data[(y + idx * 2) * 560 * 4 + (x + jdx) * 4 + 2] = color[2];
data[(y + idx * 2 + 1) * 560 * 4 + (x + jdx) * 4] = color[0];
data[(y + idx * 2 + 1) * 560 * 4 + (x + jdx) * 4 + 1] = color[1];
data[(y + idx * 2 + 1) * 560 * 4 + (x + jdx) * 4 + 2] = color[2];
}
}
}
}
}
function _updateStartPos() {
var startPos =
_regs[REGS.STARTPOS_HI] << 8 |
_regs[REGS.STARTPOS_LO];
if (_startPos != startPos) {
_startPos = startPos;
_shouldRefresh = true;
}
}
function _refresh() {
for (var idx = 0; idx < 0x800; idx++) {
_updateBuffer(idx, _buffer[idx]);
}
}
function _access(off, val) {
var writeMode = val !== undefined;
var result = undefined;
switch (off & 0x81) {
case LOC.IOREG:
if (writeMode) {
_curReg = val;
} else {
result = _curReg;
}
break;
case LOC.IOVAL:
if (writeMode) {
_regs[_curReg] = val;
switch (_curReg) {
case REGS.CURSOR_UPPER:
case REGS.CURSOR_LOWER:
_refreshCursor(true);
break;
case REGS.CURSOR_HI:
case REGS.CURSOR_LO:
_refreshCursor(true);
break;
case REGS.STARTPOS_HI:
case REGS.STARTPOS_LO:
_updateStartPos();
break;
}
} else {
result = _regs[_curReg];
}
break;
}
_bank = (off & 0x0C) >> 2;
return result;
}
_init();
return {
ioSwitch: function (off, val) {
return _access(off, val);
},
read: function(page, off) {
if (page < 0xcc) {
return ROM[(page & 0x03) << 8 | off];
} else if (page < 0xce){
var addr = ((page & 0x01) + (_bank << 1)) << 8 | off;
return _buffer[addr];
}
},
write: function(page, off, val) {
if (page > 0xcb && page < 0xce) {
var addr = ((page & 0x01) + (_bank << 1)) << 8 | off;
_updateBuffer(addr, val);
}
},
blit: function() {
if (_shouldRefresh) {
_refresh();
_shouldRefresh = false;
}
context.putImageData(_imageData, 0, 0);
}
};
}

View File

@ -2,11 +2,14 @@
CPU6502: false,
RAM: false,
Apple2ROM: false, IntBASIC: false, OriginalROM: false,
apple2_charset: false,
Apple2jROM: false,
apple2_charset: false, apple2j_charset: false,
pigfont_charset: false, apple2lc_charset: false,
Apple2IO: false
LoresPage: false, HiresPage: false, VideoModes: false
KeyBoard2: false,
KeyBoard: false,
Parallel: false,
Videoterm: false,
DiskII: false,
Printer: false,
LanguageCard: false,
@ -16,14 +19,16 @@
disk_index: false,
initAudio: false, enableSound: false,
initGamepad: false, processGamepad: false, gamepad: false,
ApplesoftDump: false, SYMBOLS: false
ApplesoftDump: false, SYMBOLS: false,
multiScreen: true
*/
/* exported openLoad, openSave, doDelete,
selectCategory, selectDisk, clickDisk,
updateJoystick,
pauseRun, step,
restoreState, saveState,
dumpProgram, PageDebug
dumpProgram, PageDebug,
multiScreen
*/
var kHz = 1023;
@ -116,7 +121,7 @@ function DriveLights()
};
}
var DISK_TYPES = ['dsk','do','po','raw','nib','2mg'];
var DISK_TYPES = ['dsk','d13','do','po','raw','nib','2mg'];
var TAPE_TYPES = ['wav','aiff','aif','mp3'];
var _currentDrive = 1;
@ -351,34 +356,76 @@ var prefs = new Prefs();
var runTimer = null;
var cpu = new CPU6502();
var context1, context2, context3, context4;
var canvas1 = document.getElementById('screen');
var canvas2 = document.getElementById('screen2');
var canvas3 = document.getElementById('screen3');
var canvas4 = document.getElementById('screen4');
context1 = canvas1.getContext('2d');
if (canvas4) {
multiScreen = true;
context2 = canvas2.getContext('2d');
context3 = canvas3.getContext('2d');
context4 = canvas4.getContext('2d');
} else if (canvas2) {
multiScreen = true;
context2 = context1;
context3 = canvas2.getContext('2d');
context4 = context3;
} else {
context2 = context1;
context3 = context1;
context4 = context1;
}
var romVersion = prefs.readPref('computer_type2');
var rom;
var char_rom = apple2_charset;
switch (romVersion) {
case 'apple2':
rom = new IntBASIC();
break;
case'original':
rom = new OriginalROM();
break;
case 'apple2jplus':
rom = new Apple2jROM();
char_rom = apple2j_charset;
break;
case 'apple2pig':
rom = new Apple2ROM();
char_rom = pigfont_charset;
break;
case 'apple2lc':
rom = new Apple2ROM();
char_rom = apple2lc_charset;
break;
default:
rom = new Apple2ROM();
}
var gr = new LoresPage(1, char_rom, context1);
var gr2 = new LoresPage(2, char_rom, context2);
var hgr = new HiresPage(1, context3);
var hgr2 = new HiresPage(2, context4);
var ram1 = new RAM(0x00, 0x03),
ram2 = new RAM(0x0C, 0x1F),
ram3 = new RAM(0x60, 0xBF);
var hgr = new HiresPage(1);
var hgr2 = new HiresPage(2);
var gr = new LoresPage(1, apple2_charset);
var gr2 = new LoresPage(2, apple2_charset);
var romVersion = prefs.readPref('computer_type');
var rom;
if (romVersion == 'apple2') {
rom = new IntBASIC();
} else if (romVersion == 'original') {
rom = new OriginalROM();
} else {
rom = new Apple2ROM();
}
var vm = new VideoModes(gr, hgr, gr2, hgr2);
var dumper = new ApplesoftDump(cpu);
var drivelights = new DriveLights();
var io = new Apple2IO(cpu, vm);
var keyboard = new KeyBoard2(io);
var keyboard = new KeyBoard(io);
var lc = new LanguageCard(io, 0, rom);
var parallel = new Parallel(io, 1, new Printer());
var slinky = new RAMFactor(io, 2, 1024 * 1024);
var videoterm = new Videoterm(io, 3, context1);
var disk2 = new DiskII(io, 6, drivelights);
var clock = new Thunderclock(io, 7);
@ -395,6 +442,7 @@ cpu.addPageHandler(lc);
io.setSlot(0, lc);
io.setSlot(1, parallel);
io.setSlot(2, slinky);
io.setSlot(3, videoterm);
io.setSlot(6, disk2);
io.setSlot(7, clock);
@ -523,7 +571,14 @@ function run(pc) {
} else {
cpu.stepCycles(step);
}
vm.blit();
if (io.annunciator(0)) {
if (multiScreen) {
vm.blit();
}
videoterm.blit();
} else {
vm.blit();
}
io.sampleTick();
}
@ -757,7 +812,7 @@ function processHash(hash) {
*/
function _keydown(evt) {
if (!focused || (!evt.metaKey || evt.ctrlKey)) {
if (!focused && (!evt.metaKey || evt.ctrlKey)) {
evt.preventDefault();
var key = keyboard.mapKeyEvent(evt);
@ -874,11 +929,6 @@ $(function() {
}, 1);
});
var canvas = document.getElementById('screen');
var context = canvas.getContext('2d');
vm.setContext(context);
/*
* Input Handling
*/

View File

@ -1,10 +1,11 @@
/* globals debug: false, gup: false, hup: false, toHex: false
CPU6502: false,
Apple2eROM: false, Apple2eEnhancedROM: false,
apple2e_charset: false,
apple2e_charset: false, rmfont_charset: false,
apple2enh_charset: false,
Apple2IO: false
LoresPage: false, HiresPage: false, VideoModes: false,
KeyBoard2e: false,
KeyBoard: false,
Parallel: false,
DiskII: false,
Printer: false,
@ -16,9 +17,11 @@
initAudio: false, enableSound: false,
initGamepad: false, processGamepad: false, gamepad: false,
ApplesoftDump: false, SYMBOLS: false,
multiScreen: true
*/
/* exported openLoad, openSave, doDelete,
selectCategory, selectDisk, clickDisk,
multiScreen,
updateJoystick,
pauseRun, step,
restoreState, saveState,
@ -115,7 +118,7 @@ function DriveLights()
};
}
var DISK_TYPES = ['dsk','do','po','raw','nib','2mg'];
var DISK_TYPES = ['dsk','d13','do','po','raw','nib','2mg'];
var TAPE_TYPES = ['wav','aiff','aif','mp3'];
var _currentDrive = 1;
@ -327,10 +330,14 @@ function doLoadHTTP(drive, _url) {
var parts = url.split(/[\/\.]/);
var name = decodeURIComponent(parts[parts.length - 2]);
var ext = parts[parts.length - 1].toLowerCase();
if (disk2.setBinary(drive, name, ext, req.response)) {
drivelights.label(drive, name);
$('#http_load').dialog('close');
initGamepad();
if (req.response.byteLength >= 400 * 1024) {
// smartport.setBinary(drive, req.response);
} else {
if (disk2.setBinary(drive, name, ext, req.response)) {
drivelights.label(drive, name);
$('#http_load').dialog('close');
initGamepad();
}
}
};
req.send(null);
@ -347,29 +354,64 @@ function openManage() {
}
var prefs = new Prefs();
var enhanced = prefs.readPref('computer_type') != 'apple2e';
var romVersion = prefs.readPref('computer_type2e');
var enhanced = false;
var rom;
var char_rom = apple2e_charset;
switch (romVersion) {
case 'apple2e':
rom = new Apple2eROM();
break;
case 'apple2rm':
rom = new Apple2eEnhancedROM();
char_rom = rmfont_charset;
enhanced = true;
break;
default:
rom = new Apple2eEnhancedROM();
char_rom =apple2enh_charset;
enhanced = true;
}
var runTimer = null;
var cpu = new CPU6502({'65C02': enhanced});
var hgr = new HiresPage(1);
var hgr2 = new HiresPage(2);
var gr = new LoresPage(1, apple2e_charset);
var gr2 = new LoresPage(2, apple2e_charset);
var context1, context2, context3, context4;
var rom;
if (enhanced) {
rom = new Apple2eEnhancedROM();
var canvas1 = document.getElementById('screen');
var canvas2 = document.getElementById('screen2');
var canvas3 = document.getElementById('screen3');
var canvas4 = document.getElementById('screen4');
context1 = canvas1.getContext('2d');
if (canvas4) {
multiScreen = true;
context2 = canvas2.getContext('2d');
context3 = canvas3.getContext('2d');
context4 = canvas4.getContext('2d');
} else if (canvas2) {
multiScreen = true;
context2 = context1;
context3 = canvas2.getContext('2d');
context4 = context3;
} else {
rom = new Apple2eROM();
context2 = context1;
context3 = context1;
context4 = context1;
}
var gr = new LoresPage(1, char_rom, context1);
var gr2 = new LoresPage(2, char_rom, context2);
var hgr = new HiresPage(1, context3);
var hgr2 = new HiresPage(2, context4);
var vm = new VideoModes(gr, hgr, gr2, hgr2);
var dumper = new ApplesoftDump(cpu);
var drivelights = new DriveLights();
var io = new Apple2IO(cpu, vm);
var keyboard = new KeyBoard2e(io);
var keyboard = new KeyBoard(io, true);
var mmu = new MMU(cpu, vm, gr, gr2, hgr, hgr2, io, rom);
@ -864,11 +906,6 @@ $(function() {
}, 1);
});
var canvas = document.getElementById('screen');
var context = canvas.getContext('2d');
vm.setContext(context);
/*
* Input Handling
*/

516
js/roms/apple2enh_char.js Normal file
View File

@ -0,0 +1,516 @@
/* exported apple2enh_charset */
var apple2enh_charset = [
0x1c,0x22,0x2a,0x3a,0x1a,0x02,0x3c,0x00,
0x08,0x14,0x22,0x22,0x3e,0x22,0x22,0x00,
0x1e,0x22,0x22,0x1e,0x22,0x22,0x1e,0x00,
0x1c,0x22,0x02,0x02,0x02,0x22,0x1c,0x00,
0x1e,0x22,0x22,0x22,0x22,0x22,0x1e,0x00,
0x3e,0x02,0x02,0x1e,0x02,0x02,0x3e,0x00,
0x3e,0x02,0x02,0x1e,0x02,0x02,0x02,0x00,
0x3c,0x02,0x02,0x02,0x32,0x22,0x3c,0x00,
0x22,0x22,0x22,0x3e,0x22,0x22,0x22,0x00,
0x1c,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,
0x20,0x20,0x20,0x20,0x20,0x22,0x1c,0x00,
0x22,0x12,0x0a,0x06,0x0a,0x12,0x22,0x00,
0x02,0x02,0x02,0x02,0x02,0x02,0x3e,0x00,
0x22,0x36,0x2a,0x2a,0x22,0x22,0x22,0x00,
0x22,0x22,0x26,0x2a,0x32,0x22,0x22,0x00,
0x1c,0x22,0x22,0x22,0x22,0x22,0x1c,0x00,
0x1e,0x22,0x22,0x1e,0x02,0x02,0x02,0x00,
0x1c,0x22,0x22,0x22,0x2a,0x12,0x2c,0x00,
0x1e,0x22,0x22,0x1e,0x0a,0x12,0x22,0x00,
0x1c,0x22,0x02,0x1c,0x20,0x22,0x1c,0x00,
0x3e,0x08,0x08,0x08,0x08,0x08,0x08,0x00,
0x22,0x22,0x22,0x22,0x22,0x22,0x1c,0x00,
0x22,0x22,0x22,0x22,0x22,0x14,0x08,0x00,
0x22,0x22,0x22,0x2a,0x2a,0x36,0x22,0x00,
0x22,0x22,0x14,0x08,0x14,0x22,0x22,0x00,
0x22,0x22,0x14,0x08,0x08,0x08,0x08,0x00,
0x3e,0x20,0x10,0x08,0x04,0x02,0x3e,0x00,
0x3e,0x06,0x06,0x06,0x06,0x06,0x3e,0x00,
0x00,0x02,0x04,0x08,0x10,0x20,0x00,0x00,
0x3e,0x30,0x30,0x30,0x30,0x30,0x3e,0x00,
0x00,0x00,0x08,0x14,0x22,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7f,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x08,0x08,0x08,0x08,0x08,0x00,0x08,0x00,
0x14,0x14,0x14,0x00,0x00,0x00,0x00,0x00,
0x14,0x14,0x3e,0x14,0x3e,0x14,0x14,0x00,
0x08,0x3c,0x0a,0x1c,0x28,0x1e,0x08,0x00,
0x06,0x26,0x10,0x08,0x04,0x32,0x30,0x00,
0x04,0x0a,0x0a,0x04,0x2a,0x12,0x2c,0x00,
0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,
0x08,0x04,0x02,0x02,0x02,0x04,0x08,0x00,
0x08,0x10,0x20,0x20,0x20,0x10,0x08,0x00,
0x08,0x2a,0x1c,0x08,0x1c,0x2a,0x08,0x00,
0x00,0x08,0x08,0x3e,0x08,0x08,0x00,0x00,
0x00,0x00,0x00,0x00,0x08,0x08,0x04,0x00,
0x00,0x00,0x00,0x3e,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,
0x00,0x20,0x10,0x08,0x04,0x02,0x00,0x00,
0x1c,0x22,0x32,0x2a,0x26,0x22,0x1c,0x00,
0x08,0x0c,0x08,0x08,0x08,0x08,0x1c,0x00,
0x1c,0x22,0x20,0x18,0x04,0x02,0x3e,0x00,
0x3e,0x20,0x10,0x18,0x20,0x22,0x1c,0x00,
0x10,0x18,0x14,0x12,0x3e,0x10,0x10,0x00,
0x3e,0x02,0x1e,0x20,0x20,0x22,0x1c,0x00,
0x38,0x04,0x02,0x1e,0x22,0x22,0x1c,0x00,
0x3e,0x20,0x10,0x08,0x04,0x04,0x04,0x00,
0x1c,0x22,0x22,0x1c,0x22,0x22,0x1c,0x00,
0x1c,0x22,0x22,0x3c,0x20,0x10,0x0e,0x00,
0x00,0x00,0x08,0x00,0x08,0x00,0x00,0x00,
0x00,0x00,0x08,0x00,0x08,0x08,0x04,0x00,
0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x00,
0x00,0x00,0x3e,0x00,0x3e,0x00,0x00,0x00,
0x04,0x08,0x10,0x20,0x10,0x08,0x04,0x00,
0x1c,0x22,0x10,0x08,0x08,0x00,0x08,0x00,
0xef,0xf7,0xc9,0x80,0xc0,0xc0,0x81,0xc9,
0xef,0xf7,0xc9,0xbe,0xde,0xde,0xb5,0xc9,
0xff,0xff,0xfd,0xf9,0xf1,0xe1,0xc9,0xbd,
0x80,0xdd,0xeb,0xf7,0xf7,0xeb,0xd5,0x80,
0xff,0xbf,0xdf,0xee,0xf5,0xfb,0xfb,0xff,
0x80,0xc0,0xa0,0x93,0x8a,0x84,0x84,0x80,
0x8f,0x9f,0x81,0xce,0x86,0xcf,0xc0,0xfd,
0xff,0xe7,0xf8,0xff,0xf8,0xf3,0xf7,0x8f,
0xf7,0xfb,0xfd,0x80,0xfd,0xfb,0xf7,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd5,
0xf7,0xf7,0xf7,0xf7,0xb6,0xd5,0xe3,0xf7,
0xf7,0xe3,0xd5,0xb6,0xf7,0xf7,0xf7,0xf7,
0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xbf,0xbf,0xbf,0xbb,0xb9,0x80,0xf9,0xfb,
0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,
0xec,0xe7,0xe3,0x81,0xe3,0xe7,0xef,0x90,
0x9b,0xf3,0xe3,0xc0,0xe3,0xf3,0xfb,0x84,
0xbf,0xb7,0xf7,0x80,0xc1,0xe3,0xb7,0xbf,
0xbf,0xb7,0xe3,0xc1,0x80,0xf7,0xb7,0xbf,
0xff,0xff,0xff,0x80,0xff,0xff,0xff,0xff,
0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0x80,
0xf7,0xef,0xdf,0x80,0xdf,0xef,0xf7,0xff,
0xd5,0xaa,0xd5,0xaa,0xd5,0xaa,0xd5,0xaa,
0xaa,0xd5,0xaa,0xd5,0xaa,0xd5,0xaa,0xd5,
0xff,0xc1,0xbe,0xfe,0xfe,0xfe,0x80,0xff,
0xff,0xff,0xc0,0xbf,0xbf,0xbf,0x80,0xff,
0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,0xbf,
0xf7,0xe3,0xc1,0x80,0xc1,0xe3,0xf7,0xff,
0x80,0xff,0xff,0xff,0xff,0xff,0xff,0x80,
0xeb,0xeb,0x88,0xff,0x88,0xeb,0xeb,0xff,
0x80,0xbf,0xbf,0xb3,0xb3,0xbf,0xbf,0x80,
0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,0xfe,
0x04,0x08,0x10,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x1c,0x20,0x3c,0x22,0x3c,0x00,
0x02,0x02,0x1e,0x22,0x22,0x22,0x1e,0x00,
0x00,0x00,0x3c,0x02,0x02,0x02,0x3c,0x00,
0x20,0x20,0x3c,0x22,0x22,0x22,0x3c,0x00,
0x00,0x00,0x1c,0x22,0x3e,0x02,0x3c,0x00,
0x18,0x24,0x04,0x1e,0x04,0x04,0x04,0x00,
0x00,0x00,0x1c,0x22,0x22,0x3c,0x20,0x1c,
0x02,0x02,0x1e,0x22,0x22,0x22,0x22,0x00,
0x08,0x00,0x0c,0x08,0x08,0x08,0x1c,0x00,
0x10,0x00,0x18,0x10,0x10,0x10,0x12,0x0c,
0x02,0x02,0x22,0x12,0x0e,0x12,0x22,0x00,
0x0c,0x08,0x08,0x08,0x08,0x08,0x1c,0x00,
0x00,0x00,0x36,0x2a,0x2a,0x2a,0x22,0x00,
0x00,0x00,0x1e,0x22,0x22,0x22,0x22,0x00,
0x00,0x00,0x1c,0x22,0x22,0x22,0x1c,0x00,
0x00,0x00,0x1e,0x22,0x22,0x1e,0x02,0x02,
0x00,0x00,0x3c,0x22,0x22,0x3c,0x20,0x20,
0x00,0x00,0x3a,0x06,0x02,0x02,0x02,0x00,
0x00,0x00,0x3c,0x02,0x1c,0x20,0x1e,0x00,
0x04,0x04,0x1e,0x04,0x04,0x24,0x18,0x00,
0x00,0x00,0x22,0x22,0x22,0x32,0x2c,0x00,
0x00,0x00,0x22,0x22,0x22,0x14,0x08,0x00,
0x00,0x00,0x22,0x22,0x2a,0x2a,0x36,0x00,
0x00,0x00,0x22,0x14,0x08,0x14,0x22,0x00,
0x00,0x00,0x22,0x22,0x22,0x3c,0x20,0x1c,
0x00,0x00,0x3e,0x10,0x08,0x04,0x3e,0x00,
0x38,0x0c,0x0c,0x06,0x0c,0x0c,0x38,0x00,
0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
0x0e,0x18,0x18,0x30,0x18,0x18,0x0e,0x00,
0x2c,0x1a,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x2a,0x14,0x2a,0x14,0x2a,0x00,0x00,
0xe3,0xdd,0xd5,0xc5,0xe5,0xfd,0xc3,0xff,
0xf7,0xeb,0xdd,0xdd,0xc1,0xdd,0xdd,0xff,
0xe1,0xdd,0xdd,0xe1,0xdd,0xdd,0xe1,0xff,
0xe3,0xdd,0xfd,0xfd,0xfd,0xdd,0xe3,0xff,
0xe1,0xdd,0xdd,0xdd,0xdd,0xdd,0xe1,0xff,
0xc1,0xfd,0xfd,0xe1,0xfd,0xfd,0xc1,0xff,
0xc1,0xfd,0xfd,0xe1,0xfd,0xfd,0xfd,0xff,
0xc3,0xfd,0xfd,0xfd,0xcd,0xdd,0xc3,0xff,
0xdd,0xdd,0xdd,0xc1,0xdd,0xdd,0xdd,0xff,
0xe3,0xf7,0xf7,0xf7,0xf7,0xf7,0xe3,0xff,
0xdf,0xdf,0xdf,0xdf,0xdf,0xdd,0xe3,0xff,
0xdd,0xed,0xf5,0xf9,0xf5,0xed,0x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0x9e,0x99,0x66,
0x9d,0x9d,0xdd,0x77,0x9d,0x9d,0x99,0x66,
0x9c,0x9c,0xcc,0x33,0x9c,0x9c,0x99,0x66,
0x9b,0x9b,0xbb,0xee,0x9b,0x9b,0x99,0x66,
0x9a,0x9a,0xaa,0xaa,0x9a,0x9a,0x99,0x66,
0x99,0x99,0x99,0x66,0x99,0x99,0x99,0x66,
0x98,0x98,0x88,0x22,0x98,0x98,0x99,0x66,
0x97,0x97,0x77,0xdd,0x97,0x97,0x99,0x66,
0x96,0x96,0x66,0x99,0x96,0x96,0x99,0x66,
0x95,0x95,0x55,0x55,0x95,0x95,0x99,0x66,
0x94,0x94,0x44,0x11,0x94,0x94,0x99,0x66,
0x93,0x93,0x33,0xcc,0x93,0x93,0x99,0x66,
0x92,0x92,0x22,0x88,0x92,0x92,0x99,0x66,
0x91,0x91,0x11,0x44,0x91,0x91,0x99,0x66,
0x90,0x90,0x00,0x00,0x90,0x90,0x99,0x66,
0x8f,0x8f,0xff,0xff,0x8f,0x8f,0x88,0x22,
0x8e,0x8e,0xee,0xbb,0x8e,0x8e,0x88,0x22,
0x8d,0x8d,0xdd,0x77,0x8d,0x8d,0x88,0x22,
0x8c,0x8c,0xcc,0x33,0x8c,0x8c,0x88,0x22,
0x8b,0x8b,0xbb,0xee,0x8b,0x8b,0x88,0x22,
0x8a,0x8a,0xaa,0xaa,0x8a,0x8a,0x88,0x22,
0x89,0x89,0x99,0x66,0x89,0x89,0x88,0x22,
0x88,0x88,0x88,0x22,0x88,0x88,0x88,0x22,
0x87,0x87,0x77,0xdd,0x87,0x87,0x88,0x22,
0x86,0x86,0x66,0x99,0x86,0x86,0x88,0x22,
0x85,0x85,0x55,0x55,0x85,0x85,0x88,0x22,
0x84,0x84,0x44,0x11,0x84,0x84,0x88,0x22,
0x83,0x83,0x33,0xcc,0x83,0x83,0x88,0x22,
0x82,0x82,0x22,0x88,0x82,0x82,0x88,0x22,
0x81,0x81,0x11,0x44,0x81,0x81,0x88,0x22,
0x80,0x80,0x00,0x00,0x80,0x80,0x88,0x22,
0xff,0xff,0xff,0xff,0xff,0xff,0x77,0xdd,
0xfe,0xfe,0xee,0xbb,0xfe,0xfe,0x77,0xdd,
0xfd,0xfd,0xdd,0x77,0xfd,0xfd,0x77,0xdd,
0xfc,0xfc,0xcc,0x33,0xfc,0xfc,0x77,0xdd,
0xfb,0xfb,0xbb,0xee,0xfb,0xfb,0x77,0xdd,
0xfa,0xfa,0xaa,0xaa,0xfa,0xfa,0x77,0xdd,
0xf9,0xf9,0x99,0x66,0xf9,0xf9,0x77,0xdd,
0xf8,0xf8,0x88,0x22,0xf8,0xf8,0x77,0xdd,
0xf7,0xf7,0x77,0xdd,0xf7,0xf7,0x77,0xdd,
0xf6,0xf6,0x66,0x99,0xf6,0xf6,0x77,0xdd,
0xf5,0xf5,0x55,0x55,0xf5,0xf5,0x77,0xdd,
0xf4,0xf4,0x44,0x11,0xf4,0xf4,0x77,0xdd,
0xf3,0xf3,0x33,0xcc,0xf3,0xf3,0x77,0xdd,
0xf2,0xf2,0x22,0x88,0xf2,0xf2,0x77,0xdd,
0xf1,0xf1,0x11,0x44,0xf1,0xf1,0x77,0xdd,
0xf0,0xf0,0x00,0x00,0xf0,0xf0,0x77,0xdd,
0xef,0xef,0xff,0xff,0xef,0xef,0x66,0x99,
0xee,0xee,0xee,0xbb,0xee,0xee,0x66,0x99,
0xed,0xed,0xdd,0x77,0xed,0xed,0x66,0x99,
0xec,0xec,0xcc,0x33,0xec,0xec,0x66,0x99,
0xeb,0xeb,0xbb,0xee,0xeb,0xeb,0x66,0x99,
0xea,0xea,0xaa,0xaa,0xea,0xea,0x66,0x99,
0xe9,0xe9,0x99,0x66,0xe9,0xe9,0x66,0x99,
0xe8,0xe8,0x88,0x22,0xe8,0xe8,0x66,0x99,
0xe7,0xe7,0x77,0xdd,0xe7,0xe7,0x66,0x99,
0xe6,0xe6,0x66,0x99,0xe6,0xe6,0x66,0x99,
0xe5,0xe5,0x55,0x55,0xe5,0xe5,0x66,0x99,
0xe4,0xe4,0x44,0x11,0xe4,0xe4,0x66,0x99,
0xe3,0xe3,0x33,0xcc,0xe3,0xe3,0x66,0x99,
0xe2,0xe2,0x22,0x88,0xe2,0xe2,0x66,0x99,
0xe1,0xe1,0x11,0x44,0xe1,0xe1,0x66,0x99,
0xe0,0xe0,0x00,0x00,0xe0,0xe0,0x66,0x99,
0xdf,0xdf,0xff,0xff,0xdf,0xdf,0x55,0x55,
0xde,0xde,0xee,0xbb,0xde,0xde,0x55,0x55,
0xdd,0xdd,0xdd,0x77,0xdd,0xdd,0x55,0x55,
0xdc,0xdc,0xcc,0x33,0xdc,0xdc,0x55,0x55,
0xdb,0xdb,0xbb,0xee,0xdb,0xdb,0x55,0x55,
0xda,0xda,0xaa,0xaa,0xda,0xda,0x55,0x55,
0xd9,0xd9,0x99,0x66,0xd9,0xd9,0x55,0x55,
0xd8,0xd8,0x88,0x22,0xd8,0xd8,0x55,0x55,
0xd7,0xd7,0x77,0xdd,0xd7,0xd7,0x55,0x55,
0xd6,0xd6,0x66,0x99,0xd6,0xd6,0x55,0x55,
0xd5,0xd5,0x55,0x55,0xd5,0xd5,0x55,0x55,
0xd4,0xd4,0x44,0x11,0xd4,0xd4,0x55,0x55,
0xd3,0xd3,0x33,0xcc,0xd3,0xd3,0x55,0x55,
0xd2,0xd2,0x22,0x88,0xd2,0xd2,0x55,0x55,
0xd1,0xd1,0x11,0x44,0xd1,0xd1,0x55,0x55,
0xd0,0xd0,0x00,0x00,0xd0,0xd0,0x55,0x55,
0xcf,0xcf,0xff,0xff,0xcf,0xcf,0x44,0x11,
0xce,0xce,0xee,0xbb,0xce,0xce,0x44,0x11,
0xcd,0xcd,0xdd,0x77,0xcd,0xcd,0x44,0x11,
0xcc,0xcc,0xcc,0x33,0xcc,0xcc,0x44,0x11,
0xcb,0xcb,0xbb,0xee,0xcb,0xcb,0x44,0x11,
0xca,0xca,0xaa,0xaa,0xca,0xca,0x44,0x11,
0xc9,0xc9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0xbb,0xae,0xae,0x22,0x88,
0xad,0xad,0xdd,0x77,0xad,0xad,0x22,0x88,
0xac,0xac,0xcc,0x33,0xac,0xac,0x22,0x88,
0xab,0xab,0xbb,0xee,0xab,0xab,0x22,0x88,
0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0x22,0x88,
0xa9,0xa9,0x99,0x66,0xa9,0xa9,0x22,0x88,
0xa8,0xa8,0x88,0x22,0xa8,0xa8,0x22,0x88,
0xa7,0xa7,0x77,0xdd,0xa7,0xa7,0x22,0x88,
0xa6,0xa6,0x66,0x99,0xa6,0xa6,0x22,0x88,
0xa5,0xa5,0x55,0x55,0xa5,0xa5,0x22,0x88,
0xa4,0xa4,0x44,0x11,0xa4,0xa4,0x22,0x88,
0xa3,0xa3,0x33,0xcc,0xa3,0xa3,0x22,0x88,
0xa2,0xa2,0x22,0x88,0xa2,0xa2,0x22,0x88,
0xa1,0xa1,0x11,0x44,0xa1,0xa1,0x22,0x88,
0xa0,0xa0,0x00,0x00,0xa0,0xa0,0x22,0x88,
0x9f,0x9f,0xff,0xff,0x9f,0x9f,0x11,0x44,
0x9e,0x9e,0xee,0xbb,0x9e,0x9e,0x11,0x44,
0x9d,0x9d,0xdd,0x77,0x9d,0x9d,0x11,0x44,
0x9c,0x9c,0xcc,0x33,0x9c,0x9c,0x11,0x44,
0x9b,0x9b,0xbb,0xee,0x9b,0x9b,0x11,0x44,
0x9a,0x9a,0xaa,0xaa,0x9a,0x9a,0x11,0x44,
0x99,0x99,0x99,0x66,0x99,0x99,0x11,0x44,
0x98,0x98,0x88,0x22,0x98,0x98,0x11,0x44,
0x97,0x97,0x77,0xdd,0x97,0x97,0x11,0x44,
0x96,0x96,0x66,0x99,0x96,0x96,0x11,0x44,
0x95,0x95,0x55,0x55,0x95,0x95,0x11,0x44,
0x94,0x94,0x44,0x11,0x94,0x94,0x11,0x44,
0x93,0x93,0x33,0xcc,0x93,0x93,0x11,0x44,
0x92,0x92,0x22,0x88,0x92,0x92,0x11,0x44,
0x91,0x91,0x11,0x44,0x91,0x91,0x11,0x44,
0x90,0x90,0x00,0x00,0x90,0x90,0x11,0x44,
0x8f,0x8f,0xff,0xff,0x8f,0x8f,0x00,0x00,
0x8e,0x8e,0xee,0xbb,0x8e,0x8e,0x00,0x00,
0x8d,0x8d,0xdd,0x77,0x8d,0x8d,0x00,0x00,
0x8c,0x8c,0xcc,0x33,0x8c,0x8c,0x00,0x00,
0x8b,0x8b,0xbb,0xee,0x8b,0x8b,0x00,0x00,
0x8a,0x8a,0xaa,0xaa,0x8a,0x8a,0x00,0x00,
0x89,0x89,0x99,0x66,0x89,0x89,0x00,0x00,
0x88,0x88,0x88,0x22,0x88,0x88,0x00,0x00,
0x87,0x87,0x77,0xdd,0x87,0x87,0x00,0x00,
0x86,0x86,0x66,0x99,0x86,0x86,0x00,0x00,
0x85,0x85,0x55,0x55,0x85,0x85,0x00,0x00,
0x84,0x84,0x44,0x11,0x84,0x84,0x00,0x00,
0x83,0x83,0x33,0xcc,0x83,0x83,0x00,0x00,
0x82,0x82,0x22,0x88,0x82,0x82,0x00,0x00,
0x81,0x81,0x11,0x44,0x81,0x81,0x00,0x00,
0x80,0x80,0x00,0x00,0x80,0x80,0x00,0x00
];

View File

@ -10,10 +10,10 @@
*/
/*jshint jquery: true, browser: true */
/*globals debug: false, toHex: false */
/*exported KeyBoard2e */
/*globals debug: false, toHex: false, reset: false */
/*exported KeyBoard */
function KeyBoard2e(io) {
function KeyBoard(io, e) {
// keycode: [plain, cntl, shift]
var keymap = {
// Most of these won't happen
@ -155,17 +155,32 @@ function KeyBoard2e(io) {
0xFF: [0xFF, 0xFF, 0xFF] // No comma line
};
var keys =
[[['ESC','1','2','3','4','5','6','7','8','9','0','-','=','DELETE'],
var keys2 =
[[['1','2','3','4','5','6','7','8','9','0',':','-','RESET'],
['ESC','Q','W','E','R','T','Y','U','I','O','P','REPT','RETURN'],
['CTRL','A','S','D','F','G','H','J','K','L',';','&larr;','&rarr;'],
['SHIFT','Z','X','C','V','B','N','M',',','.','/','SHIFT'],
['POWER', '&nbsp;']],
[['!','"','#','$','%','&','\'','(',')','0','*','=','RESET'],
['ESC','Q','W','E','R','T','Y','U','I','O','@','REPT','RETURN'],
['CTRL','A','S','D','F','BELL','H','J','K','L','+','&larr;','&rarr;'],
['SHIFT','Z','X','C','V','B','^',']','<','>','?','SHIFT'],
['POWER', '&nbsp;']]];
var keys2e = [
[['ESC','1','2','3','4','5','6','7','8','9','0','-','=','DELETE'],
['TAB','Q','W','E','R','T','Y','U','I','O','P','[',']','\\'],
['CTRL','A','S','D','F','G','H','J','K','L',';','"','RETURN'],
['SHIFT','Z','X','C','V','B','N','M',',','.','/','SHIFT'],
['LOCK','`','POW','OPEN_APPLE','&nbsp;','CLOSED_APPLE','&larr;','&rarr;','&darr;','&uarr;']],
[['ESC','!','@','#','$','%','^','&','*','(',')','_','+','DELETE'],
[['ESC','!','@','#','$','%','^','&','*','(',')','_','+','DELETE'],
['TAB','Q','W','E','R','T','Y','U','I','O','P','{','}','|'],
['CTRL','A','S','D','F','G','H','J','K','L',':','\'','RETURN'],
['SHIFT','Z','X','C','V','B','N','M','<','>','?','SHIFT'],
['CAPS','~','POW','OPEN_APPLE','&nbsp;','CLOSED_APPLE','&larr;','&rarr;','&darr;','&uarr;']]];
['CAPS','~','POW','OPEN_APPLE','&nbsp;','CLOSED_APPLE','&larr;','&rarr;','&darr;','&uarr;']]
];
var keys = e ? keys2e : keys2;
var shifted = false;
var controlled = false;
@ -191,10 +206,10 @@ function KeyBoard2e(io) {
shiftKey: function keyboard_shiftKey(down) {
shifted = down;
if (down) {
io.buttonDown(2);
io.buttonUp(2);
$('#keyboard .key-SHIFT').addClass('active');
} else {
io.buttonUp(2);
io.buttonDown(2);
$('#keyboard .key-SHIFT').removeClass('active');
}
},
@ -270,7 +285,7 @@ function KeyBoard2e(io) {
key = '\t';
break;
case 'DELETE':
key = '\0177';
key = '\177';
break;
case '&larr;':
key = '\010';
@ -307,9 +322,13 @@ function KeyBoard2e(io) {
self.capslockKey(!capslocked);
break;
case 'POW':
case 'POWER':
if (window.confirm('Power Cycle?'))
window.location.reload();
break;
case 'RESET':
reset();
break;
case 'OPEN_APPLE':
self.commandKey(!commanded);
break;
@ -322,7 +341,7 @@ function KeyBoard2e(io) {
} else {
if (controlled && key >= '@' && key <= '_') {
io.keyDown(key.charCodeAt(0) - 0x40);
} else if (!shifted && !capslocked &&
} else if (!e && !shifted && !capslocked &&
key >= 'A' && key <= 'Z') {
io.keyDown(key.charCodeAt(0) + 0x20);
} else {
@ -332,7 +351,7 @@ function KeyBoard2e(io) {
}
for (y = 0; y < 5; y++) {
row = $('<div class="row row' + y + 'e"/>');
row = $('<div class="row row' + y + '"/>');
kb.append(row);
for (x = 0; x < keys[0][y].length; x++) {
key1 = keys[0][y][x];

View File

@ -1,294 +0,0 @@
/* Copyright 2010-2016 Will Scullin <scullin@scullinsteel.com>
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation. No representations are made about the suitability of this
* software for any purpose. It is provided "as is" without express or
* implied warranty.
*/
/*globals debug: false, toHex: false, reset: false */
/*exported KeyBoard2 */
function KeyBoard2(io) {
// keycode: [plain, cntl, shift]
var keymap = {
// Most of these won't happen
0x00: [0x00, 0x00, 0x00], //
0x01: [0x01, 0x01, 0x01], //
0x02: [0x02, 0x02, 0x02], //
0x03: [0x03, 0x03, 0x03], //
0x04: [0x04, 0x04, 0x04], //
0x05: [0x05, 0x05, 0x05], //
0x06: [0x06, 0x06, 0x06], //
0x07: [0x07, 0x07, 0x07], //
0x08: [0x08, 0x08, 0x08], // BS
0x09: [0x09, 0x09, 0x09], // TAB
0x0A: [0x0A, 0x0A, 0x0A], //
0x0B: [0x0B, 0x0B, 0x0B], //
0x0C: [0x0C, 0x0C, 0x0C], //
0x0D: [0x0D, 0x0D, 0x0D], // CR
0x0E: [0x0E, 0x0E, 0x0E], //
0x0F: [0x0F, 0x0F, 0x0F], //
0x10: [0xff, 0xff, 0xff], // SHIFT
0x11: [0xff, 0xff, 0xff], // CTRL
0x12: [0xff, 0xff, 0xff], // OPTION
0x13: [0x13, 0x13, 0x13], //
0x14: [0x14, 0x14, 0x14], //
0x15: [0x15, 0x15, 0x15], //
0x16: [0x16, 0x16, 0x16], //
0x17: [0x17, 0x17, 0x18], //
0x18: [0x18, 0x18, 0x18], //
0x19: [0x19, 0x19, 0x19], //
0x1A: [0x1A, 0x1A, 0x1A], //
0x1B: [0x1B, 0x1B, 0x1B], // ESC
0x1C: [0x1C, 0x1C, 0x1C], //
0x1D: [0x1D, 0x1D, 0x1D], //
0x1E: [0x1E, 0x1E, 0x1E], //
0x1F: [0x1F, 0x1F, 0x1F], //
// Most of these besides space won't happen
0x20: [0x20, 0x20, 0x20], //
0x21: [0x21, 0x21, 0x21], //
0x22: [0x22, 0x22, 0x22], //
0x23: [0x23, 0x23, 0x23], //
0x24: [0x24, 0x24, 0x24], //
0x25: [0x08, 0x08, 0x08], // <- left
0x26: [0x0B, 0x0B, 0x0B], // ^ up
0x27: [0x15, 0x15, 0x15], // -> right
0x28: [0x0A, 0x0A, 0x0A], // v down
0x29: [0x29, 0x29, 0x29], // )
0x2A: [0x2A, 0x2A, 0x2A], // *
0x2B: [0x2B, 0x2B, 0x2B], // +
0x2C: [0x2C, 0x2C, 0x3C], // , - <
0x2D: [0x2D, 0x2D, 0x5F], // - - _
0x2E: [0x2E, 0x2E, 0x3E], // . - >
0x2F: [0x2F, 0x2F, 0x3F], // / - ?
0x30: [0x30, 0x30, 0x29], // 0 - )
0x31: [0x31, 0x31, 0x21], // 1 - !
0x32: [0x32, 0x00, 0x40], // 2 - @
0x33: [0x33, 0x33, 0x23], // 3 - #
0x34: [0x34, 0x34, 0x24], // 4 - $
0x35: [0x35, 0x35, 0x25], // 5 - %
0x36: [0x36, 0x36, 0x5E], // 6 - ^
0x37: [0x37, 0x37, 0x26], // 7 - &
0x38: [0x38, 0x38, 0x2A], // 8 - *
0x39: [0x39, 0x39, 0x28], // 9 - (
0x3A: [0x3A, 0x3A, 0x3A], // :
0x3B: [0x3B, 0x3B, 0x3A], // ; - :
0x3C: [0x3C, 0x3C, 0x3C], // <
0x3D: [0x3D, 0x3D, 0x2B], // = - +
0x3E: [0x3E, 0x3E, 0x3E], // >
0x3F: [0x3F, 0x3F, 0x3F], // ?
// Alpha and control
0x40: [0x40, 0x00, 0x40], // @
0x41: [0x41, 0x01, 0x41], // A
0x42: [0x42, 0x02, 0x42], // B
0x43: [0x43, 0x03, 0x43], // C - BRK
0x44: [0x44, 0x04, 0x44], // D
0x45: [0x45, 0x05, 0x45], // E
0x46: [0x46, 0x06, 0x46], // F
0x47: [0x47, 0x07, 0x47], // G - BELL
0x48: [0x48, 0x08, 0x48], // H
0x49: [0x49, 0x09, 0x49], // I - TAB
0x4A: [0x4A, 0x0A, 0x4A], // J - NL
0x4B: [0x4B, 0x0B, 0x4B], // K - VT
0x4C: [0x4C, 0x0C, 0x4C], // L
0x4D: [0x4D, 0x0D, 0x4D], // M - CR
0x4E: [0x4E, 0x0E, 0x4E], // N
0x4F: [0x4F, 0x0F, 0x4F], // O
0x50: [0x50, 0x10, 0x50], // P
0x51: [0x51, 0x11, 0x51], // Q
0x52: [0x52, 0x12, 0x52], // R
0x53: [0x53, 0x13, 0x53], // S
0x54: [0x54, 0x14, 0x54], // T
0x55: [0x55, 0x15, 0x55], // U
0x56: [0x56, 0x16, 0x56], // V
0x57: [0x57, 0x17, 0x57], // W
0x58: [0x58, 0x18, 0x58], // X
0x59: [0x59, 0x19, 0x59], // Y
0x5A: [0x5A, 0x1A, 0x5A], // Z
// 0x5B: [0x5B, 0x1B, 0x5B], // [ - ESC
// 0x5C: [0x5C, 0x1C, 0x5C], // \
// 0x5D: [0x5D, 0x1D, 0x5D], // ]
0x5E: [0x5E, 0x1E, 0x5E], // ^
0x5F: [0x5F, 0x1F, 0x5F], // _
// Stray keys
0xBA: [0x3B, 0x3B, 0x3A], // ; - :
0xBB: [0x3D, 0x3D, 0x2B], // = - +
0xBC: [0x2C, 0x2C, 0x3C], // , - <
0xBD: [0x2D, 0x2D, 0x5F], // - - _
0xBE: [0x2E, 0x2E, 0x3E], // . - >
0xBF: [0x2F, 0x2F, 0x3F], // / - ?
0xDB: [0x5B, 0x5B, 0x5B], // [
0xDC: [0x5C, 0x5C, 0x5C], // \
0xDD: [0x5D, 0x5D, 0x5D], // ]
0xDE: [0x27, 0x27, 0x22], // ' - '
0xFF: [0xFF, 0xFF, 0xFF] // No comma line
};
var keys =
[[['1','2','3','4','5','6','7','8','9','0',':','-','RESET'],
['ESC','Q','W','E','R','T','Y','U','I','O','P','REPT','RETURN'],
['CTRL','A','S','D','F','G','H','J','K','L',';','&larr;','&rarr;'],
['SHIFT','Z','X','C','V','B','N','M',',','.','/','SHIFT'],
['POWER', '&nbsp;']],
[['!','"','#','$','%','&','\'','(',')','0','*','=','RESET'],
['ESC','Q','W','E','R','T','Y','U','I','O','@','REPT','RETURN'],
['CTRL','A','S','D','F','BELL','H','J','K','L','+','&larr;','&rarr;'],
['SHIFT','Z','X','C','V','B','^',']','<','>','?','SHIFT'],
['POWER', '&nbsp;']]];
var shifted = false;
var controlled = false;
return {
mapKeyEvent: function keyboard_mapKeyEvent(evt) {
var code = evt.keyCode;
if (code in keymap) {
return keymap[code][evt.shiftKey ? 2 : (evt.ctrlKey ? 1 : 0)];
}
debug('Unhandled key = ' + toHex(code));
return 0xFF;
},
shiftKey: function keyboard_shiftKey(down) {
shifted = down;
if (down) {
io.buttonDown(2);
$('#keyboard .key-SHIFT').addClass('active');
} else {
io.buttonUp(2);
$('#keyboard .key-SHIFT').removeClass('active');
}
},
controlKey: function keyboard_controlKey(down) {
controlled = down;
if (down) {
$('#keyboard .key-CTRL').addClass('active');
} else {
$('#keyboard .key-CTRL').removeClass('active');
}
},
create: function keyboard_create(kb) {
var x, y, row, key, key1, key2, label, label1, label2;
kb.disableSelection();
function buildLabel(k) {
var span = $('<span>' + k + '</span>');
if (k.length > 1 && k.substr(0,1) != '&')
span.addClass('small');
return span;
}
function _mouseup(ev) {
$(ev.currentTarget).removeClass('pressed');
}
function _mousedown(ev) {
$(ev.currentTarget).addClass('pressed');
var key = $(ev.currentTarget).data(shifted ? 'key2' : 'key1');
switch (key) {
case 'BELL':
key = 'G';
break;
case 'RETURN':
key = '\r';
break;
case '&larr;':
key = '\010';
break;
case '&rarr;':
key = '\025';
break;
case '&nbsp;':
key = ' ';
break;
case 'ESC':
key = '\033';
break;
default:
break;
}
if (key.length > 1) {
switch (key) {
case 'SHIFT':
shifted = !shifted;
$('#keyboard .key-SHIFT').toggleClass('active');
break;
case 'CTRL':
controlled = !controlled;
$('#keyboard .key-CTRL').toggleClass('active');
break;
case 'RESET':
reset();
break;
case 'POWER':
if (window.confirm('Power Cycle?'))
window.location.reload();
break;
default:
break;
}
} else {
if (controlled && key >= '@' && key <= '_') {
io.keyDown(key.charCodeAt(0) - 0x40);
} else {
io.keyDown(key.charCodeAt(0));
}
}
}
for (y = 0; y < 5; y++) {
row = $('<div class="row row' + y + '"/>');
kb.append(row);
for (x = 0; x < keys[0][y].length; x++) {
key1 = keys[0][y][x];
key2 = keys[1][y][x];
label = $('<div />');
label1 = buildLabel(key1);
label2 = buildLabel(key2);
key = $('<div class="key">');
key.addClass('key-' + key1.replace(/[&;]/g,''));
if (key1.length > 1)
key.addClass('vcenter');
if (key1 != key2) {
key.addClass('key-' + key2.replace(/[&;]/g,''));
label.append(label2);
label.append('<br/>');
}
label.append(label1);
key.append(label);
key.data({'key1': key1, 'key2': key2});
if (window.ontouchstart === undefined) {
key.bind('mousedown', _mousedown);
key.bind('mouseup mouseout', _mouseup);
} else {
key.bind('touchstart', _mousedown);
key.bind('touchend touchleave', _mouseup);
}
row.append(key);
}
}
}
};
}

View File

@ -30,6 +30,9 @@ function allocMem(size) {
} else {
result = new Array(size);
}
for (var idx = 0; idx < size; idx++) {
result[idx] = (idx & 0x02) ? 0x00 : 0xff;
}
return result;
}