home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / EGAVGA.SWG / 0002_RE: Loading PCX Files.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-02-21  |  2.2 KB  |  109 lines

  1. {
  2.  KB> Hello.  I was wondering if someone could tell me how to read in PCX
  3.  KB> files in Turbo Pascal using either resolution (320 X 200, 640 X 480
  4.  KB> etc.) with 256 colours. I was using a program called clip but it does
  5.  KB> not read PCX files that are in 256 colours.  Any help is appreciated.
  6.  
  7. I can help you with the 320x200x256 mode.
  8.  
  9. Here come a little program (mostly in asm) to display a PCX-image in that
  10. resulution.
  11.  
  12. To load a PCX-image, use the procedure PCX_LOAD(PicName, Init), where 
  13. PicName = Path+Filename of image to be displayed.
  14. Init    = Should the procedure init mode 13h before displaying the pic?
  15.  
  16. Hope you can use this.
  17. }
  18.  
  19. program PCX_LOAD;
  20.  
  21. {$G+}
  22.  
  23. Var
  24.  Pic:Array [0..63999] Of Byte;
  25.  Pcx:File;
  26.  Read_Result:Integer;
  27.  
  28. Procedure Load_Pcx(Name:String; Init:Boolean);
  29. begin
  30.   If Init Then
  31.    Asm
  32.      Mov  AX, 13h
  33.      Int  10h
  34.    End;
  35.    Asm
  36.      Mov  AL, 0
  37.      Mov  DX, 03C8h
  38.      Out  DX, AL
  39.      Inc  DX
  40.      Mov  CX, 1023
  41. @l1: Out  DX, AL
  42.      Loop @l1
  43.   End;
  44.   Assign(PCX, name);
  45.   Reset(PCX, 1);
  46.   BlockRead(PCX, Pic, SizeOf(Pic), Read_Result);
  47.   Close(PCX);
  48.   Asm
  49.      Cld
  50.      Mov  AX, 0A000h
  51.      Mov  ES, AX
  52.      Lea  BX, Pic
  53.      Add  BX, 128
  54.      Xor  DI, DI
  55.      Xor  DX, DX
  56.      Xor  AX, AX
  57.      Xor  CX, CX
  58. @l2: Mov  AL, [BX]
  59.      Inc  BX
  60.      Cmp  AL, 0C0h
  61.      Ja   @r1
  62.      Stosb
  63.      Inc  DX
  64.      Jmp  @r3
  65. @r1: Sub  AL, 0C0h
  66.      Mov  CL, AL
  67.      Add  DX, AX
  68.      Mov  AL, [BX]
  69.      Inc  BX
  70.  Rep Stosb
  71. @r3: Cmp  DX, 64000
  72.      Jnz  @l2
  73.      Inc  BX
  74.      Mov  DX, 03C8h
  75.      Mov  AL, 00h
  76.      Out  DX, AL
  77.      Inc  DX
  78.      Mov  CX, 255
  79. @r4: Mov  AL, [BX]
  80.      Shr  AL, 2
  81.      Out  DX, AL
  82.      Mov  AL, [BX+1]
  83.      Shr  AL, 2
  84.      Out  DX, AL
  85.      Mov  AL, [BX+2]
  86.      Shr  AL, 2
  87.      Out  DX, AL
  88.      Add  BX, 3
  89.      Loop @r4
  90.   End;
  91. End;
  92.  
  93. begin
  94.   load_pcx('D:\artpack\esilogo.PCX', True);
  95.   Asm
  96.    Mov AH, 000h
  97.    Int 16h
  98.    Mov AX, 003h
  99.    Int 10h
  100.   End;
  101. end.
  102.  
  103. Oh, btw. this program can't handle a picture larger than 64000 bytes, but i
  104. hope you can find a way around that. If not, write a mail to me, and i will
  105. see what i can do...
  106.  
  107. TTYL
  108.    Allan Bang Andersen
  109.