home *** CD-ROM | disk | FTP | other *** search
- Unit _LoadIff; (* requires TP 5.0 or higher *)
-
- (* ******************************************************************** *)
- (* Diese Unit ermöglicht das Einladen von DPaint (*.IFF, *.LBM) Bildern *)
- (* in einer Auflösung von 320x200 Bildpunkten bei 256 Farben *)
- (* *)
- (* (c) by ICE-BLOCK / InfernO-crew in 1992 *)
- (* For some swapping (Demos, Pascal-Sources etc.) contact me at: *)
- (* PLK 050808 C, W-6110 Dieburg, United Germany *)
- (* ******************************************************************** *)
-
- Interface
- Procedure LoadIFF(Name:String);
- Procedure ShowIff;
- Procedure VGA_Mode_On;
- Procedure VGA_Mode_Off;
-
- Implementation
-
- Uses Dos, Crt;
-
- Type
- LBMPuffer=array[0..65534] of Byte;
- NeuPuffer=array[0..63999] of Byte;
-
- Var
- FarbPuffer: Array[0..767] of Byte;
- NameLBM : String[80];
- InFile : File;
- HI,LO,
- Handle,
- BildLaenge,
- addr : Word;
- BildType,
- Fehler : Byte;
- Regs : Registers;
- LBMP : ^LBMPuffer;
- NEUP : ^NEUPuffer;
-
- (* *********************************************** *)
- (* Procedure VGA_JA_NEIN -> VGA-Karte vorhanden ? *)
- (* *********************************************** *)
-
- Procedure VGA_JA_NEIN;
- begin
- Regs.AX:=$1a00;
- Intr($10,Regs);
- If Regs.al<>$1a then
- begin
- Fehler:=1;
- TextColor(4);
- GotoXY(2,20);
- Write('Keine VGA-Karrte !!');
- Exit;
- end;
- end;
-
- (* ************************************************* *)
- (* Procedure LBMDateiLaden -> öffnet die Bilddatei *)
- (* ************************************************* *)
-
- Procedure LBMDateiLaden;
- Var
- GeleseneRecords:Word;
- begin
- Assign(Infile,NameLBM);
- {$i-}
- Reset(Infile,65535);
- BlockRead(InFile,LBMP^,1,GeleseneRecords);
- {$i+}
- If IOResult<>0 then
- begin
- fehler:=1;
- TextColor(LightRed+128);
- TextBackground(Blue);
- GotoXY(2,20);
- Write('Fehler bein lesen des Programms !!');
- exit;
- end;
- Close(InFile);
- end;
-
- (* ********************************************************************* *)
- (* Procedure PruefenGrafikFormat -> ist die Datei eine IFF 320x200x256 *)
- (* Datei ? *)
- (* ********************************************************************* *)
-
- Procedure PruefenGrafikFormat;
- begin
- If (LBMP^[20]=1) and (LBMP^[21]=$40) and
- (LBMP^[22]=0) and (LBMP^[23]=$C8) and
- (LBMP^[46]=3) and (LBMP^[47]=0)
- then Fehler:=0 else Fehler:=1;
- If LBMP^[8]=$49 then BildType:=1
- else BildType:=2;
- end;
-
- (* ******************************************************************* *)
- (* Procedure FarbDatenEinlesen -> Läd die Farbtabelle in den Speicher *)
- (* ******************************************************************* *)
-
- Procedure FarbDatenEinlesen;
- Var I:Integer;
- begin
- For i:=48 to 816 do
- FarbPuffer[i-48]:=LBMP^[i];
- end;
-
- (* ********************************************************************** *)
- (* Procedure BildLaengeErmitteln -> Ermittelt die Länge der eigentlichen *)
- (* Bilddaten *)
- (* ********************************************************************** *)
-
- Procedure BildLaengeErmitteln;
- Var
- Hilfe:Word;
- I:LongInt;
- begin
- For i:=0 to 69996 do begin
- If (LBMP^[i]=$42) and (LBMP^[i+1]=$4f)
- and (LBMP^[i+2]=$44) and (LBMP^[i+3]=$59)
- then addr:=i+6;
- end;
- BildLaenge:=LBMP^[addr]+LBMP^[addr+1];
- Hilfe:=BildLaenge;
- BildLaenge:=BildLaenge SHL 8;
- BildLaenge:=BildLaenge OR $00ff;
- Hilfe:=Hilfe SHR 8;
- Hilfe:=Hilfe OR $00ff;
- BildLaenge:=BildLaenge AND Hilfe;
- end;
-
- (* ********************************************************************* *)
- (* Procedure FarbinformationenAnpassen -> Initialisiert die Farbtabelle *)
- (* ********************************************************************* *)
-
- Procedure FarbinformationenAnpassen;
- Var i:Integer;
- begin
- For i:=0 to 767 do begin
- FarbPuffer[i]:=FarbPuffer[i] SHR 2;
- end;
- end;
-
- (* ***************************************************************** *)
- (*Procedure BildDatenDekomprimieren -> Umwandeln in Bildschirmdaten *)
- (* ***************************************************************** *)
-
- Procedure BildDatenDekomprimieren;
- Var
- Zaehler:Word;
- a:Byte;
- i,j,k:LongInt;
-
- begin
- Zaehler:=0;
- i:=Addr+2;
- j:=0;
- Repeat
- If LBMP^[i]<$80 then begin
- j:=LBMP^[i];
- for K:=1 to J+1 do begin
- Neup^[Zaehler]:=LBMP^[i+k];
- Zaehler:=Zaehler+1;
- end;
- i:=i+j+2;
- end
- else begin
- a:=LBMP^[i];
- a:=-a;
- a:=a+1;
- j:=a;
- For K:=1 to J do begin
- NEUP^[Zaehler]:=LBMP^[i+1];
- Zaehler:=Zaehler+1;
- end;
- i:=i+2;
- end;
- until Zaehler>63999;
- If BildType=2 then begin
- For i:=0 to 63999 do LBMP^[i]:=Neup^[i];
- end;
- end;
-
- (* ************************************************************* *)
- (*Procedure BildDatenDecodieren -> Umwandeln in Bildschirmdaten *)
- (* ************************************************************* *)
-
- Procedure BildDatenDecodieren;
- Var
- I1,Zaehler,m,j:Longint;
- k,l,n:Integer;
- Plane,BildByte:array[0..7] of Byte;
- begin
- Zaehler:=0;
- for m:=0 to 199 do begin
- i1:=m*320;
- for j:=0 to 39 do begin
- Plane[0]:=Neup^[i1+j];
- Plane[1]:=Neup^[i1+j+40];
- Plane[2]:=Neup^[i1+j+80];
- Plane[3]:=Neup^[i1+j+120];
- Plane[4]:=Neup^[i1+j+160];
- Plane[5]:=Neup^[i1+j+200];
- Plane[6]:=Neup^[i1+j+240];
- Plane[7]:=Neup^[i1+j+280];
- l:=128;
- For K:=0 to 7 do begin
- BildByte[k]:=0;
- If Plane[0] and l=l then BildByte[k]:=BildByte[k]+1;
- If Plane[1] and l=l then BildByte[k]:=BildByte[k]+2;
- If Plane[2] and l=l then BildByte[k]:=BildByte[k]+4;
- If Plane[3] and l=l then BildByte[k]:=BildByte[k]+8;
- If Plane[4] and l=l then BildByte[k]:=BildByte[k]+16;
- If Plane[5] and l=l then BildByte[k]:=BildByte[k]+32;
- If Plane[6] and l=l then BildByte[k]:=BildByte[k]+64;
- If Plane[7] and l=l then BildByte[k]:=BildByte[k]+128;
- LBMP^[Zaehler]:=BildByte[k];
- Zaehler:=Zaehler+1;
- l:=l shr 1;
- end;
- end;
- end;
- end;
-
- (* ********************************************************************* *)
- (* Procedure ShowIff -> Bildschirmadaten in den Bildschirmspeicher laden *)
- (* ********************************************************************* *)
-
- Procedure ShowIff;
- Var i:LongInt;
- begin
- Regs.ax:=$1012;
- Regs.bx:=0;
- Regs.cx:=256;
- Regs.dx:=Ofs(FarbPuffer);
- Regs.es:=Seg(FarbPuffer);
- Intr($10,Regs);
- For i:=0 to 63999 do Mem[$a000:i]:=LBMP^[i];
- end;
-
- Procedure VGA_Mode_On;
- begin
- Regs.AX:=$0013;
- Intr($10,regs);
- end;
-
- Procedure VGA_Mode_Off;
- begin
- Regs.ax:=$0003;
- Intr($10,Regs);
- end;
-
- (* ****************************************************************** *)
- (* Procedure LoadIFF -> Bild einladen und für die Anzeige vorbereiten *)
- (* ****************************************************************** *)
-
- Procedure LoadIFF(Name:String);
- begin
- NameLBM:=Name;
- New(LBMP);
- New(NEUP);
- Fehler:=0;
- VGA_JA_NEIN;
- If Fehler=1 then Halt(2);
- LBMDateiLaden;
- PruefenGrafikFormat;
- If Fehler=1 then Halt(3);
- FarbDatenEinlesen;
- BildLaengeErmitteln;
- FarbInformationenAnpassen;
- BildDatenDekomprimieren;
- If BildType=1 then BildDatenDecodieren;
- end;
-
- Begin
- (* (c) by ICE-BLOCK in 1992 *)
- (* Copy it free as PD - but don't change the copyright-message *)
- end.
-
-
-
-
-
-
-
-
-
-
-
-
-