-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.html
135 lines (123 loc) · 3.06 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>AppleToo.js</title>
<script src="appletoo.js"></script>
<script src="disk2.js"></script>
<script src="CPU6502.js"></script>
<style type="text/css" media="screen">
canvas {
border: 1px solid #DDD;
margin: 0 auto;
display: block;
}
body {
background-color: #000000; /*#222;*/
}
#control {
width: 820px; /*Same width as canvas */
border: 1px solid #DDD;
margin: 1em auto;
padding: 10px;
color: #EEEEEE;
}
#hex_field {
width: 820px;
height: 100px;
background-color: #EEEEEE;
}
#start_field {
background-color: #EEEEEE;
}
label {
display: block;
margin-top: 5px;
margin-bottom: 5px;
}
</style>
<script type="text/javascript" charset="utf-8">
window.onload = function(){
var appleScreen = document.getElementById("screen");
a = new AppleToo({compatibility: false});
appleScreen.width = a.char_w * 40;
appleScreen.height = a.char_h * 24;
document.onkeypress = function(e) {
if (a.is_running() && e.charCode < 0x80) {
a.write_char_code(e.charCode + 128);
console.log(e.charCode);
e.preventDefault();
}
};
document.onkeydown = function(e) {
if (a.is_running()) {
var value = 0;
switch (e.keyCode) {
case 8:
value = 0x7f;
break;
case 27:
value = 27;
break;
case 37:
value = 8;
break;
case 38:
value = 11;
break;
case 39:
value = 21;
break;
case 40:
value = 10;
break;
}
if (value != 0){
a.write_char_code(value + 128);
e.preventDefault();
}
}
};
window.d = new DiskII(a);
a.setPeripheral(d, 1);
};
function load() {
var data = document.getElementById("hex_field").value;
var hex_location = document.getElementById("start_field").value;
a.load_memory(parseInt(hex_location, 16), data);
};
function run() {
var RESET_VECTOR = 0xFFFC;
var pc_num = a.cpu.read_word(RESET_VECTOR);
var pc = document.getElementById("pc_field").value;
if (pc.length > 0) {
pc_num = parseInt(pc, 16);
if (isNaN(pc_num)) {
throw new Error(pc + " is not a valid program counter.");
}
}
a.cpu.PC = pc_num;
a.run_loop();
};
function stop() {
a.stop();
var pc_field = document.getElementById("pc_field");
pc_field.value = "0x" + formatHex(a.cpu.PC);
};
</script>
</head>
<body>
<canvas id="screen"></canvas>
<div id="control">
<label for="hex">Data</label>
<textarea name="hex" id="hex_field"></textarea><br/>
<label for="location">Start Address</label>
<input type="text" name="location" id="start_field" value="0xC000"></input><br/>
<label for="pc">Program Counter (Leave blank for reset vector) </label>
<input type="text" name="pc" id="pc_field" value=""></input></br>
<br/>
<input type="submit" value="Load" onclick="load()"></input>
<input type="submit" value="Run" onclick="run()"></input>
<input type="submit" value="Stop" onclick="stop()"></input>
</div>
</body>
</html>