-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot.nj
49 lines (38 loc) · 1.24 KB
/
boot.nj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <NJDEF.nj>
#define priority=HIGHEST;
#define refName="boot";
// NUTELLAJAR BOOTLOADER
method init takesin (char* arg) {
U8 index = Data.NULLPOINTER;
const version = "1.0";
terminal.backgroundColor = terminal.color.WHITE;
terminal.fontColor = terminal.color.BLACK;
for (U32 i = 0; i < terminal.collumns - 1; i += 1)
terminal.write(" ");
terminal.setCursor(3, 0);
terminal.write("NutellaJar Bootloader version $version");
terminal.backgroundColor = terminal.color.BLACK;
terminal.fontColor = terminal.color.WHITE;
terminal.write("\n");
for (char vol in fs.volumes)
terminal.write(vol.whereAt + ". " + vol);
while (index == Data.NULLPOINTER) {
char key = terminal.waitFor.KEYBOARDIN;
if (isNum(key) && key != Data.NULLPOINTER) {
index = key>>U8;
boot(fs.volumes[index]);
} else {
terminal.fontColor = terminal.color.RED;
terminal.write("ERROR! Invalid partition.");
}
}
}
method boot takesin (char volume) {
if (volume == Data.NULLPOINTER) return void;
for (file f in fs.listFS(volume)) {
if (f.name.endsWith(.njk)) {
terminal.run(f);
break;
}
}
}