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