Ejemplo n.º 1
0
static void rtype_a_read_raw(
    struct disk *d, unsigned int tracknr, struct tbuf *tbuf)
{
    struct track_info *ti = &d->di->track[tracknr];
    uint32_t csum;

    tbuf_bits(tbuf, SPEED_AVG, bc_raw, 16, 0x9521);
    tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0);

    csum = amigados_checksum(ti->dat, ti->len);
    tbuf_bits(tbuf, SPEED_AVG, bc_mfm_odd, 32, csum);

    tbuf_bytes(tbuf, SPEED_AVG, bc_mfm_even_odd, ti->len, ti->dat);
}
Ejemplo n.º 2
0
static void *rtype_b_write_raw(
    struct disk *d, unsigned int tracknr, struct stream *s)
{
    struct track_info *ti = &d->di->track[tracknr];

    while (stream_next_bit(s) != -1) {

        unsigned int i;
        uint32_t raw_dat[2*ti->len/4];
        uint32_t csum = 0;
        char *block;

        if ((uint16_t)s->word != 0x9521)
            continue;

        ti->data_bitoff = s->index_offset - 15;

        if (stream_next_bits(s, 16) == -1)
            goto fail;
        if (mfm_decode_bits(bc_mfm, (uint16_t)s->word) != 0)
            continue;

        if (stream_next_bytes(s, raw_dat, 2*ti->len) == -1)
            goto fail;
        for (i = 0; i < ti->len/4; i++)
            mfm_decode_bytes(bc_mfm_even_odd, 4, &raw_dat[2*i], &raw_dat[i]);
        csum = amigados_checksum(raw_dat, ti->len);
        csum &= 0x55555555u;
        csum |= 0xaaaaaaaau;

        if (stream_next_bytes(s, &raw_dat[ti->len/4], 8) == -1)
            goto fail;
        mfm_decode_bytes(bc_mfm_even_odd, 4,
                         &raw_dat[ti->len/4], &raw_dat[ti->len/4]);
        if (csum != be32toh(raw_dat[ti->len/4]))
            continue;

        block = memalloc(ti->len);
        memcpy(block, raw_dat, ti->len);
        set_all_sectors_valid(ti);
        ti->total_bits = 105500;
        return block;
    }

fail:
    return NULL;
}
Ejemplo n.º 3
0
static void dugger_read_raw(
    struct disk *d, unsigned int tracknr, struct tbuf *tbuf)
{
    struct track_info *ti = &d->di->track[tracknr];
    uint32_t dat[7012/4];
    unsigned int i;

    tbuf_bits(tbuf, SPEED_AVG, bc_raw, 32, 0x44894489);

    dat[0] = htobe32(ti->len);
    dat[1] = htobe32(0x03e90100 | tracknr);
    memcpy(&dat[2], ti->dat, ti->len);
    for (i = 0; i < ti->len/4+2; i++)
        tbuf_bits(tbuf, SPEED_AVG, bc_mfm_odd_even, 32, be32toh(dat[i]));

    tbuf_bits(tbuf, SPEED_AVG, bc_mfm_odd_even, 32,
              amigados_checksum(dat, i*4));
}
Ejemplo n.º 4
0
static void rtype_b_read_raw(
    struct disk *d, unsigned int tracknr, struct tbuf *tbuf)
{
    struct track_info *ti = &d->di->track[tracknr];
    uint32_t csum, *dat = (uint32_t *)ti->dat;
    unsigned int i;

    tbuf_bits(tbuf, SPEED_AVG, bc_raw, 16, 0x9521);
    tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0);

    for (i = 0; i < ti->len/4; i++) 
        tbuf_bytes(tbuf, SPEED_AVG, bc_mfm_even_odd, 4, &dat[i]);

    csum = amigados_checksum(dat, ti->len);
    csum &= 0x55555555u;
    csum |= 0xaaaaaaaau;
    
    tbuf_bits(tbuf, SPEED_AVG, bc_mfm_even_odd, 32, csum);
}
Ejemplo n.º 5
0
static void *dugger_write_raw(
    struct disk *d, unsigned int tracknr, struct stream *s)
{
    struct track_info *ti = &d->di->track[tracknr];

    while (stream_next_bit(s) != -1) {

        uint32_t raw[2], dat[7012/4];
        unsigned int i;
        char *block;

        if (s->word != 0x44894489)
            continue;
        ti->data_bitoff = s->index_offset_bc - 31;

        if (stream_next_bytes(s, raw, 8) == -1)
            goto fail;
        mfm_decode_bytes(bc_mfm_odd_even, 4, raw, &dat[0]);
        if ((ti->len = be32toh(dat[0])) > 7000)
            continue;

        for (i = 1; i < ti->len/4+3; i++) {
            if (stream_next_bytes(s, raw, 8) == -1)
                goto fail;
            mfm_decode_bytes(bc_mfm_odd_even, 4, raw, &dat[i]);
        }

        if ((be32toh(dat[1]) != (0x03e90100 | tracknr)) ||
            (amigados_checksum(dat, i*4) != 0))
            continue;

        ti->bytes_per_sector = ti->len;
        block = memalloc(ti->len);
        memcpy(block, &dat[2], ti->len);
        set_all_sectors_valid(ti);
        ti->total_bits = 105500;
        return block;
    }

fail:
    return NULL;
}
Ejemplo n.º 6
0
static void *rtype_a_write_raw(
    struct disk *d, unsigned int tracknr, struct stream *s)
{
    struct track_info *ti = &d->di->track[tracknr];

    while (stream_next_bit(s) != -1) {

        uint8_t raw_dat[2*ti->len];
        uint32_t csum;
        char *block;

        if ((uint16_t)s->word != 0x9521)
            continue;

        ti->data_bitoff = s->index_offset - 15;

        if (stream_next_bits(s, 16) == -1)
            goto fail;
        if (mfm_decode_bits(bc_mfm, (uint16_t)s->word) != 0)
            continue;

        if (stream_next_bits(s, 32) == -1)
            goto fail;
        csum = mfm_decode_bits(bc_mfm_odd, s->word);

        if (stream_next_bytes(s, raw_dat, 2*ti->len) == -1)
            goto fail;
        mfm_decode_bytes(bc_mfm_even_odd, ti->len, raw_dat, raw_dat);

        if (amigados_checksum(raw_dat, ti->len) != csum)
            continue;

        block = memalloc(ti->len);
        memcpy(block, raw_dat, ti->len);
        set_all_sectors_valid(ti);
        return block;
    }

fail:
    return NULL;
}
Ejemplo n.º 7
0
static void psygnosis_a_read_raw(
    struct disk *d, unsigned int tracknr, struct tbuf *tbuf)
{
    struct track_info *ti = &d->di->track[tracknr];
    uint32_t *dat = (uint32_t *)ti->dat;
    unsigned int dat_len = ti->len - 4;
    uint16_t sync;

    sync = be16toh(*(uint16_t *)&ti->dat[dat_len]);
    tbuf_bits(tbuf, SPEED_AVG, bc_raw, 16, sync);
    sync = be16toh(*(uint16_t *)&ti->dat[dat_len+2]);
    if (sync)
        tbuf_bits(tbuf, SPEED_AVG, bc_raw, 16, sync);

    tbuf_bits(tbuf, SPEED_AVG, bc_mfm_even_odd, 32, (~0u << 8) | tracknr);

    tbuf_bits(tbuf, SPEED_AVG, bc_mfm_even_odd, 32,
              amigados_checksum(dat, dat_len));

    tbuf_bytes(tbuf, SPEED_AVG, bc_mfm_even_odd, dat_len, dat);
}
Ejemplo n.º 8
0
static void *psygnosis_a_write_raw(
    struct disk *d, unsigned int tracknr, struct stream *s)
{
    struct track_info *ti = &d->di->track[tracknr];
    char *block;

    while (stream_next_bit(s) != -1) {

        uint32_t raw_dat[2*ti->len/4], hdr, csum;
        uint16_t sync = s->word;
        bool_t two_sync;

        if ((sync != 0x4489) && (sync != 0x4429))
            continue;

        ti->data_bitoff = s->index_offset - 15;

        /* Check for second sync mark */
        if (stream_next_bits(s, 16) == -1)
            goto fail;
        two_sync = ((uint16_t)s->word == sync);

        /* Read the track number and checksum. If there's no second sync mark, 
         * the first 16 bits of the header info is already streamed. */
        if (stream_next_bits(s, two_sync ? 32 : 16) == -1)
            goto fail;
        raw_dat[0] = htobe32(s->word);
        if (stream_next_bytes(s, &raw_dat[1], 12) == -1)
            goto fail;

        mfm_decode_bytes(bc_mfm_even_odd, 4, &raw_dat[0], &hdr);
        mfm_decode_bytes(bc_mfm_even_odd, 4, &raw_dat[2], &csum);
        hdr = be32toh(hdr);
        csum = be32toh(csum);

        if (hdr != (0xffffff00u | tracknr))
            continue;

        if (stream_next_bytes(s, raw_dat, sizeof(raw_dat)) == -1)
            goto fail;
        mfm_decode_bytes(bc_mfm_even_odd, ti->len, raw_dat, raw_dat);
        if (amigados_checksum(raw_dat, ti->len) != csum)
            continue;

        /* Some titles (Armourgeddon, Obitus...) mastered with long tracks. */
        stream_next_index(s);
        if (s->track_bitlen > 103000)
            ti->total_bits = 105500;

        block = memalloc(ti->len + 4);
        *(uint16_t *)&block[ti->len] = htobe16(sync);
        *(uint16_t *)&block[ti->len+2] = two_sync ? htobe16(sync) : 0;
        memcpy(block, raw_dat, ti->len);
        set_all_sectors_valid(ti);
        ti->len += 4; /* for the sync marks */
        return block;
    }

fail:
    return NULL;
}