<html>
<head>
<title>SN7497 simulation & Line drawing</title>
<script>
var hCnv;
var cnt97;
var set97;
function sn7497() {
cnt97 = (cnt97 + 1) & 0x3F;
return (set97 & 0x20) > 0 && (cnt97 & 0x01) == 0x01 ? 1
: (set97 & 0x10) > 0 && (cnt97 & 0x03) == 0x02 ? 1
: (set97 & 0x08) > 0 && (cnt97 & 0x07) == 0x04 ? 1
: (set97 & 0x04) > 0 && (cnt97 & 0x0F) == 0x08 ? 1
: (set97 & 0x02) > 0 && (cnt97 & 0x1F) == 0x10 ? 1
: (set97 & 0x01) > 0 && (cnt97 & 0x3F) == 0x20 ? 1 : 0;
}
function main() {
hCnv = document.querySelector("canvas").getContext("2d");
cnt97 = 0;
set97 = 0;
loop();
}
function loop() {
var x = 0, y, z;
hCnv.fillStyle = "blue";
if(cnt97 > 0 || set97 > 0)
hCnv.fillRect(0, 0, hCnv.canvas.width / 2, hCnv.canvas.height);
else
hCnv.fillRect(0, 0, hCnv.canvas.width, hCnv.canvas.height);
hCnv.fillStyle = "yellow";
for(y = 0; y <= 64; ++ y) {
hCnv.fillRect(x * 4, y * 4, 4, 4);
z = sn7497();
x += z;
if(z)
hCnv.fillRect(256 + cnt97 * 4, set97 * 4, 2, 3);
}
set97 ++;
if(set97 > 63)
set97 = 1;
setTimeout(loop, 50);
hCnv.fillStyle = "blue";
hCnv.fillRect(256, set97 * 4, 256, 3);
}
</script>
</head>
<body onload='main()'>
<canvas width=512 height=256></canvas>
</body>