diff options
Diffstat (limited to 'v2.0/source/COPYPROC.ASM')
| -rw-r--r-- | v2.0/source/COPYPROC.ASM | 526 |
1 files changed, 526 insertions, 0 deletions
diff --git a/v2.0/source/COPYPROC.ASM b/v2.0/source/COPYPROC.ASM new file mode 100644 index 0000000..f6e3bb1 --- /dev/null +++ b/v2.0/source/COPYPROC.ASM | |||
| @@ -0,0 +1,526 @@ | |||
| 1 | TITLE COPYRPOC ;Procedures called by COPY | ||
| 2 | |||
| 3 | INCLUDE COMSW.ASM | ||
| 4 | |||
| 5 | .xlist | ||
| 6 | .xcref | ||
| 7 | INCLUDE DOSSYM.ASM | ||
| 8 | INCLUDE DEVSYM.ASM | ||
| 9 | INCLUDE COMSEG.ASM | ||
| 10 | .list | ||
| 11 | .cref | ||
| 12 | |||
| 13 | INCLUDE COMEQU.ASM | ||
| 14 | |||
| 15 | DATARES SEGMENT PUBLIC | ||
| 16 | DATARES ENDS | ||
| 17 | |||
| 18 | TRANDATA SEGMENT PUBLIC | ||
| 19 | |||
| 20 | EXTRN OVERWR:BYTE,FULDIR:BYTE,LOSTERR:BYTE | ||
| 21 | EXTRN DEVWMES:BYTE,INBDEV:BYTE,NOSPACE:BYTE | ||
| 22 | |||
| 23 | TRANDATA ENDS | ||
| 24 | |||
| 25 | TRANSPACE SEGMENT PUBLIC | ||
| 26 | |||
| 27 | EXTRN CFLAG:BYTE,NXTADD:WORD,DESTCLOSED:BYTE | ||
| 28 | EXTRN PLUS:BYTE,BINARY:BYTE,ASCII:BYTE,FILECNT:WORD | ||
| 29 | EXTRN WRITTEN:BYTE,CONCAT:BYTE,DESTBUF:BYTE,SRCBUF:BYTE | ||
| 30 | EXTRN SDIRBUF:BYTE,DIRBUF:BYTE,DESTFCB:BYTE,MELCOPY:BYTE | ||
| 31 | EXTRN FIRSTDEST:BYTE,DESTISDIR:BYTE,DESTSWITCH:WORD | ||
| 32 | EXTRN DESTTAIL:WORD,DESTINFO:BYTE,INEXACT:BYTE | ||
| 33 | EXTRN DESTVARS:BYTE,SRCINFO:BYTE,RDEOF:BYTE | ||
| 34 | EXTRN USERDIR1:BYTE,NOWRITE:BYTE | ||
| 35 | EXTRN SRCHAND:WORD,CPDATE:WORD,CPTIME:WORD | ||
| 36 | EXTRN SRCISDEV:BYTE,BYTCNT:WORD,TPA:WORD,TERMREAD:BYTE | ||
| 37 | EXTRN DESTHAND:WORD,DESTISDEV:BYTE,DIRCHAR:BYTE | ||
| 38 | |||
| 39 | TRANSPACE ENDS | ||
| 40 | |||
| 41 | TRANCODE SEGMENT PUBLIC BYTE | ||
| 42 | |||
| 43 | PUBLIC SEARCH,SEARCHNEXT,DOCOPY,CLOSEDEST,FLSHFIL,SETASC | ||
| 44 | PUBLIC BUILDNAME,COPERR | ||
| 45 | |||
| 46 | EXTRN PRINT:NEAR,BUILDPATH:NEAR,RESTUDIR1:NEAR | ||
| 47 | EXTRN COMPNAME:NEAR,ENDCOPY:NEAR | ||
| 48 | |||
| 49 | ASSUME CS:TRANGROUP,DS:TRANGROUP,ES:TRANGROUP,SS:NOTHING | ||
| 50 | |||
| 51 | |||
| 52 | SEARCHNEXT: | ||
| 53 | MOV AH,DIR_SEARCH_NEXT | ||
| 54 | TEST [SRCINFO],2 | ||
| 55 | JNZ SEARCH ; Do serach-next if ambig | ||
| 56 | OR AH,AH ; Reset zero flag | ||
| 57 | return | ||
| 58 | SEARCH: | ||
| 59 | PUSH AX | ||
| 60 | MOV AH,SET_DMA | ||
| 61 | MOV DX,OFFSET TRANGROUP:DIRBUF | ||
| 62 | INT int_command ; Put result of search in DIRBUF | ||
| 63 | POP AX ; Restore search first/next command | ||
| 64 | MOV DX,FCB | ||
| 65 | INT int_command ; Do the search | ||
| 66 | OR AL,AL | ||
| 67 | return | ||
| 68 | |||
| 69 | DOCOPY: | ||
| 70 | mov [RDEOF],0 ; No EOF yet | ||
| 71 | mov dx,offset trangroup:SRCBUF | ||
| 72 | mov ax,OPEN SHL 8 | ||
| 73 | INT int_command | ||
| 74 | retc ; If open fails, ignore | ||
| 75 | mov bx,ax ; Save handle | ||
| 76 | mov [SRCHAND],bx ; Save handle | ||
| 77 | mov ax,(FILE_TIMES SHL 8) | ||
| 78 | INT int_command | ||
| 79 | mov [CPDATE],dx ; Save DATE | ||
| 80 | mov [CPTIME],cx ; Save TIME | ||
| 81 | mov ax,(IOCTL SHL 8) | ||
| 82 | INT int_command ; Get device stuff | ||
| 83 | and dl,devid_ISDEV | ||
| 84 | mov [SRCISDEV],dl ; Set source info | ||
| 85 | jz COPYLP ; Source not a device | ||
| 86 | cmp [BINARY],0 | ||
| 87 | jz COPYLP ; ASCII device OK | ||
| 88 | mov dx,offset trangroup:INBDEV ; Cannot do binary input | ||
| 89 | jmp COPERR | ||
| 90 | |||
| 91 | COPYLP: | ||
| 92 | mov bx,[SRCHAND] | ||
| 93 | mov cx,[BYTCNT] | ||
| 94 | mov dx,[NXTADD] | ||
| 95 | sub cx,dx ; Compute available space | ||
| 96 | jnz GOTROOM | ||
| 97 | call FLSHFIL | ||
| 98 | CMP [TERMREAD],0 | ||
| 99 | JNZ CLOSESRC ; Give up | ||
| 100 | mov cx,[BYTCNT] | ||
| 101 | GOTROOM: | ||
| 102 | push ds | ||
| 103 | mov ds,[TPA] | ||
| 104 | ASSUME DS:NOTHING | ||
| 105 | mov ah,READ | ||
| 106 | INT int_command | ||
| 107 | pop ds | ||
| 108 | ASSUME DS:TRANGROUP | ||
| 109 | jc CLOSESRC ; Give up if error | ||
| 110 | mov cx,ax ; Get count | ||
| 111 | jcxz CLOSESRC ; No more to read | ||
| 112 | cmp [SRCISDEV],0 | ||
| 113 | jnz NOTESTA ; Is a device, ASCII mode | ||
| 114 | cmp [ASCII],0 | ||
| 115 | jz BINREAD | ||
| 116 | NOTESTA: | ||
| 117 | MOV DX,CX | ||
| 118 | MOV DI,[NXTADD] | ||
| 119 | MOV AL,1AH | ||
| 120 | PUSH ES | ||
| 121 | MOV ES,[TPA] | ||
| 122 | REPNE SCASB ; Scan for EOF | ||
| 123 | POP ES | ||
| 124 | JNZ USEALL | ||
| 125 | INC [RDEOF] | ||
| 126 | INC CX | ||
| 127 | USEALL: | ||
| 128 | SUB DX,CX | ||
| 129 | MOV CX,DX | ||
| 130 | BINREAD: | ||
| 131 | ADD CX,[NXTADD] | ||
| 132 | MOV [NXTADD],CX | ||
| 133 | CMP CX,[BYTCNT] ; Is buffer full? | ||
| 134 | JB TESTDEV ; If not, we may have found EOF | ||
| 135 | CALL FLSHFIL | ||
| 136 | CMP [TERMREAD],0 | ||
| 137 | JNZ CLOSESRC ; Give up | ||
| 138 | JMP SHORT COPYLP | ||
| 139 | |||
| 140 | TESTDEV: | ||
| 141 | cmp [SRCISDEV],0 | ||
| 142 | JZ CLOSESRC ; If file then EOF | ||
| 143 | CMP [RDEOF],0 | ||
| 144 | JZ COPYLP ; On device, go till ^Z | ||
| 145 | CLOSESRC: | ||
| 146 | mov bx,[SRCHAND] | ||
| 147 | mov ah,CLOSE | ||
| 148 | INT int_command | ||
| 149 | return | ||
| 150 | |||
| 151 | CLOSEDEST: | ||
| 152 | cmp [DESTCLOSED],0 | ||
| 153 | retnz ; Don't double close | ||
| 154 | MOV AL,BYTE PTR [DESTSWITCH] | ||
| 155 | CALL SETASC ; Check for B or A switch on destination | ||
| 156 | JZ BINCLOS | ||
| 157 | MOV BX,[NXTADD] | ||
| 158 | CMP BX,[BYTCNT] ; Is memory full? | ||
| 159 | JNZ PUTZ | ||
| 160 | call TRYFLUSH ; Make room for one lousy byte | ||
| 161 | jz NOCONC | ||
| 162 | CONCHNG: ; Concat flag changed on us | ||
| 163 | stc | ||
| 164 | return | ||
| 165 | NOCONC: | ||
| 166 | XOR BX,BX | ||
| 167 | PUTZ: | ||
| 168 | PUSH DS | ||
| 169 | MOV DS,[TPA] | ||
| 170 | MOV WORD PTR [BX],1AH ; Add End-of-file mark (Ctrl-Z) | ||
| 171 | POP DS | ||
| 172 | INC [NXTADD] | ||
| 173 | MOV [NOWRITE],0 ; Make sure our ^Z gets written | ||
| 174 | MOV AL,[WRITTEN] | ||
| 175 | XOR AH,AH | ||
| 176 | ADD AX,[NXTADD] | ||
| 177 | JC BINCLOS ; > 1 | ||
| 178 | CMP AX,1 | ||
| 179 | JZ FORGETIT ; WRITTEN = 0 NXTADD = 1 (the ^Z) | ||
| 180 | BINCLOS: | ||
| 181 | call TRYFLUSH | ||
| 182 | jnz CONCHNG | ||
| 183 | cmp [WRITTEN],0 | ||
| 184 | jz FORGETIT ; Never wrote nothin | ||
| 185 | MOV BX,[DESTHAND] | ||
| 186 | MOV CX,[CPTIME] | ||
| 187 | MOV DX,[CPDATE] | ||
| 188 | CMP [INEXACT],0 ; Copy not exact? | ||
| 189 | JZ DODCLOSE ; If no, copy date & time | ||
| 190 | MOV AH,GET_TIME | ||
| 191 | INT int_command | ||
| 192 | SHL CL,1 | ||
| 193 | SHL CL,1 ; Left justify min in CL | ||
| 194 | SHL CX,1 | ||
| 195 | SHL CX,1 | ||
| 196 | SHL CX,1 ; hours to high 5 bits, min to 5-10 | ||
| 197 | SHR DH,1 ; Divide seconds by 2 (now 5 bits) | ||
| 198 | OR CL,DH ; And stick into low 5 bits of CX | ||
| 199 | PUSH CX ; Save packed time | ||
| 200 | MOV AH,GET_DATE | ||
| 201 | INT int_command | ||
| 202 | SUB CX,1980 | ||
| 203 | XCHG CH,CL | ||
| 204 | SHL CX,1 ; Year to high 7 bits | ||
| 205 | SHL DH,1 ; Month to high 3 bits | ||
| 206 | SHL DH,1 | ||
| 207 | SHL DH,1 | ||
| 208 | SHL DH,1 | ||
| 209 | SHL DH,1 ; Most sig bit of month in carry | ||
| 210 | ADC CH,0 ; Put that bit next to year | ||
| 211 | OR DL,DH ; Or low three of month into day | ||
| 212 | MOV DH,CH ; Get year and high bit of month | ||
| 213 | POP CX ; Get time back | ||
| 214 | DODCLOSE: | ||
| 215 | MOV AX,(FILE_TIMES SHL 8) OR 1 | ||
| 216 | INT int_command ; Set date and time | ||
| 217 | MOV AH,CLOSE | ||
| 218 | INT int_command | ||
| 219 | INC [FILECNT] | ||
| 220 | INC [DESTCLOSED] | ||
| 221 | RET50: | ||
| 222 | CLC | ||
| 223 | return | ||
| 224 | |||
| 225 | FORGETIT: | ||
| 226 | MOV BX,[DESTHAND] | ||
| 227 | CALL DODCLOSE ; Close the dest | ||
| 228 | MOV DX,OFFSET TRANGROUP:DESTBUF | ||
| 229 | MOV AH,UNLINK | ||
| 230 | INT int_command ; And delete it | ||
| 231 | MOV [FILECNT],0 ; No files transferred | ||
| 232 | JMP RET50 | ||
| 233 | |||
| 234 | TRYFLUSH: | ||
| 235 | mov al,[CONCAT] | ||
| 236 | push ax | ||
| 237 | call FLSHFIL | ||
| 238 | pop ax | ||
| 239 | cmp al,[CONCAT] | ||
| 240 | return | ||
| 241 | |||
| 242 | FLSHFIL: | ||
| 243 | ; Write out any data remaining in memory. | ||
| 244 | ; Inputs: | ||
| 245 | ; [NXTADD] = No. of bytes to write | ||
| 246 | ; [CFLAG] <>0 if file has been created | ||
| 247 | ; Outputs: | ||
| 248 | ; [NXTADD] = 0 | ||
| 249 | |||
| 250 | MOV [TERMREAD],0 | ||
| 251 | cmp [CFLAG],0 | ||
| 252 | JZ NOTEXISTS | ||
| 253 | JMP EXISTS | ||
| 254 | NOTEXISTS: | ||
| 255 | call BUILDDEST ; Find out all about the destination | ||
| 256 | CALL COMPNAME ; Source and dest. the same? | ||
| 257 | JNZ PROCDEST ; If not, go ahead | ||
| 258 | CMP [SRCISDEV],0 | ||
| 259 | JNZ PROCDEST ; Same name on device OK | ||
| 260 | CMP [CONCAT],0 ; Concatenation? | ||
| 261 | MOV DX,OFFSET TRANGROUP:OVERWR | ||
| 262 | JZ COPERRJ ; If not, overwrite error | ||
| 263 | MOV [NOWRITE],1 ; Flag not writting (just seeking) | ||
| 264 | PROCDEST: | ||
| 265 | mov ax,(OPEN SHL 8) OR 1 | ||
| 266 | CMP [NOWRITE],0 | ||
| 267 | JNZ DODESTOPEN ; Don't actually create if NOWRITE set | ||
| 268 | mov ah,CREAT | ||
| 269 | xor cx,cx | ||
| 270 | DODESTOPEN: | ||
| 271 | mov dx,offset trangroup:DESTBUF | ||
| 272 | INT int_command | ||
| 273 | MOV DX,OFFSET TRANGROUP:FULDIR | ||
| 274 | JC COPERRJ | ||
| 275 | mov [DESTHAND],ax ; Save handle | ||
| 276 | mov [CFLAG],1 ; Destination now exists | ||
| 277 | mov bx,ax | ||
| 278 | mov ax,(IOCTL SHL 8) | ||
| 279 | INT int_command ; Get device stuff | ||
| 280 | mov [DESTISDEV],dl ; Set dest info | ||
| 281 | test dl,devid_ISDEV | ||
| 282 | jz EXISTS ; Dest not a device | ||
| 283 | mov al,BYTE PTR [DESTSWITCH] | ||
| 284 | AND AL,ASWITCH+BSWITCH | ||
| 285 | JNZ TESTBOTH | ||
| 286 | MOV AL,[ASCII] ; Neither set, use current setting | ||
| 287 | OR AL,[BINARY] | ||
| 288 | JZ EXSETA ; Neither set, default to ASCII | ||
| 289 | TESTBOTH: | ||
| 290 | JPE EXISTS ; Both are set, ignore | ||
| 291 | test AL,BSWITCH | ||
| 292 | jz EXISTS ; Leave in cooked mode | ||
| 293 | mov ax,(IOCTL SHL 8) OR 1 | ||
| 294 | xor dh,dh | ||
| 295 | or dl,devid_RAW | ||
| 296 | mov [DESTISDEV],dl ; New value | ||
| 297 | INT int_command ; Set device to RAW mode | ||
| 298 | jmp short EXISTS | ||
| 299 | |||
| 300 | COPERRJ: | ||
| 301 | jmp SHORT COPERR | ||
| 302 | |||
| 303 | EXSETA: | ||
| 304 | ; What we read in may have been in binary mode, flag zapped write OK | ||
| 305 | mov [ASCII],ASWITCH ; Set ASCII mode | ||
| 306 | or [INEXACT],ASWITCH ; ASCII -> INEXACT | ||
| 307 | EXISTS: | ||
| 308 | cmp [NOWRITE],0 | ||
| 309 | jnz NOCHECKING ; If nowrite don't bother with name check | ||
| 310 | CALL COMPNAME ; Source and dest. the same? | ||
| 311 | JNZ NOCHECKING ; If not, go ahead | ||
| 312 | CMP [SRCISDEV],0 | ||
| 313 | JNZ NOCHECKING ; Same name on device OK | ||
| 314 | ; At this point we know in append (would have gotten overwrite error on first | ||
| 315 | ; destination create otherwise), and user trying to specify destination which | ||
| 316 | ; has been scribbled already (if dest had been named first, NOWRITE would | ||
| 317 | ; be set). | ||
| 318 | MOV DX,OFFSET TRANGROUP:LOSTERR ; Tell him he's not going to get it | ||
| 319 | CALL PRINT | ||
| 320 | MOV [NXTADD],0 ; Set return | ||
| 321 | INC [TERMREAD] ; Tell Read to give up | ||
| 322 | RET60: | ||
| 323 | return | ||
| 324 | |||
| 325 | NOCHECKING: | ||
| 326 | mov bx,[DESTHAND] ; Get handle | ||
| 327 | XOR CX,CX | ||
| 328 | XCHG CX,[NXTADD] | ||
| 329 | JCXZ RET60 ; If Nothing to write, forget it | ||
| 330 | INC [WRITTEN] ; Flag that we wrote something | ||
| 331 | CMP [NOWRITE],0 ; If NOWRITE set, just seek CX bytes | ||
| 332 | JNZ SEEKEND | ||
| 333 | XOR DX,DX | ||
| 334 | PUSH DS | ||
| 335 | MOV DS,[TPA] | ||
| 336 | ASSUME DS:NOTHING | ||
| 337 | MOV AH,WRITE | ||
| 338 | INT int_command | ||
| 339 | POP DS | ||
| 340 | ASSUME DS:TRANGROUP | ||
| 341 | MOV DX,OFFSET TRANGROUP:NOSPACE | ||
| 342 | JC COPERR ; Failure | ||
| 343 | sub cx,ax | ||
| 344 | retz ; Wrote all supposed to | ||
| 345 | test [DESTISDEV],devid_ISDEV | ||
| 346 | jz COPERR ; Is a file, error | ||
| 347 | test [DESTISDEV],devid_RAW | ||
| 348 | jnz DEVWRTERR ; Is a raw device, error | ||
| 349 | cmp [INEXACT],0 | ||
| 350 | retnz ; INEXACT so OK | ||
| 351 | dec cx | ||
| 352 | retz ; Wrote one byte less (the ^Z) | ||
| 353 | DEVWRTERR: | ||
| 354 | MOV DX,OFFSET TRANGROUP:DEVWMES | ||
| 355 | COPERR: | ||
| 356 | CALL PRINT | ||
| 357 | inc [DESTCLOSED] | ||
| 358 | cmp [CFLAG],0 | ||
| 359 | jz ENDCOPYJ ; Never actually got it open | ||
| 360 | MOV bx,[DESTHAND] | ||
| 361 | MOV AH,CLOSE ; Close the file | ||
| 362 | INT int_command | ||
| 363 | MOV DX,OFFSET TRANGROUP:DESTBUF | ||
| 364 | MOV AH,UNLINK | ||
| 365 | INT int_command ; And delete it | ||
| 366 | MOV [CFLAG],0 | ||
| 367 | ENDCOPYJ: | ||
| 368 | JMP ENDCOPY | ||
| 369 | |||
| 370 | |||
| 371 | SEEKEND: | ||
| 372 | xor dx,dx ; Zero high half of offset | ||
| 373 | xchg dx,cx ; cx:dx is seek location | ||
| 374 | mov ax,(LSEEK SHL 8) OR 1 | ||
| 375 | INT int_command ; Seek ahead in the file | ||
| 376 | cmp [RDEOF],0 | ||
| 377 | retz | ||
| 378 | ; If a ^Z has been read we must set the file size to the current | ||
| 379 | ; file pointer location | ||
| 380 | MOV AH,WRITE | ||
| 381 | INT int_command ; CX is zero, truncates file | ||
| 382 | return | ||
| 383 | |||
| 384 | SETASC: | ||
| 385 | ; Given switch vector in AX, | ||
| 386 | ; Set ASCII switch if A is set | ||
| 387 | ; Clear ASCII switch if B is set | ||
| 388 | ; BINARY set if B specified | ||
| 389 | ; Leave ASCII unchanged if neither or both are set | ||
| 390 | ; Also sets INEXACT if ASCII is ever set. AL = ASCII on exit, flags set | ||
| 391 | AND AL,ASWITCH+BSWITCH | ||
| 392 | JPE LOADSW ; PE means both or neither are set | ||
| 393 | PUSH AX | ||
| 394 | AND AL,BSWITCH | ||
| 395 | MOV [BINARY],AL | ||
| 396 | POP AX | ||
| 397 | AND AL,ASWITCH | ||
| 398 | MOV [ASCII],AL | ||
| 399 | OR [INEXACT],AL | ||
| 400 | LOADSW: | ||
| 401 | MOV AL,[ASCII] | ||
| 402 | OR AL,AL | ||
| 403 | return | ||
| 404 | |||
| 405 | BUILDDEST: | ||
| 406 | cmp [DESTISDIR],-1 | ||
| 407 | jnz KNOWABOUTDEST ; Already done the figuring | ||
| 408 | MOV DI,OFFSET TRANGROUP:USERDIR1 | ||
| 409 | mov bp,offset trangroup:DESTVARS | ||
| 410 | call BUILDPATH | ||
| 411 | call RESTUDIR1 | ||
| 412 | |||
| 413 | ; Now know all about the destination | ||
| 414 | |||
| 415 | KNOWABOUTDEST: | ||
| 416 | xor al,al | ||
| 417 | xchg al,[FIRSTDEST] | ||
| 418 | or al,al | ||
| 419 | jnz FIRSTDST | ||
| 420 | jmp NOTFIRSTDEST | ||
| 421 | FIRSTDST: | ||
| 422 | mov si,[DESTTAIL] ; Create an FCB of the original DEST | ||
| 423 | mov di,offset trangroup:DESTFCB | ||
| 424 | mov ax,PARSE_FILE_DESCRIPTOR SHL 8 | ||
| 425 | INT int_command | ||
| 426 | mov ax,word ptr [DESTBUF] ; Get drive | ||
| 427 | cmp ah,':' | ||
| 428 | jz DRVSPEC4 | ||
| 429 | mov al,'@' | ||
| 430 | DRVSPEC4: | ||
| 431 | MOV CL,[ASCII] ; Save current ASCII setting | ||
| 432 | sub al,'@' | ||
| 433 | mov [DESTFCB],al | ||
| 434 | mov al,[DESTINFO] | ||
| 435 | mov ah,[SRCINFO] | ||
| 436 | and ax,0202H | ||
| 437 | or al,al | ||
| 438 | jz NOTMELCOPY | ||
| 439 | cmp al,ah | ||
| 440 | jnz NOTMELCOPY | ||
| 441 | cmp [PLUS],0 | ||
| 442 | jz NOTMELCOPY | ||
| 443 | inc [MELCOPY] ; ambig source, ambig dest, and pluses | ||
| 444 | xor al,al | ||
| 445 | jmp short SETCONC | ||
| 446 | |||
| 447 | NOTMELCOPY: | ||
| 448 | xor al,2 ; al=2 if unambig dest, =0 if ambig dest | ||
| 449 | and al,ah | ||
| 450 | shr al,1 ; al=1 if unambig dest AND ambig sorce | ||
| 451 | ; Implies concatination | ||
| 452 | SETCONC: | ||
| 453 | or al,[PLUS] ; al=1 if concat | ||
| 454 | mov [CONCAT],al | ||
| 455 | shl al,1 | ||
| 456 | shl al,1 | ||
| 457 | mov [INEXACT],al ; Concat -> inexact copy | ||
| 458 | cmp [BINARY],0 | ||
| 459 | jnz NOTFIRSTDEST ; Binary explicitly given, all OK | ||
| 460 | mov [ASCII],al ; Concat -> ASCII | ||
| 461 | or cl,cl | ||
| 462 | jnz NOTFIRSTDEST ; ASCII flag set before, DATA read correctly | ||
| 463 | or al,al | ||
| 464 | JZ NOTFIRSTDEST ; ASCII flag did not change states | ||
| 465 | ; At this point there may already be binary read data in the read buffer. | ||
| 466 | ; We need to find the first ^Z (if there is one) and trim the amount | ||
| 467 | ; of data in the buffer correctly. | ||
| 468 | MOV CX,[NXTADD] | ||
| 469 | JCXZ NOTFIRSTDEST ; No data, everything OK | ||
| 470 | MOV AL,1AH | ||
| 471 | PUSH ES | ||
| 472 | XOR DI,DI | ||
| 473 | MOV ES,[TPA] | ||
| 474 | REPNE SCASB ; Scan for EOF | ||
| 475 | POP ES | ||
| 476 | JNZ NOTFIRSTDEST ; No ^Z in buffer, everything OK | ||
| 477 | DEC DI ; Point at ^Z | ||
| 478 | MOV [NXTADD],DI ; New buffer | ||
| 479 | NOTFIRSTDEST: | ||
| 480 | mov bx,offset trangroup:DIRBUF+1 ; Source of replacement chars | ||
| 481 | cmp [CONCAT],0 | ||
| 482 | jz GOTCHRSRC ; Not a concat | ||
| 483 | mov bx,offset trangroup:SDIRBUF+1 ; Source of replacement chars | ||
| 484 | GOTCHRSRC: | ||
| 485 | mov si,offset trangroup:DESTFCB+1 ; Original dest name | ||
| 486 | mov di,[DESTTAIL] ; Where to put result | ||
| 487 | |||
| 488 | BUILDNAME: | ||
| 489 | mov cx,8 | ||
| 490 | BUILDMAIN: | ||
| 491 | lodsb | ||
| 492 | cmp al,"?" | ||
| 493 | jnz NOTAMBIG | ||
| 494 | mov al,byte ptr [BX] | ||
| 495 | NOTAMBIG: | ||
| 496 | cmp al,' ' | ||
| 497 | jz NOSTORE | ||
| 498 | stosb | ||
| 499 | NOSTORE: | ||
| 500 | inc bx | ||
| 501 | loop BUILDMAIN | ||
| 502 | mov cl,3 | ||
| 503 | cmp byte ptr [SI],' ' | ||
| 504 | jz ENDDEST ; No extension | ||
| 505 | mov al,'.' | ||
| 506 | stosb | ||
| 507 | BUILDEXT: | ||
| 508 | lodsb | ||
| 509 | cmp al,"?" | ||
| 510 | jnz NOTAMBIGE | ||
| 511 | mov al,byte ptr [BX] | ||
| 512 | NOTAMBIGE: | ||
| 513 | cmp al,' ' | ||
| 514 | jz NOSTOREE | ||
| 515 | stosb | ||
| 516 | NOSTOREE: | ||
| 517 | inc bx | ||
| 518 | loop BUILDEXT | ||
| 519 | ENDDEST: | ||
| 520 | xor al,al | ||
| 521 | stosb ; NUL terminate | ||
| 522 | return | ||
| 523 | |||
| 524 | TRANCODE ENDS | ||
| 525 | END | ||
| 526 | |||