max@plus5.UUCP (R. Max Mutrux) (12/21/85)
Say ALL you amiga developers using PC's as a cross system. Tired of waiting around for your 9600 baud transfers to complete. Well here's a quick and dirty set of programs that will send files from the PC to the AMIGA over the parallel interface. First build a cable like this: DB25 Male DB25 Female PC AMIGA --------- ----------- -STROBE 1 ......... 13 SEL D0 2 ......... 2 D0 D1 3 ......... 3 D1 D2 4 ......... 4 D2 D3 5 ......... 5 D3 D4 6 ......... 6 D4 D5 7 ......... 7 D5 D6 8 ......... 8 D6 D7 9 ......... 9 D7 -ACK 10 ......... 11 BUSY -SLCT IN 17 ......... 12 POUT GND 18 ......... 18 GND GND 19 ......... 19 GND GND 20 ......... 20 GND GND 21 ......... 21 GND GND 22 ......... 22 GND GND 23 ......... 14 GND GND 24 ......... 15 GND GND 25 ......... 16 GND * YOU DON'T REALLY NEED MORE THAN ONE GROUND BUT HOOK UP AS MANY AS POSSIBLE Then Compile TOA.C on the IBM (Microsoft C) and FIBM.C on the Amiga, hookem up. To Transfer: IBM: C> TOA FILENAME AMIGA: 1> FIBM * THE ORDER OF THESE COMMANDS DOES NOT MATTER ONE WILL ALWAYS WAIT FOR THE OTHER FIBM has no options. These are the options for TOA: -b Send following files binary (no translations) -a Send following files ascii (\n\r to \n, strip ^Z) -d<dev> Add <dev> to the begining of the file name. Useful as -dRAM: to send strait to the ram disk -p{0|1} Select Printer Port 0 or 1 (not tested) -h Hang on. Don't send EOT to amiga. Usefull if you want to send several batchs of files The Micro Emacs binary took 198 seconds with 9600 baud rs232. With a parallel connections it took 13 seconds. Also you can transfer to disk directly instead of going through the ram disk. TOA can send as many files as you can fit on a command line. FIBM will wait for an end of transmition char before exiting. I'm sure this program will come back to me across the net with all sorts of spiffy enhancements but this ain't bad for an evenings work (play?). This is Public Domain you can do anything you wan't with it as long as you keep my name in the source (ego?) and don't get any bucks for it. Two Final Notes: 1) This thing really eats up the cpu time. I would try running it in the background (the price you pay for speed). 2) If any Amiga Hardware hack at commodor read this. Tell me if I'm doing anything wrong by reversing the direction on the parallel port -------------------------------TOA.C (for IBM)------------------------------- /* TOA - Transfer files to an Amiga via Parallel connection Edit History: R. Max Mutrux 21-DEC-85 V1.0 Gee It Works(?) */ #include <stdio.h> #include <fcntl.h> char aton[32]; /* Device Added to name before opening (Remote) */ char sname[64]; /* final transmitted name */ int f_binary = 1; /* binary flag */ int f_hold = 0; /* hold flag */ int devbase = 0x278; /* Parallel Printer Port */ int reg_data = 0x278; int reg_ctrl = 0x27a; int reg_status = 0x279; main(ac,av) int ac; char *av[]; { int i; int j; char *fstrip(); if(ac<2) { printf("Usage: toa [-{b|a}] [-ddevice] [-p{0|1}] [-h] file [file...]\n"); exit(1); } aton[0] = 0; for(i=1; i<ac; i++) { if(av[i][0]=='-') { switch(av[i][1]) { case 'b': case 'B': /* Binary */ f_binary = 1; continue; case 'a': case 'A': /* Ascii */ f_binary = 0; continue; case 'd': case 'D': /* Device (Destination) */ strcpy(aton,&av[i][2]); continue; case 'p': case 'P': if(av[i][2]=='2') devbase = 0x378; else devbase = 0x278; reg_data = devbase; reg_ctrl = devbase+2; reg_status = devbase+1; continue; case 'h': case 'H': f_hold = 1; continue; default: printf("-%c Huh?\n",av[i][1]); } } if(f_binary) j = open(av[i],O_RDONLY|O_BINARY); else j = open(av[i],O_RDONLY|O_TEXT); sprintf(sname,"%s%s",aton,fstrip(av[i])); if(j>0) { printf("SEND: \"%s\" as \"%s\" ",av[i],sname); transmit(j,sname); close(j); printf("Done\n"); } } if(f_hold==0) sendbyte(0x1ff); /* send end of transmition special char */ } char *fstrip(s) register char *s; { register int l; l = strlen(s) - 1; for(;l>=0;--l) { if(s[l]==':' || s[l]=='\\' || s[l]=='/') break; } return &s[l+1]; } transmit(fd,na) int fd; char *na; { char block[512]; int l; sendbyte(0x100); /* send start of name special char */ sendblock(na,strlen(na)); sendbyte(0x101); /* send start of data special char */ while((l=read(fd,block,512))!=0) sendblock(block,l); sendbyte(0x1fe); /* send end of data special char */ } sendblock(b,l) register unsigned char *b; register int l; { while(--l >=0 ) sendbyte(*b++); } sendbyte(c) register int c; { register i7a; i7a = 0; outp(reg_data,c&255); /* assert byte onto data pins */ if(c>255) i7a = 8; /* if special char (C)*/ else i7a = 0; /* if data char (D)*/ outp(reg_ctrl,1|i7a); /* assert DAV and C/D */ while(inp(reg_status)&0x40) ; /* wait for ACK asserted*/ outp(reg_ctrl,0); /* negate DAV and C/D */ while((inp(reg_status)&0x40)==0) ; /* wait for ACK negated */ } -----------------------------FIBM.C (for Amiga)------------------------------ /* FIBM - Receive files from an IBM via Parallel connection Edit History: R. Max Mutrux 21-DEC-85 V1.0 Boy this Amiga is slick */ #include <stdio.h> #define STATE_NULL 0 /* THROW OUT DATA */ #define STATE_NAME 1 /* RECEIVE NAME */ #define STATE_DATA 2 /* RECEIVE DATA */ main() { register unsigned char *dataport; register unsigned char *ctrlport; unsigned char *datadirport; unsigned char *ctrldirport; unsigned char origdatadir; unsigned char origctrldir; register unsigned int c; register unsigned int state; register unsigned int block_len; register unsigned long filep; register int i; char block[512]; dataport = (char *)0xbfe101; datadirport = (char *)0xbfe301; ctrlport = (char *)0xbfd000; ctrldirport = (char *)0xbfd200; origdatadir = *datadirport; origctrldir = *ctrldirport; *datadirport = 0x00; *ctrldirport |= 0x01; state = 0; filep = 0; block_len = 0; for(;;) { while((*ctrlport&0x04)) ; c = *ctrlport & 0x02; if(!c) c = 0x100; else c = 0; c |= *dataport; *ctrlport &= ~1; while((*ctrlport&0x04)==0) ; *ctrlport |= 1; if(c<0x100) { if(state==STATE_NAME) { if(block_len>30) continue; block[block_len++] = c; } else { if(state==STATE_DATA) { if(block_len>511) { if(Write(filep,block,block_len)<0) { printf("write error %d\n",IoErr()); Close(filep); state = STATE_NULL; } block_len = 0; } block[block_len++] = c; } } } else { switch(c-0x100) { case 0x00: /* START OF FILE NAME */ block_len = 0; state = STATE_NAME; continue; case 0x01: /* START OF DATA FOR FILE */ block[block_len++] = 0; block_len = 0; printf("REC: \"%s\" ",block); filep = Open(block,1006); if(filep==0L) { i = IoErr(); printf("open error %d\n",i); state = STATE_NULL; continue; } state = STATE_DATA; continue; case 0xfe: /* END OF FILE */ if(state==STATE_DATA) { if(block_len>0) { if(Write(filep,block,block_len)<0) printf("Write Error %d\n",IoErr()); else printf("OK\n"); } else printf("OK\n"); Close(filep); } state = STATE_NULL; continue; case 0xff: /* END OF TRANSMITTION */ printf("EOT\n"); exit(1); } } } } ----------------------------------------------------------------------------- -- Boomshanka! (char)Max_Mutrux ..!{ihnp4,cbosgd,seismo}!plus5!max