From 084a9f7aaba0facf69623105c6ae38846ce1da66 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 30 Sep 2020 18:30:25 +0900 Subject: [PATCH] logo for the shell --- assets/JS_INIT.js | 12 +++++------ assets/tvdos/fsh.js | 26 +++++++++++++++++++++-- assets/tvdos/gl.js | 16 ++++++++++++++ fsh_logo.png | Bin 0 -> 571 bytes shell_mockup.kra | 4 ++-- src/net/torvald/tsvm/Memvwr.kt | 2 +- src/net/torvald/tsvm/VMJSR223Delegate.kt | 7 ++++-- src/net/torvald/tsvm/VMRunnerFactory.kt | 16 +++++++++----- 8 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 fsh_logo.png diff --git a/assets/JS_INIT.js b/assets/JS_INIT.js index 21bd7ee..ba060ee 100644 --- a/assets/JS_INIT.js +++ b/assets/JS_INIT.js @@ -17,13 +17,13 @@ con.getch = function() { return sys.readKey(); }; con.move = function(y, x) { - print(String.fromCharCode(27,91)+y+";"+x+"H"); + print(String.fromCharCode(27,91)+(y|0)+";"+(x|0)+"H"); }; con.addch = function(c) { - graphics.putSymbol(c); + graphics.putSymbol(c|0); }; con.mvaddch = function(y, x, c) { - move(y, x); addch(c); + con.move(y, x); con.addch(c); }; con.getmaxyx = function() { return graphics.getTermDimension(); @@ -48,13 +48,13 @@ con.color_fore = function(n) { // 0..7; -1 for transparent if (n < 0) print(String.fromCharCode(27,91)+"38;5;255m"); else - print(String.fromCharCode(27,91)+((n % 8)+30)+"m"); + print(String.fromCharCode(27,91)+(((n|0) % 8)+30)+"m"); }; con.color_back = function(n) { // 0..7; -1 for transparent if (n < 0) print(String.fromCharCode(27,91)+"48;5;255m"); else - print(String.fromCharCode(27,91)+((n % 8)+40)+"m"); + print(String.fromCharCode(27,91)+(((n|0) % 8)+40)+"m"); }; con.color_pair = function(fore, back) { // 0..255 print(String.fromCharCode(27,91)+"38;5;"+fore+"m"); @@ -64,7 +64,7 @@ con.clear = function() { print(String.fromCharCode(27,91)+"2J"); }; con.curs_set = function(arg) { - print(String.fromCharCode(27,91)+"?25"+((arg == 0) ? "l" : "h")); + print(String.fromCharCode(27,91)+"?25"+(((arg|0) == 0) ? "l" : "h")); }; Object.freeze(con); // system management function diff --git a/assets/tvdos/fsh.js b/assets/tvdos/fsh.js index e21abf5..a8a3155 100644 --- a/assets/tvdos/fsh.js +++ b/assets/tvdos/fsh.js @@ -1,10 +1,32 @@ graphics.setBackground(3,3,3); var _fsh = {}; -_fsh.titlebartex = new GL.Tex(2, 14, [254, 239, 254, 254, 253, 254, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 252, 253, 253, 252, 252, 252, 252, 251, 251, 251]); +_fsh.titlebarTex = new GL.Tex(2, 14, base64.atobarr("/u/+/v3+/f39/f39/f39/f39/P39/Pz8/Pv7+w==")); +_fsh.scrdim = con.getmaxyx(); +_fsh.scrwidth = _fsh.scrdim[1]; +_fsh.scrheight = _fsh.scrdim[0]; +_fsh.brandName = "f\xb3Sh"; +_fsh.brandLogoTexSmall = new GL.Tex(24, 14, base64.atobarr("///////////////////////////////////////////z///////////////////////////////z///////////////////////z8/Pz///z////8/Pz8/Pz8/P///////Pz///////z///z8///////8/P///////Pz///////z///z8///////8/Pz8/P/8/Pz8/Pz///z////8/Pz////8/P///Pz//Pz///////z///////z8///8/P///Pz//Pz///////z////////8/P/8/P///Pz//Pz///////z////////8/P/8/P///Pz//Pz///////z///z8/Pz8///8/P///Pz///////////z///////////////////////////////z////////////////////////////////////////////////////")); -GL.drawTexPattern(_fsh.titlebartex, 0, 0, 560, 14); +_fsh.drawTitlebar = function(titletext) { + GL.drawTexPattern(_fsh.titlebarTex, 0, 0, 560, 14); + if (titletext === undefined || titletext.length == 0) { + con.move(1,1); + print(" ".repeat(_fsh.scrwidth)); + GL.drawTexImageOver(_fsh.brandLogoTexSmall, 268, 0); + } + else { + con.color_pair(240, 255);// vvv this number must be even + GL.drawTexPattern(_fsh.titlebarTex, 268, 0, 24, 14); + con.move(1, 1 + (_fsh.scrwidth - titletext.length) / 2); + print(titletext); + } + con.color_pair(254, 255); +}; + +// screen init con.color_pair(254, 255); con.clear(); con.curs_set(0); +_fsh.drawTitlebar(); diff --git a/assets/tvdos/gl.js b/assets/tvdos/gl.js index bd23bdf..8255872 100644 --- a/assets/tvdos/gl.js +++ b/assets/tvdos/gl.js @@ -20,7 +20,23 @@ GL.drawTexPattern = function(tex, x, y, width, height) { } } }; +/* + * Draws a texture verbatim - color of 255 will be written to the screen buffer + */ GL.drawTexImage = function(tex, x, y) { GL.drawTexPattern(tex, x, y, tex.width, tex.height); }; +/* + * Draws texture with blitting - color of 255 will pass-thru what's already on the screen buffer + */ +GL.drawTexImageOver = function(tex, x, y) { + for (var ty = 0; ty < tex.height; ty++) { + for (var tx = 0; tx < tex.width; tx++) { + var c = tex.texData[ty * tex.width + tx]; + if (c != 255) { + graphics.plotPixel(x + tx, y + ty, c); + } + } + } +}; Object.freeze(GL); diff --git a/fsh_logo.png b/fsh_logo.png new file mode 100644 index 0000000000000000000000000000000000000000..b3e8039a3264d3a78ba9969191ea1f745922f2d7 GIT binary patch literal 571 zcmV-B0>u4^P)4qha}3bMNB>T2M}va3XN4Z3s)Iz(Oi zI`kjZHRxIp1Vs?hp}(N7OUU+421?{Cv+s{*=6RWU2At8HmbaQhkS~#WR;&4XR7?J*qn<^fm8MLXX-dv$6D6R3l9nh^0~71dmeQYZ@Mr) zE44>vFBUN(gz=N4%nCV53`;FYX8-#_KfY;-;?d-9u!bp)3|a98MJ-F$v{YU6w0t?% zRPKNCwDi%DYIkoKnxAa@tsmSwP}#QauOr*89E0l-E($e&QF0pp5PiF*1rETs0cV#r zEx8Nlo6!AWB+SH*hd_XJl8# zc