mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
graphics: preventing cursorxy(32,80) from scrolling the screen
This commit is contained in:
32
assets/bios/quick.js
Normal file
32
assets/bios/quick.js
Normal 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.");
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
76
assets/disk0/tvdos/tuidev/demo.js
Normal file
76
assets/disk0/tvdos/tuidev/demo.js
Normal 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();
|
||||
@@ -30,7 +30,7 @@ public class AppLoader {
|
||||
//VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, BasicRom.INSTANCE});
|
||||
//VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{OEMBios.INSTANCE, BasicRom.INSTANCE});
|
||||
|
||||
VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{GenericBios.INSTANCE});
|
||||
VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{QuickBios.INSTANCE});
|
||||
//VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{TBASRelBios.INSTANCE});
|
||||
new LwjglApplication(new VMGUI(vm, appConfig), appConfig);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ open class GraphicsAdapter(val vm: VM, val config: AdapterConfig, val sgr: Super
|
||||
var newx = x
|
||||
var newy = y
|
||||
|
||||
if (newx >= TEXT_COLS) {
|
||||
if (newx > TEXT_COLS) {
|
||||
newx = 0
|
||||
newy += 1
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class TTY(val vm: VM) : GlassTty(TEXT_ROWS, TEXT_COLS), PeriBase {
|
||||
var newx = x
|
||||
var newy = y
|
||||
|
||||
if (newx >= TEXT_COLS) {
|
||||
if (newx > TEXT_COLS) {
|
||||
newx = 0
|
||||
newy += 1
|
||||
}
|
||||
|
||||
@@ -30,6 +30,25 @@ object GenericBios : VMProgramRom {
|
||||
override fun get(addr: Int): Byte = contents[addr]
|
||||
}
|
||||
|
||||
object QuickBios : VMProgramRom {
|
||||
private val contents: ByteArray
|
||||
|
||||
init {
|
||||
val bytes = File("./assets/bios/quick.js").readBytes()
|
||||
contents = bytes.sliceArray(0 until minOf(65536, bytes.size))
|
||||
}
|
||||
|
||||
override fun readAll(): String {
|
||||
// check if bios is compressed in gzip
|
||||
return if (contents.startsWith(GZIP_HEADER))
|
||||
CompressorDelegate.decomp(contents).toString(VM.CHARSET)
|
||||
else
|
||||
contents.toString(VM.CHARSET)
|
||||
}
|
||||
|
||||
override fun get(addr: Int): Byte = contents[addr]
|
||||
}
|
||||
|
||||
object BasicBios : VMProgramRom {
|
||||
private val contents: ByteArray
|
||||
|
||||
|
||||
Reference in New Issue
Block a user