From ecd31a7118e39b4dcc354aab3b2276114963b525 Mon Sep 17 00:00:00 2001 From: dschmenk Date: Sun, 16 Jun 2013 21:23:38 -0700 Subject: [PATCH] formatting and update for plug-in card --- src/A2PI.PO | Bin 143360 -> 143360 bytes src/a2pid.c | 4 +- src/dskread.c | 101 +++++++++++++++++------------------ src/dskwrite.c | 140 +++++++++++++++++++++++++------------------------ 4 files changed, 124 insertions(+), 121 deletions(-) diff --git a/src/A2PI.PO b/src/A2PI.PO index e23c0e75c6c8195c48424e78ae5fa734f6f4728f..f021a0d33f3713213f590d96cc0e3410b969395d 100755 GIT binary patch delta 733 zcmYLFUq}=|7{9&qc302n_M=Ph5BJ3;s^~}Lb~+ce=dPuFEh08 z!Ck>*=~aq0%}ib$Y*Ni*YeY!8D*p z?n6`1*4%xno7}c#H^u_$%dmToh4fK$7SKgduYo(JfA?#~x32ULBdBls`&px|?W$3A z1l;@Vp#H$aQxKIq>0{o!r?%9caI}+-*AU-0!DDUCDRI$zAmWKMtX323Ky&Z!8r$o` yv)~E3Z$jk8HIez(q)6TYR>{u-TUT2__wn)@;;!^hdCQe6;;o6Txrr?ydioEWo=1-W delta 669 zcmZ8dQA-q26rNe#nc3BF=3urN#DEnoMG*B+Z-GQYQ-LJxLxE4F&=2q>8mkrCxY0WH zB#d{*UGwU$IJ*z6Z)+tql5#`C3?GbO3AdJo!XgSgyY5q$d%t_mcfNB!&Na6bb4!^M z{f$9kQ?va3qvCY#g#V)?UdTz!zb{(r-^1DNbuoKA5X*_dpJI0Fy|05VEpxi~!CND% zi)*W^ujt#?3v?nm_mW_=fl+=Tcja?VvX(Z3R%?~t^37G%YNRmMJBb%9keMxMo)#R|boPtW;FtuqF zz0hD*Ej*b7c3-zOeN>C-wso@<3gYQqyL9Z54VCsG zxvTnbt`wDKZAeq-QwH=gI3DUf*Gq?8#WQi%tm-}GO-@`t1Nv1kZi6?%n;mN}jW}O@ zxt{Wjf26y|`Qf`~41zbx4>`}OQoiTjH3$`tU*3Ikp;4!3|KVEdr-U+JCE0(Ybb?#>H$ MN4$34GX1Up0Q*xGb^rhX diff --git a/src/a2pid.c b/src/a2pid.c index 019f67d..378df38 100755 --- a/src/a2pid.c +++ b/src/a2pid.c @@ -714,7 +714,7 @@ void main(int argc, char **argv) } else { - printf("a2pi: Bad Sync ACK [0x%02X]\n", iopkt[0]); + prlog("a2pi: Bad Sync ACK\n"); stop = TRUE; } } @@ -740,7 +740,7 @@ void main(int argc, char **argv) { 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]) { case 0x80: /* sync */ diff --git a/src/dskread.c b/src/dskread.c index 0303f27..83279be 100755 --- a/src/dskread.c +++ b/src/dskread.c @@ -2,28 +2,28 @@ char online[] = { // ORG $300 - 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) - 0xC5, // DB ON_LINE - 0x08, 0x03, // DW PARAMS - 0x60, // RTS - 0xEA, + 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) + 0xC5, // DB ON_LINE + 0x08, 0x03, // DW PARAMS + 0x60, // RTS + 0xEA, // PARAMS @ $308 - 0x02, // PARAM_COUNT - 0x60, // UNIT_NUM = DRIVE 0, SLOT 6 - 0x00, 0x20 // DATA_BUFFER = $2000 + 0x02, // PARAM_COUNT + 0x60, // UNIT_NUM = DRIVE 0, SLOT 6 + 0x00, 0x20 // DATA_BUFFER = $2000 }; char readblk[] = { // ORG $300 - 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) - 0x80, // DB READ_BLOCK - 0x08, 0x03, // DW PARAMS - 0x60, // RTS - 0xEA, + 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) + 0x80, // DB READ_BLOCK + 0x08, 0x03, // DW PARAMS + 0x60, // RTS + 0xEA, // PARAMS @ $308 - 0x03, // PARAM_COUNT - 0x60, // UNIT_NUM = DRIVE 0, SLOT 6 - 0x00, 0x20, // DATA_BUFFER = $2000 - 0x00, 0x00 // BLOCK_NUM + 0x03, // PARAM_COUNT + 0x60, // UNIT_NUM = DRIVE 0, SLOT 6 + 0x00, 0x20, // DATA_BUFFER = $2000 + 0x00, 0x00 // BLOCK_NUM }; #define ORG 0x0300 #define BLOCK_NUM 0x030C @@ -32,37 +32,38 @@ char dsk[280][512]; int main(int argc, char **argv) { - FILE *dskfile; - char count[2], volname[21]; - int i, result, fd; - int pifd = a2open(argc > 1 ? argv[1] : "127.0.0.1"); - if (pifd < 0) - { - perror("Unable to connect to Apple II Pi"); - exit(EXIT_FAILURE); - } - a2write(pifd, ORG, sizeof(online), online); - a2call(pifd, ORG, &result); - a2read(pifd, DATA_BUFFER, 16, volname); - volname[(volname[0] & 0x0F) + 1] = '\0'; - printf("Volume name:%s\n", volname + 1); - strcat(volname + 1, ".PO"); - a2write(pifd, ORG, sizeof(readblk), readblk); - for (i = 0; i < 280; i++) - { - printf("Reading block #%d\r", i); - fflush(stdout); - count[0] = i; - count[1] = i >> 8; - a2write(pifd, BLOCK_NUM, 2, count); - a2call(pifd, ORG, &result); - a2read(pifd, DATA_BUFFER, 512, dsk[i]); - } - a2close(pifd); - if ((dskfile = fopen(volname + 1, "wb"))) - { - fwrite(dsk, 1, 280*512, dskfile); - fclose(dskfile); - } - return EXIT_SUCCESS; + FILE *dskfile; + char count[2], volname[21]; + int i, result, fd; + int pifd = a2open(argc > 1 ? argv[1] : "127.0.0.1"); + if (pifd < 0) + { + perror("Unable to connect to Apple II Pi"); + exit(EXIT_FAILURE); + } + sleep(1); + a2write(pifd, ORG, sizeof(online), online); + a2call(pifd, ORG, &result); + a2read(pifd, DATA_BUFFER, 16, volname); + volname[(volname[0] & 0x0F) + 1] = '\0'; + printf("Volume name:%s\n", volname + 1); + strcat(volname + 1, ".PO"); + a2write(pifd, ORG, sizeof(readblk), readblk); + for (i = 0; i < 280; i++) + { + printf("Reading block #%d\r", i); + fflush(stdout); + count[0] = i; + count[1] = i >> 8; + a2write(pifd, BLOCK_NUM, 2, count); + a2call(pifd, ORG, &result); + a2read(pifd, DATA_BUFFER, 512, dsk[i]); + } + a2close(pifd); + if ((dskfile = fopen(volname + 1, "wb"))) + { + fwrite(dsk, 1, 280*512, dskfile); + fclose(dskfile); + } + return EXIT_SUCCESS; } \ No newline at end of file diff --git a/src/dskwrite.c b/src/dskwrite.c index 74b4aa2..064c0d4 100755 --- a/src/dskwrite.c +++ b/src/dskwrite.c @@ -2,28 +2,28 @@ char online[] = { // ORG $300 - 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) - 0xC5, // DB ON_LINE - 0x08, 0x03, // DW PARAMS - 0x60, // RTS - 0xEA, + 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) + 0xC5, // DB ON_LINE + 0x08, 0x03, // DW PARAMS + 0x60, // RTS + 0xEA, // PARAMS @ $308 - 0x02, // PARAM_COUNT - 0x60, // UNIT_NUM = DRIVE 0, SLOT 6 - 0x00, 0x20 // DATA_BUFFER = $2000 + 0x02, // PARAM_COUNT + 0x60, // UNIT_NUM = DRIVE 0, SLOT 6 + 0x00, 0x20 // DATA_BUFFER = $2000 }; char writeblk[] = { // ORG $300 - 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) - 0x81, // DB WRITE_BLOCK - 0x08, 0x03, // DW PARAMS - 0x60, // RTS - 0xEA, + 0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS) + 0x81, // DB WRITE_BLOCK + 0x08, 0x03, // DW PARAMS + 0x60, // RTS + 0xEA, // PARAMS @ $308 - 0x03, // PARAM_COUNT - 0x60, // UNIT_NUM = DRIVE 0, SLOT 6 - 0x00, 0x20, // DATA_BUFFER = $2000 - 0x00, 0x00 // BLOCK_NUM + 0x03, // PARAM_COUNT + 0x60, // UNIT_NUM = DRIVE 0, SLOT 6 + 0x00, 0x20, // DATA_BUFFER = $2000 + 0x00, 0x00 // BLOCK_NUM }; #define ORG 0x0300 #define BLOCK_NUM 0x030C @@ -32,57 +32,59 @@ char dsk[280][512]; int main(int argc, char **argv) { - FILE *dskfile; - char count[2], volname[21]; - int i, result, fd; - int pifd = a2open(argc > 2 ? argv[2] : "127.0.0.1"); - if (pifd < 0) - { - perror("Unable to connect to Apple II Pi"); - exit(EXIT_FAILURE); - } - if (argc < 2) - { - perror("Usage: dskwrite [ip address]\n"); - exit(EXIT_FAILURE); - } - a2write(pifd, ORG, sizeof(online), online); - a2call(pifd, ORG, &result); - if (result == 0) - { - a2read(pifd, DATA_BUFFER, 16, volname); - volname[(volname[0] & 0x0F) + 1] = '\0'; - printf("Are you sure you want to overwrite volume :%s?", volname + 1); - fflush(stdout); - fgets(count, 2, stdin); - if (count[0] != 'y' && count[0] != 'Y') - { - a2close(pifd); - exit(EXIT_FAILURE); - } - } - if ((dskfile = fopen(argv[1], "rb"))) + FILE *dskfile; + char count[2], volname[21]; + int i, result, fd; + int pifd = a2open(argc > 2 ? argv[2] : "127.0.0.1"); + if (pifd < 0) + { + perror("Unable to connect to Apple II Pi"); + exit(EXIT_FAILURE); + } + if (argc < 2) + { + perror("Usage: dskwrite [ip address]\n"); + exit(EXIT_FAILURE); + } + sleep(1); + fflush(stdin); + a2write(pifd, ORG, sizeof(online), online); + a2call(pifd, ORG, &result); + if (result == 0) + { + a2read(pifd, DATA_BUFFER, 16, volname); + volname[(volname[0] & 0x0F) + 1] = '\0'; + printf("Are you sure you want to overwrite volume :%s?", volname + 1); + fflush(stdout); + fgets(count, 2, stdin); + if (count[0] != 'y' && count[0] != 'Y') { - fread(dsk, 1, 280*512, dskfile); - fclose(dskfile); - } - else - { - perror("Unable to read .PO file\n"); - a2close(pifd); - exit(EXIT_FAILURE); - } - a2write(pifd, ORG, sizeof(writeblk), writeblk); - for (i = 0; i < 280; i++) - { - printf("Writing block #%d\r", i); - fflush(stdout); - count[0] = i; - 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; + a2close(pifd); + exit(EXIT_FAILURE); + } + } + if ((dskfile = fopen(argv[1], "rb"))) + { + fread(dsk, 1, 280*512, dskfile); + fclose(dskfile); + } + else + { + perror("Unable to read .PO file\n"); + a2close(pifd); + exit(EXIT_FAILURE); + } + a2write(pifd, ORG, sizeof(writeblk), writeblk); + for (i = 0; i < 280; i++) + { + printf("Writing block #%d\r", i); + fflush(stdout); + count[0] = i; + 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; } \ No newline at end of file