home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CBM Funet Archive
/
cbm-funet-archive-2003.iso
/
cbm
/
crossplatform
/
converters
/
msdos
/
zip2d64.arj
/
ZIP2D64.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1993-11-24
|
4KB
|
139 lines
{$7b}$m 16384,0,0{$7d}
TYPE BLOCKTYPE=ARRAY [0..255] OF BYTE;
VAR TRACK, SECTOR, MAX_SECTOR: BYTE;
INFILE, OUTFILE: FILE;
TRACK_DATA: ARRAY [0..8192] OF BYTE;
SECTOR_FLAG: ARRAY [0..20] OF BYTE;
I, BLOCK_COUNT: INTEGER;
FUNCTION READ_SECTOR (VAR F: FILE; TRACK: BYTE): INTEGER;
LABEL eRROR;
VAR TRK, SEC, MAX_SEC, LEN, REP, REPNUM, CHRA: BYTE;
I, J, COUNT: INTEGER;
BEGIN
BLOCKREAD (F, TRK, 1);
BLOCKREAD (F, SEC, 1);
IF ((TRK AND 63) <> TRACK) OR (SECTOR_FLAG [SEC] <> 0) OR (SEC > MAX_SECTOR) THEN
BEGIN
eRROR:
READ_SECTOR:=1;
WRITELN ('fILE IS CORRUPTED.');
EXIT;
END;
SECTOR_FLAG [SEC]:=1;
IF ((TRK AND 128) = 128) THEN
BEGIN
WRITE ('1');
BLOCKREAD (F, LEN, 1);
BLOCKREAD (F, REP, 1);
COUNT:=0;
FOR I:=0 TO LEN-1 DO
BEGIN
IF (EOF (F)) THEN GOTO eRROR;
BLOCKREAD (F, CHRA, 1);
IF (CHRA <> REP) THEN
BEGIN
TRACK_DATA [SEC SHL 8+COUNT]:=CHRA;
INC (COUNT);
END ELSE
BEGIN
BLOCKREAD (F, REPNUM, 1);
IF (EOF (F)) THEN GOTO eRROR;
BLOCKREAD (F, CHRA, 1);
I:=I+2;
FOR J:=0 TO REPNUM-1 DO
BEGIN
TRACK_DATA [SEC SHL 8+COUNT]:=CHRA;
INC (COUNT);
END;
END;
END;
END ELSE
IF ((TRK AND 64) = 64) THEN
BEGIN
WRITE ('2');
IF (EOF (F)) THEN GOTO eRROR;
BLOCKREAD (F, CHRA, 1);
FILLCHAR (TRACK_DATA [SEC SHL 8], 256, CHRA);
END ELSE
BEGIN
WRITE ('3');
BLOCKREAD (F, TRACK_DATA [SEC SHL 8], 256, I);
IF (I<>256) THEN GOTO eRROR;
END;
READ_SECTOR:=0;
END;
FUNCTION OPENFILE (P:BYTE): INTEGER;
BEGIN
IF (P>1) THEN CLOSE (INFILE);
ASSIGN (INFILE, CHR (P+48)+'!'+PARAMSTR (1));
{$7b}$i-{$7d}
RESET (INFILE, 1);
IF (IORESULT<>0) THEN
BEGIN
WRITELN ('eRROR OPENING FILE');
OPENFILE:=1;
EXIT;
END;
{$7b}$i+{$7d}
IF (P=1) THEN SEEK (INFILE, 4) ELSE SEEK (INFILE, 2);
OPENFILE:=0;
END;
LABEL eRROR, eRROR2;
BEGIN
WRITELN;
WRITELN ('zIPcODE 2 d64 - eXTRACT zIPCODE DISKS TO c64s .d64 IMAGES');
IF (PARAMCOUNT<>2) THEN
BEGIN
WRITELN ('uSAGE: ZIP2D64 <ZIPCODE FILE> <D64 IMAGE>');
END ELSE
BEGIN
IF (POS ('.D64', PARAMSTR (2)) > 0) THEN ASSIGN (OUTFILE, PARAMSTR (2)) ELSE
ASSIGN (OUTFILE, PARAMSTR (2)+'.d64');
REWRITE (OUTFILE, 1);
BLOCK_COUNT:=0;
FOR TRACK:=1 TO 35 DO
BEGIN
FILLCHAR (TRACK_DATA, SIZEOF (TRACK_DATA), 0);
IF (TRACK>=1) AND (TRACK<=17) THEN MAX_SECTOR:=20;
IF (TRACK>=18) AND (TRACK<=24) THEN MAX_SECTOR:=18;
IF (TRACK>=25) AND (TRACK<=30) THEN MAX_SECTOR:=17;
IF (TRACK>=31) AND (TRACK<=35) THEN MAX_SECTOR:=16;
CASE TRACK OF
1: IF (OPENFILE (1) <>0) THEN GOTO eRROR2;
9: IF (OPENFILE (2) <>0) THEN GOTO eRROR2;
17: IF (OPENFILE (3) <>0) THEN GOTO eRROR2;
26: IF (OPENFILE (4) <>0) THEN GOTO eRROR2;
END;
FILLCHAR (SECTOR_FLAG, SIZEOF (SECTOR_FLAG), 0);
WRITE ('tRACK ', TRACK,' ');
FOR SECTOR:=0 TO MAX_SECTOR DO
BEGIN
INC (BLOCK_COUNT);
IF (READ_SECTOR (INFILE, TRACK) <>0) THEN GOTO eRROR;
END;
BLOCKWRITE (OUTFILE, TRACK_DATA, MAX_SECTOR*256+256);
WRITELN;
END;
CLOSE (INFILE);
CLOSE (OUTFILE);
END;
EXIT;
eRROR:
CLOSE (INFILE);
eRROR2:
CLOSE (OUTFILE);
HALT (2);
END.