Skip to content

Instantly share code, notes, and snippets.

@Alikberov
Last active March 8, 2023 15:15
Show Gist options
  • Save Alikberov/42cf4e8015ba7ccd8bcec123256543ae to your computer and use it in GitHub Desktop.
Save Alikberov/42cf4e8015ba7ccd8bcec123256543ae to your computer and use it in GitHub Desktop.
SN7497
<html>
<head>
<title>7497</title>
<script>
var hCnv;
var Chip97;
var set97;
class SN7497 {
ticks = 0;
pinout = 0;
constructor() {
}
counting(factor) {
this.ticks = (this.ticks + 1) & 0x3F;
this.pinout
= (factor & 0x20) > 0 && (this.ticks & 0x01) == 0x01 ? 1
: (factor & 0x10) > 0 && (this.ticks & 0x03) == 0x02 ? 1
: (factor & 0x08) > 0 && (this.ticks & 0x07) == 0x04 ? 1
: (factor & 0x04) > 0 && (this.ticks & 0x0F) == 0x08 ? 1
: (factor & 0x02) > 0 && (this.ticks & 0x1F) == 0x10 ? 1
: (factor & 0x01) > 0 && (this.ticks & 0x3F) == 0x20 ? 1 : 0;
return this.pinout;
}
get out() {
return this.pinout;
}
get tick() {
return this.ticks;
}
}
function main() {
hCnv = document.querySelector("canvas").getContext("2d");
Chip97 = new SN7497();
set97 = 63;
loop();
}
function loop() {
var x = 0, y, z;
hCnv.fillStyle = "blue";
hCnv.fillRect(0, 0, hCnv.canvas.width / 2, hCnv.canvas.height);
hCnv.fillStyle = "yellow";
for(y = 0; y <= 64; ++ y) {
hCnv.fillRect(x * 4, y * 4, 4, 4);
z = Chip97.counting(set97);
x += z;
if(z)
hCnv.fillRect(256 + set97 * 4, Chip97.tick * 4, 2, 3);
}
set97 = (set97 + 1) & 63;
setTimeout(loop, 50);
hCnv.fillStyle = "blue";
hCnv.fillRect(256 + set97 * 4, 0, 4, 256);
}
setTimeout(main, 1000);
</script>
</head>
<body>
<canvas width=512 height=256></canvas>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment