Program TimeOscillograph;
{$G+,N+,E-,D+}
Uses Graph, CRT;
{$L C:\PROGRA~2\BP70\BIN\EGAVGA.OBJ}
Procedure EGAVGA; External;
const
OldInt1Ch : Pointer = NIL;
flag : Word = 0;
var
x, y, Col : Word;
D, e, R : Integer;
P : Pointer;
v, w : Extended;
Function GetTime : Word; Assembler;
asm
@repeat:
mov ah, 2Ch
int 21h
xor ax, ax
{ mov al, ch ; час}
mov al, cl ; минута
mov cl, 60
mul cl
add al, dh ; секунда
adc ah, 0
{ mov al, dl ; сотая доля секунды}
test ax, ax
jz @repeat
end;
Function GetTimeX : Word; Assembler;
asm
@repeat:
mov ah, 2Ch
int 21h
xor ax, ax
mov al, ch ; час
add al, cl ; минута
adc ah, 0
add al, dh ; секунда
adc ah, 0
add al, dl ; сотая доля секунды
adc ah, 0
test ax, ax
jz @repeat
end;
Procedure SetInt1Ch; Assembler;
asm
push es
mov ax, 351Ch
int 21h
mov word ptr OldInt1Ch, bx
mov word ptr OldInt1Ch+2, es
mov word ptr @OI1Ch, bx
mov word ptr @OI1Ch+2, es
pop es
mov ax, 251Ch
push ds
mov dx, seg @int1Ch
mov ds, dx
mov dx, offset @int1Ch
int 21h
pop ds
ret
@int1Ch:
pusha
push ds
push ax
mov ax, Seg flag
mov ds, ax
mov word ptr flag, 1
pop ax
pop ds
popa
db 02Eh, 0EAh {cs:jmp 00000000}
@OI1Ch :
dd 0
{ iret}
end;
Procedure PutPixelX; Assembler;
asm
mov al, 8
mov dx, 03CEh
out dx, al
inc dx
mov cx, word ptr x
xor al, al
and cx, 0Fh
inc al
inc cl
ror al, cl
out dx, al
push ds
mov ax, word ptr y
mov bx, ax
shl bx, 2
add bx, ax
shl bx, 4
mov ax, word ptr x
shr ax, 3
add bx, ax
mov cl, byte ptr Col
mov ax, 0A000h
mov ds, ax
mov byte ptr [bx], cl {Поместили точку}
pop ds
end;
Procedure RestoreInt1Ch; Assembler;
asm
push ds
lds dx, OldInt1Ch
mov ax, 251Ch
int 21h
pop ds
end;
begin
P := @EGAVGA;
D := Detect;
if RegisterBGIdriver(P) < 0 then
begin
Writeln('Ошибка регистрации драйвера: ',
GraphErrorMsg(GraphResult));
Halt(1);
end;
InitGraph(D, R, '');
e := GraphResult;
if e <> grOk then
begin
WriteLn('Произошла ошибка графики!!!');
WriteLn(GraphErrorMsg(e));
Halt;
end;
v := 1;
w := 1;
SetInt1Ch;
Col := LightGreen;
SetColor(Black);
Randomize;
While not Keypressed do
begin
v := v*(2.0*Random-1);
Col := Random(16);
{ v := v*GetTimeX;}
v := v+0.001*(2.1396*(1-w*w)-w);
{ v := v/(Random+1);}
w := w + 0.0001*v + 0.01*Random;
{ if flag=1 then}
begin
y := 240-Round(12000*v);
x := Round(w*700);
PutPixel(x, y, Col);
{ inc(x);}
if x >639 then w := 0;
flag := 0;
end;
{ Line(x+1, 0, x+1, 479);}
end;
CloseGraph;
RestoreInt1Ch;
end.