forked from vAmigaWeb/vAmigaWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AmiGoDOS.php
296 lines (294 loc) · 9.46 KB
/
AmiGoDOS.php
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?php
$usermode = "SERIAL_MODE_AUX";
$server_name = $_ENV['SERVER_NAME'];
$prompt = '0.SYS:> ';
?>
<!DOCTYPE html>
<html>
<head>
<script src="../js/jquery.js"></script>
<script src="../js/jquery.terminal.min.js"></script>
<link href="../css/jquery.terminal.min.css" rel="stylesheet"/>
<!-- vAmigaWeb-block start -->
<script src="js/vAmigaWeb_player.js"></script>
<script src="../js/keyboard.js"></script>
<script>
var term;
const MODE_AUX = 0;
const MODE_MIDI_MONITOR = 1;
const MODE_AUX_CONSOLE = 2;
const MODE_MIDI_RUNTIME = 3;
const MODE_RAW = 4;
//var CURRENT_MODE = MODE_RAW;
var CURRENT_MODE = MODE_AUX_CONSOLE;
const help = [];
const user_mode = [];
user_mode.push(
"<?php echo $usermode;?>" ,
"SERIAL_MODE_MIDI_MONITOR",
"SERIAL_MODE_AUX_CONSOLE",
"SERIAL_MODE_MIDI_RUNTIME",
"SERIAL_MODE_RAW"
);
//the following lines of code demonstrate how to receive AUX: serial data from the Amiga
//formatted in a compact way
let out_buffer="";
let count=0;
window.addEventListener('message', event => {
if(event.data.msg == 'serial_port_out')
{
switch (CURRENT_MODE) {
case MODE_AUX, MODE_AUX_CONSOLE:
let byte_from_amiga=event.data.value;
out_buffer+=String.fromCharCode( byte_from_amiga & 0xff );
switch (byte_from_amiga &0xff){
case 0x0a:
term.echo(out_buffer.trim());
out_buffer="";
break;
}
if (out_buffer.includes(": ")==true){
term.echo(out_buffer.trim());
out_buffer="";
}
if (out_buffer.includes("> ")==true){
term.set_prompt(out_buffer.trim());
//term.echo(out_buffer, {newline: false});
out_buffer="";
}
if (out_buffer.includes("Process ")==true){
if (out_buffer.includes(" ending")==true){
term.set_prompt("> ");
//term.echo(out_buffer, {newline: false});
out_buffer="";
}
}
break;
case MODE_MIDI_MONITOR:
let midi_byte_from_amiga=event.data.value & 0xff ;
switch ( midi_byte_from_amiga ){
case 0xF8: break; //filter midiclocks
default:
count = count +1;
if (count<31){
term.echo( " 0x"+midi_byte_from_amiga.toString(16).toUpperCase().padStart(2, 0), {newline: false} );
}else{
term.echo( " 0x"+midi_byte_from_amiga.toString(16).toUpperCase().padStart(2, 0) );
count = 0;
}
// term.echo( "0x"+midi_byte_from_amiga.toString(16).toUpperCase().padStart(2, 0) );
break;
}
// term.echo(performance.now()+": "+ midi_byte_from_amiga.toString(16));
break;
case MODE_RAW:
let raw_byte_from_amiga=event.data.value & 0xff ;
switch ( raw_byte_from_amiga ){
default:
count = count +1;
if (count<31){
term.echo( " 0x"+raw_byte_from_amiga.toString(16).toUpperCase().padStart(2, 0), {newline: false} );
}else{
term.echo( " 0x"+raw_byte_from_amiga.toString(16).toUpperCase().padStart(2, 0) );
count = 0;
}
// term.echo( "0x"+midi_byte_from_amiga.toString(16).toUpperCase().padStart(2, 0) );
break;
}
// term.echo(performance.now()+": "+ midi_byte_from_amiga.toString(16));
break;
}
}
});
function ADOS_TX_LINE(msg){
//get the vAmigaWeb iFrame window
let vAmigaWeb_window = document.getElementById("vAmigaWeb").contentWindow;
let data = msg;
switch (CURRENT_MODE) {
case MODE_AUX_CONSOLE:
//data that should be written into the serial port needs a $0C or \r
data = data + "\r";
break;
}
//send the data to the serial port of vAmigaWeb
vAmigaWeb_window.postMessage({cmd:"ser:", text: data}, "*");
}
function ADOS_TX_CHAR(msg){
// conver msg_key to data_byte
//get the vAmigaWeb iFrame window
let vAmigaWeb_window = document.getElementById("vAmigaWeb").contentWindow;
if (msg == "_BREAK_"){
let _BREAK_=0x03;
let data = String.fromCharCode(_BREAK_);
//send the data to the serial port of vAmigaWeb
vAmigaWeb_window.postMessage({cmd:"ser:", text: data}, "*");
}
}
</script>
<style>
.terminal,span,.cmd,div{--background: silver; --color:rgba(45,45,45,0.99); --font: NewTopaz;}
.terminal,span{--size: 1.0;}
/*Fonts*/
@font-face{
font-family: NewTopaz;
src: url("../fonts/Topaz_a1200_v2.0.ttf");
}
body {
background-color: darkgray;
color: white;
}
#vAmigaWeb {
border:none;
}
#player_container div {
display: none !important;
}
</style>
</head>
<body>
<div style="display: flex;align-items: center;justify-content: left;">
<div id="container2">
<script>
jQuery( function($){
var id = 1;
term = $('body').terminal(
function(command, term) {
const command_arr = command.split(" ");
let cmd = command_arr[0];
if (cmd!=''){
switch(command_arr.length){
case 1:
if (cmd == 'help') { term.echo("Available commands:\n alias, assign, cls, echo, exit, help, loadwb, prompt,\n clear, click, close, engage, logout, mode\n ftp(dummy)"); }
else if (cmd == 'cls') { term.clear(); term.echo("AmiGoDOS - Developer Shell [" + user_mode[CURRENT_MODE] + "]"); }
else if (cmd == 'alias'){ term.echo("WIP: make short version of long commands/args"); }
else if (cmd == 'assign'){
switch (CURRENT_MODE){
case MODE_MIDI_MONITOR:
term.echo("WIP: assign i.e. 0xFA midi byte to trigger function in the webpage");
break;
case MODE_AUX, MODE_AUX_CONSOLE:
ADOS_TX_LINE(cmd);
break;
default:
term.echo(cmd + ': Unknown command for chosen MODE');
break;
}
}
else if (cmd == 'prompt'){ term.echo("<?php echo "$prompt";?>"); }
else if (cmd == 'about1'){ term.echo("AmiGoDOS dialect is my amiga-ish syntax flavoured devshell originated in Delphi7 Pascal in 2002..");}
else if (cmd == 'about2'){ term.echo("tried to keep the AmigaDOS syntax somehow alive.. to get things done on MS side.. even in Amiga GUI style");}
else if (cmd == 'about3'){ term.echo("used to connect to Amiga (FS-UAE) via TCP-COMPORT and relay to MIDI or REMOTE-CONSOLE..");}
else if (cmd == 'about4'){ term.echo("now using it to connect to vAmigaWeb..AUX/SER/MIDI for Classic Amiga Web usage and using the experience..");}
else if (cmd == 'about5'){ term.echo("to get it also working for TAWS in the end.. on behalf of the ultimate Amiga Anywhere experience IYKWIM..");}
else if (cmd == 'about6'){ term.echo("AmiGoDOS for the Web uses JavaScript JQueryTerminal as versatile framework.. with AmiGoDOS syntax/functions..");}
else if (cmd == 'about7'){ term.echo("a for Web usage simplified AmiGoDOS is just a nice nostalgic label for WIP to keep the momentum going..");}
else if (cmd == 'about8'){ term.echo("with kind regards.. PTz(Peter Slootbeek)uAH");}
else if (cmd == 'close'){ parent.close(); }
else if (cmd == 'exit'){ parent.location.assign("../home.php"); }
else if (cmd == 'click'){ parent.newcli(); }
else if (cmd == 'loadwb'){ parent.location.assign("../taws.php"); }
else if (cmd == 'logout'){ parent.location.assign("../access/logout.php"); }
else if (cmd == 'ftp'){
term.push(
function(command, term) {
if (command == 'help') {term.echo('Available FTP (dummy) commands: ping');}
else if (command == 'ping') {term.echo('pong');}
else if (command == 'exit') {term.pop();}
else {
term.echo('unknown FTP command ' + command);
}
},
{
prompt: 'FTP> ',
name: 'ftp'
}
);
}
else {
switch (CURRENT_MODE){
case MODE_AUX, MODE_AUX_CONSOLE:
ADOS_TX_LINE(cmd);
//term.echo( cmd +': Unknown command! Type [help] for more info..');
break;
default:
term.echo(cmd + ': Unknown command for chosen MODE');
break;
}
// term.echo( cmd +': Unknown command');
}
break;
default:
if (command_arr.length>>1){ command_arr.splice(0,1);}
if (cmd == 'echo') { term.echo( command_arr.join(" ") ); }
else if (cmd == 'tx'){ ADOS_TX_LINE( command_arr.join(" ") ); }
else if (cmd == 'click'){ parent.newcli(command_arr[0]); }
else if (cmd == 'mode') { CURRENT_MODE=Number(command_arr[0]); term.echo("CURRENT_MODE: " + user_mode[CURRENT_MODE] ); }
else if (cmd == 'exit'){ parent.location.assign(command_arr[0]); }
else {
switch (CURRENT_MODE){
case MODE_AUX, MODE_AUX_CONSOLE:
ADOS_TX_LINE(command);
//term.echo( cmd +': Unknown command! Type [help] for more info..');
break;
default:
term.echo(command + ': Unknown command for chosen MODE');
break;
}
}
}
}
},
{
keymap: {
"CTRL+C": function() {ADOS_TX_CHAR("_BREAK_"); return false; }
},
width: 960,
height: 320,
greetings: "AmiGoDOS - Developer Shell [" + user_mode[CURRENT_MODE] + "]",
prompt: "> ", // we get the prompt from the amiga aux console
onBlur: function() { // prevent loosing focus
return false;
}
}
);
});
</script>
</div>
</div>
<div style="display: flex;align-items: center;justify-content: left;">
<div id="container">
<img style="width:960px; height:633px" src="../img/C1084.gif"
ontouchstart="touched=true"
onclick="
vAmigaWeb_player.vAmigaWeb_url='./'; //the emulator files are in the same folder as the run.html
let touch=(typeof touched!='undefined')?touched:false;touched=false;
let config={
touch:touch,
AROS:false,
x_wait_for_kickstart_injection:true,
navbar:false, //you can also enable this and disable the players toolbar (see styles section above)
wide:true,
border:20.20,
port2:false,
//url:'https://github.com/PTz0uAH/AmiGoDOS/raw/main/Ahoy!.ADF',
kickstart_rom_url:'./roms/kick31.rom'
};
vAmigaWeb_player.load(this,encodeURIComponent(JSON.stringify(config)));
return false;"
/>
</div>
</div>
<!--
<div style="display: flex;align-items: right;justify-content: right;">
<div id="container3">
<img style="position: absolute; left:960px; top:0px; width:960px; height:633px; z-index:10" src="../img/C1084.gif"
ontouchstart="touched=true"
onclick="
vAmigaWeb_player.wasm_write_string_to_ser('echo dit is een test\r');
return false;
"
>
</div>
</div>-->
</body>
</html>