mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
edit: much much simpler interface xD
This commit is contained in:
@@ -2,13 +2,16 @@ let scroll = 0;
|
||||
let textbuffer = ["The quick brown fox","jumps over a lazy dog 12345678901234567890", "Pack my box with", "five dozen liquor jugs"];
|
||||
let cursorRow = 0;
|
||||
let cursorCol = 0;
|
||||
let exit = false;
|
||||
let scene = -1; // -1: main, 0: filemenu, 1: editmenu , ...
|
||||
|
||||
let windowSize = con.getmaxyx();
|
||||
let paintWidth = windowSize[1]-4;
|
||||
let paintHeight = windowSize[0]-1;
|
||||
let scrollPeek = Math.ceil((paintHeight / 7));
|
||||
|
||||
const menubarItems = ["File","Edit","View"];
|
||||
//const menubarItems = ["File","Edit","View"];
|
||||
const menubarItems = [`^S${String.fromCharCode(221)}save`,`^X${String.fromCharCode(221)}exit`];
|
||||
const menubarFile = ["New","Open","Save","Save as","Exit"];
|
||||
const menubarEdit = ["Undo","Redo","Cut","Copy","Paste","Select All","Deselect"];
|
||||
const menubarView = ["Go To Line"];
|
||||
@@ -45,7 +48,7 @@ function drawMain() {
|
||||
print(String.fromCharCode(222));
|
||||
for (let i = 0; i < v.length; i++) {
|
||||
let c = v.charCodeAt(i);
|
||||
if (c >= 65 && c <= 90)
|
||||
if (c >= 65 && c <= 90 || c == 94)
|
||||
con.color_pair(COL_TEXT, COL_BACK);
|
||||
else
|
||||
con.color_pair(COL_BACK, COL_TEXT);
|
||||
@@ -132,6 +135,20 @@ function drawTextbuffer() {
|
||||
con.move(2 + cursorRow, 5 + cursorCol);
|
||||
}
|
||||
|
||||
drawMenubarBase(0);
|
||||
function hitCtrlS() {
|
||||
sys.poke(-40, 1);
|
||||
return (sys.peek(-41) == 47 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));
|
||||
}
|
||||
|
||||
function hitCtrlX() {
|
||||
sys.poke(-40, 1);
|
||||
return (sys.peek(-41) == 52 && (sys.peek(-42) == 129 || sys.peek(-42) == 130));
|
||||
}
|
||||
|
||||
reset_status();
|
||||
drawMain();
|
||||
drawTextbuffer();
|
||||
while (!exit) {
|
||||
if (hitCtrlX()) exit = true;
|
||||
|
||||
|
||||
}
|
||||
43
assets/disk0/tvdos/bin/graphicstest.js
Normal file
43
assets/disk0/tvdos/bin/graphicstest.js
Normal file
@@ -0,0 +1,43 @@
|
||||
var w = 560;
|
||||
var h = 448;
|
||||
var hwoff = 1048576;
|
||||
|
||||
function inthash(x) {
|
||||
x = ((x >> 16) ^ x) * 0x45d9f3b;
|
||||
x = ((x >> 16) ^ x) * 0x45d9f3b;
|
||||
x = (x >> 16) ^ x;
|
||||
return x;
|
||||
}
|
||||
|
||||
var rng = Math.floor(Math.random() * 2147483647) + 1;
|
||||
|
||||
while (!con.hitterminate()) {
|
||||
|
||||
var tstart = sys.nanoTime();
|
||||
|
||||
for (var y = 0; y < 360; y++) {
|
||||
for (var x = 0; x < w; x++) {
|
||||
var palnum = 20 * Math.floor(y / 30) + Math.floor(x / 28);
|
||||
sys.poke(-(y * w + x + 1) - hwoff, inthash(palnum + rng));
|
||||
}
|
||||
}
|
||||
|
||||
for (var y = 360; y < h; y++) {
|
||||
for (var x = 0; x < w; x++) {
|
||||
var palnum = 240 + Math.floor(x / 35);
|
||||
sys.poke(-(y * w + x + 1) - hwoff, palnum);
|
||||
}
|
||||
}
|
||||
|
||||
/*for (var k = 0; k < 2560; k++) {
|
||||
sys.poke(-(253952 + k + 1) - hwoff, -2); // transparent
|
||||
sys.poke(-(253952 + 2560 + k + 1) - hwoff, -1); // white
|
||||
/*sys.poke(-(253952 + 2560*2 + k + 1) - hwoff, Math.round(Math.random() * 255));*/
|
||||
//}*/
|
||||
|
||||
rng = inthash(rng);
|
||||
|
||||
var tend = sys.nanoTime();
|
||||
|
||||
println("Apparent FPS: " + (1000000000 / (tend - tstart)));
|
||||
}
|
||||
Reference in New Issue
Block a user