6 System.Classes, System.Generics.Collections, System.SysUtils, System.Types,
29 cyls, leds, vmode, reserve: Int8;
38 procedure settime(priority: integer);
40 constructor Create(data0: integer);
44 backlink, esp0, ss0, esp1, ss1, esp2, ss2, cr3: integer;
46 eflags, eax, ecx, edx, ebx, ebp, esi, edi: integer;
47 es, cs, ss, ds, fs, gs: integer;
54 priority, level: integer;
59 procedure run(level, priority: integer);
70 p, q, size, space, flags: integer;
73 constructor Create(size: integer);
74 destructor Destroy; override;
75 function Put(data: integer): Boolean;
76 function Get: SmallInt;
77 function Status: integer;
85 KEYSTA_SEND_NOTREADY = $02;
86 KEYCMD_WRITE_MODE = $60;
91 procedure wait_KBC_sendready;
92 procedure inthandler21(var esp: integer); virtual; abstract;
95 TKeyboard = class(TDevice)
98 procedure make_table(const keys1, keys2: array of const);
100 keytable0, keytable1: array [$00 .. $80] of Byte;
101 constructor Create(fifo: TFifo; data0: integer);
102 procedure inthandler21(var esp: integer); override;
106 buf: array [0 .. 2] of Byte;
111 TMouse = class(TDevice)
113 KEYCMD_SENDTO_MOUSE = $D4;
114 MOUSECMD_ENABLE = $F4;
119 constructor Create(fifo: TFifo; data0: integer);
120 function decode(dat: UInt8): integer;
121 procedure inthandler21(var esp: integer); override;
124 TTaskCtl = class(TList)
132 procedure taskswitchsub;
136 buf: array [0 .. MAX_TASKLEVELS - 1] of TTask;
137 task: array [0 .. MAX_TASKLEVELS] of TTaskCtl;
144 procedure inthandler20(var esp: integer);
147 constructor Create(fifo: TFifo);
148 destructor Destroy; override;
149 function run(level, priority: integer): TTask;
150 procedure remove(task: TTask);
151 procedure sleep(task: TTask);
153 procedure taskswitch;
154 function settime(data: integer; timeout: integer): TTimer;
159 function memtest_sub(start, endpos: Cardinal): Cardinal;
161 function memtest(start, endpos: Cardinal): Cardinal;
170 frees, maxfrees, lostsize, losts: integer;
171 free: TList<TFREEINFO>;
173 destructor Destroy; override;
178 procedure Init(mem: TMEMMAN);
179 function total(mem: TMEMMAN): UInt32;
180 function alloc(mem: TMEMMAN; size: UInt32): UInt32;
181 function memfree(mem: TMEMMAN; addr, size: Cardinal): integer;
192 procedure inthandler27(var esp: integer);
195 TRefresh = procedure(Sender: TObject) of object;
199 table: array [0 .. 14, 0 .. 2] of Byte = (($00, $00, $00), ($FF, $00, $00),
200 ($00, $FF, $00), ($FF, $FF, $00), ($00, $00, $FF), ($FF, $00, $FF),
201 ($00, $FF, $FF), ($C6, $C6, $C6), ($84, $00, $00), ($00, $84, $00),
202 ($84, $84, $00), ($00, $00, $84), ($84, $00, $84), ($00, $84, $84),
207 procedure putfont8(x, y: integer; c: Int8; font: PChar);
208 procedure putfonts8_asc(x, y: integer; c: Int8; s: string);
212 bxsize, bysize, vx0, vy0, col_inv, flags: integer;
214 hankaku: TResourceStream;
217 constructor Create(x, y, act: integer);
218 destructor Destroy; override;
219 procedure boxfill8(c: UInt8; x0, y0, x1, y1: integer); overload;
220 procedure boxfill8(c: UInt8; rect: TRect); overload;
221 procedure setp(start, endpos: integer; rgb: TBytes);
222 procedure putfonts8_asc_sht(x, y: integer; font: string;
223 const back: integer = COL8_000000; const color: integer = COL8_FFFFFF);
226 TCursor = class(TSheet)
228 constructor Create(x, y, act: integer);
231 TScreen = class(TSheet)
233 constructor Create(x, y, act: integer);
236 TWindow = class(TScreen)
238 procedure wintitl(title: string; act: integer);
240 constructor Create(xsize, ysize: integer; title: string; act: integer);
243 TConsole = class(TWindow)
246 info: array of TFileInfo;
248 procedure putchar(ch: Char; move: integer);
249 procedure putstr0(str: string);
250 procedure putstrl(str: string; length: integer);
255 constructor Create(xsize, ysize: integer; title: string; act: integer);
256 destructor Destroy; override;
258 procedure cmd_type(param: string);
266 procedure refreshmap(arect: TRect);
267 procedure refreshsub(arect: TRect);
271 xsize, ysize: integer;
275 constructor Create(x, y: integer);
276 destructor Destroy; override;
277 procedure updown(sheet: TSheet; height: integer);
278 procedure refresh(bx0, by0, bx1, by1: integer); overload;
279 procedure refresh(Sender: TObject); overload;
280 procedure slide(sheet: TSheet; x, y: integer);
281 procedure delete(index: integer);
282 procedure add(sheet: TSheet);
286 FLAGSOVERRUN = $0001;
301 ADR_BOOTINFO = $00000FF0;
303 LIMIT_IDT = $000007FF;
305 LIMIT_GDT = $0000FFFF;
306 ADR_BOTPAK = $00280000;
307 LIMIT_BOTPAK = $0007FFFF;
308 AR_DATA32_RW = $4092;
309 AR_CODE32_ER = $409A;
311 AR_INTGATE32 = $008E;
324 constructor TTimer.Create(data0: integer);
327 io_out8(PIT_CTRL, $34);
328 io_out8(PIT_CNT0, $9C);
329 io_out8(PIT_CNT0, $2E);
334 procedure TTimer.settime(priority: integer);
336 Self.timeout := priority;
341 constructor TTask.Create;
367 procedure TTask.run(level, priority: integer);
372 Self.priority := priority;
373 if (flags = 2) and (Self.level <> level) then
386 destructor TFifo.Destroy;
392 function TFifo.Get: SmallInt;
406 constructor TFifo.Create(size: integer);
409 SetLength(buf, size);
417 function TFifo.Put(data: integer): Boolean;
421 flags := FLAGSOVERRUN;
430 if (task <> nil) and (task.flags <> 2) then
435 function TFifo.Status: integer;
437 result := size - space;
442 function TMemtest.memtest(start, endpos: Cardinal): Cardinal;
444 EFLAGS_AC_BIT = $00040000;
445 CR0_CASH_DISABLE = $60000000;
451 eflg := io_load_eflags;
452 eflg := eflg or EFLAGS_AC_BIT;
453 io_store_eflags(eflg);
454 eflg := io_load_eflags();
455 if (eflg and EFLAGS_AC_BIT) <> 0 then
457 eflg := eflg and EFLAGS_AC_BIT;
458 io_store_eflags(eflg);
462 cr0 := cr0 or CR0_CASH_DISABLE;
465 result := memtest_sub(start, endpos);
469 cr0 := cr0 and CR0_CASH_DISABLE;
474 function TMemtest.memtest_sub(start, endpos: Cardinal): Cardinal;
485 p := Pointer(i + $FFC);
488 p^ := p^ XOR $FFFFFFFF;
494 p^ := p^ XOR $FFFFFFFF;
508 function TMem.alloc(mem: TMEMMAN; size: UInt32): UInt32;
514 for i := 0 to mem.free.count - 1 do
515 if mem.free[i].size >= size then
529 procedure TMem.Init(mem: TMEMMAN);
537 function TMem.memfree(mem: TMEMMAN; addr, size: Cardinal): integer;
543 for i := 0 to mem.free.count - 1 do
544 if mem.free[i].addr > addr then
550 if mem.free[i - 1].addr + mem.free[i - 1].size = addr then
552 s := mem.free[i - 1];
554 if addr + size = s.addr then
556 inc(s.size, mem.free[i].size);
559 mem.free[i - 1] := s;
563 if addr + size = mem.free[i].addr then
574 mem.maxfrees := mem.free.count;
575 mem.free.Insert(i, s);
579 function TMem.total(mem: TMEMMAN): UInt32;
584 for i := 0 to mem.free.count - 1 do
585 inc(result, mem.free[i].size);
590 constructor TMEMMAN.Create;
593 free := TList<TFREEINFO>.Create;
596 destructor TMEMMAN.Destroy;
604 constructor TMouse.Create(fifo: TFifo; data0: integer);
609 wait_KBC_sendready();
610 io_out8(PORT_KEYCMD, KEYCMD_SENDTO_MOUSE);
611 wait_KBC_sendready();
612 io_out8(PORT_KEYDAT, MOUSECMD_ENABLE);
616 function TMouse.decode(dat: UInt8): integer;
625 if (dat and $CB) = $08 then
643 btn := dec.buf[0] and $07;
646 if (buf[0] and $10) <> 0 then
648 if (buf[0] and $20) <> 0 then
659 procedure TMouse.inthandler21(var esp: integer);
663 io_out8(PIC1_OCW2, $64);
664 io_out8(PIC0_OCW2, $62);
665 i := io_in8(PORT_KEYDAT);
666 fifo.Put(i + mousedata);
671 procedure TDevice.wait_KBC_sendready;
674 if io_in8(PORT_KEYSTA) and KEYSTA_SEND_NOTREADY = 0 then
680 constructor TKeyboard.Create(fifo: TFifo; data0: integer);
686 io_out8(PORT_KEYCMD, KEYCMD_WRITE_MODE);
688 io_out8(PORT_KEYDAT, KBC_MODE);
689 make_table([0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '^',
690 $08, 0, 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '@', '[', $0A, 0,
691 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', ':', 0, 0, ']', 'Z', 'X',
692 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0,
693 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3',
694 '0', '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
695 0, 0, 0, 0, 0, 0, 0, 0, 0, $5C, 0, 0, 0, 0, 0, 0, 0, 0, 0, $5C, 0, 0],
696 [0, 0, '!', $22, '#', '$', '%', '&', $27, '(', ')', '~', '=', '~', $08, 0,
697 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '`', '{', $0A, 0, 'A',
698 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', '+', '*', 0, 0, '}', 'Z', 'X', 'C',
699 'V', 'B', 'N', 'M', '<', '>', '?', 0, '*', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0,
700 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0',
701 '.', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
702 0, 0, 0, 0, 0, 0, 0, '_', 0, 0, 0, 0, 0, 0, 0, 0, 0, '|', 0, 0]);
705 procedure TKeyboard.inthandler21(var esp: integer);
709 io_out8(PIC0_OCW2, $61);
710 i := io_in8(PORT_KEYDAT);
711 fifo.Put(i + keydata);
714 procedure TKeyboard.make_table(const keys1, keys2: array of const);
718 for i := 0 to High(keys1) do
719 keytable0[i] := keys1[i].VType;
720 for i := 0 to High(keys2) do
721 keytable1[i] := keys2[i].VType;
724 procedure init_pit(timerctl: TCtl);
731 procedure TCtl.inthandler20(var esp: integer);
736 io_out8(PIC0_OCW2, $60);
741 for i := 0 to list.count - 1 do
744 if s.timeout > count then
750 if s <> mt_timer then
755 next := TTimer(list[0]).timeout;
760 function TCtl.now: TTask;
762 result := task[now_lv].Items[top];
765 procedure TCtl.remove(task: TTask);
771 for i := 0 to High(Self.task) do
774 for j := 0 to Self.task[i].count - 1 do
778 if s.now >= s.count then
783 function TCtl.run(level, priority: integer): TTask;
788 for i := 0 to High(buf) do
789 if buf[i].flags = 1 then
795 result.level := level;
797 result.priority := priority;
799 task[result.level].add(result);
802 constructor TCtl.Create(fifo: TFifo);
809 for i := 0 to j - 1 do
810 buf[i] := TTask.Create;
811 buf[j] := TIdle.Create;
813 list := TList.Create;
814 for i := 0 to High(task) do
815 task[i] := TTaskCtl.Create;
822 task[s.level].add(s);
826 mt_timer := settime(0, s.priority);
827 s0.run(MAX_TASKLEVELS - 1, 1);
828 task[s.level].add(s0);
831 destructor TCtl.Destroy;
836 for i := 0 to High(buf) do
838 for i := 0 to list.count - 1 do
843 for i := 0 to High(task) do
849 function TCtl.settime(data: integer; timeout: integer): TTimer;
855 if list.count < MAX_TIMER then
857 eflags := io_load_eflags;
859 timer := TTimer.Create(data);
860 timer.settime(timeout + count);
862 for i := 0 to list.count - 1 do
864 s := TTimer(list[i]);
865 if s.timeout >= timer.timeout then
867 list.Insert(i, timer);
869 io_store_eflags(eflags);
874 io_store_eflags(eflags);
880 procedure TCtl.sleep(task: TTask);
884 if task.flags = 2 then
897 procedure TCtl.taskswitch;
906 for i := 0 to High(task) do
909 for j := 0 to s.count - 1 do
912 if t1.lv_change = true then
914 t1.lv_change := false;
923 if s.now = s.count then
931 mt_timer.settime(t2.priority);
933 farjump(0, TTask(task[top]).sel);
936 procedure TCtl.taskswitchsub;
940 for i := 0 to High(task) do
941 if task[i].count > 0 then
947 constructor TShtCtl.Create(x, y: integer);
949 sheets := TList.Create;
950 SetLength(vram, x * y);
951 SetLength(map, x * y);
952 add(TScreen.Create(x, y, -1));
955 procedure TShtCtl.delete(index: integer);
961 sheets.delete(index);
964 destructor TShtCtl.Destroy;
973 procedure TShtCtl.add(sheet: TSheet);
976 sheet.OnRefresh := refresh;
977 sheet.flags := SHEET_USE;
980 procedure TShtCtl.refresh(bx0, by0, bx1, by1: integer);
986 arect := rect(bx0, by0, bx1, by1);
987 if arect.Left < 0 then
989 if arect.Right >= xsize then
990 arect.Right := xsize;
991 if arect.top < 0 then
993 if arect.Bottom >= ysize then
994 arect.Bottom := ysize;
995 for i := 0 to sheets.count - 1 do
997 s := TSheet(sheets[i]);
998 arect.Left := arect.Left - s.vx0;
999 arect.Right := arect.Right - s.vx0;
1000 arect.top := arect.top - s.vy0;
1001 arect.Bottom := arect.Bottom - s.vy0;
1002 if arect.Left < 0 then
1004 if arect.Right > xsize then
1005 arect.Right := xsize;
1006 if arect.top < 0 then
1008 if arect.Bottom > ysize then
1009 arect.Bottom := ysize;
1015 procedure TShtCtl.refresh(Sender: TObject);
1020 obj := Sender as TSheet;
1021 if Assigned(obj.OnRefresh) = false then
1024 refresh(arect.Left + obj.vx0, arect.top + obj.vy0, arect.Right + obj.vx0,
1025 arect.Bottom + obj.vy0);
1028 procedure TShtCtl.refreshmap(arect: TRect);
1034 bx0, by0, bx1, by1, vx, vy: integer;
1036 if arect.Left < 0 then
1038 if arect.Right > xsize then
1039 arect.Right := xsize;
1040 if arect.top < 0 then
1042 if arect.Bottom > ysize then
1043 arect.Bottom := ysize;
1044 for i := top to sheets.count - 1 do
1046 s := TSheet(sheets[i]);
1047 if arect.Left < s.vx0 then
1051 if arect.Right > s.vx0 + s.bxsize then
1055 if arect.top < s.vy0 then
1059 if arect.Bottom > s.bysize then
1062 by1 := arect.Bottom;
1063 for y := by0 to by1 do
1066 for x := bx0 to bx1 do
1069 if s.vram[y * s.bxsize + x] <> s.col_inv then
1070 vram[vy * xsize + vx] := s.col_inv;
1076 procedure TShtCtl.refreshsub(arect: TRect);
1078 x, y, vx, vy: integer;
1084 for y := arect.top to arect.Bottom do
1085 for x := arect.Left to arect.Right do
1087 if c <> map[y * xsize + y] then
1089 c := map[y * xsize + x];
1094 vram[y * xsize + x] := s.vram[vy * s.bxsize + vx];
1098 procedure TShtCtl.slide(sheet: TSheet; x, y: integer);
1106 if sheet.flags = SHEET_USE then
1108 refresh(i, j, i + sheet.bxsize, j + sheet.bysize);
1109 refresh(x, y, x + sheet.bxsize, y + sheet.bysize);
1113 procedure TShtCtl.updown(sheet: TSheet; height: integer);
1118 for i := 0 to sheets.count - 1 do
1119 if sheet = sheets[i] then
1121 if height >= sheets.count then
1122 height := sheets.count - 1;
1125 if (height >= 0) and (sheet.flags = SHEET_USE) then
1126 sheets.move(j, height);
1131 procedure TSheet.boxfill8(c: UInt8; x0, y0, x1, y1: integer);
1133 clip := rect(x0, y0, x1, y1);
1137 procedure TSheet.boxfill8(c: UInt8; rect: TRect);
1142 for y := rect.top to rect.Bottom do
1143 for x := rect.Left to rect.Right do
1144 vram[y * bxsize + x] := c;
1147 constructor TSheet.Create(x, y, act: integer);
1151 SetLength(vram, x * y);
1152 setp(0, 15, TBytes(@table));
1153 hankaku := TResourceStream.Create(HInstance, 'hankaku', RT_RCDATA);
1156 destructor TSheet.Destroy;
1163 procedure TSheet.putfont8(x, y: integer; c: Int8; font: PChar);
1171 p := TBytes(@vram[(y + i) * bxsize + x]);
1173 if d and $80 <> 0 then
1175 if d and $40 <> 0 then
1177 if d and $20 <> 0 then
1179 if d and $10 <> 0 then
1181 if d and $08 <> 0 then
1183 if d and $04 <> 0 then
1185 if d and $02 <> 0 then
1187 if d and $01 <> 0 then
1192 procedure TSheet.putfonts8_asc(x, y: integer; c: Int8; s: string);
1195 buf: array [0 .. 15] of Byte;
1198 for i := 1 to length(s) do
1200 hankaku.Write(TBytes(@buf), Ord(s[i]), 16);
1201 putfont8(x, y, c, PChar(@buf));
1206 procedure TSheet.putfonts8_asc_sht(x, y: integer; font: string;
1207 const back: integer = COL8_000000; const color: integer = COL8_FFFFFF);
1209 clip := rect(x, y, x + bxsize * 8 - 1, y + 15);
1210 boxfill8(back, clip);
1211 putfonts8_asc(x, y, color, font);
1215 procedure TSheet.setp(start, endpos: integer; rgb: TBytes);
1220 eflags := io_load_eflags;
1222 io_out8($03C8, start);
1224 for i := start to endpos - 1 do
1226 io_out8($03C9, rgb[j + 0] div 4);
1227 io_out8($03C9, rgb[j + 1] div 4);
1228 io_out8($03C9, rgb[j + 2] div 4);
1231 io_store_eflags(eflags);
1236 constructor TScreen.Create(x, y, act: integer);
1239 boxfill8(COL8_008484, 0, 0, x - 1, y - 29);
1240 boxfill8(COL8_C6C6C6, 0, y - 28, x - 1, y - 28);
1241 boxfill8(COL8_FFFFFF, 0, y - 27, x - 1, y - 27);
1242 boxfill8(COL8_C6C6C6, 0, y - 26, x - 1, y - 1);
1244 boxfill8(COL8_FFFFFF, 3, y - 24, 59, y - 24);
1245 boxfill8(COL8_FFFFFF, 2, y - 24, 2, y - 4);
1246 boxfill8(COL8_848484, 3, y - 4, 59, y - 4);
1247 boxfill8(COL8_848484, 59, y - 23, 59, y - 5);
1248 boxfill8(COL8_000000, 2, y - 3, 59, y - 3);
1249 boxfill8(COL8_000000, 60, y - 24, 60, y - 3);
1251 boxfill8(COL8_848484, x - 47, y - 24, x - 4, y - 24);
1252 boxfill8(COL8_848484, x - 47, y - 23, x - 47, y - 4);
1253 boxfill8(COL8_FFFFFF, x - 47, y - 3, x - 4, y - 3);
1254 boxfill8(COL8_FFFFFF, x - 3, y - 24, x - 3, y - 3);
1259 constructor TWindow.Create(xsize, ysize: integer; title: string; act: integer);
1261 inherited Create(xsize, ysize, act);
1262 putfonts8_asc(24, 4, COL8_FFFFFF, title);
1263 boxfill8(COL8_C6C6C6, 0, 0, xsize - 1, 0);
1264 boxfill8(COL8_FFFFFF, 1, 1, xsize - 2, 1);
1265 boxfill8(COL8_C6C6C6, 0, 0, 0, ysize - 1);
1266 boxfill8(COL8_FFFFFF, 1, 1, 1, ysize - 2);
1267 boxfill8(COL8_848484, xsize - 2, 1, xsize - 2, ysize - 2);
1268 boxfill8(COL8_000000, xsize - 1, 0, xsize - 1, ysize - 1);
1269 boxfill8(COL8_C6C6C6, 2, 2, xsize - 3, ysize - 3);
1270 boxfill8(COL8_000084, 3, 3, xsize - 4, 20);
1271 boxfill8(COL8_848484, 1, ysize - 2, xsize - 2, ysize - 2);
1272 boxfill8(COL8_000000, 0, ysize - 1, xsize - 1, ysize - 1);
1273 wintitl(title, act);
1276 procedure TWindow.wintitl(title: string; act: integer);
1278 closebtn: array [0 .. 14] of string[16] = ( //
1279 ('000000000000000@'), //
1280 ('0QQQQQQQQQQQQQ$@'), //
1281 ('0QQQQQQQQQQQQQ$@'), //
1282 ('0QQQQQQQQQQQQQ$@'), //
1283 ('0QQQ@@QQQQ@@QQ$@'), //
1284 ('0QQQQ@@QQ@@QQQ$@'), //
1285 ('0QQQQQ@@@@QQQQ$@'), //
1286 ('0QQQQQQ@@QQQQQ$@'), //
1287 ('0QQQQQ@@@@QQQQ$@'), //
1288 ('00QQQ@@QQ@@QQQ$@'), //
1289 ('0QQQ@@QQQQ@@QQ$@'), //
1290 ('0QQQQQQQQQQQQQ$@'), //
1291 ('0QQQQQQQQQQQQQ$@'), //
1292 ('0$$$$$$$$$$$$$$@'), //
1293 ('@@@@@@@@@@@@@@@@') //
1312 boxfill8(tbc, 3, 3, bxsize - 4, 20);
1313 putfonts8_asc(24, 4, tc, title);
1317 c := closebtn[y][x];
1328 vram[(5 + y) * bxsize + (bxsize - 21 + x)] := i;
1334 constructor TCursor.Create(x, y, act: integer);
1336 cursor: array [0 .. 15] of string[16] = ( //
1337 ('**************..'), //
1338 ('*00000000000*...'), //
1339 ('*0000000000*....'), //
1340 ('*000000000*.....'), //
1341 ('*00000000*......'), //
1342 ('*0000000*.......'), //
1343 ('*0000000*.......'), //
1344 ('*00000000*......'), //
1345 ('*0000**000*.....'), //
1346 ('*000*..*000*....'), //
1347 ('*00*....*000*...'), //
1348 ('*0*......*000*..'), //
1349 ('**........*000*.'), //
1350 ('*..........*000*'), //
1351 ('............*00*'), //
1352 ('.............***') //
1361 case cursor[j, i] of // x , y ?
1363 vram[j * 16 + i] := COL8_000000;
1365 vram[j * 16 + i] := COL8_FFFFFF;
1367 vram[j * 16 + i] := act;
1373 procedure TConsole.cmd_type(param: string);
1378 i := files.search(Copy(param, 1, 5), info, 224);
1381 GetMem(Pointer(buf), info[i].size);
1382 files.loadfile(info[i].clustno, info[i].size, buf,
1383 Pointer(ADR_DISKIMG + $003E00));
1384 putstrl(PChar(buf), info[i].size);
1385 FreeMem(Pointer(buf));
1388 putstr0('file not found.');
1391 procedure TConsole.cmd_cls;
1396 constructor TConsole.Create(xsize, ysize: integer; title: string; act: integer);
1406 fifo := TFifo.Create(128);
1408 files := TFiles.Create;
1411 cursor_c := COL8_000000;
1412 ctl.run(ctl.MAX_TASKLEVELS - 1, 1);
1414 ctl := TCtl.Create(fifo);
1416 info := Pointer(ADR_DISKIMG + $002600);
1420 if fifo.Status = 0 then
1435 cursor_c := COL8_FFFFFF;
1440 cursor_c := COL8_000000;
1442 boxfill8(cursor_c, cursor_x, 28, cursor_x + 7, 43);
1443 clip := rect(cursor_x, 28, cursor_x + 8, 44);
1448 cursor_c := COL8_FFFFFF;
1451 boxfill8(COL8_000000, cursor_x, 28, cursor_x + 7, 43);
1455 if (i >= 256) and (i <= 511) then
1458 if cursor_x > 16 then
1460 putfonts8_asc(cursor_x, 28, 1, ' ');
1464 else if i = 10 + 256 then
1466 putfonts8_asc_sht(cursor_x, cursor_y, ' ');
1468 cmd := LowerCase(str);
1471 else if cmd = 'cls' then
1473 else if cmd = 'ls' then
1475 else if cmd = 'type' then
1477 else if Length(cmd) <> 0 then;
1479 else if cursor_x < 240 then
1481 cmd := LowerCase(str);
1482 cmd[1] := Char(i - 256);
1484 putfonts8_asc(cursor_x, 28, 1, cmd);
1487 if cursor_c >= 0 then
1488 boxfill8(cursor_c, cursor_x, 28, cursor_x + 7, 43);
1489 boxfill8(cursor_c, cursor_x, 28, cursor_x + 7, 43);
1495 destructor TConsole.Destroy;
1503 procedure TConsole.cmd_ls;
1508 for i := 0 to 223 do
1510 case Byte(info[i].name[1]) of
1514 if Byte(info[i].tpye) and $18 = 0 then
1516 str := info[i].name;
1517 str := str + info[i].ext;
1518 putfonts8_asc_sht(8, cursor_y, str);
1526 procedure TConsole.cmd_mem;
1531 procedure TConsole.newline;
1536 if cursor_y < 28 + 112 then
1540 for i := 28 + 112 to 28 + 127 do
1541 for j := 8 to 8 + 239 do
1542 vram[j + i * bxsize] := vram[j + (i + 16) * bxsize];
1543 for i := 28 to 28 + 111 do
1544 for j := 8 to 8 + 239 do
1545 vram[j + i * bxsize] := COL8_000000;
1546 clip := rect(8, 28, 8 + 240, 128 + 28);
1551 procedure TConsole.putchar(ch: Char; move: integer);
1553 if Byte(ch) = $09 then
1556 putfonts8_asc(cursor_x, cursor_y, 1, ch);
1558 if cursor_x = 8 + 240 then
1560 else if cursor_x - 8 and $1F = 0 then
1563 else if Byte(ch) = $0A then
1565 else if Byte(ch) = $0D then
1569 putfonts8_asc(cursor_x, cursor_y, 1, ch);
1573 if cursor_x = 8 + 240 then
1579 procedure TConsole.putstr0(str: string);
1583 for i := 1 to length(str) do
1587 procedure TConsole.putstrl(str: string; length: integer);
1591 for i := 1 to length do
1597 constructor TIdle.Create;
1602 esp := Pointer(integer(Self) + SizeOf(TIdle));
1615 constructor TPic.Create;
1617 io_out8(PIC0_IMR, $FF);
1618 io_out8(PIC1_IMR, $FF);
1620 io_out8(PIC0_ICW1, $11);
1621 io_out8(PIC0_ICW2, $20);
1622 io_out8(PIC0_ICW3, 1 shl 2);
1623 io_out8(PIC0_ICW4, $01);
1625 io_out8(PIC1_ICW1, $11);
1626 io_out8(PIC1_ICW2, $28);
1627 io_out8(PIC1_ICW3, 2);
1628 io_out8(PIC1_ICW4, $01);
1630 io_out8(PIC0_IMR, $FB);
1631 io_out8(PIC1_IMR, $FF);
1634 procedure TPic.inthandler27(var esp: integer);
1636 io_out8(PIC0_OCW2, $67);
1641 constructor TDesk.Create;