mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 11:51:49 +09:00
dos: text substitution using dollar sign
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -51,3 +51,5 @@ tmp_*
|
||||
*.out
|
||||
*.pdf
|
||||
*.toc
|
||||
|
||||
assets/disk0/home/basic/*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
echo "Starting TVDOS..."
|
||||
|
||||
rem put set-xxx commands here:
|
||||
set PATH=\tvdos\tuidev;$PATH
|
||||
|
||||
rem this line specifies which shell to be presented after the boot precess:
|
||||
command /fancy
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
1 FOR I = 99 TO 1 STEP -1
|
||||
2 MODE = 1
|
||||
3 GOSUB 12
|
||||
4 PRINT I;" bottle";BOTTLES;" of beer on the wall, ";i;" bottle";BOTTLES;" of beer."
|
||||
5 MODE = 2
|
||||
6 GOSUB 12
|
||||
7 PRINT "Take one down and pass it around, ";(I-1);" bottle";BOTTLES;" of beer on the wall."
|
||||
8 NEXT
|
||||
9 PRINT "No more bottles of beer on the wall, no more bottles of beer."
|
||||
10 PRINT "Go to the store and buy some more. 99 bottles of beer on the wall."
|
||||
11 END
|
||||
12 IF I == MODE THEN BOTTLES = "" ELSE BOTTLES = "s"
|
||||
13 RETURN
|
||||
10 FOR I = 99 TO 1 STEP -1
|
||||
20 MODE = 1
|
||||
30 GOSUB 120
|
||||
40 PRINT I;" bottle";BOTTLES;" of beer on the wall, ";i;" bottle";BOTTLES;" of beer."
|
||||
50 MODE = 2
|
||||
60 GOSUB 120
|
||||
70 PRINT "Take one down and pass it around, ";(I-1);" bottle";BOTTLES;" of beer on the wall."
|
||||
80 NEXT
|
||||
90 PRINT "No more bottles of beer on the wall, no more bottles of beer."
|
||||
100 PRINT "Go to the store and buy some more. 99 bottles of beer on the wall."
|
||||
110 END
|
||||
120 IF I == MODE THEN BOTTLES = "" ELSE BOTTLES = "s"
|
||||
130 RETURN
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
10 DEFUN FAC(N)=IF N==0 THEN 1 ELSE N*FAC(N-1)
|
||||
20 K=MAP FAC, 1 TO 10
|
||||
20 K=MAP(FAC, 1 TO 10)
|
||||
30 PRINT K
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
10 DEFUN LESS(P,X)=X<P
|
||||
11 DEFUN GTEQ(P,X)=X>=P
|
||||
12 DEFUN QSORT(XS)=IF LEN(XS)<1 THEN NIL ELSE QSORT(FILTER(LESS~<HEAD(XS),TAIL(XS))) # HEAD(XS)!NIL # QSORT(FILTER(GTEQ~<HEAD(XS),TAIL(XS)))
|
||||
10 QSORT=[XS]~>IF LEN(XS)<1 THEN NIL ELSE QSORT(FILTER([X]~>X<HEAD XS,TAIL XS)) # HEAD(XS)!NIL # QSORT(FILTER([X]~>X>=HEAD XS,TAIL XS))
|
||||
100 L=7!9!4!5!2!3!1!8!6!NIL
|
||||
110 PRINT L
|
||||
120 PRINT QSORT(L)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
10 print(chr(47+round(rnd(1))*45);)
|
||||
20 goto 10
|
||||
10 PRINT(CHR(47+ROUND(RND(1))*45);)
|
||||
20 GOTO 10
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
Nuke comments:
|
||||
Nuke comments until no match left:
|
||||
|
||||
/\*[ -~\n]+?\*/|//[^\n]*
|
||||
|
||||
@@ -10,4 +10,10 @@ replace into
|
||||
|
||||
\n
|
||||
|
||||
until there's no match left
|
||||
until no match left
|
||||
|
||||
(4 spaces)
|
||||
|
||||
replace into
|
||||
|
||||
\t
|
||||
|
||||
@@ -9,13 +9,13 @@ _TVDOS.DRIVES["A"] = _BIOS.FIRST_BOOTABLE_PORT;
|
||||
|
||||
|
||||
_TVDOS.getPath = function() {
|
||||
return _TVDOS.variables.PATH.split(';');
|
||||
return [''].concat(_TVDOS.variables.PATH.split(';'));
|
||||
};
|
||||
// initial values
|
||||
_TVDOS.variables = {
|
||||
DOSDIR: "\\tvdos",
|
||||
LANG: "EN",
|
||||
PATH: ";\\tvdos\\bin;\\tbas;\\home",
|
||||
PATH: "\\tvdos\\bin;\\tbas;\\home",
|
||||
PATHEXT: ".com;.bat;.js",
|
||||
HELPPATH: "\\tvdos\\help",
|
||||
OS_NAME: "Terrarum Virtual DOS",
|
||||
|
||||
@@ -9,7 +9,12 @@ let DEBUG_PRINT = true;
|
||||
|
||||
let errorlevel = 0;
|
||||
|
||||
|
||||
const termWidth = con.getmaxyx()[1];
|
||||
const termHeight = con.getmaxyx()[0];
|
||||
const welcome_text = "TSVM Disk Operating System, version " + _TVDOS.VERSION;
|
||||
const greetLeftPad = (termWidth - welcome_text.length - 6) >> 1;
|
||||
const greetRightPad = termWidth - greetLeftPad - welcome_text.length - 6;
|
||||
|
||||
function print_prompt_text() {
|
||||
if (goFancy) {
|
||||
@@ -38,11 +43,15 @@ function print_prompt_text() {
|
||||
|
||||
function greet() {
|
||||
if (goFancy) {
|
||||
con.color_pair(0,253);
|
||||
//print(welcome_text + " ".repeat(_fsh.scrwidth - welcome_text.length));
|
||||
print(welcome_text + " ".repeat(80 - welcome_text.length));
|
||||
con.color_pair(239,255);
|
||||
println();
|
||||
con.clear();
|
||||
con.color_pair(253,255);
|
||||
print(' ');con.addch(17);
|
||||
con.color_pair(0,253);
|
||||
print(" ".repeat(greetLeftPad)+welcome_text+" ".repeat(greetRightPad));
|
||||
con.color_pair(253,255);
|
||||
con.addch(16);
|
||||
con.move(3,1);
|
||||
}
|
||||
else
|
||||
println(welcome_text);
|
||||
@@ -62,6 +71,31 @@ function trimStartRevSlash(s) {
|
||||
}
|
||||
|
||||
let shell = {};
|
||||
shell.replaceVarCall = function(value) {
|
||||
// syntax:
|
||||
// line = literal [varcall] [literal] ;
|
||||
// varcall = "$" ident ;
|
||||
// ident = ? regex: [A-Za-z_]+ ? ;
|
||||
// literal = ? you know what it is ? ;
|
||||
let replaceMap = [];
|
||||
let varMode = false;
|
||||
let sb = '';
|
||||
for (let i=0; i<value.length; i++) {
|
||||
let char = value.charAt(i);
|
||||
let cp = value.charCodeAt(i);
|
||||
if (!varMode && char == '$') {
|
||||
replaceMap.push({s:sb,r:false});
|
||||
sb = ''; varMode = true;
|
||||
}
|
||||
else if (varMode && !(cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp == 95 || cp >= 97 && cp <= 122)) {
|
||||
replaceMap.push({s:sb,r:true});
|
||||
sb = ''+char; varMode = false;
|
||||
}
|
||||
else sb += char;
|
||||
}; replaceMap.push({s:sb,r:(varMode)});
|
||||
|
||||
return replaceMap.map(it => (it.r) ? _TVDOS.variables[it.s] : it.s).join('');
|
||||
}
|
||||
shell.getPwd = function() { return shell_pwd; }
|
||||
shell.getCurrentDrive = function() { return CURRENT_DRIVE; }
|
||||
// example input: echo "the string" > subdir\test.txt
|
||||
@@ -211,7 +245,7 @@ shell.coreutils = {
|
||||
},
|
||||
echo: function(args) {
|
||||
if (args[1] !== undefined) {
|
||||
args.forEach(function(it,i) { if (i > 0) print(it+" ") });
|
||||
args.forEach(function(it,i) { if (i > 0) print(shell.replaceVarCall(it)+" ") });
|
||||
}
|
||||
println();
|
||||
},
|
||||
@@ -245,8 +279,7 @@ shell.coreutils = {
|
||||
println(_TVDOS.variables[key])
|
||||
}
|
||||
else {
|
||||
// TODO parse %var_name% line
|
||||
_TVDOS.variables[key] = value;
|
||||
_TVDOS.variables[key] = shell.replaceVarCall(value);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -22,16 +22,16 @@ public class AppLoader {
|
||||
appConfig.resizable = false;
|
||||
appConfig.title = appTitle;
|
||||
appConfig.forceExit = true;
|
||||
appConfig.width = 560;
|
||||
appConfig.height = 448;
|
||||
appConfig.width = 720;//480;
|
||||
appConfig.height = 480;//128;
|
||||
|
||||
|
||||
// val vm = VM(64.kB(), TheRealWorld(), arrayOf(GenericBios))
|
||||
//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[]{TBASRelBios.INSTANCE});
|
||||
VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{GenericBios.INSTANCE});
|
||||
//VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{TBASRelBios.INSTANCE});
|
||||
new LwjglApplication(new VMGUI(vm, appConfig), appConfig);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ class VMGUI(val vm: VM, val appConfig: LwjglApplicationConfiguration) : Applicat
|
||||
override fun create() {
|
||||
super.create()
|
||||
|
||||
gpu = GraphicsAdapter(vm, GraphicsAdapter.DEFAULT_CONFIG_COLOR_CRT)
|
||||
//gpu = TexticsAdapter(vm)
|
||||
//gpu = GraphicsAdapter(vm, GraphicsAdapter.DEFAULT_CONFIG_COLOR_CRT)
|
||||
gpu = TexticsAdapter(vm)
|
||||
//gpu = CharacterLCDdisplay(vm)
|
||||
|
||||
vm.peripheralTable[1] = PeripheralEntry(
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.tsvm.VM
|
||||
|
||||
class CharacterLCDdisplay(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
|
||||
"pmlcd_inverted", 960, 400, 80, 25, 249, 255, 262144L, "lcd.png", 0.7f, TEXT_TILING_SHADER_LCD, DRAW_SHADER_FRAG_LCD
|
||||
"pmlcd_inverted", 480, 128, 40, 8, 249, 255, 262144L, "lcd.png", 0.7f, TEXT_TILING_SHADER_LCD, DRAW_SHADER_FRAG_LCD
|
||||
)
|
||||
) {
|
||||
|
||||
|
||||
@@ -11,9 +11,9 @@ import kotlin.math.absoluteValue
|
||||
class TexticsAdapter(vm: VM) : GraphicsAdapter(vm, AdapterConfig(
|
||||
"crt_white",
|
||||
720,
|
||||
375,
|
||||
480,
|
||||
80,
|
||||
25,
|
||||
32,
|
||||
254,
|
||||
0,
|
||||
256.kB(),
|
||||
|
||||
Reference in New Issue
Block a user