Example #1
0
static int
readblock(CBM_FILE fd, unsigned char *p, unsigned int length)
{
    unsigned char c1;
    unsigned char c2;
                                                                        SETSTATEDEBUG(DebugByteCount = 0);
    for (; length < 0x100; length++)
    {
                                                                        SETSTATEDEBUG(DebugByteCount += 2);
        if (pp_read(fd, &c1, &c2))
        {
                                                                        SETSTATEDEBUG(DebugByteCount = -1);
            return 1;
        }

        *p++ = c1; length++;

        if (length < 0x100)
            *p++ = c2;
    }
                                                                        SETSTATEDEBUG(DebugByteCount = -1);
    // perform end-handshake
    pp_read(fd, &c1, &c2);
                                                                        SETSTATEDEBUG((void)0);
    return 0;
}
Example #2
0
static int read_block(unsigned char tr, unsigned char se, unsigned char *block)
{
    int  i;
    unsigned char status;

    pp_write(fd_cbm, tr, se);
#ifndef USE_CBM_IEC_WAIT
    arch_usleep(20000);
#endif
    pp_read(fd_cbm, &status, &status);

    for(i=0; i<BLOCKSIZE; i+=2) pp_read(fd_cbm, &block[i], &block[i+1]);

    return status;
}
Example #3
0
static int
read2byte(CBM_FILE fd, unsigned char *c1, unsigned char *c2)
{
    int ret;
                                                                        SETSTATEDEBUG(DebugByteCount = -12801);
    ret = pp_read(fd, c1, c2);
                                                                        SETSTATEDEBUG(DebugByteCount = -1);
    return ret;
}
Example #4
0
static int read_gcr_block(unsigned char *se, unsigned char *gcrbuf)
{
    int i;
    unsigned char s;

    pp_read(fd_cbm, &s, &s);
    *se = s;
    pp_read(fd_cbm, &s, &s);

    if(s) {
        return s;
    }

    for(i = 0; i < GCRBUFSIZE; i += 2) {
        pp_read(fd_cbm, &gcrbuf[i], &gcrbuf[i+1]);
    }

    return 0;
}
Example #5
0
static int
read1byte(CBM_FILE fd, unsigned char *c1)
{
    unsigned char dummy;
    int ret;
                                                                        SETSTATEDEBUG(DebugByteCount = -6401);
    ret = pp_read(fd, c1, &dummy);
                                                                        SETSTATEDEBUG(DebugByteCount = -1);
    return ret;
}
Example #6
0
/* read_n redirects USB reads to the external reader if required */
static void read_n(unsigned char *data, int size) 
{
    int i;

    if (opencbm_plugin_pp_dc_read_n)
    {
        opencbm_plugin_pp_dc_read_n(fd_cbm, data, size);
        return;
    }

    for(i=0;i<size/2;i++,data+=2)
	pp_read(fd_cbm, data, data+1);
}
Example #7
0
static int write_block(unsigned char tr, unsigned char se, const unsigned char *blk, int size, int read_status)
{
    int i = 0;
    unsigned char status;

    pp_write(fd_cbm, tr, se);

    if(size % 2) {
        pp_write(fd_cbm, *blk, *blk);
        i = 1;
    }

    for(; i<size; i+=2) pp_write(fd_cbm, blk[i], blk[i+1]);

#ifndef USE_CBM_IEC_WAIT
    if(size == BLOCKSIZE) {
        arch_usleep(20000);
    }
#endif

    pp_read(fd_cbm, &status, &status);

    return status;
}