graphics: preventing cursorxy(32,80) from scrolling the screen

This commit is contained in:
minjaesong
2021-01-29 13:43:45 +09:00
parent 91fdc7ec99
commit c73a725466
7 changed files with 132 additions and 5 deletions

32
assets/bios/quick.js Normal file
View File

@@ -0,0 +1,32 @@
// probe bootable device
var _BIOS = {};
// Syntax: [Port, Drive-number]
// Port #0-3: Serial port 1-4
// #4+ : Left for future extension
// Drive-number always starts at 1
_BIOS.FIRST_BOOTABLE_PORT = [0,1]; // ah screw it
Object.freeze(_BIOS);
///////////////////////////////////////////////////////////////////////////////
// load a bootsector using 'LOADBOOT'
let portNumber = 0;
let driveStatus = 0;
while (portNumber < 4) {
if (com.areYouThere(portNumber)) {
com.sendMessage(portNumber, "LOADBOOT");
driveStatus = com.getStatusCode(portNumber);
if (driveStatus == 0) break;
}
portNumber += 1;
}
if (portNumber < 4) {
eval(com.fetchResponse(portNumber).trimNull());
}
else {
printerrln("No bootable medium found.");
}

View File

@@ -50,7 +50,7 @@ function greet() {
con.color_pair(0,253);
print(" ".repeat(greetLeftPad)+welcome_text+" ".repeat(greetRightPad));
con.color_pair(253,255);
con.addch(16);
con.addch(16);print(' ');
con.move(3,1);
}
else
@@ -434,7 +434,7 @@ if (goInteractive) {
if (isNaN(errorlevel)) errorlevel = 2;
}
catch (e) {
printerrln("\n"+e);
printerrln("\n"+(e.stack || e));
if (errorlevel === 0 || isNaN(errorlevel)) {
errorlevel = 1; // generic failure
}

View File

@@ -0,0 +1,76 @@
/*
Screen:
===================
Titlebar
===================
C A N V A S
===================
there are usually two separate canvases: main-screen and menu-screen
*/
class SimpleScreen {
constructor(title) {
this.title = title;
this.termWidth = con.getmaxyx()[1];
this.termHeight = con.getmaxyx()[0];
}
drawTitlebar() {
let titleLeftPad = (this.termWidth - this.title.length - 6) >> 1;
let titleRightPad = this.termWidth - titleLeftPad - this.title.length - 6;
con.move(1,1);
con.color_pair(253,255);
print(' ');con.addch(17);
con.color_pair(0,253);
print(" ".repeat(titleLeftPad)+this.title+" ".repeat(titleRightPad));
con.color_pair(253,255);
con.addch(16);print(' ');
}
redraw() {
con.color_pair(239,255);
con.clear();
this.drawTitlebar();
if (this.canvas !== undefined) this.canvas.redraw();
}
update() {
if (this.canvas !== undefined) this.canvas.update();
}
}
class Canvas {
constructor(identifier) {
this.id = identifier;
}
redraw() {}
update() {}
}
class Demo extends SimpleScreen {
constructor(title) {
super(title);
let mainCanvas = new Canvas("main");
mainCanvas.redraw = () => {
}
mainCanvas.update = () => {
con.move(2 + (Math.random()*(this.termHeight - 1)), 1 + (Math.random()*this.termWidth));
con.addch(0xB3 + (Math.random()*39));
}
this.mainCanvas = mainCanvas
this.canvas = this.mainCanvas;
}
}
let s = new Demo("Ctrl-C to exit");
s.redraw();
while (!con.hitterminate()) {
s.update();
}
con.clear();