Skip to content
Snippets Groups Projects
Commit b1eac6bb authored by deuce's avatar deuce
Browse files

Use a background thread for SBBS input. This will allow us to multiplex

the local and remote I/O into a single queue which can be waited on.

A *very* simple door now "works".
parent b69bf653
No related branches found
No related tags found
No related merge requests found
function Attribute(value) { function Attribute(value) {
if (typeof(value) == 'object' && value.constructor === Attribute) if (value === undefined)
this.value = 7;
else if (typeof(value) == 'object' && value.constructor === Attribute)
this.value = value.value; this.value = value.value;
else else
this.value = value; this.value = value;
......
...@@ -5,7 +5,15 @@ ...@@ -5,7 +5,15 @@
if (js.global.Graphic === undefined) if (js.global.Graphic === undefined)
load("graphic.js"); load("graphic.js");
dk.local = { dk.console.local_io = {
graphic:new Graphic(dk.cols, dk.height, 7, ' '); graphic:new Graphic(dk.cols, dk.height, 7, ' '),
clear:function() {
},
cleareol:function() {
},
gotoxy:function(x,y) {
},
print:function(string) {
},
}; };
js.global.dk_old_ctrlkey_passthru = console.ctrlkey_passthru; js.global.dk_old_ctrlkey_passthru = console.ctrlkey_passthru;
js.on_exit("console.ctrlkey_passthru=js.global.dk_old_ctrlkey_passthru"); js.on_exit("console.ctrlkey_passthru=js.global.dk_old_ctrlkey_passthru");
console.ctrlkey_passthru=0xffffffff; // Disable all parsing. console.ctrlkey_passthru=0x7fffffff; // Disable all parsing.
/* /*
* Clears the current screen to black and moves to location 1,1 * Clears the current screen to black and moves to location 1,1
* sets the current attribute to 7 * sets the current attribute to 7
*/ */
dk.remote.clear=function() {
console.clear(7);
}
/* dk.console.remote_io = {
* Clears to end of line. clear:function() {
* Not available witout ANSI (???) console.clear(7);
*/ },
dk.remote.cleareol=function() {
console.cleartoeol(); /*
} * Clears to end of line.
* Not available witout ANSI (???)
/* */
* Moves the cursor to the specified position. cleareol:function() {
* returns false on error. console.cleartoeol();
* Not available without ANSI },
*/
dk.remote.gotoxy=function(x,y) { /*
console.gotoxy(x,y); * Moves the cursor to the specified position.
} * returns false on error.
* Not available without ANSI
/* */
* Writes a string with a "\r\n" appended. gotoxy:function(x,y) {
*/ console.gotoxy(x,y);
dk.remote.println=function(line) { },
console.writeln(line);
} /*
* Writes a string unmodified.
/* */
* Writes a string unmodified. print:function(string) {
*/ console.write(string);
dk.remote.print=function(string) { },
console.write(string); };
}
var input_queue = load(true, "sbbs_input.js");
/* js.on_exit("input_queue.write(''); input_queue.poll(0x7fffffff);");
* Writes a string after parsing ^A codes and appends a "\r\n".
*/
dk.remote.aprintln=function(line) {
console.putmsg(line+"\r\n");
}
/*
* Writes a string after parsing ^A codes.
*/
dk.remote.aprint=function(string) {
// Can't use putmsg() due to pipe-code etc support.
console.putmsg(line, P_NOATCODES|P_NOPAUSE);
}
/*
* Waits up to timeout millisections and returns true if a key
* is pressed before the timeout. For ANSI sequences, returns
* true when the entire ANSI sequence is available.
*/
dk.remote.waitkey=function(timeout) {
}
/*
* Returns a single *KEY*, ANSI is parsed to a single key.
* Returns undefined if there is no key pressed.
*/
dk.remote.getkey=function() {
}
/*
* Returns a single byte... ANSI is not parsed.
*/
dk.remote.getbyte=function() {
}
var q = new Queue("dorkit_input");
var k;
while(!js.terminated) {
if (parent_queue.poll(0))
break;
k = console.inkey(0, 100);
if (k.length) {
q.write(k);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment