{ For sources of the used units send an e-mail to: cellux@vekoll.saturnus.vein.hu } program DeZip64; {$R-,G-,Q-,D-,L-} uses LowDos,Video,Glob; const MaxSectorsPerTrack = 21; type TSector = record Loaded : boolean; Data : array[0..255] of byte; end; PTrack = ^TTrack; TTrack = array[0..MaxSectorsPerTrack-1] of TSector; TTable = object procedure Draw; procedure SetSector(t,s : byte; c : char); end; var zfname : string; dfname : string; ZipFile : TFile; D64File : TFile; Tracks : array[1..35] of PTrack; i,j : word; Table : TTable; Window : TWindow; procedure Error(s : string); var w : TWindow; begin w.Init(255,255,Length(s)+4,5,'Error'); w.Draw; w.PutStringAt(2,2,s); Glob.ReadKey; w.Done; Window.Done; Halt(1); end; procedure Message(s : string); var i : word; begin with Window do begin for i:=1 to Size.X-2 do PutCharAt(i,Size.Y-1,Frame^.FrameChars[6]); PutStringAt(2,Size.Y-1,' '+s+' '); end; end; function SectorsPerTrack(track : byte) : byte; begin case track of 1..17 : SectorsPerTrack:=21; 18..24 : SectorsPerTrack:=19; 25..30 : SectorsPerTrack:=18; 31..35 : SectorsPerTrack:=17; end; end; procedure ProcessZipFile(index : byte); var track,sector : byte; packmethod : byte; len,sign,count,char : byte; i,j : word; begin ZipFile.Open(Chr($30+index)+'!'+zfname, omReadOnly); if ZipFile.ErrorCode<>0 then Error('Cannot open file '+Chr($30+index)+'!'+zfname); if index=1 then ZipFile.Seek(smFromStart,4) else ZipFile.Seek(smFromStart,2); while not ZipFile.Eof do begin ZipFile.Read(track,1); ZipFile.Read(sector,1); packmethod:=(track and $C0); track:=(track and $3F); if (not track in [1..35]) then Error('Invalid track number'); if (sector>=SectorsPerTrack(track)) then Error('Invalid sector number'); Table.SetSector(track,sector,'R'); Tracks[track]^[sector].Loaded:=True; j:=0; case packmethod of $80,$C0 : begin ZipFile.Read(len,1); ZipFile.Read(sign,1); i:=0; while (i0) and (j<256) do begin Tracks[track]^[sector].Data[j]:=char; Inc(j); Dec(count); end; if count>0 then Error('More than 256 bytes in sector'); end else begin Tracks[track]^[sector].Data[j]:=char; Inc(j); end; end; if i0 then Delete(dfname,Pos('.',dfname),255); dfname:=dfname+'.D64'; zfname:=UpStr(zfname); dfname:=UpStr(dfname); D64File.Create(dfname,atNormal); if D64File.ErrorCode<>0 then Error('Cant create file '+dfname); Window.Draw; Table.Draw; for i:=1 to 35 do begin if MaxAvail