; ; ; ============================================ ; ; BATCH MODE ROUTINES ; ; ============================================ ; ; ; If in batch receive, gets a file name from the buffer ; and then asks for a description. ; bchd1: lhld nbsave; Get address of next batch filename lxi d,fcb; Where to put it call move12 shld nbsave; Store address for next filename ret ; ; If receiving batch, increment the file count, store the filename ; so we can later ask for a description. ; bchinr: lhld nbsave; Where to put the name lxi d,fcb; Where to get the name xchg call move12; Move the current file name into buffer xchg shld nbsave; Store address for next filename lda filcnt; Increment the file count inr a sta filcnt ret ; ; Show batch files remaining after this one is sent ; cumsts: call ilprt db 'When done: ',0 lda shocnt; Get cumulative files dcr a sta shocnt; Less one call decouta call ilprt db ' left with ',0 lhld rcnt; Get this file's record count again xchg lhld totrec; Total records remaining mov a,l sub e mov l,a mov a,h sbb d mov h,a jnc cmst1 lxi h,0; In case of a slightly negative number cmst1: shld totrec push h call decout; Show remote remaining records call ilprt db ' records (',0 pop h call decoutk call ilprt db 'k)',cr,lf,0 ret ; ; ------------------------------------------------ ; ; RXMD receive batch mode ; rcvfn: lxi h,fcb call initfcb; Does not initialize drive mvi a,1; Insure printing only to local CRT sta remoff xra a sta rcvtry rkmd1: call ckabort; Check for user abort mvi b,3; Wait up to 3 sec. for SOH from remote call recv jc rkmd2; No char, decrement counter cpi cancel; Was it a CTL-X for cancel? jz abortx; Abort if yes cpi soh jz rkmd4; Got SOH jmp rkmd1; None of these, wait some more ; rkmd2: mvi a,crc; Send a 'C' call send rkmd3: lda rcvtry inr a sta rcvtry cpi 33 jc rkmd1 jmp abort; Quit and try to force him to quit also ; rkmd4: mvi b,5; 5 seconds to get sector number call recv jc kmdtot mov d,a; Save sector number in D ora a; Must be a 0 if sending batch jnz kmdhdr mvi b,5; 5 seconds to get reciprocal call recv jc kmdtot cma; Invert it and compare to sector # cmp d jnz kmdcrc; Bad match lxi h,0 shld crcval; Clear CRC counter mvi e,128; Expecting a 128 byte block lhld recptr; Point to the buffer address rkmd5: mvi b,5; 5 seconds to get 128 byte header block call recv; Get the byte jc kmdtot; Exit if no byte mov m,a; Store the byte inx h; Point to next buffer location dcr e; One less to go jnz rkmd5 mvi e,2; Number of CRC bytes to get rkmd6: mvi b,5 call recv; Get CRC bytes jc kmdtot dcr e jnz rkmd6; Not done call crcchk; Compare CRC received against ours ora a jnz kmdcrc; Not ok call sndack; Yes, acknowledge to remote ; " " ; Decode pathname into CPM format ; lxi d,fcb+1; Where to put it lhld recptr; Where to get it mvi b,8; Filename length rkmd7: mov a,m; Get the char from the buffer ora a; Was it a zero? jz rkmd12; If yes, all done cpi '.'; Was it a delimiter? jz rkmd9 cpi '_'; Unix can't handle this properly jnz rkmd8 mvi a,'/'; Change it to a slash rkmd8: call ucase; Insure name is in upper case stax d; Store filename char in FCB inx d; Increment pointers inx h dcr b; One less to go jnz rkmd7; If not 8, keep going mov a,m; Get the char back ora a; We had 8, was there a type? jz rkmd11; If zero, was all done jmp rkmd10; Else must be a '.' ; rkmd9: mvi a,' '; Spaces to make up 8 spaces for name stax d; Store space char in FCB inx d; Increment pointers dcr b; One less to go jnz rkmd9; Keep going until in type field rkmd10: inx h; Skip the '.' position mvi b,3; type field length rkmd11: mov a,m; Get char from buffer ora a; Was it a zero? jz rkmd12; If yes, all done call ucase; Insure type is in upper case stax d; Store type char inx d; Increment pointers inx h dcr b; One less to go jnz rkmd11; Keep going until finished rkmd12: lda fcb+1; See if there was any filename at all cpi ' ' stc; If not set the carry flag rz; No, all done, no more files call ilprt db cr,lf,'File name: ',0 lhld recptr; Print filename rkmd13: mov a,m ora a jz rkmd14 call ucase call ctype inx h jmp rkmd13 ; rkmd14: lhld bufstr; Get the file length, if provided mov a,h ora l jz rkmd15; If both zero, length not provided shld rcnt; Store the file length call fisopen call ilprt db 'k)',cr,lf,'Recv time: ',0 call ktim call showtime rkmd15: call crlf; Finish the filename line xra a; Reset carry sta rcvtry; and the error counter ret ; kmdcrc: call ilprt db '++ CRC error ++',cr,lf,0 jmp kmdxfr ; kmdhdr: call ilprt db '++ Wrong header type ++',cr,lf,0 jmp kmdxfr ; kmdtot: call ilprt db ' ++ Time out receiving filename ++',cr,lf,0 ; " " kmdxfr: call wait1; For sender to stop mvi a,nak; Tell sender it was not successful call send lda rcvtry; Increment error counter inr a sta rcvtry cpi 33 jc rkmd3; Send a NAK and tell him to try again jmp abort; Else abort ; ; ; end of RXMD/KMD get batch file name ; ------------------------------------------------------------------- ; RXMD/KMD send batch mode ; sndfn: lxi h,fcb call initfcb; Does not initialize drive xra a sta errct; Reset the error count call catch; Clear the decks for action mvi e,61; Wait up to 60 seconds to abort sndfn1: dcr e; One less to go jz ackmsg; Abort if timed out and no char sndfn2: call ckabort; Manually requesting an abort? mvi b,1; Wait up to 1 sec for a char call recv jc sndfn1; No char, decrement counter cpi cancel; If they sent a CTL-X, abort now jz abort cpi crc; If they sent a CRC, go to work jnz sndfn2; None of these, wait some more mvi a,1 sta crcflg; Make sure in CRC mode lda filcnt; Get the file count dcr a; Decrement it for this one sta filcnt jm kmdend; If no more files, abort call bchd1; Get the name into FCB lhld recptr; Where to load the 0 block xchg; Put into DE lxi h,fcb+1; Get the start of the filename in HL mvi b,8 skmd1: mov a,m ani 7fh; Strip any high bit set ora a jz skmd6; Null pathname cpi ' ' jz skmd3 cpi '/'; Change / to underline jnz skmd2 mvi a,'_' skmd2: call lcase; lower case file name for UNIX stax d inx h inx d dcr b jnz skmd1 jmp skmd4 skmd3: inx h; Skip over spaces if short name dcr b jnz skmd3 skmd4: mov a,m cpi ' ' jz skmd6; Missing file type field mvi a,'.'; Send name-type separator stax d inx d mvi b,3 skmd5: mov a,m ani 7fh; Strip any high bit set cpi ' ' jz skmd6 call lcase; lower case for UNIX stax d inx h inx d dcr b jnz skmd5 skmd6: xchg; Get the address back to HL skmd7: mvi m,0; Fill rest of block with zeroes inr l jnz skmd7 call cnrec; Get num records in this file lhld rcnt shld bufstr; Store the file length at end of block xra a; Make sure the header starts with Zero sta rcdcnt ; " " ; Now send the 128-byte file name record skmd8: xra a sta kflg mvi a,soh; Send SOH call send call sndhnm; Send header (record number, inverse) call sndrec; Send a 128 byte record call sndcrc; Send a two byte CRC mvi b,5 call recv; Get acknowledgement of good send cpi ack jnz kmdbad; Bad name send mvi a,1 sta kflg; Now change to 1k for normal file xfer xra a; Clear carry sta errct; Start fresh for the main file ret ; ; kmdbad: cpi cancel; Was it a CTL-X for cancel? jz abort; Abort if yes call ilprt; Bad name block db '++ CRC error ++',cr,lf,0 lda errct; Increment error counter inr a sta errct cpi 10 jc skmd8; If not timed out, try again jmp ackmsg; Else abort ; ; kmdend: xra a; Reset the pointers lhld recptr mov m,a sta rcdcnt; Reset record counter sta kflg; Show in 128 size now mvi a,soh; Send a start of header call send call sndhnm; This header is a zero count call sndrec; Send an empty record call sndcrc; Send the CRC for the empty record stc; Set carry flag to show all done ret ; ; end of send RXMD/KMD batch name ; -------------------------------------------------- ; ; Downshift (a) ; a,f lcase: cpi 'A' rc cpi 'Z'+1 rnc ori 20h; downshift ret ; ; Upshift (a) ; a,f ucase: cpi 'a' rc cpi 'z'+1 rnc ani 5fh; upshift ret ;