dump disk to edd format

command: eddread </4> for 0.25 track </2> for 0.5 track
edd4+ card must in slot 5 and disk II card must in slot 6
This commit is contained in:
ivanli88 2017-11-14 08:51:01 +08:00 committed by GitHub
parent 62eb8820f5
commit f2a12e5af6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

99
src/eddread.c Normal file
View File

@ -0,0 +1,99 @@
#include "a2lib.c"
#include "stdlib.h"
char eddctr[] = {
// ORG $C00
0xA9, 0x00, 0x20, 0x04, 0x0D, 0xA6, 0x43, 0xBC, 0x89, 0xC0, 0x48, 0x20, 0xD0, 0x0C, 0x68, 0x20,
0x3F, 0x0C, 0xAD, 0x0E, 0x0D, 0x0A, 0x0A, 0x0A, 0x0A, 0xAA, 0xA9, 0x40, 0x85, 0x01, 0xA0, 0x00,
0x84, 0x00, 0xA5, 0x01, 0xC9, 0x80, 0xF0, 0x11, 0xBD, 0x81, 0xC0, 0x10, 0xFB, 0xBD, 0x80, 0xC0,
0x91, 0x00, 0xC8, 0xD0, 0xED, 0xE6, 0x01, 0xD0, 0xEF, 0xA6, 0x43, 0xBC, 0x88, 0xC0, 0x60, 0xA0,
0x00, 0xF0, 0x02, 0xA0, 0x01, 0x8C, 0x0F, 0x0D, 0xA4, 0x12, 0xC0, 0xFF, 0xD0, 0x07, 0x48, 0xA9,
0x00, 0x20, 0x55, 0x0C, 0x68, 0x8D, 0x13, 0x0D, 0xC5, 0x12, 0xF0, 0x59, 0x29, 0xFE, 0x8D, 0x14,
0x0D, 0xA0, 0x01, 0x8C, 0x15, 0x0D, 0xA5, 0x12, 0x29, 0xFE, 0x20, 0xB6, 0x0C, 0xA5, 0x12, 0xCD,
0x14, 0x0D, 0xF0, 0x13, 0xB0, 0x07, 0xE6, 0x12, 0xE6, 0x12, 0x4C, 0x81, 0x0C, 0xC6, 0x12, 0xC6,
0x12, 0x20, 0xB8, 0x0C, 0x4C, 0x6D, 0x0C, 0xAD, 0x13, 0x0D, 0xC5, 0x12, 0xF0, 0x16, 0x85,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07, 0x0D, 0xAD, 0x00, 0x03, 0xCE, 0x07, 0x0D, 0xD0, 0xF8, 0x88, 0xC0,
0xFF, 0xD0, 0xEE, 0xCA, 0xE0, 0xFF, 0xD0, 0xE9, 0x60, 0xA0, 0xFF, 0x84, 0x12, 0xA0, 0x2C, 0x8C,
0x02, 0x0C, 0x60, 0x05, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x00
}; */
#define ORG 0x0C00
#define TRACK_NUM 0x0C01
#define DATA_BUFFER 0x4000
char dsk[137][16384];
int main(int argc, char **argv)
{
FILE *dskfile;
char count[2]; //, volname[21];
int i,j=0, result, fd, sp=0, pifd;
if (argc > 1)
{
if (strcmp(argv[1],"/2")==0) {
sp = 2;
} else if (strcmp(argv[1],"/4")==0) {
sp = 1;
} else {
sp = 4;
}
pifd = a2open(sp == 4 ? argv[1] : "127.0.0.1");
}
else
{
pifd = a2open("127.0.0.1");
sp = 4;
}
if (pifd < 0)
{
perror("Unable to connect to Apple II Pi");
exit(EXIT_FAILURE);
}
char volname[] = "nibble.edd";
a2write(pifd, ORG, sizeof(eddctr), eddctr);
// count[0] = 0;
// a2write(pifd, TRACK_NUM, 1, count);
// a2call(pifd, ORG, &result);
for (i = 0; i < 137; i=i+sp)
{
printf("Reading Track #%.02f\r", (float)i/4);
fflush(stdout);
count[0] = i;
a2write(pifd, TRACK_NUM, 1, count);
a2call(pifd, ORG, &result);
a2read(pifd, DATA_BUFFER, 16384, dsk[j]);
j++;
}
a2close(pifd);
if ((dskfile = fopen(volname, "wb")))
{
fwrite(dsk, 1, j*16384, dskfile);
fclose(dskfile);
}
return EXIT_SUCCESS;
}