Skip to content

Commit c19f012

Browse files
committed
Merge branch 'quanyang-master'
* quanyang-master: simplify busy work move folder vanillaJS port
2 parents c6dd89a + 1029934 commit c19f012

File tree

3 files changed

+182
-0
lines changed

3 files changed

+182
-0
lines changed

In Javascript/airgap.html

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
7+
<title>System Bus Radio</title>
8+
<meta name="description" content="Simulator for MIPS">
9+
<link rel="stylesheet" href="main.css">
10+
<script src="./airgap.js"></script>
11+
</head>
12+
<body>
13+
<div class="header">
14+
System Bus Radio
15+
</div>
16+
<div class="content">
17+
</br>
18+
<input type="button" value="Play Song" onclick="start()"></br></br>
19+
<textarea id="logs" style="width:70%;min-height:300px">Tested with Chrome at 1560Khz
20+
</textarea>
21+
<div style="font-size:14px">Ported by Yeo Quan Yang. Credits to the original author William Entriken @https://github.com/fulldecent</div><br/>
22+
</div>
23+
</body>
24+
</html>

In Javascript/airgap.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//Credits to https://github.com/fulldecent/system-bus-radio
2+
//As well as Jordan Harband for the nodejs simd library
3+
//Tested to be working on Chrome at 1560khz
4+
5+
function now() {
6+
return performance.now()*1000000;
7+
}
8+
9+
var NSEC_PER_SEC = 1000000000;
10+
var register = 3.1415
11+
12+
function square_am_signal(time,freq) {
13+
document.getElementById('logs').value += "Playing / "+time+" seconds / "+freq+"Hz\n";
14+
var period = NSEC_PER_SEC/freq;
15+
var start = now();
16+
var end = now()+time*NSEC_PER_SEC;
17+
while (now() < end) {
18+
var mid = start+period/2;
19+
var reset = start+period;
20+
while (now()<mid) {
21+
for (i = 0; i < 100; i++) {
22+
register = 1 - Math.log(register) / 1.7193
23+
}
24+
}
25+
while(now() < reset){
26+
}
27+
start = reset
28+
}
29+
}
30+
31+
function start() {
32+
square_am_signal(0.400, 2673);
33+
square_am_signal(0.400, 2349);
34+
square_am_signal(0.400, 2093);
35+
square_am_signal(0.400, 2349);
36+
square_am_signal(0.400, 2673);
37+
square_am_signal(0.400, 2673);
38+
square_am_signal(0.790, 2673);
39+
square_am_signal(0.400, 2349);
40+
square_am_signal(0.400, 2349);
41+
square_am_signal(0.790, 2349);
42+
square_am_signal(0.400, 2673);
43+
square_am_signal(0.400, 3136);
44+
square_am_signal(0.790, 3136);
45+
square_am_signal(0.400, 2673);
46+
square_am_signal(0.400, 2349);
47+
square_am_signal(0.400, 2093);
48+
square_am_signal(0.400, 2349);
49+
square_am_signal(0.400, 2673);
50+
square_am_signal(0.400, 2673);
51+
square_am_signal(0.400, 2673);
52+
square_am_signal(0.400, 2673);
53+
square_am_signal(0.400, 2349);
54+
square_am_signal(0.400, 2349);
55+
square_am_signal(0.400, 2673);
56+
square_am_signal(0.400, 2349);
57+
square_am_signal(0.790, 2093);
58+
}

In Javascript/main.css

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
body {
2+
background-color: #3498db;
3+
font-family: Futura,Helvetica, "Century Gothic";
4+
text-shadow: 1px 1px 0px black;
5+
margin:0px;
6+
padding:0px;
7+
}
8+
9+
.todo {
10+
font-size:12px;
11+
}
12+
.header {
13+
color: white;
14+
font-size: 50px;
15+
padding-top:20px;
16+
text-align: center;
17+
}
18+
.content {
19+
text-align: center;
20+
margin:auto;
21+
width:80%;
22+
font-size:12px;
23+
color:white;
24+
}
25+
#instructionBlock,.data {
26+
font-size:12px !important;
27+
}
28+
.data td {
29+
border:1px solid black;
30+
border-bottom:0px;
31+
border-right:0px;
32+
}
33+
.data td:last-child {
34+
border-right:1px solid black;
35+
}
36+
.data tr:last-child td{
37+
border-bottom:1px solid black;
38+
}
39+
40+
a.button, input.button {
41+
cursor: pointer;
42+
font-family:Futura,Century Gothic;
43+
background: #44c650;
44+
border: 0px;
45+
padding: 5px 80px;
46+
font-weight:bold;
47+
text-transform:uppercase;
48+
color: white;
49+
font-size: 15px;
50+
text-shadow: 1px 1px 0px #222;
51+
box-shadow: 3px 3px 0px #006633;
52+
-webkit-transition: background-color 0.15s ease-in-out;
53+
-moz-transition: background-color 0.15s ease-in-out;
54+
-o-transition: background-color 0.15s ease-in-out;
55+
transition: background-color 0.15s ease-in-out;
56+
}
57+
a.button {
58+
display: inline-block;
59+
text-decoration: none;
60+
padding: 6px 12px 6px 12px;
61+
}
62+
input.button {
63+
//font-size:15px!important;
64+
padding: 5px 20px;
65+
}
66+
a.button:active, input.button:active {
67+
position:relative;
68+
top:1px;
69+
}
70+
a.button:hover, input.button:hover {
71+
background: #00b200;
72+
color:white;
73+
text-shadow: 1px 1px 0px #222;
74+
position:relative;
75+
cursor:pointer;
76+
cursor:hand;
77+
}
78+
input[type="text"],input[type="password"],textarea, select {
79+
margin-left:0px;
80+
background-color: #F7f7f7;
81+
border: 1px solid black;
82+
padding: 5px;
83+
color:#444;
84+
-webkit-transition: border-color 0.2s ease-in-out;
85+
-moz-transition: border-color 0.2s ease-in-out;
86+
-o-transition: border-color 0.2s ease-in-out;
87+
transition: border-color 0.2s ease-in-out;
88+
}
89+
input[type="text"]:hover ,input[type="password"]:hover,textarea:hover,select:hover {
90+
// border :1px solid pink;
91+
box-shadow: 0px 0px 9px black;
92+
}
93+
input[type="text"]:focus ,input[type="password"]:focus,textarea:focus,select:focus {
94+
border :1px solid #CB4242;
95+
box-shadow: 0px 0px 9px #cb4242;
96+
}
97+
input, textarea, keygen, select, button, isindex {
98+
outline:none;
99+
resize: none;
100+
}

0 commit comments

Comments
 (0)