Advertisement
aNNiMON

СПиОС LR_5 VAR_10

Dec 15th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.08 KB | None | 0 0
  1. program LR_5;
  2. { Melnik Victor  ISPR A1  10 var  }
  3.  
  4. uses crt;
  5. var color : byte;
  6.  
  7. procedure plot(x, y : word);
  8.    var video_offset : word;
  9.        pix_col, value, shift: byte;
  10. begin
  11.     { вычисляем смещение в видеобуфере }
  12.     video_offset := 80 * (y div 2) + (x div 4);
  13.     if (y mod 2 = 1) then video_offset := video_offset + $2000;
  14.     shift := 6 - 2 * (x mod 4);
  15.    
  16.   asm
  17.     mov ax, 0b800h
  18.     mov es, ax
  19.     mov di, [video_offset]
  20.     lodsb
  21.    
  22.     xor ah, ah
  23.     mov bl, 0
  24.     and al, bl
  25.     mov [value], al
  26.   end;
  27.     pix_col := color shl shift;
  28.     value := value or pix_col;
  29.    
  30.   asm
  31.     mov ax, 0b800h
  32.     mov es, ax
  33.     mov al, [value]
  34.     mov di, [video_offset]
  35.     stosb
  36.   end;
  37. end;
  38.  
  39. function sign(value: integer) : integer;
  40. begin
  41.     if (value > 0) then sign := 1
  42.     else sign := -1;
  43. end;
  44.  
  45. procedure drawLine(x1, y1, x2, y2 : integer);
  46.     var dx, dy, i, sx, sy, check, e, x, y : integer;
  47. begin
  48.     dx := abs(x1 - x2);
  49.     dy := abs(y1 - y2);
  50.     sx := sign(x2 - x1);
  51.     sy := sign(y2 - y1);
  52.     x := x1;
  53.     y := y1;
  54.     check := 0;
  55.     if (dy > dx) then begin
  56.         dx := dx + dy;
  57.         dy := dx - dy;
  58.         dx := dx - dy;
  59.         check := 1;
  60.     end;
  61.     e:= 2 * dy - dx;
  62.     for i := 1 to dx do begin
  63.         plot(x, y);
  64.         if (e >= 0) then begin
  65.             if (check = 1) then x := x + sx
  66.             else y := y + sy;
  67.             e := e - 2 * dx;
  68.         end;
  69.         if (check = 1) then y := y + sy
  70.         else x := x + sx;
  71.         e := e + 2 * dy;
  72.     end;
  73. end;
  74.  
  75. begin
  76. { граф. режим 320x200x4 }
  77.    asm
  78.        mov ax, 4
  79.        int 10h
  80.    end;
  81.    
  82.    color := 1;
  83.    drawLine(60, 25, 20, 155);
  84.    drawLine(60, 25, 100, 155);
  85.    drawLine(35, 110, 85, 110);
  86.    
  87.    color := 2;
  88.    drawLine(180, 25, 125, 25);
  89.    drawLine(125, 25, 125, 90);
  90.    drawLine(125, 90, 180, 90);
  91.    drawLine(180, 90, 180, 155);
  92.    drawLine(180, 155, 125, 155);
  93.    
  94.    color := 3;
  95.    drawLine(215, 155, 215, 25);
  96.    drawLine(215, 25, 250, 90);
  97.    drawLine(250, 90, 285, 25);
  98.    drawLine(285, 25, 285, 155);
  99.    
  100.    readln;
  101.    { текст режим }
  102.    asm
  103.        mov ax, 3
  104.        int 10h
  105.    end;
  106. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement