mirror of
https://github.com/dschmenk/apple2pi.git
synced 2025-01-09 08:29:41 +00:00
Merge pull request #15 from ivanli88/master
dskread, dskwrite add 40 track support and new nibread command
This commit is contained in:
commit
dc36fcae7a
@ -7,7 +7,7 @@ else
|
|||||||
BINDIR=$(DESTDIR)/usr/bin
|
BINDIR=$(DESTDIR)/usr/bin
|
||||||
SHAREDIR=$(DESTDIR)/usr/share/a2pi
|
SHAREDIR=$(DESTDIR)/usr/share/a2pi
|
||||||
endif
|
endif
|
||||||
BIN=a2joy a2joymou a2joypad a2mon a2term fusea2pi a2pidcmd dskread dskwrite bload brun
|
BIN=a2joy a2joymou a2joypad a2mon a2term fusea2pi a2pidcmd dskread dskwrite bload brun nibread dskformat eddread
|
||||||
SBIN=a2pid
|
SBIN=a2pid
|
||||||
A2PIDEFS=-DSETSERCLK
|
A2PIDEFS=-DSETSERCLK
|
||||||
|
|
||||||
|
73
src/dskformat.c
Normal file
73
src/dskformat.c
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#include "a2lib.c"
|
||||||
|
|
||||||
|
char writeblk[] = {
|
||||||
|
// ORG $280
|
||||||
|
0xA0, 0x00, 0xA2, 0xFE, 0x86, 0x60, 0xA6, 0x43, 0x86, 0x2B, 0xBD, 0x89, 0xC0, 0xAD, 0x8B, 0xC0,
|
||||||
|
0x98, 0x85, 0x61, 0x20, 0x0C, 0xD1, 0xA0, 0x07, 0x20, 0x85, 0xD3, 0x88, 0xD0, 0xFA, 0xA6, 0x43,
|
||||||
|
0xAD, 0x81, 0xC0, 0xAD, 0xB1, 0x02, 0xA6, 0x43, 0xBC, 0x88, 0xC0, 0xA9, 0x20, 0x8D, 0xA3, 0x02,
|
||||||
|
0x60, 0xA0, 0x00, 0x84, 0x63, 0xA2, 0x60, 0xBD, 0x8D, 0xC0, 0xBD, 0x8E, 0xC0, 0x10, 0x00, 0xA9,
|
||||||
|
0xFF, 0x9D, 0x8F, 0xC0, 0xCD, 0xEC, 0xC0, 0x85, 0x64, 0xA2, 0x02, 0xEA, 0xEA, 0xEA, 0x20, 0xB6,
|
||||||
|
0x03, 0xC1, 0x00, 0xA5, 0x64, 0x8D, 0xED, 0xC0, 0xCD, 0xEC, 0xC0, 0x88, 0xD0, 0xED, 0xCA, 0xD0,
|
||||||
|
0xEC, 0xA9, 0xD5, 0x20, 0xA1, 0x03, 0xA9, 0xAA, 0x20, 0xA7, 0x03, 0xA9, 0x96, 0x20, 0xA7, 0x03,
|
||||||
|
0xA5, 0x60, 0x20, 0x91, 0x03, 0xA5, 0x61, 0x20, 0x91, 0x03, 0xA5, 0x63, 0x20, 0x91, 0x03, 0xA5,
|
||||||
|
0x60, 0x45, 0x61, 0x45, 0x63, 0x48, 0x4A, 0x09, 0xAA, 0xEA, 0x8D, 0xED, 0xC0, 0xCD, 0xEC, 0xC0,
|
||||||
|
0x68, 0x09, 0xAA, 0x20, 0xA5, 0x03, 0xA9, 0xDE, 0x20, 0xA7, 0x03, 0xA9, 0xAA, 0x20, 0xA7, 0x03,
|
||||||
|
0xA9, 0xEB, 0x20, 0xA7, 0x03, 0xA0, 0x08, 0xA5, 0x64, 0x20, 0xAA, 0x03, 0xC1, 0x00, 0xEA, 0x88,
|
||||||
|
0xD0, 0xF7, 0xA9, 0xD5, 0x20, 0xAB, 0x03, 0xA9, 0xAA, 0x20, 0xA7, 0x03, 0xA9, 0xAD, 0x20, 0xA7,
|
||||||
|
0x03, 0xA0, 0x57, 0xC5, 0xEA, 0xEA, 0xC5, 0xEA, 0xA9, 0x96, 0x20, 0xB0, 0x03, 0x88, 0xD0, 0xF5,
|
||||||
|
0xC5, 0xEA, 0xC5, 0xEA, 0xA9, 0x96, 0x20, 0xB0, 0x03, 0xC8, 0xD0, 0xF5, 0xA9, 0xDE, 0x20, 0xAB,
|
||||||
|
0x03, 0xA9, 0xAA, 0x20, 0xA7, 0x03, 0xA9, 0xEB, 0xE6, 0x63, 0x20, 0xAC, 0x03, 0xA5, 0x63, 0xC9,
|
||||||
|
0x10, 0xF0, 0x11, 0xA0, 0x0F, 0xC1, 0x00, 0xA5, 0x64, 0x8D, 0xED, 0xC0, 0xCD, 0xEC, 0xC0, 0xA2,
|
||||||
|
0x01, 0x4C, 0xCB, 0x02, 0xEA, 0xEA, 0xC1, 0x00, 0xAD, 0xEE, 0xC0, 0xAD, 0xEC, 0xC0, 0x60, 0x38,
|
||||||
|
0x60, 0xEA, 0x48, 0x4A, 0x09, 0xAA, 0x8D, 0xED, 0xC0, 0xCD, 0xEC, 0xC0, 0x68, 0x09, 0xAA, 0xC9,
|
||||||
|
0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC5, 0xEA,
|
||||||
|
0x8D, 0xED, 0xC0, 0xCD, 0xEC, 0xC0, 0x60
|
||||||
|
};
|
||||||
|
#define ORG 0x280
|
||||||
|
#define TRACK_NUM 0x281
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
FILE *dskfile;
|
||||||
|
char count[2], volname[21];
|
||||||
|
long fsize;
|
||||||
|
int i, result, fd, etrk;
|
||||||
|
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: dskformat <end track> [ip address]\n");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
sleep(1);
|
||||||
|
fflush(stdin);
|
||||||
|
|
||||||
|
if (argv[1])
|
||||||
|
{
|
||||||
|
etrk = atoi(argv[1]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
perror("Please type end track to format\n");
|
||||||
|
a2close(pifd);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
count[0] = 0;
|
||||||
|
a2write(pifd, ORG, sizeof(writeblk), writeblk);
|
||||||
|
a2write(pifd, TRACK_NUM, 1, count);
|
||||||
|
a2call(pifd, ORG, &result);
|
||||||
|
for (i = 0; i < etrk; i++)
|
||||||
|
{
|
||||||
|
printf("Formating Track #%d\r", i);
|
||||||
|
fflush(stdout);
|
||||||
|
count[0] = i;
|
||||||
|
a2write(pifd, TRACK_NUM, 1, count);
|
||||||
|
a2call(pifd, ORG, &result);
|
||||||
|
}
|
||||||
|
a2close(pifd);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
@ -11,6 +11,12 @@ char online[] = {
|
|||||||
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 chgmtrk[] = {
|
||||||
|
// ORG $301
|
||||||
|
0xAD, 0x8B, 0xC0, 0xAD, 0x8B, 0xC0, 0xAD, 0xE3,
|
||||||
|
0xD6, 0xC9, 0x18, 0xD0, 0x05, 0xA9, 0x40, 0x8D,
|
||||||
|
0xE3, 0xD6, 0xAD, 0x81, 0xC0, 0x60
|
||||||
|
};
|
||||||
char readblk[] = {
|
char readblk[] = {
|
||||||
// ORG $301
|
// ORG $301
|
||||||
0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS)
|
0x20, 0x00, 0xBF, // JSR $BF00 (PRODOS)
|
||||||
@ -26,27 +32,48 @@ char readblk[] = {
|
|||||||
#define ORG 0x0301
|
#define ORG 0x0301
|
||||||
#define BLOCK_NUM 0x030C
|
#define BLOCK_NUM 0x030C
|
||||||
#define DATA_BUFFER 0x2000
|
#define DATA_BUFFER 0x2000
|
||||||
char dsk[280][512];
|
char dsk[320][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;
|
char noname[] = "_NONAME";
|
||||||
int pifd = a2open(argc > 1 ? argv[1] : "127.0.0.1");
|
int i, result, fd, trk, pifd;
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
i = strtol(argv[1],NULL,10);
|
||||||
|
pifd = a2open(i > 41 ? argv[1] : "127.0.0.1");
|
||||||
|
trk = (i < 41 ? i : 35);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pifd = a2open("127.0.0.1");
|
||||||
|
trk = 35;
|
||||||
|
}
|
||||||
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(chgmtrk), chgmtrk);
|
||||||
|
a2call(pifd, ORG, &result);
|
||||||
|
|
||||||
a2write(pifd, ORG, sizeof(online), online);
|
a2write(pifd, ORG, sizeof(online), online);
|
||||||
a2call(pifd, ORG, &result);
|
a2call(pifd, ORG, &result);
|
||||||
a2read(pifd, DATA_BUFFER, 16, volname);
|
a2read(pifd, DATA_BUFFER, 16, volname);
|
||||||
volname[(volname[0] & 0x0F) + 1] = '\0';
|
volname[(volname[0] & 0x0F) + 1] = '\0';
|
||||||
|
printf("%x\n",volname[0]);
|
||||||
|
printf("%x\n",volname);
|
||||||
|
if ( !isprint(volname[1]) )
|
||||||
|
{
|
||||||
|
strcpy(volname, noname);
|
||||||
|
printf("NO VOL NAME OR HEX VOL\n");
|
||||||
|
}
|
||||||
printf("Volume name:%s\n", volname +1);
|
printf("Volume name:%s\n", volname +1);
|
||||||
strcat(volname + 1, ".PO");
|
strcat(volname + 1, ".PO");
|
||||||
a2write(pifd, ORG, sizeof(readblk), readblk);
|
a2write(pifd, ORG, sizeof(readblk), readblk);
|
||||||
for (i = 0; i < 280; i++)
|
for (i = 0; i < trk*8; i++)
|
||||||
{
|
{
|
||||||
printf("Reading block #%d\r", i);
|
printf("Reading block #%d\r", i);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -59,7 +86,7 @@ int main(int argc, char **argv)
|
|||||||
a2close(pifd);
|
a2close(pifd);
|
||||||
if ((dskfile = fopen(volname + 1, "wb")))
|
if ((dskfile = fopen(volname + 1, "wb")))
|
||||||
{
|
{
|
||||||
fwrite(dsk, 1, 280*512, dskfile);
|
fwrite(dsk, 1, trk*8*512, dskfile);
|
||||||
fclose(dskfile);
|
fclose(dskfile);
|
||||||
}
|
}
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
@ -23,16 +23,24 @@ char writeblk[] = {
|
|||||||
0x00, 0x20, // DATA_BUFFER = $2000
|
0x00, 0x20, // DATA_BUFFER = $2000
|
||||||
0x00, 0x00 // BLOCK_NUM
|
0x00, 0x00 // BLOCK_NUM
|
||||||
};
|
};
|
||||||
|
char chgmtrk[] = {
|
||||||
|
// ORG $301
|
||||||
|
0xAD, 0x8B, 0xC0, 0xAD, 0x8B, 0xC0, 0xAD, 0xE3,
|
||||||
|
0xD6, 0xC9, 0x18, 0xD0, 0x05, 0xA9, 0x40, 0x8D,
|
||||||
|
0xE3, 0xD6, 0xAD, 0x81, 0xC0, 0x60
|
||||||
|
};
|
||||||
#define ORG 0x0301
|
#define ORG 0x0301
|
||||||
#define BLOCK_NUM 0x030C
|
#define BLOCK_NUM 0x030C
|
||||||
#define DATA_BUFFER 0x2000
|
#define DATA_BUFFER 0x2000
|
||||||
char dsk[280][512];
|
|
||||||
|
char dsk[320][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;
|
long fsize;
|
||||||
|
int i, result, fd, dblock;
|
||||||
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)
|
||||||
{
|
{
|
||||||
@ -46,8 +54,10 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
fflush(stdin);
|
fflush(stdin);
|
||||||
|
|
||||||
a2write(pifd, ORG, sizeof(online), online);
|
a2write(pifd, ORG, sizeof(online), online);
|
||||||
a2call(pifd, ORG, &result);
|
a2call(pifd, ORG, &result);
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
a2read(pifd, DATA_BUFFER, 16, volname);
|
a2read(pifd, DATA_BUFFER, 16, volname);
|
||||||
@ -61,9 +71,18 @@ int main(int argc, char **argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
a2write(pifd, ORG, sizeof(chgmtrk), chgmtrk);
|
||||||
|
a2call(pifd, ORG, &result);
|
||||||
|
|
||||||
if ((dskfile = fopen(argv[1], "rb")))
|
if ((dskfile = fopen(argv[1], "rb")))
|
||||||
{
|
{
|
||||||
fread(dsk, 1, 280*512, dskfile);
|
|
||||||
|
fseek(dskfile, 0, SEEK_END);
|
||||||
|
fsize = ftell(dskfile);
|
||||||
|
fseek(dskfile, 0 , SEEK_SET);
|
||||||
|
|
||||||
|
dblock = fsize / 512;
|
||||||
|
fread(dsk, 1, fsize , dskfile);
|
||||||
fclose(dskfile);
|
fclose(dskfile);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -73,7 +92,8 @@ int main(int argc, char **argv)
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
a2write(pifd, ORG, sizeof(writeblk), writeblk);
|
a2write(pifd, ORG, sizeof(writeblk), writeblk);
|
||||||
for (i = 0; i < 280; i++)
|
|
||||||
|
for (i = 0; i < dblock; i++)
|
||||||
{
|
{
|
||||||
printf("Writing block #%d\r", i);
|
printf("Writing block #%d\r", i);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -83,6 +103,7 @@ int main(int argc, char **argv)
|
|||||||
a2write(pifd, BLOCK_NUM, 2, count);
|
a2write(pifd, BLOCK_NUM, 2, count);
|
||||||
a2call(pifd, ORG, &result);
|
a2call(pifd, ORG, &result);
|
||||||
}
|
}
|
||||||
|
|
||||||
a2close(pifd);
|
a2close(pifd);
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
99
src/eddread.c
Normal file
99
src/eddread.c
Normal 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, 0x12,
|
||||||
|
0x29, 0x07, 0x05, 0x43, 0xA8, 0x18, 0x69, 0x02, 0x29, 0xF7, 0xAA, 0xB9, 0x80, 0xC0, 0xBD, 0x80,
|
||||||
|
0xC0, 0x20, 0xD0, 0x0C, 0x20, 0xE5, 0x0C, 0xA6, 0x43, 0xBD, 0x80, 0xC0, 0xBD, 0x82, 0xC0, 0xBD,
|
||||||
|
0x84, 0xC0, 0xBD, 0x86, 0xC0, 0x60, 0x85, 0x12, 0xA5, 0x12, 0x29, 0x06, 0x05, 0x43, 0xAA, 0xE8,
|
||||||
|
0xAC, 0x15, 0x0D, 0x8D, 0x15, 0x0D, 0xB9, 0x80, 0xC0, 0xBD, 0x80, 0xC0, 0x20, 0xD0, 0x0C, 0x60,
|
||||||
|
0xAD, 0x0F, 0x0D, 0xF0, 0x09, 0xAE, 0x11, 0x0D, 0xAC, 0x10, 0x0D, 0x4C, 0xEC, 0x0C, 0xA2, 0x00,
|
||||||
|
0xA0, 0xDC, 0x4C, 0xEC, 0x0C, 0xA2, 0x04, 0xA0, 0x00, 0x4C, 0xEC, 0x0C, 0xA9, 0x02, 0x8D, 0x12,
|
||||||
|
0x0D, 0xAD, 0x00, 0x03, 0xCE, 0x12, 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, 0x01, 0x00, 0x00, 0x00, 0x00
|
||||||
|
};
|
||||||
|
/* char eddctr[] = {
|
||||||
|
// ORG $C00
|
||||||
|
0xA9, 0x00, 0x20, 0xF9, 0x0C, 0xA6, 0x43, 0xBC, 0x89, 0xC0, 0x48, 0x20, 0xCA, 0x0C, 0x68, 0x20,
|
||||||
|
0x34, 0x0C, 0xA0, 0x00, 0x84, 0x00, 0xA9, 0x40, 0x85, 0x01, 0xA6, 0x43, 0xBD, 0x8C, 0xC0, 0x10,
|
||||||
|
0xFB, 0x91, 0x00, 0xC8, 0xD0, 0xF6, 0xE6, 0x01, 0xA5, 0x01, 0xC9, 0x80, 0xD0, 0xEE, 0xA6, 0x43,
|
||||||
|
0xBC, 0x88, 0xC0, 0x60, 0xA0, 0x00, 0xF0, 0x02, 0xA0, 0x01, 0x8C, 0x04, 0x0D, 0xA4, 0x12, 0xC0,
|
||||||
|
0xFF, 0xD0, 0x07, 0x48, 0xA9, 0x00, 0x20, 0x4A, 0x0C, 0x68, 0x8D, 0x08, 0x0D, 0xC5, 0x12, 0xF0,
|
||||||
|
0x59, 0x29, 0xFE, 0x8D, 0x09, 0x0D, 0xA0, 0x01, 0x8C, 0x0A, 0x0D, 0xA5, 0x12, 0x29, 0xFE, 0x20,
|
||||||
|
0xAB, 0x0C, 0xA5, 0x12, 0xCD, 0x09, 0x0D, 0xF0, 0x13, 0xB0, 0x07, 0xE6, 0x12, 0xE6, 0x12, 0x4C,
|
||||||
|
0x76, 0x0C, 0xC6, 0x12, 0xC6, 0x12, 0x20, 0xAD, 0x0C, 0x4C, 0x62, 0x0C, 0xAD, 0x08, 0x0D, 0xC5,
|
||||||
|
0x12, 0xF0, 0x16, 0x85, 0x12, 0x29, 0x07, 0x05, 0x43, 0xA8, 0x18, 0x69, 0x02, 0x29, 0xF7, 0xAA,
|
||||||
|
0xB9, 0x80, 0xC0, 0xBD, 0x80, 0xC0, 0x20, 0xC5, 0x0C, 0x20, 0xDA, 0x0C, 0xA6, 0x43, 0xBD, 0x80,
|
||||||
|
0xC0, 0xBD, 0x82, 0xC0, 0xBD, 0x84, 0xC0, 0xBD, 0x86, 0xC0, 0x60, 0x85, 0x12, 0xA5, 0x12, 0x29,
|
||||||
|
0x06, 0x05, 0x43, 0xAA, 0xE8, 0xAC, 0x0A, 0x0D, 0x8D, 0x0A, 0x0D, 0xB9, 0x80, 0xC0, 0xBD, 0x80,
|
||||||
|
0xC0, 0x20, 0xC5, 0x0C, 0x60, 0xAD, 0x04, 0x0D, 0xF0, 0x09, 0xAE, 0x06, 0x0D, 0xAC, 0x05, 0x0D,
|
||||||
|
0x4C, 0xE1, 0x0C, 0xA2, 0x00, 0xA0, 0xDC, 0x4C, 0xE1, 0x0C, 0xA2, 0x04, 0xA0, 0x00, 0x4C, 0xE1,
|
||||||
|
0x0C, 0xA9, 0x02, 0x8D, 0x07, 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;
|
||||||
|
}
|
68
src/nibread.c
Normal file
68
src/nibread.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
#include "a2lib.c"
|
||||||
|
#include "stdlib.h"
|
||||||
|
|
||||||
|
char readblk[] = {
|
||||||
|
// ORG $2C0
|
||||||
|
0xA0, 0x00, 0xA6, 0x43, 0x86, 0x2B, 0xBD, 0x89, 0xC0, 0xAD, 0x8B, 0xC0, 0x98, 0x20, 0x0C, 0xD1,
|
||||||
|
0xA0, 0x07, 0x20, 0x85, 0xD3, 0x88, 0xD0, 0xFA, 0xA6, 0x43, 0xAD, 0x81, 0xC0, 0x20, 0xE6, 0x02,
|
||||||
|
0xA6, 0x43, 0xBC, 0x88, 0xC0, 0x60, 0xA9, 0x24, 0x85, 0x45, 0xA9, 0x00, 0x85, 0x44, 0x85, 0x3A,
|
||||||
|
0xA0, 0x00, 0xC6, 0x44, 0xD0, 0x04, 0xC6, 0x45, 0x30, 0x1F, 0xBD, 0x8C, 0xC0, 0x10, 0xFB, 0xDD,
|
||||||
|
0x8C, 0xC0, 0xF0, 0x02, 0xD0, 0xEA, 0xC8, 0xC0, 0x18, 0xD0, 0xEF, 0x85, 0x3A, 0xBD, 0x8C, 0xC0,
|
||||||
|
0x10, 0xFB, 0xC5, 0x3A, 0xF0, 0xF7, 0x85, 0x3B, 0xC8, 0xA9, 0x20, 0x85, 0x45, 0xA9, 0x00, 0x85,
|
||||||
|
0x44, 0xBD, 0x8C, 0xC0, 0x10, 0xFB, 0x91, 0x44, 0xC8, 0xD0, 0xF6, 0xE6, 0x45, 0xA5, 0x45, 0xC9,
|
||||||
|
0x3B, 0xD0, 0xEE, 0xA5, 0x3A, 0xF0, 0x5A, 0xA4, 0x3B, 0x8C, 0x18, 0x20, 0xA0, 0x17, 0x99, 0x00,
|
||||||
|
0x20, 0x88, 0x10, 0xFA, 0xC8, 0xC8, 0xF0, 0x49, 0xB9, 0x18, 0x20, 0xC5, 0x3A, 0xF0, 0xF6, 0x98,
|
||||||
|
0x18, 0x69, 0x18, 0x8D, 0x63, 0x03, 0xA9, 0x35, 0x85, 0x45, 0xA9, 0x00, 0x85, 0x44, 0xA8, 0xAA,
|
||||||
|
0xB1, 0x44, 0xDD, 0x18, 0x20, 0xD0, 0x07, 0xE0, 0x0B, 0xF0, 0x12, 0xE8, 0xD0, 0x02, 0xA2, 0x00,
|
||||||
|
0xC8, 0xD0, 0xED, 0xE6, 0x45, 0xA5, 0x45, 0xC9, 0x3B, 0xD0, 0xE5, 0xF0, 0x14, 0x98, 0x38, 0xE9,
|
||||||
|
0x0B, 0xA8, 0xA5, 0x3A, 0x91, 0x44, 0xC8, 0xD0, 0xFB, 0xE6, 0x45, 0xA5, 0x45, 0xC9, 0x3B, 0x90,
|
||||||
|
0xF1, 0x60
|
||||||
|
};
|
||||||
|
#define ORG 0x02C0
|
||||||
|
#define TRACK_NUM 0x02C1
|
||||||
|
#define DATA_BUFFER 0x2000
|
||||||
|
char dsk[42][6656];
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
FILE *dskfile;
|
||||||
|
char count[2];
|
||||||
|
int i, result, fd, trk, pifd;
|
||||||
|
if (argc > 1)
|
||||||
|
{
|
||||||
|
i = strtol(argv[1],NULL,10);
|
||||||
|
pifd = a2open(i > 43 ? argv[1] : "127.0.0.1");
|
||||||
|
trk = (i < 43 ? i : 35);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pifd = a2open("127.0.0.1");
|
||||||
|
trk = 35;
|
||||||
|
}
|
||||||
|
if (pifd < 0)
|
||||||
|
{
|
||||||
|
perror("Unable to connect to Apple II Pi");
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
char volname[] = "nibble.nib";
|
||||||
|
a2write(pifd, ORG, sizeof(readblk), readblk);
|
||||||
|
count[0] = 0;
|
||||||
|
a2write(pifd, TRACK_NUM, 1, count);
|
||||||
|
a2call(pifd, ORG, &result);
|
||||||
|
for (i = 0; i < trk; i++)
|
||||||
|
{
|
||||||
|
printf("Reading Track #%d\r", i);
|
||||||
|
fflush(stdout);
|
||||||
|
count[0] = i;
|
||||||
|
a2write(pifd, TRACK_NUM, 1, count);
|
||||||
|
a2call(pifd, ORG, &result);
|
||||||
|
a2read(pifd, DATA_BUFFER, 6656, dsk[i]);
|
||||||
|
}
|
||||||
|
a2close(pifd);
|
||||||
|
if ((dskfile = fopen(volname, "wb")))
|
||||||
|
{
|
||||||
|
fwrite(dsk, 1, trk*6656, dskfile);
|
||||||
|
fclose(dskfile);
|
||||||
|
}
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user