1
0
mirror of https://github.com/pkimpel/retro-b5500.git synced 2026-02-13 03:34:29 +00:00
Files
pkimpel.retro-b5500/tools/BCD-Build-Xlate.html
paul.kimpel@digm.com 085bfd48da Release emulator version 0.19:
1. Implement write to tape and persistence of tape image data.
2014-01-10 22:17:12 +00:00

167 lines
5.5 KiB
HTML

<html>
<head>
<title>Build .bdc Tape Image Translate Tables</title>
<style>
TD {
font-family: Lucida Sans Typewriter, Courier New, Courier, monospace;
font-size: smaller;
text-align: right}
</style>
</head>
<body>
<script>
BICtoANSI = [ // Index by 6-bit BIC to get 8-bit ANSI code
"0", "1", "2", "3", "4", "5", "6", "7", // 00-07, @00-07
"8", "9", "#", "@", "?", ":", ">", "}", // 08-0F, @10-17
"+", "A", "B", "C", "D", "E", "F", "G", // 10-17, @20-27
"H", "I", ".", "[", "&", "(", "<", "~", // 18-1F, @30-37
"|", "J", "K", "L", "M", "N", "O", "P", // 20-27, @40-47
"Q", "R", "$", "*", "-", ")", ";", "{", // 28-2F, @50-57
" ", "/", "S", "T", "U", "V", "W", "X", // 30-37, @60-67
"Y", "Z", ",", "%", "!", "=", "]", "\""]; // 38-3F, @70-77
BICtoBCLANSI = [ // Index by 6-bit BIC to get 8-bit BCL-as-ANSI code
"#", "1", "2", "3", "4", "5", "6", "7", // 00-07, @00-07
"8", "9", "@", "?", "0", ":", ">", "}", // 08-1F, @10-17
",", "/", "S", "T", "U", "V", "W", "X", // 10-17, @20-27
"Y", "Z", "%", "!", " ", "=", "]", "\"", // 18-1F, @30-37
"$", "J", "K", "L", "M", "N", "O", "P", // 20-27, @40-47
"Q", "R", "*", "-", "|", ")", ";", "{", // 28-2F, @50-57
"+", "A", "B", "C", "D", "E", "F", "G", // 30-37, @60-67
"H", "I", "[", "&", ".", "(", "<", "~"]; // 38-3F, @70-77
BCLtoANSI = [ // Index by 6-bit BCL to get 8-bit ANSI code
"?", "1", "2", "3", "4", "5", "6", "7", // 00-07, @00-07
"8", "9", "0", "#", "@", ":", ">", "}", // 08-0F, @10-17
" ", "/", "S", "T", "U", "V", "W", "X", // 10-17, @20-27
"Y", "Z", "!", ",", "%", "=", "]", "\"", // 18-1F, @30-37
"-", "J", "K", "L", "M", "N", "O", "P", // 20-27, @40-47
"Q", "R", "|", "$", "*", ")", ";", "{", // 28-2F, @50-57
"&", "A", "B", "C", "D", "E", "F", "G", // 30-37, @60-67
"H", "I", "+", ".", "[", "(", "<", "~"]; // 38-3F, @70-77
function html(c) {
/* Filter ANSI characters to escaped HTML */
switch(c) {
case "<": return "&lt;";
case ">": return "&gt;";
case '"': return "&quot;";
case "&": return "&amp;";
case " ": return "&nbsp;"
default: return c;
}
}
function parity(c) {
/* Compute even parity over six bits. Returns 0 or 1 */
return ((c & 0x01) ^ ((c & 0x02) >>> 1) ^ ((c & 0x04) >>> 2) ^
((c & 0x08) >>> 3) ^ ((c & 0x10) >>> 4) ^ ((c & 0x20) >>> 5));
}
function pic9n(v, n) {
/* Formats a value padded with leading zeroes to length "n" */
var text = v.toString();
if (text.length > n) {
text = text.substring(-n);
} else {
while (text.length < n) {
text = "0" + text;
}
}
return text;
}
var bcdEven = new Array(128);
var bcdOdd = new Array(128);
var ansiOdd = new Array(128);
var ansiEven= new Array(128);
var c;
var even;
var odd;
var x;
var y;
document.write("<h3>Build .bdc Tape Image Translate Tables</h3>");
// Initialize the tables with invalid parity codes
for (x=0; x<128; x++) {
bcdEven[x] = ansiEven[x] = bcdOdd[x] = ansiOdd[x] = 0xFF;
}
// Build the even/odd parity codes
document.write("<table border=1 cellspacing=0><thead><tr><th>Code<th>P<th>BIC<th>Odd<th>BCL<th>Even<tbody>");
for (c=0; c<64; c++) {
// Odd parity translates
odd = 1-parity(c);
x = c | (odd << 6);
bcdOdd[x] = BICtoANSI[c].charCodeAt(0);
ansiOdd[bcdOdd[x]] = x;
// Even parity translates
even = parity(c);
y = c | (even << 6);
bcdEven[y] = BCLtoANSI[c].charCodeAt(0);
ansiEven[bcdEven[y]] = y;
document.write("<tr><td>");
document.write(pic9n(c.toString(8), 2));
document.write("<td>");
document.write(odd.toString(2));
document.write("<td>");
document.write(html(BICtoANSI[c]));
document.write("<td>");
document.write(pic9n(x.toString(2), 7));
document.write("<td>");
document.write(html(BCLtoANSI[c]));
document.write("<td>");
document.write(pic9n(y.toString(2), 7));
}
document.write("</table>");
document.write("<h3>BCD Odd Parity BIC to ANSI Table</h3><code>");
for (x=0; x<128; x++) {
document.write("0x" + pic9n(bcdOdd[x].toString(16).toUpperCase(), 2) + ", ");
if (x % 16 == 15) {
document.write("<br>");
}
}
document.write("</code>");
document.write("<h3>BCD Odd Parity ANSI to BIC Table</h3><code>");
for (x=0; x<128; x++) {
document.write("0x" + pic9n(ansiOdd[x].toString(16).toUpperCase(), 2) + ", ");
if (x % 16 == 15) {
document.write("<br>");
}
}
document.write("</code>");
document.write("<h3>BCD Even Parity BCL to ANSI Table</h3><code>");
for (x=0; x<128; x++) {
document.write("0x" + pic9n(bcdEven[x].toString(16).toUpperCase(), 2) + ", ");
if (x % 16 == 15) {
document.write("<br>");
}
}
document.write("</code>");
document.write("<h3>BCD Even Parity ANSI to BCL Table</h3><code>");
for (x=0; x<128; x++) {
document.write("0x" + pic9n(ansiEven[x].toString(16).toUpperCase(), 2) + ", ");
if (x % 16 == 15) {
document.write("<br>");
}
}
document.write("</code>");
</script>
</body>
</html>