-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththread.li
99 lines (83 loc) · 2.74 KB
/
thread.li
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
///////////////////////////////////////////////////////////////////////////////
// Isaac Operating System //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; version 3 of the License. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// http://www.lisaac.org //
///////////////////////////////////////////////////////////////////////////////
Section Header
+ name := THREAD;
- copyright := "2003-2008 Sonntag Benoit";
- author := "Sonntag Benoit (sonntag@icps.u-strasbg.fr)";
- comment := "The main prototype";
Section Inherit
+ parent_task:Expanded TASK;
Section Public
+ message:ABSTRACT_STRING;
+ color:UINTEGER_8;
+ posx:INTEGER;
+ posy:INTEGER;
//
// Creation.
//
- create (x,y:INTEGER) message msg:ABSTRACT_STRING color col:UINTEGER_8 :SELF <-
( + result:SELF;
result := clone;
result.make (x,y) message msg color col;
result
);
- make (x,y:INTEGER) message msg:ABSTRACT_STRING color col:UINTEGER_8 <-
(
message := msg;
color := col;
posx := x;
posy := y;
SCHEDULER.add Self;
);
- action <-
( + dx,dy:INTEGER;
dx := 1;
dy := 1;
{
put (posx,posy) string message color 0;
posx := posx + dx;
posy := posy + dy;
((posx + message.count >= 80) || {posx <= 0}).if {
dx := -dx;
};
((posy >= 23) || {posy <= 0}).if {
dy := -dy;
};
put (posx,posy) string message color color;
//KEYBOARD.wait_key;
(SYSTEM.itemb 060h = 1h).if {
+ str:STRING;
{SYSTEM.itemb 060h = 1}.while_do {};
str := STRING.create 50;
str.copy "ISAAC ";
SCHEDULER.task_list.count.append_in str;
THREAD.create (40,10) message str color ((color+1)&0Fh);
};
// `asm("hlt")`;
}.do_while {`(1)`:BOOLEAN(TRUE,FALSE)};
);
Section Private
- put (x,y:INTEGER) string str:ABSTRACT_STRING color col:UINTEGER_8 <-
( + ecr:NATIVE_ARRAY(UINTEGER_8);
+ ofs:INTEGER;
ecr := CONVERT(INTEGER,NATIVE_ARRAY(UINTEGER_8)).on 0B8000h;
ofs := y*160 + 2*x;
(str.lower).to (str.upper) do { i:INTEGER;
ecr.put (str.item i.to_uinteger_8) to ofs;
ofs := ofs + 1;
ecr.put col to ofs;
ofs := ofs + 1;
};
);