home *** CD-ROM | disk | FTP | other *** search
/ Solo Programadores 22 / SOLO_22.iso / disk22 / modosx / modox.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-03-25  |  6.5 KB  |  153 lines

  1. {▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒C▒O▒M▒P▒I▒L▒E▒R▒▒▒▒▒▒▒▒▒▒▒S▒O▒F▒T▒W▒A▒R▒E▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  2. ▒▒                                                                      ▒▒
  3. ▒▒  MODOX.INC                                                           ▒▒
  4. ▒▒                                                                      ▒▒
  5. ▒▒  Esta librería es introductoria y a partir del próximo número estará ▒▒
  6. ▒▒  completamente  optimizada para  286+  usando assembler en  su mayor ▒▒
  7. ▒▒  parte. Para usarla en tus programas debe estar en el directorio ac- ▒▒
  8. ▒▒  tual en el momento de la compilación e incluir la directiva entre   ▒▒
  9. ▒▒  llaves :                                                            ▒▒
  10. ▒▒                                                                      ▒▒
  11. ▒▒  $I MODOX.INC                                                        ▒▒
  12. ▒▒                                                                      ▒▒
  13. ▒▒  Set_320x200X --> Establece modo 320x200x4 planos                    ▒▒
  14. ▒▒  Set_320x240X --> Establece modo 320x240x4 planos                    ▒▒
  15. ▒▒  PutPixelX    --> Pone un punto en la coord x,y de color 'color'     ▒▒
  16. ▒▒  GetPixelX    --> Devuelve el color de la coordenada x, y            ▒▒
  17. ▒▒                                                                      ▒▒
  18. ▒▒  1996 Compiler SoftWare. Para dudas y contactos leer el fichero de   ▒▒
  19. ▒▒  texto COMPILER.NFO del subdirectorio INFO.                          ▒▒
  20. ▒▒                                                                      ▒▒
  21. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒;-)▒▒▒▒}
  22.  
  23. Uses crt, dos;
  24.  
  25. CONST
  26.      SEQU_ADDR = $3c4;
  27.      CRTC_ADDR = $3d4;
  28.      GRAC_ADDR = $3ce;
  29.  
  30. {
  31. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  32. ▒▒                       DECLARACIONES DE FUNCIONES                     ▒▒
  33. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  34. }
  35.  
  36. {
  37. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  38. ▒▒ Set_320x200X;                                                        ▒▒
  39. ▒▒                                                                      ▒▒
  40. ▒▒ Inicializa el Modo 13X de 320x200 a 256 colores en sistema 1x4.      ▒▒
  41. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  42. }
  43.  
  44. Procedure Set_320x200X;
  45. Begin
  46.     asm  mov ax , 13h                          { inicializamos modo 13h estándar }
  47.          int 10h
  48.     end;
  49.         
  50.         portw[ SEQU_ADDR] := $0604;         { ponemos el bit CHAIN-4 a 0 }
  51.         portw[ CRTC_ADDR] := $E317;         { ajuste del modo de palabras }
  52.         portw[ CRTC_ADDR] := $0014;         { ajuste del modo de dobles palabras }
  53.         portw[ SEQU_ADDR] := $0F02;         { seleccionar los cuatro planos para...}
  54.  
  55.     asm                                      { ...borrar la pantalla }
  56.          mov ax , $A000 
  57.          mov es , ax
  58.          xor di , di
  59.          xor ax , ax
  60.          mov cx , 32000
  61.          rep stosw
  62.     end;                                                  
  63. end;
  64.  
  65.  
  66. {
  67. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  68. ▒▒ Set_320x240X;                                                        ▒▒
  69. ▒▒                                                                      ▒▒
  70. ▒▒ Inicializa el Modo X de 320x240 a 256 colores en sistema 1x4.        ▒▒
  71. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  72. }
  73.  
  74. Procedure Set_320x240X;
  75. Begin
  76.         Set_320x200X;                      { primero inicializamos 13X }
  77.  
  78.         port [$3C2] := $E3;  
  79.         portw[CRTC_ADDR] := $2C11;         { permitir escritura }
  80.         portw[CRTC_ADDR] := $0D06;         { Total vertical }
  81.         portw[CRTC_ADDR] := $3E07;         { Overflow Register }
  82.         portw[CRTC_ADDR] := $EA10;         { Vertical retrace start }
  83.         portw[CRTC_ADDR] := $AC11;         { Vertical retrace end y Write prot. }
  84.         portw[CRTC_ADDR] := $DF12;         { Vertical display enable end }
  85.         portw[CRTC_ADDR] := $E715;         { Start vertical blanking }
  86.         portw[CRTC_ADDR] := $0616;         { End vertical blanking }
  87.  
  88. end;
  89.  
  90.  
  91. {
  92. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  93. ▒▒ PutPixelX (integer x, integer y, byte color);                        ▒▒
  94. ▒▒                                                                      ▒▒
  95. ▒▒ Coloca un punto en (X,Y) de color color.                             ▒▒
  96. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  97. }
  98.  
  99. Procedure PutPixelX( x, y : integer;color : byte ) ;
  100.  
  101. Var offs : word;
  102.  
  103. Begin
  104. port[ SEQU_ADDR] := $02 ;                  { función seleccionar plano }
  105. port[ SEQU_ADDR+1] := 1 shl ( x and 3 ) ;  { esto calcula automáticamente 
  106.                                                   el plano a partir de los 2 
  107.                                                   últimos bits de la coord.x}
  108.  
  109. offs := (y shl 6) + (y shl 4) + (x shr 2);       { calculamos el offset }
  110.                                                  { esta línea equivale a
  111.                                                     off = (80*y) + (x/4) ; 
  112.                                                    pero es MUCHO más rápida.}
  113. asm 
  114.         mov ax , $a000
  115.         mov es , ax
  116.         mov di , offs
  117.         mov al , color
  118.         stosb                                      { ponemos el punto }
  119.     end;
  120. end;
  121.  
  122. {
  123. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  124. ▒▒ GetPixelX(integer x, integer y);                                     ▒▒
  125. ▒▒                                                                      ▒▒
  126. ▒▒ Devuelve el color de un pixel en (X,Y) en sistema 1x4.               ▒▒
  127. ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  128. }
  129.  
  130. Function GetPixelX(x, y : integer) : byte;
  131.  
  132. Var offs  : word;
  133.     valor : byte;
  134. Begin                
  135.         port[GRAC_ADDR] := $04;
  136.         port[GRAC_ADDR+1] :=  x and 3 ;          { nº de plano }
  137.  
  138. offs := (y shl 6) + (y shl 4) + (x shr 2);       { calculamos el offset }
  139.                                                  { esta línea equivale a
  140.                                                    off = (80*y) + (x/4) ; 
  141.                                                    pero es MUCHO más rápida.}
  142. asm 
  143.         mov ax , $a000
  144.         mov es , ax
  145.         mov di , offs                          { lo leemos }
  146.         mov al, es:[di]
  147.         mov [valor], al
  148.    end;
  149.  
  150.    GetPixelX := valor;                        { y lo devolvemos }
  151. end;
  152.  
  153.