formatting and update for plug-in card

This commit is contained in:
dschmenk 2013-06-16 21:23:38 -07:00
parent 91f7c94d58
commit ecd31a7118
4 changed files with 124 additions and 121 deletions

Binary file not shown.

View File

@ -714,7 +714,7 @@ void main(int argc, char **argv)
} }
else else
{ {
printf("a2pi: Bad Sync ACK [0x%02X]\n", iopkt[0]); prlog("a2pi: Bad Sync ACK\n");
stop = TRUE; stop = TRUE;
} }
} }
@ -740,7 +740,7 @@ void main(int argc, char **argv)
{ {
if (read(a2fd, iopkt, 3) == 3) if (read(a2fd, iopkt, 3) == 3)
{ {
// printf("a2pi: Event [0x%02X] [0x%02X] [0x%02X]\n", iopkt[0], iopkt[1], iopkt[2]); printf("a2pi: Event [0x%02X] [0x%02X] [0x%02X]\n", iopkt[0], iopkt[1], iopkt[2]);
switch (iopkt[0]) switch (iopkt[0])
{ {
case 0x80: /* sync */ case 0x80: /* sync */

View File

@ -2,28 +2,28 @@
char online[] = { char online[] = {
// ORG $300 // ORG $300
0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS)
0xC5, // DB ON_LINE 0xC5, // DB ON_LINE
0x08, 0x03, // DW PARAMS 0x08, 0x03, // DW PARAMS
0x60, // RTS 0x60, // RTS
0xEA, 0xEA,
// PARAMS @ $308 // PARAMS @ $308
0x02, // PARAM_COUNT 0x02, // PARAM_COUNT
0x60, // UNIT_NUM = DRIVE 0, SLOT 6 0x60, // UNIT_NUM = DRIVE 0, SLOT 6
0x00, 0x20 // DATA_BUFFER = $2000 0x00, 0x20 // DATA_BUFFER = $2000
}; };
char readblk[] = { char readblk[] = {
// ORG $300 // ORG $300
0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS)
0x80, // DB READ_BLOCK 0x80, // DB READ_BLOCK
0x08, 0x03, // DW PARAMS 0x08, 0x03, // DW PARAMS
0x60, // RTS 0x60, // RTS
0xEA, 0xEA,
// PARAMS @ $308 // PARAMS @ $308
0x03, // PARAM_COUNT 0x03, // PARAM_COUNT
0x60, // UNIT_NUM = DRIVE 0, SLOT 6 0x60, // UNIT_NUM = DRIVE 0, SLOT 6
0x00, 0x20, // DATA_BUFFER = $2000 0x00, 0x20, // DATA_BUFFER = $2000
0x00, 0x00 // BLOCK_NUM 0x00, 0x00 // BLOCK_NUM
}; };
#define ORG 0x0300 #define ORG 0x0300
#define BLOCK_NUM 0x030C #define BLOCK_NUM 0x030C
@ -32,37 +32,38 @@ char dsk[280][512];
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
FILE *dskfile; FILE *dskfile;
char count[2], volname[21]; char count[2], volname[21];
int i, result, fd; int i, result, fd;
int pifd = a2open(argc > 1 ? argv[1] : "127.0.0.1"); int pifd = a2open(argc > 1 ? argv[1] : "127.0.0.1");
if (pifd < 0) if (pifd < 0)
{ {
perror("Unable to connect to Apple II Pi"); perror("Unable to connect to Apple II Pi");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
a2write(pifd, ORG, sizeof(online), online); sleep(1);
a2call(pifd, ORG, &result); a2write(pifd, ORG, sizeof(online), online);
a2read(pifd, DATA_BUFFER, 16, volname); a2call(pifd, ORG, &result);
volname[(volname[0] & 0x0F) + 1] = '\0'; a2read(pifd, DATA_BUFFER, 16, volname);
printf("Volume name:%s\n", volname + 1); volname[(volname[0] & 0x0F) + 1] = '\0';
strcat(volname + 1, ".PO"); printf("Volume name:%s\n", volname + 1);
a2write(pifd, ORG, sizeof(readblk), readblk); strcat(volname + 1, ".PO");
for (i = 0; i < 280; i++) a2write(pifd, ORG, sizeof(readblk), readblk);
{ for (i = 0; i < 280; i++)
printf("Reading block #%d\r", i); {
fflush(stdout); printf("Reading block #%d\r", i);
count[0] = i; fflush(stdout);
count[1] = i >> 8; count[0] = i;
a2write(pifd, BLOCK_NUM, 2, count); count[1] = i >> 8;
a2call(pifd, ORG, &result); a2write(pifd, BLOCK_NUM, 2, count);
a2read(pifd, DATA_BUFFER, 512, dsk[i]); a2call(pifd, ORG, &result);
} a2read(pifd, DATA_BUFFER, 512, dsk[i]);
a2close(pifd); }
if ((dskfile = fopen(volname + 1, "wb"))) a2close(pifd);
{ if ((dskfile = fopen(volname + 1, "wb")))
fwrite(dsk, 1, 280*512, dskfile); {
fclose(dskfile); fwrite(dsk, 1, 280*512, dskfile);
} fclose(dskfile);
return EXIT_SUCCESS; }
return EXIT_SUCCESS;
} }

View File

@ -2,28 +2,28 @@
char online[] = { char online[] = {
// ORG $300 // ORG $300
0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS)
0xC5, // DB ON_LINE 0xC5, // DB ON_LINE
0x08, 0x03, // DW PARAMS 0x08, 0x03, // DW PARAMS
0x60, // RTS 0x60, // RTS
0xEA, 0xEA,
// PARAMS @ $308 // PARAMS @ $308
0x02, // PARAM_COUNT 0x02, // PARAM_COUNT
0x60, // UNIT_NUM = DRIVE 0, SLOT 6 0x60, // UNIT_NUM = DRIVE 0, SLOT 6
0x00, 0x20 // DATA_BUFFER = $2000 0x00, 0x20 // DATA_BUFFER = $2000
}; };
char writeblk[] = { char writeblk[] = {
// ORG $300 // ORG $300
0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS)
0x81, // DB WRITE_BLOCK 0x81, // DB WRITE_BLOCK
0x08, 0x03, // DW PARAMS 0x08, 0x03, // DW PARAMS
0x60, // RTS 0x60, // RTS
0xEA, 0xEA,
// PARAMS @ $308 // PARAMS @ $308
0x03, // PARAM_COUNT 0x03, // PARAM_COUNT
0x60, // UNIT_NUM = DRIVE 0, SLOT 6 0x60, // UNIT_NUM = DRIVE 0, SLOT 6
0x00, 0x20, // DATA_BUFFER = $2000 0x00, 0x20, // DATA_BUFFER = $2000
0x00, 0x00 // BLOCK_NUM 0x00, 0x00 // BLOCK_NUM
}; };
#define ORG 0x0300 #define ORG 0x0300
#define BLOCK_NUM 0x030C #define BLOCK_NUM 0x030C
@ -32,57 +32,59 @@ char dsk[280][512];
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
FILE *dskfile; FILE *dskfile;
char count[2], volname[21]; char count[2], volname[21];
int i, result, fd; int i, result, fd;
int pifd = a2open(argc > 2 ? argv[2] : "127.0.0.1"); int pifd = a2open(argc > 2 ? argv[2] : "127.0.0.1");
if (pifd < 0) if (pifd < 0)
{ {
perror("Unable to connect to Apple II Pi"); perror("Unable to connect to Apple II Pi");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (argc < 2) if (argc < 2)
{ {
perror("Usage: dskwrite <filename> [ip address]\n"); perror("Usage: dskwrite <filename> [ip address]\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
a2write(pifd, ORG, sizeof(online), online); sleep(1);
a2call(pifd, ORG, &result); fflush(stdin);
if (result == 0) a2write(pifd, ORG, sizeof(online), online);
{ a2call(pifd, ORG, &result);
a2read(pifd, DATA_BUFFER, 16, volname); if (result == 0)
volname[(volname[0] & 0x0F) + 1] = '\0'; {
printf("Are you sure you want to overwrite volume :%s?", volname + 1); a2read(pifd, DATA_BUFFER, 16, volname);
fflush(stdout); volname[(volname[0] & 0x0F) + 1] = '\0';
fgets(count, 2, stdin); printf("Are you sure you want to overwrite volume :%s?", volname + 1);
if (count[0] != 'y' && count[0] != 'Y') fflush(stdout);
{ fgets(count, 2, stdin);
a2close(pifd); if (count[0] != 'y' && count[0] != 'Y')
exit(EXIT_FAILURE);
}
}
if ((dskfile = fopen(argv[1], "rb")))
{ {
fread(dsk, 1, 280*512, dskfile); a2close(pifd);
fclose(dskfile); exit(EXIT_FAILURE);
} }
else }
{ if ((dskfile = fopen(argv[1], "rb")))
perror("Unable to read .PO file\n"); {
a2close(pifd); fread(dsk, 1, 280*512, dskfile);
exit(EXIT_FAILURE); fclose(dskfile);
} }
a2write(pifd, ORG, sizeof(writeblk), writeblk); else
for (i = 0; i < 280; i++) {
{ perror("Unable to read .PO file\n");
printf("Writing block #%d\r", i); a2close(pifd);
fflush(stdout); exit(EXIT_FAILURE);
count[0] = i; }
count[1] = i >> 8; a2write(pifd, ORG, sizeof(writeblk), writeblk);
a2write(pifd, DATA_BUFFER, 512, dsk[i]); for (i = 0; i < 280; i++)
a2write(pifd, BLOCK_NUM, 2, count); {
a2call(pifd, ORG, &result); printf("Writing block #%d\r", i);
} fflush(stdout);
a2close(pifd); count[0] = i;
return EXIT_SUCCESS; count[1] = i >> 8;
a2write(pifd, DATA_BUFFER, 512, dsk[i]);
a2write(pifd, BLOCK_NUM, 2, count);
a2call(pifd, ORG, &result);
}
a2close(pifd);
return EXIT_SUCCESS;
} }