static void kbic_read_block( PIA *pi, char * buf, int count ) { int k, a, b; switch (pi->mode) { case 0: w0(0x98); w2(4); w2(6); w2(4); for (k=0;k<count/2;k++) { w2(1); w0(8); a = r1(); w0(0x28); b = r1(); buf[2*k] = j44(a,b); w2(5); b = r1(); w0(8); a = r1(); buf[2*k+1] = j44(a,b); w2(4); } break; case 1: w0(0xb8); w2(4); w2(6); w2(4); for (k=0;k<count/4;k++) { w0(0xb8); w2(4); w2(5); w0(8); buf[4*k] = j53(r12w()); w0(0xb8); buf[4*k+1] = j53(r12w()); w2(4); w2(5); buf[4*k+3] = j53(r12w()); w0(8); buf[4*k+2] = j53(r12w()); } w2(4); break; case 2: w0(0x88); w2(4); w2(6); w2(4); for (k=0;k<count/2;k++) { w2(0xa0); w2(0xa1); buf[2*k] = r0(); w2(0xa5); buf[2*k+1] = r0(); } w2(4); break; case 3: w0(0xa0); w2(4); w2(6); w2(4); w3(0); for (k=0;k<count;k++) buf[k] = r4(); w2(4); w2(0); w2(4); break; case 4: w0(0xa0); w2(4); w2(6); w2(4); w3(0); for (k=0;k<count/2;k++) ((u16 *)buf)[k] = r4w(); w2(4); w2(0); w2(4); break; case 5: w0(0xa0); w2(4); w2(6); w2(4); w3(0); for (k=0;k<count/4;k++) ((u32 *)buf)[k] = r4l(); w2(4); w2(0); w2(4); break; } }
static int epat_read_regr( PIA *pi, int cont, int regr ) { int a, b, r; r = regr + cont_map[cont]; switch (pi->mode) { case 0: w0(r); w2(1); w2(3); a = r1(); w2(4); b = r1(); return j44(a,b); case 1: w0(0x40+r); w2(1); w2(4); a = r1(); b = r2(); w0(0xff); return j53(a,b); case 2: w0(0x20+r); w2(1); w2(0x25); a = r0(); w2(4); return a; case 3: case 4: case 5: w3(r); w2(0x24); a = r4(); w2(4); return a; } return -1; /* never gets here */ }
static int kbic_read_regr( PIA *pi, int cont, int regr ) { int a, b, s; s = cont_map[cont]; switch (pi->mode) { case 0: w0(regr|0x18|s); w2(4); w2(6); w2(4); w2(1); w0(8); a = r1(); w0(0x28); b = r1(); w2(4); return j44(a,b); case 1: w0(regr|0x38|s); w2(4); w2(6); w2(4); w2(5); w0(8); a = r12w(); w2(4); return j53(a); case 2: w0(regr|0x08|s); w2(4); w2(6); w2(4); w2(0xa5); w2(0xa1); a = r0(); w2(4); return a; case 3: case 4: case 5: w0(0x20|s); w2(4); w2(6); w2(4); w3(regr); a = r4(); b = r4(); w2(4); w2(0); w2(4); return a; } return -1; }
static int epia_read_regr( PIA *pi, int cont, int regr ) { int a, b, r; regr += cont_map[cont]; switch (pi->mode) { case 0: r = regr^0x39; w0(r); w2(1); w2(3); w0(r); a = r1(); w2(1); b = r1(); w2(4); return j44(a,b); case 1: r = regr^0x31; w0(r); w2(1); w0(r&0x37); w2(3); w2(5); w0(r|0xf0); a = r1(); b = r2(); w2(4); return j53(a,b); case 2: r = regr^0x29; w0(r); w2(1); w2(0X21); w2(0x23); a = r0(); w2(4); return a; case 3: case 4: case 5: w3(regr); w2(0x24); a = r4(); w2(4); return a; } return -1; }
static void epia_read_block( PIA *pi, char * buf, int count ) { int k, ph, a, b; switch (pi->mode) { case 0: w0(0x81); w2(1); w2(3); w0(0xc1); ph = 1; for (k=0;k<count;k++) { w2(2+ph); a = r1(); w2(4+ph); b = r1(); buf[k] = j44(a,b); ph = 1 - ph; } w0(0); w2(4); break; case 1: w0(0x91); w2(1); w0(0x10); w2(3); w0(0x51); w2(5); w0(0xd1); ph = 1; for (k=0;k<count;k++) { w2(4+ph); a = r1(); b = r2(); buf[k] = j53(a,b); ph = 1 - ph; } w0(0); w2(4); break; case 2: w0(0x89); w2(1); w2(0x23); w2(0x21); ph = 1; for (k=0;k<count;k++) { w2(0x24+ph); buf[k] = r0(); ph = 1 - ph; } w2(6); w2(4); break; case 3: if (count > 512) WR(0x84,3); w3(0); w2(0x24); for (k=0;k<count;k++) buf[k] = r4(); w2(4); WR(0x84,0); break; case 4: if (count > 512) WR(0x84,3); w3(0); w2(0x24); for (k=0;k<count/2;k++) ((u16 *)buf)[k] = r4w(); w2(4); WR(0x84,0); break; case 5: if (count > 512) WR(0x84,3); w3(0); w2(0x24); for (k=0;k<count/4;k++) ((u32 *)buf)[k] = r4l(); w2(4); WR(0x84,0); break; } }
static void epat_read_block( PIA *pi, char * buf, int count ) { int k, ph, a, b; switch (pi->mode) { case 0: w0(7); w2(1); w2(3); w0(0xff); ph = 0; for(k=0;k<count;k++) { if (k == count-1) w0(0xfd); w2(6+ph); a = r1(); if (a & 8) b = a; else { w2(4+ph); b = r1(); } buf[k] = j44(a,b); ph = 1 - ph; } w0(0); w2(4); break; case 1: w0(0x47); w2(1); w2(5); w0(0xff); ph = 0; for(k=0;k<count;k++) { if (k == count-1) w0(0xfd); w2(4+ph); a = r1(); b = r2(); buf[k] = j53(a,b); ph = 1 - ph; } w0(0); w2(4); break; case 2: w0(0x27); w2(1); w2(0x25); w0(0); ph = 0; for(k=0;k<count-1;k++) { w2(0x24+ph); buf[k] = r0(); ph = 1 - ph; } w2(0x26); w2(0x27); buf[count-1] = r0(); w2(0x25); w2(4); break; case 3: w3(0x80); w2(0x24); for(k=0;k<count-1;k++) buf[k] = r4(); w2(4); w3(0xa0); w2(0x24); buf[count-1] = r4(); w2(4); break; case 4: w3(0x80); w2(0x24); for(k=0;k<(count/2)-1;k++) ((u16 *)buf)[k] = r4w(); buf[count-2] = r4(); w2(4); w3(0xa0); w2(0x24); buf[count-1] = r4(); w2(4); break; case 5: w3(0x80); w2(0x24); for(k=0;k<(count/4)-1;k++) ((u32 *)buf)[k] = r4l(); for(k=count-4;k<count-1;k++) buf[k] = r4(); w2(4); w3(0xa0); w2(0x24); buf[count-1] = r4(); w2(4); break; } }