Rev 666 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
666 | bw | 1 | {-$codepage cp866} |
616 | bw | 2 | |
3 | type |
||
4 | TKosPoint = packed record |
||
5 | X: Longint; |
||
6 | Y: Longint; |
||
7 | end; |
||
8 | |||
9 | TKosRect = packed record |
||
10 | case Integer of |
||
11 | 0: (Left, Top, Width, Height: Longint); |
||
12 | 1: (TopLeft, HeightWidth: TKosPoint); |
||
13 | end; |
||
14 | |||
15 | { User interface } |
||
16 | procedure kos_definewindow(x, y, w, h: Word; style: DWord = $23FFFFFF; header: DWord = $008899FF; clframe: DWord = $008899FF); |
||
17 | procedure kos_movewindow(x, y, w, h: DWord); |
||
18 | function kos_getkey(): DWord; |
||
19 | function kos_getevent(wait: Boolean = True): DWord; |
||
20 | function kos_waitevent(timeout: DWord): DWord; |
||
21 | function kos_getbutton(): DWord; |
||
22 | function kos_getmousepos(): TKosPoint; |
||
23 | function kos_getmousewinpos(): TKosPoint; |
||
24 | function kos_getmousebuttons(): DWord; |
||
25 | procedure kos_maskevents(mask: DWord); |
||
763 | bw | 26 | procedure kos_setkeyboardmode(mode: DWord); |
27 | function kos_getkeyboardmode(): DWord; |
||
616 | bw | 28 | procedure kos_setcaption(caption: PChar); |
29 | |||
30 | { Graphics } |
||
619 | bw | 31 | function kos_screensize(): TKosPoint; |
616 | bw | 32 | procedure kos_begindraw(); |
33 | procedure kos_enddraw(); |
||
34 | procedure kos_putpixel(x, y: Word; color: DWord = $000000); |
||
35 | procedure kos_drawtext(x, y: Word; text: String; flags: DWord = $000000; bgcolor: DWord = $00FFFFFF); |
||
36 | procedure kos_drawrect(x, y, w, h: Word; color: DWord = $000000); |
||
37 | procedure kos_drawline(x1, y1, x2, y2: Word; color: DWord = $000000); |
||
38 | procedure kos_drawimage(x, y, w, h, depth: DWord; image: Pointer; palette: Pointer = nil; xoffset: DWord = 0); |
||
39 | procedure kos_drawimage24(x, y, w, h: DWord; image: Pointer); |
||
40 | |||
41 | { Work with system } |
||
42 | |||
43 | { Work with system - System services } |
||
44 | function kos_killthread(tid: TThreadID): Boolean; |
||
45 | procedure kos_setactivewindow(slot: TThreadSlot); |
||
46 | function kos_getthreadslot(tid: TThreadID): TThreadSlot; |
||
47 | |||
48 | { Work with system - Set system parameters } |
||
49 | procedure kos_enablepci(); |
||
50 | |||
666 | bw | 51 | { Work with system - Get system parameters } |
52 | function kos_timecounter(): DWord; |
||
53 | |||
616 | bw | 54 | { Work with system - Internal system services } |
55 | procedure kos_switchthread(); |
||
56 | function kos_initheap(): DWord; |
||
57 | function kos_alloc(size: DWord): Pointer; |
||
58 | function kos_free(ptr: Pointer): Boolean; |
||
59 | function kos_loaddriver(name: PChar): THandle; |
||
60 | |||
61 | { Processes and threads } |
||
62 | type |
||
63 | PKosThreadInfo = ^TKosThreadInfo; |
||
64 | TKosThreadInfo = packed record |
||
65 | Speed: DWord; |
||
66 | WindowID: Word; |
||
67 | ThreadSlot: Word; |
||
68 | Reserved1: Word; |
||
69 | AppName: array[0..10] of Char; |
||
70 | Reserved2: Byte; |
||
71 | ProcessBase: Pointer; |
||
72 | MemoryUsage: DWord; |
||
73 | ThreadID: TThreadID; |
||
74 | WindowRect: TKosRect; |
||
666 | bw | 75 | Reserved3: DWord; |
76 | ClientRect: TKosRect; |
||
77 | Reserved4: array[1..1046] of Byte; |
||
616 | bw | 78 | end; |
79 | |||
80 | {Буфер IPC} |
||
81 | PKosIPC = ^TKosIPC; |
||
82 | TKosIPC = packed record |
||
83 | Lock: LongBool; |
||
84 | Size: DWord; |
||
85 | {сообщение #1...} |
||
86 | {сообщение #2...} |
||
87 | {...} |
||
88 | end; |
||
89 | |||
90 | {Сообщение IPC} |
||
91 | PKosMessage = ^TKosMessage; |
||
92 | TKosMessage = packed record |
||
93 | SenderID: TThreadID; |
||
94 | Size: DWord; |
||
95 | {тело сообщения...} |
||
96 | end; |
||
97 | |||
98 | function kos_threadinfo(info: PKosThreadInfo; slot: TThreadSlot = -1): DWord; |
||
99 | function kos_newthread(entry, stack: Pointer): TThreadID; |
||
100 | procedure kos_initipc(ipc: PKosIPC; size: DWord); |
||
101 | function kos_sendmsg(tid: TThreadID; msg: Pointer; size: DWord): DWord; |
||
102 | function kos_resizemem(size: DWord): Boolean; |
||
103 | |||
104 | { File system } |
||
105 | { File system - Work with the current folder } |
||
106 | |||
107 | procedure kos_setdir(path: PChar); |
||
108 | function kos_getdir(path: PChar; size: DWord): DWord; |
||
109 | |||
110 | { File system - Work with file system with long names support } |
||
111 | |||
112 | const |
||
113 | kfReadOnly = $01; |
||
114 | kfHidden = $02; |
||
115 | kfSystem = $04; |
||
116 | kfLabel = $08; |
||
117 | kfFolder = $10; |
||
118 | kfNotArchive = $20; |
||
119 | |||
120 | type |
||
121 | PKosFile = ^TKosFile; |
||
122 | TKosFile = packed record |
||
123 | SubFunc: DWord; |
||
124 | Position, PositionReserved: DWord; |
||
125 | Size: DWord; |
||
126 | Data: Pointer; |
||
127 | Name: array[0..0] of Char; {...ASCIIZ} |
||
128 | end; |
||
129 | |||
130 | PKosBDFE = ^TKosBDFE; |
||
131 | TKosBDFE = packed record |
||
132 | Attributes: DWord; |
||
133 | NameType: Byte; {bit0 - 0:ascii, 1:unicode} |
||
134 | Reserved: array[0..2] of Byte; |
||
135 | CTime: DWord; {ss,mm,hh,00} |
||
136 | CDate: DWord; {dd,mm,yyyy} |
||
137 | ATime: DWord; |
||
138 | ADate: DWord; |
||
139 | MTime: DWord; |
||
140 | MDate: DWord; |
||
141 | Size: QWord; |
||
142 | Name: array[0..519] of Char; |
||
143 | end; |
||
144 | |||
145 | function kos_readfile(kosfile: PKosFile; var readed: Longint): DWord; |
||
146 | function kos_rewritefile(kosfile: PKosFile; var writed: Longint): DWord; |
||
147 | function kos_writefile(kosfile: PKosFile; var writed: Longint): DWord; |
||
148 | function kos_fileinfo(kosfile: PKosFile): DWord; |
||
149 | |||
623 | bw | 150 | { Sound } |
151 | |||
643 | bw | 152 | function kos_speaker(notes: Pointer): Boolean; |
623 | bw | 153 | |
616 | bw | 154 | { Work with hardware } |
155 | function kos_readport(index: DWord): DWord; |
||
156 | procedure kos_writeport(index, value: DWord); |
||
157 | function kos_reserveport(port: DWord): Boolean; |
||
158 | |||
159 | { Work with hardware - Low-level access to PCI} |
||
160 | function kos_lastpcibus(): Byte; |
||
161 | function kos_readpcib(bus, dev, func, reg: Byte): Byte; |
||
162 | function kos_readpciw(bus, dev, func, reg: Byte): Word; |
||
163 | function kos_readpcid(bus, dev, func, reg: Byte): DWord; |
||
164 | |||
165 | { Other } |
||
166 | procedure kos_delay(ms: DWord); {1/100 s} |
||
167 | |||
168 | { my } |
||
169 | type |
||
170 | TKosSign = array[0..7] of Byte; |
||
171 | PKosHeader = ^TKosHeader; |
||
172 | TKosHeader = packed record |
||
173 | sign : TKOSSign; |
||
174 | version: DWord; |
||
175 | start : DWord; |
||
176 | size : DWord; |
||
177 | memory : DWord; |
||
178 | stack : DWord; |
||
179 | args : PChar; |
||
180 | path : PChar; |
||
181 | end; |
||
182 | |||
183 | |||
184 | type |
||
185 | PKonsole = ^TKonsole; |
||
186 | TKonsole = object |
||
187 | private |
||
188 | FCaption: String; |
||
666 | bw | 189 | FLines: array of ShortString; |
616 | bw | 190 | FCursor: TKosPoint; |
191 | FMaxLines: Word; |
||
192 | FThreadID: TThreadID; |
||
193 | FThreadSlot: TThreadSlot; |
||
194 | FIPCBuffer: PKosIPC; |
||
195 | FIPCBufferSize: DWord; |
||
196 | FTerminate: Boolean; |
||
197 | FOpened: Boolean; |
||
666 | bw | 198 | FOnAir : Boolean; |
616 | bw | 199 | FKeyPressed: Word; |
200 | function ReceiveMessage(var Message: ShortString): Boolean; |
||
201 | procedure ProcessMessage(Message: ShortString); |
||
202 | procedure ProcessKeyboard(Key: Word); |
||
203 | function GetRect(): TKosRect; |
||
204 | function GetKeyPressed(): Word; |
||
205 | procedure Paint(BottomRow: Boolean = False); |
||
666 | bw | 206 | procedure Flush(); |
616 | bw | 207 | public |
208 | constructor Init(ACaption: String = ''); |
||
209 | destructor Done(); |
||
210 | procedure Write(Message: ShortString); |
||
211 | property KeyPressed: Word read GetKeyPressed; |
||
212 | property Opened: Boolean read FOpened; |
||
213 | property ThreadID: TThreadID read FThreadID; {JustForFun, must be hidden, do not use} |
||
214 | property ThreadSlot: TThreadSlot read FThreadSlot; {JustForFun, must be hidden, do not use} |
||
215 | end; |
||
216 | |||
666 | bw | 217 | (*Разработка терминала в рамках RTL прекращена. Терминал будет выделен из кода |
218 | консольного приложения и должен быть реализован как отдельный сервис с |
||
219 | динамическим подключением, либо как отдельный модуль FreePascal со статическим |
||
220 | или динамическим подключением терминального функционала. |
||
221 | |||
222 | PTermKursor = ^TTermKursor; |
||
223 | TTermKursor = object |
||
224 | private |
||
225 | FVisible: Boolean; |
||
226 | procedure SetVisbile(Value: Boolean); |
||
227 | public |
||
228 | constructor Init; |
||
229 | procedure Repaint; |
||
230 | property Visible: Boolean read FVisible write SetVisbile; |
||
616 | bw | 231 | end; |
666 | bw | 232 | |
233 | PTermKIO = ^TTermKIO; |
||
234 | TTermKIO = object |
||
235 | private |
||
236 | FBuffer: Pointer; |
||
237 | FBufferScreen: Pointer; |
||
238 | FBufferSize : Longword; |
||
239 | FBufferWidth: Longword; |
||
240 | FBufferLines: Longword; |
||
241 | FIPCBuffer: PKosIPC; |
||
242 | FIPCBufferSize: Longword; |
||
243 | FCursor: TTermKursor; |
||
244 | FCaption: String; |
||
245 | FThreadID: TThreadID; |
||
246 | FThreadSlot: TThreadSlot; |
||
247 | FTerminate: Boolean; |
||
248 | FOpened: Boolean; |
||
249 | FWindowBounds: TKosRect; |
||
250 | FWindowStyle : Longword; |
||
251 | FClientBounds: TKosRect; |
||
252 | FMaxWidth : Longword; |
||
253 | FFirstLine: Longword; |
||
254 | FDefaultChar: Word; |
||
255 | FPalette: array[0..15] of Longword; |
||
256 | procedure MainLoop; |
||
257 | procedure ReallocBuffer(Size: Longword); |
||
258 | procedure ResizeBuffer(NewWidth, NewLines: Longword); |
||
259 | procedure FillDefaultChar(var X; Count: Longword); |
||
260 | function GetLine(Index: Longint): Pointer; |
||
261 | function PrevLine(Line: Pointer): Pointer; |
||
262 | {function ReceiveMessage(var Message: ShortString): Boolean; |
||
263 | procedure ProcessMessage(Message: ShortString);} |
||
264 | procedure ProcessKeyboard(Key: Word); |
||
265 | procedure DoPaint(const Bounds: TKosRect); |
||
266 | procedure DoResize; |
||
267 | public |
||
268 | constructor Init(ACaption: String = ''); |
||
269 | destructor Done; |
||
270 | procedure Write(Message: ShortString); |
||
271 | property Cursor: TTermKursor read FCursor; |
||
272 | end;*) |