unit impresor;
 
interface
 
Uses printer;
 
var lineas_avanzadas:real;
 
procedure inicializa(opc:byte);
procedure imprime(x,y:real;cad:string);
procedure finaliza;
 
implementation
procedure inicializa(opc:byte);
begin
 write(lst,#27+'M'+#27+'x');
 if opc=0 then
   write(lst,#0)
 else
 begin
   write(lst,#1);
   write(lst,#27+'k'+chr(opc-1))
 end;
 lineas_avanzadas:=0;
end;
 
procedure imprime(x,y:real;cad:string);
var a:word;
    x1,y1,y2:byte;
    spa:string;
begin
 x:=x/2.54;
 y:=(y-0.8)/2.54-lineas_avanzadas;
 lineas_avanzadas:=lineas_avanzadas+y;
 y1:=round(y*216) div 216;
 y2:=round(y*216) mod 216;
 x1:=round(x*12);
 spa:='';
 if y1<>0 then
 begin
   write(lst,#27+'3'+#216);
   for a:=1 to y1 do write(lst,#13,#10)
 end;
 write(lst,#27+'3'+#0);
  if y2<>0 then
      write(lst,#27+'J'+chr(y2));
 for a:=1 to x1 do
    spa:=spa+' ';
 write(lst,spa);
 writeln(lst,cad); 
end;
 
procedure finaliza;
begin
  write(lst,#27+'x'+#0,#12)
end;
 
end.