Vielleicht helfen dir ja meine kleinen Tools weiter.
Erstmal ein dskread.c, damit mache ich aus einem DSK ein CPM file.
/*
Copyright 2020, dettus@dettus.net
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PARSE_INT32BE(ptr,idx) (\
(((unsigned int)((ptr)[((idx)+0)])&0xff)<<24) |\
(((unsigned int)((ptr)[((idx)+1)])&0xff)<<16) |\
(((unsigned int)((ptr)[((idx)+2)])&0xff)<< 8) |\
(((unsigned int)((ptr)[((idx)+3)])&0xff)<< 0) |\
0)
#define PARSE_INT16BE(ptr,idx) (\
(((unsigned int)((ptr)[((idx)+0)])&0xff)<< 8) |\
(((unsigned int)((ptr)[((idx)+1)])&0xff)<< 0) |\
0)
#define PARSE_INT32LE(ptr,idx) (\
(((unsigned int)((ptr)[((idx)+3)])&0xff)<<24) |\
(((unsigned int)((ptr)[((idx)+2)])&0xff)<<16) |\
(((unsigned int)((ptr)[((idx)+1)])&0xff)<< 8) |\
(((unsigned int)((ptr)[((idx)+0)])&0xff)<< 0) |\
0)
#define PARSE_INT16LE(ptr,idx) (\
(((unsigned int)((ptr)[((idx)+1)])&0xff)<< 8) |\
(((unsigned int)((ptr)[((idx)+0)])&0xff)<< 0) |\
0)
unsigned char buf[1<<20];
int main(int argc,char** argv)
{
FILE *f;
int dsksize;
int i,j;
int tracknum;
int sidenum;
int tracksize;
int idx;
f=fopen(argv[1],"rb");
dsksize=fread(buf,sizeof(char),sizeof(buf),f);
fclose(f);
f=fopen(argv[2],"wb");
printf("dsksize:%d\n",dsksize);
printf("<<magic:");
for (i=0;i<=0x21;i++)
{
printf("%c",buf[i]);
}
printf(">>");
printf("<<name of creator:");
for (i=0x22;i<=0x2f;i++) printf("%c",buf[i]);
printf(">>");
printf("<<number of tracks:%d>>",buf[0x30]);
printf("<<number of sides:%d>>",buf[0x31]);
printf("<<size of a track:%d>>",PARSE_INT16LE(buf,0x32));
printf("\n");
printf("-------------------------\n");
tracknum=buf[0x30];
sidenum=buf[0x31];
tracksize=PARSE_INT16LE(buf,0x32);
idx=256;
for (i=0;i<tracknum*sidenum;i++)
{
int idx0;
int sectorsize;
int sectornum;
int sectorids[16]={0};
int order[16]={0};
idx0=idx;
printf("\x1b[0;30;47mtrack:%d side:%d\x1b[0m\n",tracknum/sidenum,tracknum%sidenum);
printf("magic: ");
for (j=0;j<0x0c;j++) printf("%c",buf[idx++]);
printf("\n");
idx+=4; // 0x0c-0x0f: unused
printf("track: %d\n",buf[idx++]);
printf("side: %d\n",buf[idx++]);
idx+=2; //0x12-0x13: unused
sectorsize=buf[idx];
printf("sector size:%d\n",buf[idx++]);
sectornum=buf[idx];
printf("sector num: %d\n",buf[idx++]);
printf("gap3 length:%d\n",buf[idx++]);
printf("filler byte:%d\n",buf[idx++]);
for (j=0;j<sectornum;j++)
{
order[j]=j;
printf(" %d> track: %d\n",j,buf[idx++]);
printf(" %d> side: %d\n",j,buf[idx++]);
sectorids[j]=buf[idx];
printf(" %d> sectorID: %d\n",j,buf[idx++]);
sectorsize=128<<buf[idx];
printf(" %d> sectorsize: %d --> %d bytes\n",j,buf[idx++],sectorsize);
printf(" %d> FDC status1:%d\n",j,buf[idx++]);
printf(" %d> FDC status2:%d\n",j,buf[idx++]);
idx+=2; // 06-07: unused
}
for (j=0;j<sectornum-1;j++)
{
int k;
for (k=j+1;k<sectornum;k++)
{
if (sectorids[order[j]]>sectorids[order[k]])
{
int x;
x=order[j];
order[j]=order[k];
order[k]=x;
}
}
}
printf("track %2d> order ",i);
for (j=0;j<sectornum;j++)
{
printf("%d ",order[j]);
}
printf("\n");
idx=idx0+0x100;
for (j=0;j<sectornum;j++)
{
printf("@%06x ",idx+order[j]*sectorsize);
printf("writing sector %d id=%d\n",order[j],sectorids[order[j]]);
fwrite(&buf[idx+order[j]*sectorsize],sizeof(char),sectorsize,f);
}
idx=idx0+tracksize;
}
fclose(f);
}
Anschliessend verwende ich mein cpmextract.c, um die Dateien aus dem CPM Filesystem zu extrahieren
/*
Copyright 2020, dettus@dettus.net
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// http://www.seasip.info/Cpm/format22.html
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PARSE_INT32BE(ptr,idx) (\
(((unsigned int)((ptr)[((idx)+0)])&0xff)<<24) |\
(((unsigned int)((ptr)[((idx)+1)])&0xff)<<16) |\
(((unsigned int)((ptr)[((idx)+2)])&0xff)<< 8) |\
(((unsigned int)((ptr)[((idx)+3)])&0xff)<< 0) |\
0)
#define PARSE_INT16BE(ptr,idx) (\
(((unsigned int)((ptr)[((idx)+0)])&0xff)<< 8) |\
(((unsigned int)((ptr)[((idx)+1)])&0xff)<< 0) |\
0)
#define PARSE_INT32LE(ptr,idx) (\
(((unsigned int)((ptr)[((idx)+3)])&0xff)<<24) |\
(((unsigned int)((ptr)[((idx)+2)])&0xff)<<16) |\
(((unsigned int)((ptr)[((idx)+1)])&0xff)<< 8) |\
(((unsigned int)((ptr)[((idx)+0)])&0xff)<< 0) |\
0)
#define PARSE_INT16LE(ptr,idx) (\
(((unsigned int)((ptr)[((idx)+1)])&0xff)<< 8) |\
(((unsigned int)((ptr)[((idx)+0)])&0xff)<< 0) |\
0)
#define BLOCKSIZE 1024
unsigned char buf[1<<20];
int main(int argc,char** argv)
{
FILE *f;
int bufsize;
int i,j;
int idx;
int firstblock;
int entrycnt;
int attrs;
int extent;
char filename[16]={0};
char lastfilename[16]={0};
f=fopen(argv[1],"rb");
bufsize=fread(buf,sizeof(char),sizeof(buf),f);
fclose(f);
f=NULL;
firstblock=bufsize/BLOCKSIZE;
idx=0;
entrycnt=0;
while (idx<firstblock*BLOCKSIZE)
{
if ((buf[idx]&0xf0)==0)
{
printf("%2d> ",entrycnt);
for (i=0;i<32;i++) printf("%02x ",buf[idx+i]);
printf("user: %x ",buf[idx]&0xf);
idx++;
j=0;
filename[j++]='_';
for (i=0;i<11;i++)
{
unsigned char c;
c=buf[idx++]&0x7f;
if (i==8) filename[j++]='.';
if (c!=' ') filename[j++]=c;
filename[j]=0;
}
printf("[%s]",filename);
if (memcmp(filename,lastfilename,16))
{
if (f!=NULL) fclose(f);
memcpy(lastfilename,filename,16);
f=fopen(filename,"wb");
}
extent=buf[idx++]; // EX
idx++; // S1=0
extent=buf[idx++]<<8; // S2 little endian
extent*=128;
extent+=buf[idx++]; // rc
printf("extent:%6d ",extent);
printf("{");
for (i=0;i<16;i++)
{
int block;
block=buf[idx++];
if (block && block<firstblock) firstblock=block;
printf("%02X ",block);
if (block) fwrite(&buf[block*BLOCKSIZE],sizeof(char),BLOCKSIZE,f);
}
printf("}");
printf("\n");
entrycnt++;
} else {
idx+=32;
}
}
if (f!=NULL) fclose(f);
}