Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
gestione a finestre 2 (dos) - MEM_VID.PAS

MEM_VID.PAS

Caricato da: David
Scarica il programma completo

  1. unit mem_vid;
  2.  
  3.             (**************) INTERFACE (******************)
  4. type
  5.   tipo_monitor=(b_n,col);
  6.  
  7.  
  8. procedure fissa_col(x,y,fg,bg:byte);
  9. procedure fissa_col_tb(x,y,tb:byte);
  10. procedure fissa_car(x,y:byte;ch:char);
  11. function leggi_car(x,y:byte):char;
  12. (*legge carattere nella posizione x,y in memoria video*)
  13. function leggi_str(x,y,lunghezza:byte):string;
  14. (*legge stringa in memoria video*)
  15. procedure fissa_car_col(x,y:byte;ch:char;fg,bg:byte);
  16. (*fissa carattere,colore testo e colore sfondo in una word della memoria
  17. video *)
  18. procedure str_vid(x,y:byte;str:string;fg,bg:byte);
  19. (*fissa una stringa con colore testo e sfondo direttamente in
  20. memoria video*)
  21. procedure str_vid_car(x,y:byte;str:string);
  22. (*fissa una stringa direttamente in memoria video*)
  23. procedure str_vid_att(x,y,lunghezza,fg,bg:byte);
  24. (*fissa colore testo e sfondo partendo da x,y in memoria video*)
  25. procedure pulisci(x1,y1,x2,y2,fg,bg:byte);
  26. (*riempie una finestra con spazi ' ' in memoria video, fissando i colori
  27. di testo e sfondo*)
  28. procedure pulisci_car(x1,y1,x2,y2:byte);
  29. (*riempie una finestra con spazi ' ' in memoria video*)
  30. procedure pulisci_att(x1,y1,x2,y2,fg,bg:byte);
  31. (*fissa i colori di testo e sfondo di una finestra in memoria video*)
  32.  
  33.  
  34.  
  35.  
  36. var
  37.   seg_vid:word;
  38.   t_mon:tipo_monitor;
  39.  
  40.                   (************) IMPLEMENTATION (*******************)
  41.  
  42.  
  43.  
  44.  
  45. procedure fissa_car_col(x,y:byte;ch:char;fg,bg:byte);
  46. var
  47.   w:word;
  48.   attrib:word;
  49. begin
  50.   w:=((y-1)*80+(x-1))*2;
  51.   attrib:=(bg shl 4)+ fg;
  52.   memW[seg_vid:W]:=(attrib shl 8)+ ord(ch);
  53. end;
  54.  
  55.  
  56.                            {***************}
  57.  
  58. procedure str_vid(x,y:byte;str:string;fg,bg:byte);
  59. var
  60.   i:byte;
  61. begin
  62.   if str='' then exit;
  63.   for i:=1 to (length(str)) do fissa_car_col(x+i-1,y,str[i],fg,bg);
  64. end;
  65.  
  66.                            {***************}
  67.  
  68. procedure pulisci(x1,y1,x2,y2,fg,bg:byte);
  69. var
  70.   i,j:byte;
  71. begin
  72.   for i:=y1 to y2
  73.     do for j:=x1 to x2
  74.          do fissa_car_col(j,i,' ',fg,bg);
  75. end;
  76.  
  77.                        {*******************}
  78.  
  79. procedure fissa_car(x,y:byte;ch:char);
  80. var
  81.   w:integer;
  82. begin
  83.   if ch='' then exit;
  84.   w:=((y-1)*80+(x-1))*2;
  85.   memW[seg_vid:w]:=((memW[seg_vid:w] shr 8) shl 8) + ord(ch);
  86. end;
  87.  
  88.                            {***************}
  89.  
  90.  
  91. function leggi_car(x,y:byte):char;
  92. var
  93.   w:word;
  94. begin
  95.   w:=((y-1)*80+(x-1))*2;
  96.   leggi_car:=char((memW[seg_vid:w] shl 8) shr 8);
  97. end;
  98.  
  99.  
  100.                         (********************)
  101.  
  102.  
  103. function leggi_str(x,y,lunghezza:byte):string;
  104. var
  105.   i:byte; s:string; ch:char;
  106. begin
  107.   s:='';
  108.   for i:=0 to lunghezza-1 do
  109.     begin
  110.       ch:=leggi_Car(x+i,y);
  111.       if ch=' ' then break;
  112.       s:=s+ch
  113.     end;
  114.   leggi_str:=s;
  115. end;
  116.  
  117.  
  118.  
  119.                         (***********************)
  120.  
  121.  
  122. procedure fissa_col(x,y,fg,bg:byte);
  123. var
  124.   w:integer;
  125.   k:byte;
  126. begin
  127.   w:=((y-1)*80+(x-1))*2;
  128.   k:=(bg shl 4) + fg;
  129.   memW[seg_vid:w]:=(k shl 8) + ((memW[seg_vid:w] shl 8) shr 8);
  130. end;
  131.  
  132.                        {*******************}
  133.  
  134.  
  135.  
  136. procedure fissa_col_tb(x,y,tb:byte);
  137. var
  138.   w:integer; k:byte;
  139. begin
  140.   w:=((y-1)*80+(x-1))*2;
  141.   k:=(tb shl 4) + ((memW[seg_vid:w] shl 4) shr 12) ;
  142.   memW[seg_vid:w]:=(k shl 8) + ((memW[seg_vid:w] shl 8) shr 8);
  143. end;
  144.  
  145.  
  146.                       (***********************)
  147.  
  148.  
  149. procedure str_vid_car(x,y:byte;str:string);
  150. var
  151.   i:byte;
  152. begin
  153.   if str='' then exit;
  154.   for i:=0 to length(str)-1
  155.     do fissa_car(x+i,y,str[i+1]);
  156. end;
  157.  
  158.                        {*******************}
  159.  
  160. procedure str_vid_att(x,y,lunghezza,fg,bg:byte);
  161. var
  162.   i:byte;
  163. begin
  164.   for i:=0 to lunghezza
  165.     do fissa_col(x+i,y,fg,bg);
  166. end;
  167.  
  168.                        {*******************}
  169.  
  170.  
  171. procedure pulisci_car(x1,y1,x2,y2:byte);
  172. var
  173.   i,j:byte;
  174. begin
  175.   for i:=y1 to y2
  176.     do for j:=x1 to x2
  177.          do fissa_car(j,i,' ');
  178. end;
  179.  
  180.                        {*******************}
  181.  
  182. procedure pulisci_att(x1,y1,x2,y2,fg,bg:byte);
  183. var
  184.   i,j:byte;
  185. begin
  186.   for i:=y1 to y2
  187.     do for j:=x1 to x2
  188.          do fissa_col(j,i,fg,bg);
  189. end;
  190.  
  191.  
  192.  
  193.  
  194. begin
  195.   if mem[$0000:$0449]=7 then
  196.     begin
  197.       seg_vid:=$B000;
  198.       t_mon:=b_n;
  199.     end else
  200.     begin
  201.       seg_vid:=$B800;
  202.       t_mon:=col;
  203.     end;
  204. end.