Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program LR_5;
- { Melnik Victor ISPR A1 10 var }
- uses crt;
- var color : byte;
- procedure plot(x, y : word);
- var video_offset : word;
- pix_col, value, shift: byte;
- begin
- { вычисляем смещение в видеобуфере }
- video_offset := 80 * (y div 2) + (x div 4);
- if (y mod 2 = 1) then video_offset := video_offset + $2000;
- shift := 6 - 2 * (x mod 4);
- asm
- mov ax, 0b800h
- mov es, ax
- mov di, [video_offset]
- lodsb
- xor ah, ah
- mov bl, 0
- and al, bl
- mov [value], al
- end;
- pix_col := color shl shift;
- value := value or pix_col;
- asm
- mov ax, 0b800h
- mov es, ax
- mov al, [value]
- mov di, [video_offset]
- stosb
- end;
- end;
- function sign(value: integer) : integer;
- begin
- if (value > 0) then sign := 1
- else sign := -1;
- end;
- procedure drawLine(x1, y1, x2, y2 : integer);
- var dx, dy, i, sx, sy, check, e, x, y : integer;
- begin
- dx := abs(x1 - x2);
- dy := abs(y1 - y2);
- sx := sign(x2 - x1);
- sy := sign(y2 - y1);
- x := x1;
- y := y1;
- check := 0;
- if (dy > dx) then begin
- dx := dx + dy;
- dy := dx - dy;
- dx := dx - dy;
- check := 1;
- end;
- e:= 2 * dy - dx;
- for i := 1 to dx do begin
- plot(x, y);
- if (e >= 0) then begin
- if (check = 1) then x := x + sx
- else y := y + sy;
- e := e - 2 * dx;
- end;
- if (check = 1) then y := y + sy
- else x := x + sx;
- e := e + 2 * dy;
- end;
- end;
- begin
- { граф. режим 320x200x4 }
- asm
- mov ax, 4
- int 10h
- end;
- color := 1;
- drawLine(60, 25, 20, 155);
- drawLine(60, 25, 100, 155);
- drawLine(35, 110, 85, 110);
- color := 2;
- drawLine(180, 25, 125, 25);
- drawLine(125, 25, 125, 90);
- drawLine(125, 90, 180, 90);
- drawLine(180, 90, 180, 155);
- drawLine(180, 155, 125, 155);
- color := 3;
- drawLine(215, 155, 215, 25);
- drawLine(215, 25, 250, 90);
- drawLine(250, 90, 285, 25);
- drawLine(285, 25, 285, 155);
- readln;
- { текст режим }
- asm
- mov ax, 3
- int 10h
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement