datajerk / c2t

Retro Code (Apple II, Cosmac VIP) to Tape/Text
BSD 3-Clause "New" or "Revised" License
64 stars 11 forks source link

Can a ProDOS formatted Insta-disk be produced with c2t? #33

Closed devorn closed 5 months ago

devorn commented 5 months ago

I compiled version 0.997 and it is generally working amazingly well. This is a truly impressive concept and program.

However I am having difficulty determining if I can use this utility to package a ProDOS disk image of file type '.po' and how/if I would do that?

When using the 'c2t -8 prodos243.po prodos243.wav' for example, the wave file is produced in 28k segments. The resultant .wav file is loaded on my old iPhone SE (with audio out jack). Applesoft LOAD command loads the file successfully, formats the blank disk in drive 1 and writes the data.

However the Apple II crashes to monitor when I try and boot the disk, presumably because the interleave and sector formats of a ProDOS disk are quite different than a DOS 3.3 that the program is designed to handle. Attempts to read the catalog of the produced disk from a known utility program is also unsuccessful.

Is there any particular or recommended mechanism of managing a .po image with c2t ?

datajerk commented 5 months ago

Have you tried c2t-96h? That has support for prodos order.

Or convert your .po to .dsk with:

#include <stdio.h>

typedef struct s {
    unsigned char bytes[256];
} sector;

typedef struct t {
    sector sectors[16];
} track;

typedef struct d {
    track tracks[35];
} disk;

int main(int argc, char **argv)
{
    disk po;
    FILE *ifp, *ofp;
    int i,j,k,x;
    unsigned int xref[]={0x0,0xE,0xD,0xC,0xB,0xA,0x9,0x8,0x7,0x6,0x5,0x4,0x3,0x2,0x1,0xF};
    sector *tmp;

    if ((ifp = fopen(argv[1], "rb")) == NULL) {
        fprintf(stderr,"Cannot read: %s\n\n",argv[1]);
        return 1;
    }

    if ((ofp = fopen(argv[2], "w")) == NULL) {
        fprintf(stderr,"Cannot write: %s\n\n",argv[2]);
        return 1;
    }

    x = fread(&po, 1, 143360, ifp);
    printf("read %d bytes\n",x);

    for(i=0;i<35;i++)
        for(j=0;j<16;j++)
            fwrite(&(po.tracks[i].sectors[xref[j]]), 256, 1, ofp);

    return 0;
}
devorn commented 5 months ago

Thanks for the hints and the code.

I compiled c2t-96h (v0.997) and it worked like a charm with a .po (proDOS format image).

Loaded up via my old iPhone SE (which is a convenient player of .wav files, since it has a 3.5mm audio outlet socket).

Success! The resultant disk that was created booted without issue.

image

datajerk commented 5 months ago

Good news. Newer iPhones with lighting or usb-c to 3.5mm also work.