Есть программа выполняющая различные процедуры.
Необходимо добавить в неё функцию при нажатии Alt+Q менять местами окна с часами и мерцающим текстом.
Вот, что у меня получается:
Код:
{$M $1000, 0, 0}
program Lab6;
uses Crt, Dos;
const Thread11Count = 1;
Thread12Count = 1;
FNameC = '1.txt';
X3C = 45; Y3C = 5; X4C = 5; Y4C = 4; X2C = 5; Y2C = 3;
xT: integer = 42;
xF: integer = 1;
AllTicks = 1;
N = 10;
Pic = '█';
type
video = array[1..25, 1..80] of
record
symbol: char;
attr: byte;
end;
var
memory: video absolute $B800:$0000;
isShift: byte absolute $0000:$0417;
kbFlags: Word absolute $40:$17;
Scr: Array[1..25, 1..80] of Record
symbol: Char;
attr: Byte;
end Absolute $B800:$0000;
Save: record
symbol: char;
attr: byte;
end;
x3, y3, dx3, dy3: Integer;
x4, y4, x2, y2: Integer;
h, m, s, s100: Word;
f: Text;
Old8h, Old9h: Procedure;
Thread11, Thread12, SumThread: Integer;
Error, CurCount, CurLine, i, T, Process: Integer;
On11, On12, On2, On3, On4, Start, isExit: Boolean;
Stop11, Stop12, Stop2, Stop3, Stop4: Boolean;
KeyCode, NewAttr, OldAttr: byte;
CurStr, FName, hs, ms, ss: String;
A: array [1..N] of String;
procedure SetCurSize(BegLine, EndLine: Byte);
var
Regs: Registers;
begin
with Regs do
begin
AH := $01;
CH := BegLine;
CL := EndLine;
end;
Intr($10, Regs);
end;
procedure DrawCurrentInfo;
begin
Window(1, 21, 40, 25);
GotoXY(1, 1); Write('ESC - Выход');
GotoXY(1, 3); Write('Буфер - ', CurCount / N * 100:3:0, '%');
GotoXY(1, 2); Write('Активен процесс № ');
if On11 then Write('1-Производитель');
if On12 then Write('1-Потребитель ');
if On2 then Write('2 ');
if On3 then Write('3 ');
if On4 then Write('4 ');
end;
procedure Pr11;
begin
if CurCount < N then
begin
if EOF(f) then
begin
Close(f);
Reset(f);
end;
ReadLn(f, CurStr);
Inc(CurCount);
A[CurCount] := CurStr;
end;
end;
procedure Pr12;
begin
if CurCount > 0 then
begin
Window(1, 1, 40, 9);
CurStr := A[1];
for i := 2 to CurCount do A[i - 1] := A[i];
Dec(CurCount);
Inc(CurLine);
if CurLine < 10 then GotoXY(1, CurLine)
else
begin
GotoXY(1, 1); DelLine;
GotoXY(1, 9 - 1);
end;
WriteLn(CurStr);
end;
end;
procedure Pr2;
begin
Window(xF, 11, 40, 19);
OldAttr := TextAttr;
NewAttr := 1 + Random(15); TextColor(NewAttr);
GotoXY(x2, y2); Write('Мерцающий текст');
GotoXY(x2, y2+2); Write('на две строки');
TextAttr := OldAttr;
end;
procedure Pr3;
begin
Memory[y3, x3].Symbol := Save.Symbol;
Memory[y3, x3].Attr := Save.Attr;
if (x3 + dx3 > 80) or (x3 + dx3 < 42) then dx3 := -dx3;
if (y3 + dy3 > 9) or (y3 + dy3 < 1) then dy3 := -dy3;
Inc(x3, dx3); Inc(y3, dy3);
Save.Symbol := Memory[y3, x3].Symbol;
Save.Attr := Memory[y3, x3].Attr;
Memory[y3, x3].Symbol := Pic;
Memory[y3, x3].Attr := 3;
end;
procedure Pr4;
begin
Window(xT, 11, 80, 19);
GetTime(h, m, s, s100);
Str(h, hs); Str(m, ms); Str(s, ss);
if h < 10 then hs := '0' + hs;
if m < 10 then ms := '0' + ms;
if s < 10 then ss := '0' + ss;
GotoXY(x4, y4); Write(hs, ':', ms, ':', ss);
end;
procedure SwapWnd;
var
t: Integer;
buf: array [0..39] of Word;
begin
t:=xT; xT:=xF; xF:=t;
for t:=11 to 17 do begin
Move(Scr[t,42],buf,SizeOf(buf));
Move(Scr[t,1],Scr[t,42],SizeOf(buf));
Move(buf,Scr[t,1],SizeOF(buf));
end;
end;
{$F+}
procedure Key; Interrupt;
begin
KeyCode := port[$60];
case KeyCode of
1: isExit := true;
17: if kbFlags and 8 <>0 then SwapWnd;
2: begin
if (isShift and $02) = $02 then Stop11 := true
else if Thread11 > 1 then Dec(Thread11);
end;
3: begin
if (isShift and $02) = $02 then Stop11 := false
else Inc(Thread11);
end;
4: begin
if (isShift and $02) = $02 then Stop12 := true
else if Thread12 > 1 then Dec(Thread12);
end;
5: begin
if (isShift and $02) = $02 then Stop12 := false
else Inc(Thread12);
end;
6: if (isShift and $02) = $02 then Stop2 := true;
7: if (isShift and $02) = $02 then Stop2 := false;
8: if (isShift and $02) = $02 then Stop3 := true;
9: if (isShift and $02) = $02 then Stop3 := false;
10: if (isShift and $02) = $02 then Stop4 := true;
11: if (isShift and $02) = $02 then Stop4 := false;
end;
Inline($9C);
Old9h;
end;
procedure Timer; Interrupt;
begin
if Start then
if T < AllTicks then
begin
if On11 then Pr11 else
if On12 then Pr12 else
if On2 then Pr2 else
if On3 then Pr3 else
if On4 then Pr4;
Inc(T);
DrawCurrentInfo;
end
else
begin
Start := false;
if On11 then On11 := false else
if On12 then On12 := false else
if On2 then On2 := false else
if On3 then On3 := false else
if On4 then On4 := false;
end;
Inline($9C);
Old8h;
end;
{$F-}
Часы перемещаются нормально, а мерцающий текст на долю секунды прыгает в нужное окно(4), после чего падает вниз(5)(