1 ; _____________________________________________ 2 ; | | 3 ; | Project: APPLER | 4 ; | File: FM.ASM | 5 ; | Compiler: 16-bit TASM (2.5) | 6 ; | | 7 ; | Subject: File Manager | 8 ; | | 9 ; | Author: Emil Dotchevski | 10 ; |_____________________________________________| 11 12 include GLOBALS.INC 13 include INTERFAC.INC 14 include CONIO.INC 15 include FM.INC 16 17 G_DIRECTORY = 0 18 G_MEMORY = 1 19 G_PATH_FILTER = 2 20 21 FM segment public 22 assume cs:FM,ds:FM,es:Emulate 23 24 GetLineBuf db 80h dup (0) 25 26 GetLineParams GL_ParamStruc 27 ScreenIOParams SIO_ParamStruc <1,FM,0,0,offset Screen,seg Screen,1,0,1,1> 28 GetKeyParams RK_ParamStruc <1,Fkey,1,Alt_Key,0,?,ShowAll,0> 29 30 FMInInit proc far 31 cli 32 push ax ds es 33 mov ax,Emulate 34 mov es,ax 35 mov al,es:[C000] 36 mov cs:KeyPressed,al 37 mov es:C000,0 38 call DebugKeysOn 39 assume ds:CONio 40 mov ax,CONio 41 mov ds,ax 42 mov GL_ParamsOfs, offset GetLineParams 43 mov GL_ParamsSeg, seg GetLineParams 44 mov SIO_ParamsOfs, offset ScreenIOParams 45 mov SIO_ParamsSeg, seg ScreenIOParams 46 mov RK_ParamsOfs, offset GetKeyParams 47 mov RK_ParamsSeg, seg GetKeyParams 48 assume ds:FM 49 mov cs:GetKeyParams.RK_ErrPtr,0 50 pop es ds ax 51 call UnsetBreaks 52 sti 53 ret 54 FMInInit endp 55 56 KeyPressed db 0 57 FMOutInit proc far 58 cli 59 push ax es 60 mov ax,Emulate 61 mov es,ax 62 mov al,cs:KeyPressed 63 mov es:C000,al 64 mov ax,seg T_Iflags 65 mov es,ax 66 assume es:seg T_Iflags 67 mov byte ptr es:T_Iflags,00000010b 68 assume es:Emulate 69 pop es ax 70 call SetBreaks 71 call AppleKeysOn 72 ret 73 FMOutInit endp 74 75 76 77 ; Entry: 78 ; DS --> segment 79 ; SI --> ^ext to add (ASCIIZ) 80 ; DI --> ^filespec (ASCIIZ) 81 ; Exit: 82 ; CF --> 1 ext is not as expected, 0 - otherwise 83 84 AE_Ext db 3 dup (?) 85 AE_Start dw ? 86 AddExt proc far 87 push ax cx si di es 88 push si 89 mov cs:AE_Start,di 90 push ds 91 pop es 92 cld 93 mov cx,0FFh 94 xor al,al 95 repne scasb 96 dec di 97 mov cx,di 98 AE_Loop: dec di 99 cmp di,cs:AE_Start 100 je AE_DoAddExt 101 mov al,ds:[di] 102 cmp al,'.' 103 je AE_ret 104 cmp al,'\' 105 jne AE_Loop 106 AE_DoAddExt: mov di,cx 107 push di 108 mov cx,5 109 rep movsb 110 pop di 111 AE_ret: pop si 112 AE_WhatExtLoop: lodsb 113 or al,al 114 clc 115 jz AE_Quit 116 scasb 117 je AE_WhatExtLoop 118 call Upcase 119 cmp al,ds:[di-1] 120 je AE_WhatExtLoop 121 stc 122 AE_Quit: pop es di si cx ax 123 ret 124 AddExt endp 125 126 127 ; Entry: 128 ; DS --> segment 129 ; SI --> ^ext to add (ASCIIZ) 130 ; DI --> ^filespec (ASCIIZ) 131 ; Exit: 132 ; ZF --> 1 ext is as expected, 0 - otherwise 133 134 CE_Ext db 3 dup (?) 135 CE_Start dw ? 136 CmpExt proc far 137 push ax cx si di es 138 mov cs:CE_Start,di 139 push ds 140 pop es 141 cld 142 mov cx,0FFh 143 xor al,al 144 repne scasb 145 CE_Loop: dec di 146 cmp di,cs:CE_Start 147 je CE_Quit 148 mov al,ds:[di] 149 cmp al,'\' 150 je CE_Quit 151 cmp al,'.' 152 jne CE_Loop 153 CE_CmpLoop: lodsb 154 or al,al 155 je CE_Quit 156 scasb 157 je CE_CmpLoop 158 call Upcase 159 cmp al,es:[di-1] 160 je CE_CmpLoop 161 CE_Quit: or al,al 162 pop es di si cx ax 163 ret 164 CmpExt endp 165 166 167 GoWhere? dw G_DIRECTORY 168 FM_MainRet: push cs 169 pop ds 170 mov F_MaxLength,0 171 call ReadDir 172 BigLoop: mov ch,GetLineParams.GL_BegPrint 173 mov cl,GetLineParams.GL_Pos 174 mov di,GoWhere? 175 shl di,1 176 mov GoWhere?,G_DIRECTORY 177 call CmndAddress[di] 178 mov GetLineParams.GL_Pos,cl 179 mov GetLineParams.GL_BegPrint,ch 180 jmp BigLoop 181 182 CmndAddress dw Directory,Memory,S_PathFilter 183 184 185 186 Directory: mov F_or_M,0 187 jmp Select 188 189 Memory: mov F_or_M,1 190 jmp Select 191 192 193 S_CommandsNum = 8 194 S_ParamsStruc struc 195 S_MaxLength db ? 196 S_BegPrint db ? 197 S_Pos db ? 198 S_CX dw ? 199 S_LinesNum db ? 200 S_Buffer db ? 201 S_ParamsStruc ends 202 203 F_or_M db 0 204 db ? 205 S_ActiveFlags dw 0000000000000100b,0000000000001000b 206 S_Parameters dw DirectoryParams,MemoryParams 207 208 DirectoryParams label byte 209 F_MaxLength db 0 210 F_BegPrint db 0 211 F_Pos db 0 212 F_CX dw 72Ah 213 F_LinesNum db 17 214 FileBuffer db MAX_DIRECTORY_ENTRIES * size FileDescription dup (0) 215 FileTmpBuffer db size FileDescription dup (0) 216 217 MemoryParams label byte 218 M_MaxLength db 1 219 M_BegPrint db 0 220 M_Pos db 0 221 M_CX dw 0B02h 222 M_LinesNum db 12 223 MemoryBuffer db 1,0Fh,'',0 224 db FD_STATUS 225 dw 0,0FFFFh,0 226 db 0 227 dw 0,0 228 db MAX_MEMORY_ENTRIES * size FileDescription dup (0) 229 230 S_Commands db 'tben',18h 231 db 7,8,3,4,1,2,0Dh,0Ch 232 S_Subrt dw S_Type,S_BegAdr,S_EndAdr,S_Name,S_Enter 233 dw S_Up,S_Down,S_PgUp,S_PgDn,S_Home,S_End,S_Tab,GoAppleII 234 S_CallIfZero? db 0,0,0,0,0,0,0,0,0,0,0,0,1 235 236 Select: xor bx,bx 237 mov SHL_Flag,1 238 mov GetLineParams.GL_AllowSpc,0 239 gotoxy 2,0 240 mov cs:GetLineParams.GL_CX,cx 241 mov bl,F_or_M 242 shl bx,1 243 mov bp,S_Parameters[bx] 244 mov ax,S_ActiveFlags[bx] 245 mov ActiveFlags,ax 246 mov FkeysFlags,1111111111b 247 mov ScreenIOparams.CursorFlag,0 248 mov GetLineParams.GL_Color,0Bh 249 mov cx,ds:[bp].S_CX 250 call ReadKey 251 cmp al,7Fh 252 je SelectRet 253 mov di,offset S_Commands 254 mov cx,offset S_Subrt- offset S_Commands 255 call CalcCommand 256 jc Select 257 cmp ds:[bp].S_MaxLength,0 258 jnz S_ok1 259 test S_CallIfZero?[di],1 260 jz Select 261 S_ok1: shl di,1 262 call S_Subrt[di] 263 jnc Select 264 call GoAppleII 265 jmp Select 266 SelectRet: GetLineService _GL_CLRBUFF 267 mov F_or_M,0 268 ret 269 270 271 S_Tab: xor F_or_M,1 272 clc 273 ret 274 275 276 NameEntering db 0 277 S_NameFlags db 0,1,1,1 278 S_Name: call EnterFilename 279 clc 280 ret 281 EnterFilename: push ax bx cx dx di bp 282 mov NameEntering,1 283 push word ptr [GetKeyParams.RK_AltFlag] 284 mov bl,0Bh 285 mov GetLineParams.GL_Color,bl 286 mov GetKeyParams.RK_AltFlag,0 287 mov SHL_Flag,0 288 mov bl,ds:[bp].S_Pos 289 call CalcBuffer 290 test ds:[bp].S_Buffer[di].FileFlags,FF_DAMAGED? 291 jnz S_NameRet 292 test ds:[bp].S_Buffer[di].FileFlags,FF_MODIFYNAME? 293 jz S_NameRet 294 mov cs:GetKeyParams.RK_ErrPtr,offset SMS_EnterFilename 295 mov FkeysFlags,0000000010b 296 mov ScreenIOparams.CursorFlag,1 297 mov bl,ds:[bp].S_Pos 298 call CalcBuffer 299 lea bx,ds:[bp].S_Buffer[di].FileName 300 mov GetLineParams.GL_Buffer,bx 301 mov GetLineParams.GL_Pos,0 302 mov GetLineParams.GL_BegPrint,0 303 mov GetLineParams.GL_MaxLength,0Ch 304 mov GetLineParams.GL_MaxPrint,0Dh 305 call Seek0 306 mov GetLineParams.GL_Length,bl 307 mov ScreenIOparams.CursorLen,1 308 mov cx,ds:[bp].S_CX 309 dec ch 310 inc cl 311 mov al,80 * 2 312 mul ch 313 xor bx,bx 314 mov bl,cl 315 shl bx,1 316 add ax,bx 317 mov cx,ax 318 GetLineService _GETLINE 319 S_NameRet: pop word ptr [GetKeyParams.RK_AltFlag] 320 mov NameEntering,0 321 pop bp di dx cx bx ax 322 ret 323 324 S_PathFilter: push word ptr ds:[ScreenIOparams.CursorFlag] 325 push word ptr ds:[GetKeyParams.RK_AltFlag] 326 mov SHL_Flag,0 327 mov GetKeyParams.RK_AltFlag,0 328 mov GetLineParams.GL_AllowSpc,0 329 mov ActiveFlags,0000000000000001b 330 mov FkeysFlags,0000000010b 331 mov ScreenIOparams.CursorFlag,1 332 mov GetLineParams.GL_Buffer,offset PathFilter 333 mov GetLineParams.GL_Pos,0 334 mov GetLineParams.GL_BegPrint,0 335 mov GetLineParams.GL_MaxLength,67+20h 336 mov GetLineParams.GL_MaxPrint,35 337 mov ScreenIOparams.CursorLen,1 338 call LinkPathFilter 339 mov GetLineParams.GL_Length,bl 340 gotoxy 5,2 341 GetLineService _GETLINE 342 jc S_Path1 343 mov GoWhere?,G_DIRECTORY 344 S_Path1: call GetPathFilter 345 call ReadDir 346 pop word ptr ds:[GetKeyParams.RK_AltFlag] 347 pop word ptr ds:[ScreenIOparams.CursorFlag] 348 mov SHL_Flag,1 349 GetLineService _GL_CLRBUFF 350 clc 351 ret 352 353 S_Up: push ax 354 mov al,ds:[bp].S_Pos 355 or al,al 356 jz S_UpRet 357 dec al 358 mov ah,al 359 sub ah,ds:[bp].S_BegPrint 360 cmp ah,2 361 jae S_UpOk1 362 cmp ds:[bp].S_BegPrint,0 363 jz S_UpOk1 364 dec ds:[bp].S_BegPrint 365 inc byte ptr ds:[bp].S_CX[1] 366 S_UpOk1: dec byte ptr ds:[bp].S_CX[1] 367 S_UpRet: mov ds:[bp].S_Pos,al 368 pop ax 369 clc 370 ret 371 372 S_Down: push ax 373 mov al,ds:[bp].S_Pos 374 mov ah,ds:[bp].S_MaxLength 375 dec ah 376 cmp al,ah 377 je S_DownRet 378 inc al 379 mov ah,al 380 sub ah,ds:[bp].S_BegPrint 381 add ah,2 382 cmp ah,ds:[bp].S_LinesNum 383 jb S_DownOk1 384 mov ah,ds:[bp].S_BegPrint 385 add ah,ds:[bp].S_LinesNum 386 jc S_DownOk1 387 cmp ah,ds:[bp].S_MaxLength 388 jae S_DownOk1 389 inc ds:[bp].S_BegPrint 390 dec byte ptr ds:[bp].S_CX[1] 391 S_DownOk1: inc byte ptr ds:[bp].S_CX[1] 392 S_DownRet: mov ds:[bp].S_Pos,al 393 pop ax 394 clc 395 ret 396 397 S_PgUp: push cx 398 xor ch,ch 399 mov cl,ds:[bp].S_LinesNum 400 dec cx 401 S_PgUpLoop: call S_Up 402 loop S_PgUpLoop 403 pop cx 404 clc 405 ret 406 407 S_PgDn: push cx 408 xor ch,ch 409 mov cl,ds:[bp].S_LinesNum 410 dec cx 411 S_PgDnLoop: call S_Down 412 loop S_PgDnLoop 413 pop cx 414 clc 415 ret 416 417 S_Home: push cx 418 mov cx,MAX_DIRECTORY_ENTRIES 419 dec cx 420 S_HomeLoop: call S_Up 421 loop S_HomeLoop 422 pop cx 423 clc 424 ret 425 426 S_End: push cx 427 mov cx,MAX_DIRECTORY_ENTRIES 428 dec cx 429 S_EndLoop: call S_Down 430 loop S_EndLoop 431 pop cx 432 clc 433 ret 434 435 S_TypeNewVal db FD_Directory,FD_MSdos,FD_Code,FD_Status 436 S_TypeProcs dw STP_Directory,STP_Code,STP_Status,STP_MSdos 437 S_Type: push ax bx di 438 mov bl,ds:[bp].S_Pos 439 call CalcBuffer 440 test ds:[bp].S_Buffer[di].FileFlags,FF_DAMAGED? 441 jnz S_TypeRet 442 test ds:[bp].S_Buffer[di].FileFlags,FF_MODIFYTYPE? 443 jz S_TypeRet 444 xor bx,bx 445 mov bl,ds:[bp].S_Buffer[di].FileType 446 mov bl,S_TypeNewVal[bx] 447 mov ds:[bp].S_Buffer[di].FileType,bl 448 shl bx,1 449 cmp F_or_M,0 450 mov al,FF_MODIFYNAME? 451 jnz S_TypeCallProc 452 call FU_Procs[bx] 453 mov al,0 454 S_TypeCallProc: call S_TypeProcs[bx] 455 S_TypeRet: pop di bx ax 456 ret 457 458 STP_Directory: ret 459 460 STP_Code: or al,FF_SHOWADDR? or FF_MODIFYADDR? or FF_MODIFYTYPE? 461 mov ds:[bp].S_Buffer[di].FileFlags,al 462 ret 463 464 STP_Status: or al,FF_MODIFYTYPE? 465 mov ds:[bp].S_Buffer[di].FileFlags,al 466 ret 467 468 STP_MSdos: or al,FF_SHOWADDR? or FF_MODIFYADDR? or FF_MODIFYTYPE? 469 mov ds:[bp].S_Buffer[di].FileFlags,al 470 ret 471 472 473 474 475 S_BegAdrX db 65,25 476 S_BegAdr: push ax bx cx dx di 477 mov SHL_Flag,0 478 mov bl,ds:[bp].S_Pos 479 call CalcBuffer 480 test ds:[bp].S_Buffer[di].FileFlags,FF_MODIFYADDR? 481 jz S_BegAdrRet 482 test ds:[bp].S_Buffer[di].FileFlags,FF_DAMAGED? 483 jnz S_BegAdrRet 484 mov cx,ds:[bp].S_CX 485 xor bx,bx 486 mov bl,F_or_M 487 mov cl,S_BegAdrX[bx] 488 mov dx,ds:[bp].S_Buffer[di].FileEndAdr 489 sub dx,ds:[bp].S_Buffer[di].FileBegAdr 490 mov bx,0FFFFh 491 sub bx,dx 492 call GetAddress 493 jc S_BegAdrRet 494 cmp ax,bx 495 jna S_BegAdrOK 496 mov dx,0FFFFh 497 sub dx,ax 498 S_BegAdrOK: mov ds:[bp].S_Buffer[di].FileBegAdr,ax 499 add ax,dx 500 mov ds:[bp].S_Buffer[di].FileEndAdr,ax 501 S_BegAdrRet: pop di dx cx bx ax 502 clc 503 ret 504 505 S_EndAdrX db 72,32 506 S_EndAdr: push ax bx cx di 507 mov SHL_Flag,0 508 mov bl,ds:[bp].S_Pos 509 call CalcBuffer 510 test ds:[bp].S_Buffer[di].FileFlags,FF_DAMAGED? 511 jnz S_EndAdrRet 512 test ds:[bp].S_Buffer[di].FileFlags,FF_MODIFYADDR? 513 jz S_EndAdrRet 514 mov cx,ds:[bp].S_CX 515 xor bx,bx 516 mov bl,F_or_M 517 mov cl,S_EndAdrX[bx] 518 call GetAddress 519 jc S_EndAdrRet 520 cmp ax,ds:[bp].S_Buffer[di].FileBegAdr 521 jb S_EndAdrRet 522 cmp ds:[bp].S_Buffer[di].FileBegAdr,0 523 jnz S_EndAdrOk 524 S_EndAdrOk: mov ds:[bp].S_Buffer[di].FileEndAdr,ax 525 S_EndAdrRet: pop di cx bx ax 526 clc 527 ret 528 529 S_EnterErrorFL db 0 530 S_EnterProcs dw S_EnterF,S_EnterM 531 S_Enter: push ax bx cx dx si di ds es 532 cmp ds:[bp].S_MaxLength,0 533 jz S_EnterRet 534 mov bl,ds:[bp].S_Pos 535 call CalcBuffer 536 xor bx,bx 537 mov bl,F_or_M 538 shl bx,1 539 call S_EnterProcs[bx] 540 S_EnterRet: pop es ds di si dx cx bx ax 541 clc 542 ret 543 544 SEF_Procs dw SEF_Directory,SEF_Code,SEF_Status,SEF_Fragment 545 S_EnterF: mov bl,DirectoryParams.S_Pos 546 call CalcBuffer 547 xor bx,bx 548 mov bl,FileBuffer[di].FileType 549 mov si,bx 550 mov bx,di 551 call LinkName 552 shl si,1 553 mov dx,offset Path 554 call SEF_Procs[si] 555 call UnLinkName 556 ret 557 558 SEF_Directory: mov bx,LN_BX 559 mov byte ptr Path[bx],'\' 560 mov byte ptr Path[bx+1],0 561 call ReadDir 562 ret 563 564 SEF_Code: mov RF_ErrPtr,offset SMS_ErrFileLoad 565 mov RF_MesPtr,offset SMS_FileLoaded 566 call OpenReadFile 567 jc SEF_CodeRet 568 mov cx,4 569 call ReadFile 570 SEF_CodeRet: ret 571 572 SEF_Status: push es 573 call OpenReadFile 574 jc SEF_StatusRet 575 call FloppyLoad 576 call DRAMLoad 577 mov RF_ErrPtr,offset SMS_ErrStatLoad 578 mov RF_MesPtr,offset SMS_StatLoaded 579 mov cx,size RW_Header 580 call ReadFile 581 mov si,offset RW_Header 582 cld 583 assume es:TaskControl 584 mov ax,TaskControl 585 mov es,ax 586 lodsb 587 mov es:r_A,al 588 lodsb 589 mov es:r_X,al 590 lodsb 591 mov es:r_Y,al 592 lodsb 593 mov es:r_S,al 594 lodsb 595 mov es:r_P,al 596 lodsw 597 mov es:r_PC,ax 598 599 mov ax,Peripher 600 mov es,ax 601 assume es:Peripher 602 lodsb 603 mov es:FLAGS,al 604 lodsw 605 mov es:BufferPTR,ax 606 lodsw 607 mov es:WriteCNT,ax 608 lodsb 609 mov es:WriteREG,al 610 mov di,offset CurrentDrive 611 mov cx,5 ; non-dos fields size 612 rep movsb 613 mov di,offset OtherDrive 614 mov cx,5 ; non-dos fields size 615 rep movsb 616 617 mov ax,Emulate 618 mov es,ax 619 assume es:Emulate 620 lodsb 621 mov es:C050,al 622 lodsb 623 mov es:C080,al 624 625 SEF_StatusRet: pop es 626 ret 627 assume es:Emulate 628 629 SEF_Fragment: mov RF_ErrPtr,offset SMS_ErrFileLoad 630 mov RF_MesPtr,offset SMS_FileLoaded 631 xor cx,cx 632 call OpenReadFile 633 jc SEF_FrgRet 634 call ReadFile 635 SEF_FrgRet: ret 636 637 638 SEM_SVD db '.SVD',0 639 SEM_APL db '.APL',0 640 SEM_Procs dw SEM_Directory,SEM_Code,SEM_Status,SEM_Fragment 641 SEM_NewFile db ? 642 S_EnterM: mov bl,MemoryParams.S_Pos 643 call CalcBuffer 644 cmp MemoryBuffer[di].FileName[0],1 645 mov SEM_NewFile,0 646 jne SEM_NotNewFile 647 mov SEM_NewFile,1 648 dec MemoryBuffer[di].FileName[0] 649 mov MemoryBuffer[di].FileFlags,FF_MODIFYNAME? 650 call EnterFilename 651 push di 652 lea di,MemoryBuffer[di].FileName 653 jnc SEM_ok1 654 push es 655 mov si,offset FL_NewFile 656 push ds 657 pop es 658 mov cx,13 659 rep movsb 660 pop es di 661 ret 662 SEM_ok1: mov si,offset SEM_SVD 663 call AddExt 664 mov cl,FD_STATUS 665 mov ch,FF_MODIFYNAME? or FF_MODIFYTYPE? 666 jnc SEM_ok2 667 or ch,FF_MODIFYADDR? or FF_SHOWADDR? 668 mov si,offset SEM_APL 669 call CmpExt 670 mov cl,FD_CODE 671 je SEM_ok2 672 mov cl,FD_MSDOS 673 SEM_ok2: pop di 674 mov MemoryBuffer[di].FileFlags,ch 675 mov MemoryBuffer[di].FileType,cl 676 cmp cl,FD_STATUS 677 je SEM_NotNewFile 678 call S_BegAdr 679 call S_EndAdr 680 SEM_NotNewFile: xor bx,bx 681 mov bl,MemoryBuffer[di].FileType 682 mov si,bx 683 mov bx,di 684 call LinkName 685 shl si,1 686 mov dx,offset Path 687 call SEM_Procs[si] 688 call UnlinkName 689 cmp SEM_NewFile,0 690 jz SEM_Ret 691 lea si,MemoryBuffer[di].FileName 692 mov cl,MemoryBuffer[di].FileType 693 mov ch,MemoryBuffer[di].FileFlags 694 mov ax,MemoryBuffer[di].FileBegAdr 695 mov bx,MemoryBuffer[di].FileEndAdr 696 sub bx,ax 697 inc bx 698 call FileIsLoaded 699 SEM_Ret: ret 700 701 SEM_Directory: clc 702 ret 703 704 SEM_Code: mov WF_ErrPtr,offset SMS_ErrFileSave 705 mov WF_MesPtr,offset SMS_FileSaved 706 mov ax,MemoryBuffer[di].FileBegAdr 707 mov word ptr RW_Header[0],ax 708 mov ax,MemoryBuffer[di].FileEndAdr 709 sub ax,word ptr RW_Header[0] 710 inc ax 711 mov word ptr RW_Header[2],ax 712 call OpenFileWrite 713 jc SEM_CodeRet 714 mov cx,4 715 call WriteFile 716 SEM_CodeRet: ret 717 718 SEM_Status: mov WF_ErrPtr,offset SMS_ErrStatSave 719 mov WF_MesPtr,offset SMS_StatSaved 720 call OpenFileWrite 721 jc SEM_StatusRet 722 call FloppySave 723 call DRAMSave 724 push si di ds es 725 mov di,offset RW_Header 726 cld 727 push cs 728 pop es 729 assume ds:TaskControl 730 mov ax,TaskControl 731 mov ds,ax 732 mov al,ds:r_A 733 stosb 734 mov al,ds:r_X 735 stosb 736 mov al,ds:r_Y 737 stosb 738 mov al,ds:r_S 739 stosb 740 mov al,ds:r_P 741 stosb 742 mov ax,ds:r_PC 743 stosw 744 745 mov ax,Peripher 746 mov ds,ax 747 assume ds:Peripher 748 mov al,FLAGS 749 stosb 750 mov ax,BufferPTR 751 stosw 752 mov ax,WriteCNT 753 stosw 754 mov al,WriteREG 755 stosb 756 mov si,offset CurrentDrive 757 mov cx,5 ; non-dos fields size 758 rep movsb 759 mov si,offset OtherDrive 760 mov cx,5 ; non-dos fields size 761 rep movsb 762 763 mov ax,Emulate 764 mov ds,ax 765 assume ds:Emulate 766 mov al,ds:C050 767 stosb 768 mov al,C080 769 stosb 770 771 pop es ds di si 772 assume ds:FM 773 mov cx,size RW_Header 774 call WriteFile 775 SEM_StatusRet: ret 776 assume ds:FM 777 778 SEM_Fragment: mov WF_ErrPtr,offset SMS_ErrFileSave 779 mov WF_MesPtr,offset SMS_FileSaved 780 call OpenFileWrite 781 jc SEM_FragmentRet 782 xor cx,cx 783 call WriteFile 784 SEM_FragmentRet: ret 785 786 787 788 LinkPathFilter: push ax si di es 789 xor bx,bx 790 push cs 791 pop es 792 mov si,offset Path 793 mov di,offset PathFilter 794 cld 795 LPF_Loop1: lodsb 796 or al,al 797 jz LPF_Filter 798 stosb 799 inc bx 800 jmp LPF_Loop1 801 LPF_Filter: mov si,offset Filter 802 LPF_Loop2: lodsb 803 stosb 804 inc bx 805 or al,al 806 jnz LPF_Loop2 807 dec bx 808 pop es di si ax 809 ret 810 811 812 813 GetPathFilter: push ax cx dx si di es 814 push cs 815 pop es 816 xor al,al 817 mov di,offset PathFilter 818 cld 819 mov cx,20h+67 820 repne scasb 821 dec di 822 mov si,di 823 std 824 GPF_Loop1: cmp si,offset PathFilter 825 jna GPF_NoPath 826 lodsb 827 cmp al,'\' 828 jne GPF_Loop1 829 add si,2 830 mov dx,si 831 mov si,offset PathFilter 832 mov di,offset Path 833 cld 834 GPF_Loop2: lodsb 835 stosb 836 cmp si,dx 837 jna GPF_Loop2 838 dec si 839 dec di 840 xor al,al 841 stosb 842 mov Path[67],0 843 GPF_NoPath: cld 844 mov di,offset Filter 845 xor cx,cx 846 GPF_Loop3: lodsb 847 stosb 848 cmp cx,20h 849 je GPF_LongFilt 850 inc cx 851 or al,al 852 jnz GPF_Loop3 853 cmp cx,1 854 je GPF_NoFilter 855 GPF_Ret: pop es di si dx cx ax 856 ret 857 858 GPF_LongFilt: dec di 859 xor ax,ax 860 stosb 861 jmp GPF_Ret 862 863 GPF_DefaultFilt db '*.APL,*.ROM,*.SVD',0 864 GPF_NoFilter: mov si,offset PathFilter 865 mov di,offset Path 866 cld 867 GPF_Loop4: lodsb 868 stosb 869 or al,al 870 jnz GPF_Loop4 871 mov si,offset GPF_DefaultFilt 872 mov di,offset Filter 873 mov cx,offset GPF_NoFilter - offset GPF_DefaultFilt 874 rep movsb 875 jmp GPF_Ret 876 877 878 879 Seek0: push si 880 xor si,si 881 Seek0_Loop: cmp byte ptr ds:[bx][si],0 882 jz Seek0_Done 883 inc si 884 jmp Seek0_Loop 885 Seek0_Done: mov bx,si 886 pop si 887 ret 888 889 890 ; Entry: 891 ; DS:SI -> Name,0 892 ; AX - Begin Address 893 ; BX - Length 894 ; CL - Type 895 ; CH - Flags 896 FIL_Buffer db 80 dup (0) 897 FileIsLoaded proc far 898 push ax bx cx dx si di bp ds es 899 push ax 900 mov di,offset FIL_Buffer 901 push cs 902 pop es 903 mov ah,60h 904 int 21h 905 mov si,di 906 push cs 907 pop ds 908 lea di,FileTmpBuffer.FileName 909 mov dx,di 910 FIL_Loop: lodsb 911 cmp al,':' 912 je FIL_Hop1 913 cmp al,'\' 914 jne FIL_ok1 915 FIL_Hop1: mov di,dx 916 jmp FIL_Loop 917 FIL_ok1: stosb 918 or al,al 919 jnz FIL_Loop 920 pop ax 921 mov FileTmpBuffer.FileBegAdr,ax 922 mov word ptr FileTmpBuffer.File1st4bytes[0],ax 923 mov dx,bx 924 or bx,bx 925 jnz FIL_ok2 926 dec dx 927 FIL_ok2: mov word ptr FileTmpBuffer.File1st4bytes[2],dx 928 add bx,ax 929 dec bx 930 mov FileTmpBuffer.FileEndAdr,bx 931 mov FileTmpBuffer.FileType,cl 932 mov FileTmpBuffer.FileFlags,ch 933 mov bx,MAX_DIRECTORY_ENTRIES 934 mov ax,size FileDescription 935 mul bx 936 mov di,ax 937 call FileLoaded 938 pop es ds bp di si dx cx bx ax 939 ret 940 FileIsLoaded endp 941 942 943 944 FL_NewFile db 1,0Fh,'',0 945 db FD_STATUS 946 dw 0,0FFFFh,0 947 db 0 948 dw 0,0 949 FileLoaded: push ax bx dx si di bp 950 mov bp,offset MemoryParams 951 mov si,di 952 mov bl,M_MaxLength 953 dec bl 954 cmp M_MaxLength,MAX_MEMORY_ENTRIES 955 jae FL_NoInc 956 inc M_MaxLength 957 FL_NoInc: call CalcBuffer 958 mov bx,size FileDescription 959 dec bx 960 FL_Loop0: mov al,FileBuffer[si][bx] 961 mov MemoryBuffer[di][bx],al 962 mov al,FL_NewFile[bx] 963 mov MemoryBuffer[size FileDescription+di][bx],al 964 dec bx 965 jns FL_Loop0 966 or MemoryBuffer[di].FileFlags,FF_MODIFYNAME? 967 xor si,si 968 mov bx,1 969 FL_Loop1: cmp si,di 970 je FL_Next1 971 mov ax,MemoryBuffer[di].FileBegAdr 972 cmp ax,MemoryBuffer[si].FileEndAdr 973 ja FL_Next1 974 mov ax,MemoryBuffer[di].FileEndAdr 975 cmp ax,MemoryBuffer[si].FileBegAdr 976 jb FL_Next1 977 cmp ax,MemoryBuffer[si].FileEndAdr 978 jb FL_Damaged 979 mov ax,MemoryBuffer[di].FileBegAdr 980 cmp ax,MemoryBuffer[si].FileBegAdr 981 ja FL_Damaged 982 dec bx 983 call Delete 984 inc bx 985 sub di,size FileDescription 986 jmp FL_Next2 987 FL_Damaged: or MemoryBuffer[si].FileFlags,FF_DAMAGED? 988 FL_Next1: add si,size FileDescription 989 inc bl 990 FL_Next2: cmp bl,M_MaxLength 991 jb FL_Loop1 992 mov bp,offset MemoryParams 993 call S_End 994 call S_Up 995 pop bp di si dx bx ax 996 ret 997 998 999 Delete: push ax cx si di es 1000 mov cl,ds:[bp].S_MaxLength 1001 cmp cl,1 1002 jz DelRet 1003 sub cl,bl 1004 dec ds:[bp].S_MaxLength 1005 cmp cl,1 1006 je DelRet 1007 mov al,Size FileDescription 1008 mul cl 1009 mov cx,ax 1010 call CalcBuffer 1011 lea si,ds:[bp].S_Buffer 1012 add di,si 1013 mov si,di 1014 add si,size FileDescription 1015 push cs 1016 pop es 1017 cld 1018 rep movsb 1019 DelRet: mov al,ds:[bp].S_Pos 1020 cmp al,ds:[bp].S_MaxLength 1021 jb DelRetOk 1022 call S_Up 1023 DelRetOk: pop es di si cx ax 1024 ret 1025 1026 1027 GA_Buffer db 5 dup (?) 1028 GetAddress: push word ptr [GetKeyParams.RK_AltFlag] 1029 mov GetKeyParams.RK_AltFlag,0 1030 push bx bp cx 1031 xor bx,bx 1032 mov bl,F_or_M 1033 mov bl,0Bh 1034 mov GetLineParams.GL_Color,bl 1035 mov FkeysFlags,0000000010b 1036 mov ScreenIOparams.CursorFlag,1 1037 mov GetLineParams.GL_Buffer,offset GA_Buffer 1038 mov GetLineParams.GL_MaxLength,4 1039 mov GetLineParams.GL_MaxPrint,4 1040 mov ScreenIOparams.CursorLen,1 1041 GetLineService _GL_ClrBuff 1042 pop cx 1043 push cx 1044 dec ch 1045 mov al,80 * 2 1046 mul ch 1047 xor bx,bx 1048 mov bl,cl 1049 shl bx,1 1050 add ax,bx 1051 mov cx,ax 1052 GetLineService _GETLINE 1053 jc GetAddressRet 1054 xor cx,cx 1055 call GetAddr 1056 GetAddressRet: pop cx bp bx 1057 pop word ptr [GetKeyParams.RK_AltFlag] 1058 ret 1059 1060 1061 GA_Delimiters db ',/',0 1062 GA_DelimitersC = 3 1063 GetAddr: push bx bp 1064 xor bx,bx 1065 GetLineService _GL_GetSymb 1066 or al,al 1067 jz GA_error 1068 dec cl 1069 GA_Loop: GetLineService _GL_GetSymb 1070 push cx di 1071 mov di,offset GA_Delimiters 1072 mov cx,GA_DelimitersC 1073 call CalcCommand 1074 pop di cx 1075 jnc GA_Exit 1076 call Upcase 1077 cmp al,'0' 1078 jb GA_error 1079 cmp al,'9' 1080 jbe GA_Anumb 1081 cmp al,'a' 1082 jb GA_error 1083 cmp al,'f' 1084 ja GA_error 1085 sub al,27h 1086 GA_Anumb: sub al,'0' 1087 shl bx,4 1088 or bl,al 1089 jmp GA_Loop 1090 GA_error: stc 1091 jmp GA_Ret 1092 GA_Exit: mov ax,bx 1093 clc 1094 GA_Ret: pop bp bx 1095 ret 1096 1097 1098 RF_ErrPtr dw ? 1099 RF_MesPtr dw ? 1100 RW_Header db 100h dup (?) 1101 1102 OpenReadFile: push ax 1103 call Prepare4DOS 1104 mov ax,3D00h 1105 int 21h 1106 mov bx,ax 1107 call SOD4eraperP 1108 pop ax 1109 ret 1110 1111 ReadFile: push ax bx cx dx ds 1112 call Prepare4DOS 1113 mov ah,3Fh 1114 mov dx,offset RW_Header 1115 or cx,cx 1116 jz RF_NoHeader 1117 int 21h 1118 cmp ax,cx 1119 jne RF_Error 1120 jc RF_Error 1121 RF_NoHeader: mov cx,FileBuffer[di].FileEndAdr 1122 mov dx,FileBuffer[di].FileBegAdr 1123 sub cx,dx 1124 mov ax,Apple 1125 mov ds,ax 1126 mov ah,3Fh 1127 inc cx 1128 jnz RF_NoLong 1129 inc cl 1130 mov ah,3Fh 1131 int 21h 1132 jc RF_Error 1133 mov cx,0FFFFh 1134 inc dx 1135 RF_NoLong: mov ah,3Fh 1136 int 21h 1137 jc RF_Error 1138 cmp cx,ax 1139 jz RF_NoErr1 1140 add dx,ax 1141 dec dx 1142 mov cs:FileBuffer[di].FileEndAdr,dx 1143 jmp RF_Error 1144 RF_NoErr1: mov ax,cs:RF_MesPtr 1145 mov cs:GetKeyParams.RK_ErrPtr,ax 1146 mov cs:S_EnterErrorFL,0 1147 and cs:FileBuffer[di].FileFlags,not FF_DAMAGED? 1148 RF_ErrorRet: mov ah,3Eh 1149 int 21h 1150 pop ds 1151 call SOD4eraperP 1152 call FileLoaded 1153 pop dx cx bx ax 1154 ret 1155 RF_Error: mov ax,cs:RF_ErrPtr 1156 mov cs:GetKeyParams.RK_ErrPtr,ax 1157 mov cs:S_EnterErrorFL,1 1158 or cs:FileBuffer[di].FileFlags,FF_DAMAGED? 1159 jmp RF_ErrorRet 1160 1161 1162 WF_ErrPtr dw ? 1163 WF_MesPtr dw ? 1164 1165 ; Create (rewrite) a file. Set CF if an error occured. Exit: BX -- file handle 1166 1167 OpenFileWrite: push ax cx dx ds 1168 test MemoryBuffer[di].FileFlags,FF_DAMAGED? 1169 jz OFW_1 1170 OFW_GetKeyLoop1: mov SC1_Flag,1 1171 mov SHL_Flag,0 1172 mov ActiveFlags,0000000000010000b 1173 call ReadKey 1174 mov SC1_Flag,0 1175 mov SHL_Flag,1 1176 cmp al,0Ch 1177 stc 1178 je OFW_Ret 1179 or al,20h 1180 cmp al,'n' 1181 stc 1182 je OFW_Ret 1183 cmp al,'y' 1184 jne OFW_GetKeyLoop1 1185 and MemoryBuffer[di].FileFlags,not FF_DAMAGED? 1186 OFW_1: call Prepare4DOS 1187 xor cx,cx 1188 mov ah,5Bh 1189 int 21h 1190 jnc OFW_NoError 1191 cmp ax,50h 1192 jne OFW_Error 1193 call SOD4eraperP 1194 OFW_GetKeyLoop: mov SC_Flag,1 1195 mov SHL_Flag,0 1196 mov ActiveFlags,0000000000010000b 1197 call ReadKey 1198 mov SC_Flag,0 1199 mov SHL_Flag,1 1200 cmp al,0Ch 1201 stc 1202 je OFW_Ret 1203 or al,20h 1204 cmp al,'n' 1205 stc 1206 je OFW_Ret 1207 cmp al,'y' 1208 jne OFW_GetKeyLoop 1209 call Prepare4DOS 1210 xor cx,cx 1211 mov ax,3C01h 1212 int 21h 1213 jc OFW_Error 1214 OFW_NoError: mov bx,ax 1215 call SOD4eraperP 1216 OFW_Ret: pop ds dx cx ax 1217 ret 1218 OFW_Error: mov ax,cs:WF_ErrPtr 1219 mov cs:GetKeyParams.RK_ErrPtr,ax 1220 mov cs:S_EnterErrorFL,1 1221 jmp OFW_NoError 1222 1223 1224 ; Entry: BX -- file handle ... 1225 1226 WriteFile: push ax bx cx dx ds 1227 call Prepare4DOS 1228 mov ah,40h 1229 mov dx,offset RW_Header 1230 or cx,cx 1231 jz WF_NoHeader 1232 int 21h 1233 jc WF_Error 1234 cmp ax,cx 1235 jne WF_Error 1236 WF_NoHeader: mov cx,MemoryBuffer[di].FileEndAdr 1237 mov dx,MemoryBuffer[di].FileBegAdr 1238 sub cx,dx 1239 mov ax,Apple 1240 mov ds,ax 1241 mov ah,40h 1242 inc cx 1243 jnz WF_NoLong 1244 inc cl 1245 mov ah,40h 1246 int 21h 1247 jc WF_Error 1248 mov cx,0FFFFh 1249 inc dx 1250 WF_NoLong: mov ah,40h 1251 int 21h 1252 jc WF_Error 1253 cmp ax,cx 1254 jne WF_Error 1255 mov ax,cs:WF_MesPtr 1256 mov cs:GetKeyParams.RK_ErrPtr,ax 1257 mov cs:S_EnterErrorFL,0 1258 WF_Ret: mov ah,3Eh 1259 int 21h 1260 call SOD4eraperP 1261 call UnLinkName 1262 pop ds dx cx bx ax 1263 ret 1264 WF_Error: mov ax,cs:WF_ErrPtr 1265 mov cs:GetKeyParams.RK_ErrPtr,ax 1266 mov cs:S_EnterErrorFL,1 1267 jmp WF_Ret 1268 1269 1270 1271 ; -- Read Directory ------------------ 1272 1273 RD_GetDirs? db 1 1274 Path db '.\',66 dup (0) ; Current Path 1275 Filter db '*.APL,*.ROM,*.SVD',020h dup (0) ; Scan Filter 1276 PathFilter db 68+20h dup (0) ; Path&Filter 1277 WildCard db 0Dh dup (0) ; Temp 1278 WC_AnyFile db '*.*',0 ; For SubDirs scanning 1279 1280 BufPtr dw 0 1281 RD_0OfsSvd dw 0 1282 DTA DTA_S <0,0,0,0,0,0> 1283 1284 ReadDirectory proc near 1285 push ax bx cx dx si di es 1286 call Prepare4DOS 1287 mov si,offset Path 1288 mov di,si 1289 push ds 1290 pop es 1291 mov ah,60h 1292 int 21h 1293 mov dx,offset DTA 1294 mov ah,1Ah 1295 int 21h 1296 1297 xor bx,bx 1298 RD_SearchFor0: cmp Path[bx],0 1299 jz RD_0Found 1300 inc bx 1301 jmp RD_SearchFor0 1302 RD_0Found: or bx,bx 1303 jz RD_PathOK 1304 cmp Path[bx-1],'\' 1305 je RD_PathOK 1306 mov Path[bx],'\' 1307 inc bx 1308 mov Path[bx],0 1309 RD_PathOK: xor si,si 1310 mov RD_0OfsSvd,bx 1311 1312 cmp RD_GetDirs?,0 1313 jz RD_GetFiles 1314 1315 RD_CopyWC1: mov al,WC_AnyFile[si] 1316 mov Path[bx],al 1317 inc si 1318 inc bx 1319 cmp al,0 1320 jnz RD_CopyWC1 1321 mov bx,BufPtr 1322 mov dx,offset Path 1323 mov cx,FA_DIRECTORY 1324 FindFirst 1325 jc RD_GetFiles 1326 RD_GetDirLoop: test DTA.Attributes,FA_DIRECTORY 1327 jz RD_GD_Next 1328 cmp F_MaxLength,0FFh 1329 je RD_NoMoreFiles 1330 call RD_PutFile 1331 inc F_MaxLength 1332 add bx,size FileDescription 1333 RD_GD_Next: FindNext 1334 jnc RD_GetDirLoop 1335 mov BufPtr,bx 1336 1337 RD_GetFiles: mov bx,RD_0OfsSvd 1338 xor si,si 1339 RD_CopyWC2: mov al,WildCard[si] 1340 mov Path[bx],al 1341 inc si 1342 inc bx 1343 cmp al,0 1344 jnz RD_CopyWC2 1345 mov bx,BufPtr 1346 mov dx,offset Path 1347 mov cx,FA_ARCHIVE 1348 FindFirst 1349 jc RD_NoMoreFiles 1350 RD_GetFilesLoop: cmp F_MaxLength,0FFh 1351 je RD_NoMoreFiles 1352 call RD_PutFile 1353 inc F_MaxLength 1354 add bx,size FileDescription 1355 FindNext 1356 jnc RD_GetFilesLoop 1357 1358 RD_NoMoreFiles: mov si,RD_0OfsSvd 1359 mov byte ptr Path[si],0 1360 mov BufPtr,bx 1361 call SOD4eraperP 1362 pop es di si dx cx bx ax 1363 ret 1364 ReadDirectory endp 1365 1366 1367 1368 PF_FileExts db 'FRGAPLROMSVD' 1369 PF_FileTypes db FD_MSdos,FD_Code,FD_Code,FD_Status 1370 PF_Addr dw PF_Directory,PF_Code,PF_Status,PF_MSdos 1371 PF_NameLength dw ? 1372 RD_PutFile proc near 1373 push ax cx dx si di bp es 1374 xor si,si 1375 PF_GetNameLoop: mov al,DTA.FileSpec[si] 1376 mov FileBuffer[bx].FileName[si],al 1377 inc si 1378 or al,al 1379 jnz PF_GetNameLoop 1380 mov PF_NameLength,si 1381 1382 or bx,bx 1383 jz PF_Cont1 1384 xor bp,bp 1385 PF_Cmp0: xor di,di 1386 PF_Cmp1: mov al,ds:FileBuffer[bp].FileName[di] 1387 cmp al,FileBuffer[bx].FileName[di] 1388 jne PF_NotMatch 1389 inc di 1390 or al,al 1391 jnz PF_Cmp1 1392 PF_Error: sub bx,size FileDescription 1393 dec F_MaxLength 1394 jmp PF_Ret 1395 PF_NotMatch: add bp,size FileDescription 1396 cmp bp,bx 1397 jne PF_Cmp0 1398 1399 PF_Cont1: mov FileBuffer[bx].FileFlags,0 1400 test DTA.Attributes,FA_DIRECTORY 1401 jz PF_NotDir 1402 mov FileBuffer[bx].FileType,FD_DIRECTORY 1403 jmp PF_Ret 1404 1405 PF_NotDir: mov ax,word ptr DTA.FileSize 1406 cmp word ptr DTA.FileSize[2],0 1407 jz PF_NotBig 1408 mov ax,0FFFFh 1409 PF_NotBig: mov FileBuffer[bx].FileLength,ax 1410 push cs 1411 pop es 1412 cld 1413 lea di,FileBuffer[bx].FileName 1414 inc di 1415 mov al,'.' 1416 mov cx,PF_NameLength 1417 repne scasb 1418 xor dl,dl 1419 jcxz PF_PokeType 1420 mov bp,di 1421 mov si,offset PF_FileExts 1422 mov dh,4 1423 PF_CmpExtLoop: mov di,bp 1424 mov cx,3 1425 repe cmpsb 1426 je PF_PokeType 1427 PF_3: inc si 1428 loop PF_3 1429 inc dl 1430 dec dh 1431 jnz PF_CmpExtLoop 1432 xor dl,dl 1433 PF_PokeType: xor dh,dh 1434 mov di,dx 1435 xor ax,ax 1436 mov al,PF_FileTypes[di] 1437 mov FileBuffer[bx].FileType,al 1438 mov di,ax 1439 mov si,bx 1440 mov bp,offset DirectoryParams 1441 call LinkName 1442 mov dx,offset Path 1443 mov ax,3D00h 1444 int 21h 1445 call UnLinkName 1446 jc PF_Ret1 1447 lea dx,FileBuffer[si].File1st4bytes 1448 mov cx,4 1449 mov bx,ax 1450 mov ah,3Fh 1451 int 21h 1452 mov ah,3Eh 1453 int 21h 1454 shl di,1 1455 call PF_Addr[di] 1456 PF_Ret1: mov bx,si 1457 PF_Ret: pop es bp di si dx cx ax 1458 ret 1459 RD_PutFile endp 1460 1461 PF_Directory: mov FileBuffer[si].FileFlags,0 1462 ret 1463 1464 PF_Code: mov FileBuffer[si].FileFlags,FF_SHOWADDR? or FF_MODIFYADDR? or FF_MODIFYTYPE? 1465 mov ax,word ptr FileBuffer[si].File1st4bytes 1466 mov FileBuffer[si].FileBegAdr,ax 1467 mov ax,word ptr FileBuffer[si].File1st4bytes[2] 1468 add ax,FileBuffer[si].FileBegAdr 1469 jnc PF_Code_ok 1470 xor ax,ax 1471 PF_Code_ok: dec ax 1472 mov FileBuffer[si].FileEndAdr,ax 1473 ret 1474 1475 PF_Status: mov FileBuffer[si].FileFlags,FF_MODIFYTYPE? 1476 xor ax,ax 1477 mov FileBuffer[si].FileBegAdr,ax 1478 dec ax 1479 mov FileBuffer[si].FileEndAdr,ax 1480 ret 1481 1482 PF_MSdos: mov FileBuffer[si].FileFlags,FF_SHOWADDR? or FF_MODIFYADDR? or FF_MODIFYTYPE? 1483 mov FileBuffer[si].FileBegAdr,800h 1484 mov ax,FileBuffer[si].FileLength 1485 add ax,800h 1486 jnc PF_MSdos_ok 1487 xor ax,ax 1488 PF_MSdos_ok: dec ax 1489 mov FileBuffer[si].FileEndAdr,ax 1490 ret 1491 1492 1493 1494 ReadDir proc near 1495 push ax si di 1496 mov GetKeyParams.RK_ErrPtr,offset SMS_ReadDir 1497 xor ax,ax 1498 mov F_MaxLength,al 1499 mov BufPtr,ax 1500 mov F_BegPrint,al 1501 mov F_Pos,al 1502 mov F_CX,72Ah 1503 mov RD_GetDirs?,1 1504 xor si,si 1505 RD1_Loop0: xor di,di 1506 RD1_Cloop: mov al,Filter[si] 1507 or al,al 1508 jz RD1_CallRead 1509 cmp al,',' 1510 je RD1_CallRead 1511 mov WildCard[di],al 1512 inc si 1513 inc di 1514 cmp di,0Ch 1515 jb RD1_Cloop 1516 RD1_CallRead: mov byte ptr WildCard[di],0 1517 call ReadDirectory 1518 mov RD_GetDirs?,0 1519 cmp byte ptr Filter[si],0 1520 jz RD1_Done 1521 RD1_Ignore: inc si 1522 cmp byte ptr Filter[si],',' 1523 je RD1_Ignore 1524 jmp RD1_Loop0 1525 RD1_Done: mov GetKeyParams.RK_ErrPtr,0 1526 pop di si ax 1527 call LinkPathFilter 1528 ret 1529 ReadDir endp 1530 1531 1532 LN_BX dw ? 1533 LinkName: pushf 1534 push ax bx si di 1535 mov si,bx 1536 lea si,ds:[bp].S_Buffer[si] 1537 mov di,cs:RD_0OfsSvd 1538 xor bx,bx 1539 LN_Loop: mov al,cs:[si].FileName[bx] 1540 mov cs:Path[di][bx],al 1541 inc bx 1542 or al,al 1543 jnz LN_Loop 1544 dec bx 1545 add bx,di 1546 mov cs:LN_BX,bx 1547 pop di si bx ax 1548 popf 1549 ret 1550 1551 1552 1553 UnLinkName: pushf 1554 push bx 1555 mov bx,cs:RD_0OfsSvd 1556 mov cs:Path[bx],0 1557 pop bx 1558 popf 1559 ret 1560 1561 1562 1563 Upcase: cmp al,'A' 1564 jb UPCSret 1565 cmp al,'Z' 1566 ja UPCSret 1567 or al,20h 1568 UPCSret: ret 1569 1570 1571 1572 CalcBuffer: push ax 1573 mov al,size FileDescription 1574 mul bl 1575 mov di,ax 1576 pop ax 1577 ret 1578 1579 1580 CalcCommand: push ax bx cx es ; Returns number of a command 1581 push cs ; Input: 1582 pop es ; di -> offset Commands 1583 call Upcase ; al -> search command 1584 cld ; cx -> commands count 1585 mov bx,di 1586 repne scasb ; Output: 1587 stc ; di <- Number of the command 1588 jne CC_end ; cf <- 1 if not found 1589 sub di,bx 1590 dec di 1591 clc 1592 CC_end: pop es cx bx ax 1593 ret 1594 1595 1596 1597 ; -- Hook INT 24h ---------------------- 1598 1599 DOSflag db 0 1600 OldFlags dw 0 1601 Prepare4DOS: saveall 1602 pushf 1603 xor ax,ax 1604 mov cs:SHL_Flag,al 1605 xchg ax,cs:ActiveFlags 1606 mov cs:OldFlags,ax 1607 mov cs:DOSflag,1 1608 call ShowAll 1609 ScreenIOservice _SHOWSCREEN 1610 call far ptr SystemTINI 1611 popf 1612 restoreall 1613 ret 1614 1615 1616 1617 ; -- Unhook INT 24h -------------------- 1618 1619 SOD4eraperP: saveall 1620 pushf 1621 mov ax,cs:OldFlags 1622 mov cs:ActiveFlags,ax 1623 mov cs:SHL_Flag,1 1624 mov ax,Emulate 1625 mov es,ax 1626 mov byte ptr [C000],0 1627 call far ptr SystemINIT 1628 mov cs:DOSflag,0 1629 popf 1630 restoreall 1631 ret 1632 1633 1634 ; ******************************************************************* 1635 ; ** ** 1636 ; ** ** 1637 ; ** S H O W A L L ** 1638 ; ** ** 1639 ; ** ** 1640 ; ******************************************************************* 1641 1642 ActiveFlags dw 0 1643 ShowAll proc far 1644 push ds bp 1645 push word ptr [ScreenIOparams.CursorColor] 1646 push word ptr [ScreenIOparams.CursorLen] 1647 push word ptr [ScreenIOparams.CursorFlag] 1648 push cs 1649 pop ds 1650 mov ScreenIOparams.CursorLen,14 ;35 1651 mov ScreenIOparams.CursorColor,10h 1652 mov ScreenIOparams.CursorFlag,1 1653 call InitFlags 1654 call ShowPathFilter 1655 call ShowDirectory 1656 call ShowMemory 1657 call ShowFuncKeys 1658 ScreenIOservice _SHOWLINE 1659 call ShowTitle 1660 call ShowMessage 1661 call ShowHilights 1662 call ShowConfirm 1663 call ShowConfirm1 1664 pop word ptr [ScreenIOparams.CursorFlag] 1665 pop word ptr [ScreenIOparams.CursorLen] 1666 pop word ptr [ScreenIOparams.CursorColor] 1667 pop bp ds 1668 ret 1669 ShowAll endp 1670 1671 1672 ; -- Draw box -------------------------- 1673 ; Entry: 1674 ; AH = Active Flag Bit 1675 ; CX = HTAB & VTAB 1676 ; BX = Offset of the strings 1677 ; DL = Length of the box line - 1 1678 ; DH = Number of lines - 1 1679 ; Destroy: 1680 ; AX,BX,CX,DX 1681 DB_CX dw ? 1682 DrawBox: push ax 1683 mov ax,cx 1684 add ax,80 * 2 1685 mov cs:DB_CX,ax 1686 pop ax 1687 test ActiveFlags,ax 1688 mov ah,7 1689 jz DB_ok1 1690 mov ah,0Eh 1691 DB_ok1: ScreenIOservice _STRINGPRINT 1692 mov bx,ScreenIOparams.SP_bx 1693 dec dh 1694 mov al,dh 1695 mov dx,cs:DB_CX 1696 DB_Loop1: mov cx,dx 1697 add dx,80 * 2 1698 ScreenIOservice _STRINGPRINT 1699 dec al 1700 jnz DB_Loop1 1701 mov cx,dx 1702 mov bx,ScreenIOparams.SP_bx 1703 ScreenIOservice _STRINGPRINT 1704 ret 1705 1706 1707 1708 IF_Procs dw IFP_F1,IFP_F2,IFP_F3,IFP_F4,IFP_F5 1709 dw IFP_F6,IFP_F7,IFP_F8,IFP_F9,IFP_F0 1710 InitFlags: push ax bx si di bp 1711 xor bx,bx 1712 mov bl,F_or_M 1713 shl bx,1 1714 mov bp,S_Parameters[bx] 1715 mov bl,ds:[bp].S_Pos 1716 call CalcBuffer 1717 xor si,si 1718 cmp DOSflag,0 1719 mov FkeysFlags,0000000000b 1720 jnz IF_Ret 1721 cmp SHL_Flag,0 1722 mov FkeysFlags,0000000010b 1723 jz IF_Ret 1724 IF_Loop: call IF_Procs[si] 1725 add si,2 1726 cmp si,20 1727 jb IF_Loop 1728 cmp ActiveFlags,0 1729 jnz IF_Ret 1730 mov FkeysFlags,0 1731 IF_Ret: pop bp di si bx ax 1732 ret 1733 1734 IFP1_fl dw 0000000000b,0000000001b,0000000001b,0000000001b 1735 IFP_F1: cmp ds:[bp].S_MaxLength,0 1736 jz IFP1_Ret 1737 xor bx,bx 1738 mov bl,ds:[bp].S_Buffer[di].FileType 1739 shl bx,1 1740 mov ax,IFP1_fl[bx] 1741 or FkeysFlags,ax 1742 IFP1_Ret: 1743 1744 IFP_F2: or FkeysFlags,0000000010b 1745 ret 1746 1747 IFP3_fl dw 0000000000b,0000000100b,0000000100b,0000000100b 1748 IFP_F3: push di 1749 cmp F_MaxLength,0 1750 jz IFP3_Ret 1751 mov bl,F_Pos 1752 call CalcBuffer 1753 xor bx,bx 1754 mov bl,FileBuffer[di].FileType 1755 shl bx,1 1756 mov ax,IFP3_fl[bx] 1757 or FkeysFlags,ax 1758 IFP3_Ret: pop di 1759 ret 1760 1761 IFP4_fl dw 0000000000b,0000001000b,0000001000b,0000001000b 1762 IFP_F4: push di 1763 mov bl,M_Pos 1764 call CalcBuffer 1765 xor bx,bx 1766 mov bl,MemoryBuffer[di].FileType 1767 shl bx,1 1768 mov ax,IFP4_fl[bx] 1769 or FkeysFlags,ax 1770 pop di 1771 ret 1772 1773 IFP_F5: push di 1774 cmp F_or_M,0 1775 jz IFP5_Ret 1776 cmp ds:[bp].S_MaxLength,1 1777 jbe IFP5_Ret 1778 mov bl,M_Pos 1779 call CalcBuffer 1780 cmp MemoryBuffer[di].FileName[0],1 1781 je IFP5_Ret 1782 or FkeysFlags,0000010000b 1783 IFP5_Ret: pop di 1784 ret 1785 1786 IFP_F6: 1787 IFP_F7: 1788 IFP_F8: 1789 IFP_F9: ret 1790 1791 IFP_F0: or FkeysFlags,1100000000b 1792 test ActiveFlags,1 1793 jz IFP0_Ret 1794 mov FkeysFlags,0000000010b 1795 IFP0_Ret: ret 1796 1797 1798 ST_Str db ' APPLER FILE MANAGER ',1,7,' ',0 1799 ShowTitle: push ax bx cx 1800 gotoxy 1,0 1801 mov ah,2Fh 1802 mov bx,offset ST_Str 1803 ScreenIOservice _STRINGPRINT 1804 gotoxy 2,0 1805 xor ah,ah 1806 ScreenIOservice _STRINGPRINT 1807 pop cx bx ax 1808 ret 1809 1810 1811 comment % 1812 push ax dx ds 1813 mov ax,2a1h 1814 mov ds,ax 1815 mov dx,24h 1816 mov ax,2509h 1817 int 21h 1818 pop ds dx ax 1819 int 3 1820 % 1821 1822 SP_Str db 'ÚPath&FilterÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ',0 1823 db '³ ³ ',0 1824 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ',0 1825 ShowPathFilter: push ax bx cx dx 1826 gotoxy 3,0 1827 mov bx,offset SP_Str 1828 mov dh,3 1829 mov ax,0000000000000001b 1830 call DrawBox 1831 mov bx,35 1832 xor al,al 1833 xchg PathFilter[bx],al 1834 mov bx,offset PathFilter 1835 mov ah,0Bh 1836 gotoxy 5,2 1837 ScreenIOservice _StringPrint 1838 mov bx,35 1839 xchg PathFilter[bx],al 1840 pop dx cx bx ax 1841 ret 1842 1843 1844 SD_Str db 'ÚDirectoryÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ',0 1845 db '³ ³ ',0 1846 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ',0 1847 1848 SD_AntetAddr dw SD_Antet1,SD_Antet1,SD_Antet1,SD_Antet1 1849 dw SD_Antet3,SD_Antet1,SD_Antet4,SD_Antet1 1850 dw SD_Antet2,SD_Antet1,SD_Antet2,SD_Antet1 1851 dw SD_Antet3,SD_Antet1,SD_Antet3,SD_Antet1 1852 dw SD_Antet5,SD_Antet1,SD_Antet5,SD_Antet1 1853 dw SD_Antet7,SD_Antet1,SD_Antet8,SD_Antet1 1854 dw SD_Antet6,SD_Antet1,SD_Antet6,SD_Antet1 1855 dw SD_Antet7,SD_Antet1,SD_Antet7,SD_Antet1 1856 1857 SD_Antet1 db 1,07h,'N', 'ame ', 'T', 'ype ', 'B', 'egin ', 'E', 'nd',0 1858 SD_Antet2 db 1,07h,'N', 'ame ',1,0Fh,'T',1,7,'ype ', 'B', 'egin ', 'E', 'nd',0 1859 SD_Antet3 db 1,07h,'N', 'ame ',1,0Fh,'T',1,7,'ype ',1,0Fh,'B',1,7,'egin ',1,0Fh,'E',1,7,'nd',0 1860 SD_Antet4 db 1,07h,'N', 'ame ', 'T', 'ype ',1,0Fh,'B',1,7,'egin ',1,0Fh,'E',1,7,'nd',0 1861 SD_Antet5 db 1,0Fh,'N',1,7,'ame ', 'T', 'ype ', 'B', 'egin ', 'E', 'nd',0 1862 SD_Antet6 db 1,0Fh,'N',1,7,'ame ',1,0Fh,'T',1,7,'ype ', 'B', 'egin ', 'E', 'nd',0 1863 SD_Antet7 db 1,0Fh,'N',1,7,'ame ',1,0Fh,'T',1,7,'ype ',1,0Fh,'B',1,7,'egin ',1,0Fh,'E',1,7,'nd',0 1864 SD_Antet8 db 1,0Fh,'N',1,7,'ame ', 'T', 'ype ',1,0Fh,'B',1,7,'egin ',1,0Fh,'E',1,7,'nd',0 1865 1866 SD_Antet0 db 1,7,'ÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄ ÄÄÄÄ',0 1867 1868 SD_NotFndMsg db 1,7,'No Matching Files in Directory',0 1869 1870 ShowDirectory: push ax bx cx dx di 1871 gotoxy 3,40 1872 mov bx,offset SD_Str 1873 mov dh,21 1874 mov ax,0000000000000100b 1875 call DrawBox 1876 cmp F_MaxLength,0 1877 jnz SD_ok2 1878 gotoxy 5,2Bh 1879 mov bx,offset SD_NotFndMsg 1880 ScreenIOservice _STRINGPRINT 1881 jmp SD_Ret 1882 SD_ok2: mov bl,F_Pos 1883 call CalcBuffer 1884 xor bx,bx 1885 mov bl,FileBuffer[di].FileFlags 1886 shl bx,1 1887 mov bx,SD_AntetAddr[bx] 1888 cmp SHL_Flag,0 1889 jz SD_ok25 1890 test ActiveFlags,0000000000000100b 1891 jnz SD_ok3 1892 SD_ok25: mov bx,offset SD_Antet1 1893 SD_ok3: gotoxy 5,2Bh 1894 ScreenIOservice _STRINGPRINT 1895 mov bx,offset SD_Antet0 1896 gotoxy 6,2Bh 1897 ScreenIOservice _STRINGPRINT 1898 mov bl,F_BegPrint 1899 mov dx,17 1900 mov di,offset FileBuffer 1901 gotoxy 7,43 1902 mov ah,7 1903 SD_Loop0: call OneFile 1904 add cx,80 * 2 1905 inc bl 1906 cmp bl,F_MaxLength 1907 je SD_Ret0 1908 dec dx 1909 jnz SD_Loop0 1910 SD_Ret0: mov cx,F_CX 1911 ScreenIOservice _SHOWCURSOR 1912 SD_Ret: pop di dx cx bx ax 1913 ret 1914 1915 SM_Str db 'ÚMemoryÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ',0 1916 db '³ ³ ',0 1917 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ',0 1918 ShowMemory: push ax bx cx dx di 1919 gotoxy 7,0 1920 mov bx,offset SM_Str 1921 mov dh,16 1922 mov ax,0000000000001000b 1923 call DrawBox 1924 mov bl,M_Pos 1925 call CalcBuffer 1926 xor bx,bx 1927 mov bl,MemoryBuffer[di].FileFlags 1928 shl bx,1 1929 mov bx,SD_AntetAddr[bx] 1930 cmp SHL_Flag,0 1931 jz SM_ok25 1932 test ActiveFlags,0000000000001000b 1933 jnz SM_ok3 1934 SM_ok25: mov bx,offset SD_Antet1 1935 SM_ok3: gotoxy 9,3 1936 ScreenIOservice _STRINGPRINT 1937 mov bx,offset SD_Antet0 1938 gotoxy 10,3 1939 ScreenIOservice _STRINGPRINT 1940 mov bl,M_BegPrint 1941 mov dx,12 1942 mov di,offset MemoryBuffer 1943 gotoxy 11,3 1944 mov ah,0Bh 1945 SM_Loop0: call OneFile 1946 add cx,80 * 2 1947 inc bl 1948 cmp bl,M_MaxLength 1949 jae SM_Ret0 1950 dec dx 1951 jnz SM_Loop0 1952 SM_Ret0: cmp NameEntering,0 1953 jnz SM_Ret 1954 mov cx,M_CX 1955 mov ScreenIOparams.CursorColor,40h 1956 ScreenIOservice _SHOWCURSOR 1957 SM_Ret: pop di dx cx bx ax 1958 ret 1959 1960 1961 SMS_Clear db ' ',0 1962 SMS_ReadDir db 'Accessing Disk Directory...',0 1963 SMS_FileLoaded db 'File loaded',0 1964 SMS_FileSaved db 'File saved',0 1965 SMS_StatLoaded db 'Status restored',0 1966 SMS_StatSaved db 'Status saved',0 1967 SMS_ErrFileLoad db 1,0Ch,'Error loading file',0 1968 SMS_ErrFileSave db 1,0Ch,'Error saving file',0 1969 SMS_ErrStatLoad db 1,0Ch,'Error restoring status',0 1970 SMS_ErrStatSave db 1,0Ch,'Error saving status',0 1971 SMS_EnterFilename db 'Enter Filename ( cancel)',0 1972 ShowMessage: push ax bx cx 1973 gotoxy 18h,0 1974 mov bx,offset SMS_Clear 1975 mov ah,0Ah 1976 ScreenIOservice _STRINGPRINT 1977 cmp GetKeyParams.RK_ErrPtr,0 1978 jz SMS_Ret 1979 gotoxy 18h,1 1980 mov bx,GetKeyParams.RK_ErrPtr 1981 ScreenIOservice _STRINGPRINT 1982 SMS_Ret: pop cx bx ax 1983 ret 1984 1985 1986 1987 SFK_Str db '1 2 3 4 5 ' 1988 db '6 7 8 9 10 ',0 1989 FkeysFlags dw 1111111111b 1990 SFK_FkeysMain dw SFK_Run,SFK_Cont,SFK_Load,SFK_Save,SFK_Delete 1991 dw SFK_None,SFK_None,SFK_None,SFK_PathFilter,SFK_Rescan 1992 SFK_Run db 1,2Fh,'Run ',0 1993 SFK_Cont db 1,2Fh,'Apple ',0 1994 SFK_Load db 1,1Fh,'Load ',0 1995 SFK_Save db 1,4Fh,'Save ',0 1996 SFK_Delete db 1,2Fh,'Delete',0 1997 SFK_PathFilter db 1,2Fh,'Path&F',0 1998 SFK_Rescan db 1,2Fh,'Rescan',0 1999 SFK_None db 1,2Fh,' ',0 2000 2001 ShowFuncKeys: push ax bx cx dx si 2002 gotoxy 19h,0 2003 mov bx,offset SFK_Str 2004 mov ah,7 2005 ScreenIOservice _STRINGPRINT 2006 gotoxy 19h,1 2007 xor si,si 2008 mov dx,FkeysFlags 2009 SFK_Loop0: shr dx,1 2010 mov ah,8 2011 jnc SFK_Next0 2012 mov ah,0Fh 2013 SFK_Next0: mov bx,SFK_FkeysMain[si] 2014 and byte ptr [bx+1],0F0h 2015 or byte ptr [bx+1],ah 2016 ScreenIOservice _STRINGPRINT 2017 add cx,4 2018 add si,2 2019 cmp si,20 2020 jb SFK_Loop0 2021 pop si dx cx bx ax 2022 ret 2023 2024 SHL_Flag db 1 2025 ShowHilights: cmp SHL_Flag,0 2026 jz SHL_Ret 2027 push ax cx 2028 gotoxy 3,1 2029 mov ax,0E00h+'P' 2030 ScreenIOservice _SYMBPRINT 2031 gotoxy 3,41 2032 mov al,'D' 2033 ScreenIOservice _SYMBPRINT 2034 gotoxy 7,1 2035 mov al,'M' 2036 ScreenIOservice _SYMBPRINT 2037 pop cx ax 2038 SHL_Ret: ret 2039 2040 2041 SC_Str db 'ÚConfirmÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿',0 2042 db '³ ³',0 2043 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ',0 2044 SC_FileMes db 1,7,'File ',1,0Fh,0 2045 SC_AlreadyMes db 1,7,' already exists.',0 2046 SC_SureMes db 1,7,'Are you sure you want to overwrite this file?',0 2047 SC_Flag db 0 2048 ShowConfirm: cmp SC_Flag,0 2049 jz SC1_Ret 2050 push ax bx cx dx di 2051 gotoxy 9,7 2052 mov bx,offset SC_Str 2053 mov dh,6 2054 mov ax,0000000000010000b 2055 call DrawBox 2056 gotoxy 11,9 2057 mov bx,offset SC_FileMes 2058 ScreenIOservice _STRINGPRINT 2059 mov bl,M_Pos 2060 call CalcBuffer 2061 lea bx,MemoryBuffer[di].FileName 2062 mov ah,0Fh 2063 ScreenIOservice _STRINGPRINT 2064 mov bx,offset SC_AlreadyMes 2065 ScreenIOservice _STRINGPRINT 2066 gotoxy 13,9 2067 mov bx,offset SC_SureMes 2068 ScreenIOservice _STRINGPRINT 2069 pop di dx cx bx ax 2070 SC1_Ret: ret 2071 2072 2073 2074 SC1_Str db 'ÚConfirmÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿',0 2075 db '³ ³',0 2076 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ',0 2077 SC1_FileMes db 1,7,'File ',1,0Fh,0 2078 SC1_OverWritten db 1,7,' is overwritten by another file.',0 2079 SC1_SureMes db 1,7,'Are you sure you want to save this file?',0 2080 SC1_Flag db 0 2081 ShowConfirm1: cmp SC1_Flag,0 2082 jz SC_Ret 2083 push ax bx cx dx di 2084 gotoxy 16,20 2085 mov bx,offset SC1_Str 2086 mov dh,6 2087 mov ax,0000000000010000b 2088 call DrawBox 2089 gotoxy 18,22 2090 mov bx,offset SC1_FileMes 2091 ScreenIOservice _STRINGPRINT 2092 mov bl,M_Pos 2093 call CalcBuffer 2094 lea bx,MemoryBuffer[di].FileName 2095 mov ah,0Fh 2096 ScreenIOservice _STRINGPRINT 2097 mov bx,offset SC1_OverWritten 2098 ScreenIOservice _STRINGPRINT 2099 gotoxy 20,22 2100 mov bx,offset SC1_SureMes 2101 ScreenIOservice _STRINGPRINT 2102 pop di dx cx bx ax 2103 SC_Ret: ret 2104 2105 2106 2107 OF_CX dw ? 2108 OF_Types dw OF_Directory,OF_Code,OF_Status,OF_MSdos 2109 OF_Directory db 1,7,'',0 2110 OF_Code db 'DOS3.3',0 2111 OF_Status db 'Status',0 2112 OF_MSdos db 'MS-DOS',0 2113 OF_NoAddr db 1,7,' -- -- ',0 2114 OF_Base dw ? 2115 OF_Color db ? 2116 OneFile: push ax bx cx dx di 2117 mov OF_Base,di 2118 mov OF_CX,cx 2119 call CalcBuffer 2120 mov bp,OF_Base 2121 lea bx,ds:[bp][di].FileName 2122 test ds:[bp][di].FileFlags,FF_DAMAGED? 2123 mov OF_Color,0Bh 2124 jz OF_hop1 2125 mov ah,0Ch 2126 mov OF_Color,ah 2127 OF_hop1: ScreenIOservice _STRINGPRINT 2128 cmp byte ptr ds:[bx],1 2129 je OF_Ret 2130 mov cx,OF_CX 2131 add cx,2*14 2132 xor bx,bx 2133 mov bp,OF_Base 2134 mov bl,ds:[bp][di].FileType 2135 shl bx,1 2136 mov bx,OF_Types[bx] 2137 mov ah,OF_Color 2138 ScreenIOservice _STRINGPRINT 2139 mov cx,OF_CX 2140 add cx,2*22 2141 mov bx,offset OF_NoAddr 2142 ScreenIOservice _STRINGPRINT 2143 mov bp,OF_Base 2144 test ds:[bp][di].FileFlags,FF_SHOWADDR? 2145 jz OF_Ret 2146 mov cx,OF_CX 2147 add cx,2*22 2148 mov ah,OF_Color 2149 mov bp,OF_Base 2150 mov al,byte ptr ds:[bp][di].FileBegAdr[1] 2151 ScreenIOservice _BYTEPRINT 2152 mov bp,OF_Base 2153 mov al,byte ptr ds:[bp][di].FileBegAdr[0] 2154 ScreenIOservice _BYTEPRINT 2155 mov bp,OF_Base 2156 mov cx,OF_CX 2157 add cx,2*29 2158 mov ah,OF_Color 2159 mov bp,OF_Base 2160 mov al,byte ptr ds:[bp][di].FileEndAdr[1] 2161 ScreenIOservice _BYTEPRINT 2162 mov bp,OF_Base 2163 mov al,byte ptr ds:[bp][di].FileEndAdr[0] 2164 ScreenIOservice _BYTEPRINT 2165 OF_Ret: pop di dx cx bx ax 2166 ret 2167 2168 2169 2170 2171 ; ******************************************************************* 2172 ; ** ** 2173 ; ** ** 2174 ; ** K E Y B O A R D S E R V I C E S ** 2175 ; ** ** 2176 ; ** ** 2177 ; ******************************************************************* 2178 2179 GetLineUser proc far 2180 ret 2181 GetLineUser endp 2182 2183 Alt_Keys db 'pdm' 2184 Alt_Procs dw Alt_PathFilter,Alt_Directory,Alt_Memory 2185 Alt_Key proc far 2186 push cx si di ds 2187 mov di,offset Alt_Keys 2188 mov cx,offset Alt_Procs- offset Alt_Keys 2189 call CalcCommand 2190 jc Alt_Ret 2191 shl di,1 2192 call cs:Alt_Procs[di] 2193 mov al,7Fh 2194 Alt_Ret: pop ds di si cx 2195 ret 2196 2197 Alt_PathFilter proc near 2198 mov cs:GoWhere?,G_PATH_FILTER 2199 ret 2200 Alt_PathFilter endp 2201 2202 Alt_Directory proc near 2203 mov cs:GoWhere?,G_DIRECTORY 2204 ret 2205 Alt_Directory endp 2206 2207 Alt_Memory proc near 2208 mov cs:GoWhere?,G_MEMORY 2209 ret 2210 Alt_Memory endp 2211 2212 Alt_Key endp 2213 2214 2215 2216 FkeysMasks dw 1b,10b,100b,1000b,10000b,100000b,1000000b,10000000b,100000000b,1000000000b 2217 Fkeys_Main dw Fkey_Run,Fkey_Cont,Fkey_Load,Fkey_Save,Fkey_Delete 2218 dw ?,?,?,Fkey_PathFilter,Fkey_Rescan 2219 Fkey proc far 2220 push ax bx cx dx si di bp ds es 2221 push cs 2222 pop ds 2223 push word ptr ds:[ScreenIOparams.CursorLen] 2224 push word ptr ds:[ScreenIOparams.CursorFlag] 2225 push ds:[GetLineParams.GL_Buffer] 2226 push ds:[GetLineParams.GL_CX] 2227 push [ActiveFlags] 2228 push [FkeysFlags] 2229 xor bx,bx 2230 mov bl,al 2231 shl bx,1 2232 mov si,bx 2233 mov ax,FkeysMasks[si] 2234 test FkeysFlags,ax 2235 jz Fkey_Ret 2236 xor bx,bx 2237 mov bl,F_or_M 2238 shl bx,1 2239 mov bp,S_Parameters[bx] 2240 call Fkeys_Main[si] 2241 xor bx,bx 2242 mov bl,F_or_M 2243 shl bx,1 2244 mov bp,S_Parameters[bx] 2245 mov cx,ds:[bp].S_CX 2246 Fkey_Ret: pop [FkeysFlags] 2247 pop [ActiveFlags] 2248 pop ds:[GetLineParams.GL_CX] 2249 pop ds:[GetLineParams.GL_Buffer] 2250 pop word ptr ds:[ScreenIOparams.CursorFlag] 2251 pop word ptr ds:[ScreenIOparams.CursorLen] 2252 pop es ds bp di si dx cx bx ax 2253 ret 2254 Fkey endp 2255 2256 FU_Procs dw FU_Dir,FU_Code,FU_Status,FU_MSDos 2257 Fkey_Update: push ax bx di 2258 mov bl,ds:[bp].S_Pos 2259 call CalcBuffer 2260 test ds:[bp].S_Buffer[di].FileFlags,FF_DAMAGED? 2261 jnz FU_Ret 2262 test ds:[bp].S_Buffer[di].FileFlags,FF_MODIFYADDR? 2263 jz FU_Ret 2264 xor bx,bx 2265 mov bl,ds:[bp].S_Buffer[di].FileType 2266 shl bx,1 2267 call FU_Procs[bx] 2268 FU_Ret: pop di bx ax 2269 ret 2270 2271 FU_Dir: ret 2272 2273 FU_Code: mov ax,word ptr ds:[bp].S_Buffer[di].File1st4bytes 2274 mov ds:[bp].S_Buffer[di].FileBegAdr,ax 2275 mov ax,word ptr ds:[bp].S_Buffer[di].File1st4bytes[2] 2276 add ax,ds:[bp].S_Buffer[di].FileBegAdr 2277 jnc FU_Code_ok 2278 xor ax,ax 2279 FU_Code_ok: dec ax 2280 mov ds:[bp].S_Buffer[di].FileEndAdr,ax 2281 ret 2282 2283 FU_Status: xor ax,ax 2284 mov ds:[bp].S_Buffer[di].FileBegAdr,ax 2285 dec ax 2286 mov ds:[bp].S_Buffer[di].FileEndAdr,ax 2287 ret 2288 2289 FU_MSdos: mov ds:[bp].S_Buffer[di].FileBegAdr,800h 2290 mov ax,ds:[bp].S_Buffer[di].FileLength 2291 add ax,800h 2292 jnc FU_MSdos_ok 2293 xor ax,ax 2294 FU_MSdos_ok: dec ax 2295 mov ds:[bp].S_Buffer[di].FileEndAdr,ax 2296 ret 2297 2298 Fkey_RunProcs dw FRP_Run,FRP_Go 2299 Fkey_Run: mov si,bx 2300 mov bl,ds:[bp].S_Pos 2301 call CalcBuffer 2302 cmp ds:[bp].S_Buffer[di].FileType,FD_Code 2303 jb Fkey_RunRet 2304 mov bx,ds:[bp].S_Buffer[di].FileBegAdr 2305 call Fkey_RunProcs[si] 2306 Fkey_RunRet: ret 2307 2308 FRP_RunProgram db 0A9h,20h,0A9h,0,0A9h,3,0A9h,3Ch,4Ch 2309 FRP_RunAddress dw ? 2310 FRP_Procs dw FRPP_Directory,FRPP_Code,FRPP_Status,FRPP_MSdos 2311 FRP_Run: call ResetAppleII 2312 mov bp,offset DirectoryParams 2313 call S_Enter 2314 cmp S_EnterErrorFL,0 2315 jnz FRP_RunRet 2316 push bx 2317 mov bl,M_MaxLength 2318 sub bl,2 2319 call CalcBuffer 2320 pop bx 2321 xor ax,ax 2322 mov al,MemoryBuffer[di].FileType 2323 mov di,ax 2324 shl di,1 2325 call FRP_Procs[di] 2326 call GoAppleII 2327 FRP_RunRet: ret 2328 2329 FRPP_MSdos: 2330 FRPP_Code: push es 2331 mov ax,Apple 2332 mov es,ax 2333 assume es:Apple 2334 mov GetKeyParams.RK_ErrPtr,0 2335 mov FRP_RunAddress,bx 2336 mov di,0C700h 2337 mov si,offset FRP_RunProgram 2338 mov cx,11 2339 cld 2340 rep movsb 2341 pop es 2342 ret 2343 assume es:Emulate 2344 2345 FRPP_Damaged: 2346 FRPP_Directory: 2347 FRPP_Status: ret 2348 2349 2350 FRP_Go: push ds 2351 cmp ds:[bp].S_Buffer[di].FileType,FD_Status 2352 je FRPG_NoBegAdr 2353 mov ax,TaskControl 2354 mov ds,ax 2355 assume ds:TaskControl 2356 mov ds:r_PC,bx 2357 FRPG_NoBegAdr: pop ds 2358 assume ds:FM 2359 call GoAppleII 2360 ret 2361 2362 2363 2364 Fkey_Cont: call GoAppleII 2365 ret 2366 2367 Fkey_Load: mov bp,offset DirectoryParams 2368 call S_EnterF 2369 ret 2370 2371 Fkey_Save: push word ptr F_or_M 2372 mov F_or_M,1 2373 mov bp,offset MemoryParams 2374 call S_EnterM 2375 pop word ptr F_or_M 2376 ret 2377 2378 Fkey_Delete: mov bl,ds:[bp].S_Pos 2379 call Delete 2380 ret 2381 2382 Fkey_PathFilter: call S_PathFilter 2383 ret 2384 2385 Fkey_Rescan: call ReadDir 2386 ret 2387 2388 2389 RA_FictiveName db 'ESD$$$$$.$$$',0 2390 ResetAppleII proc far 2391 push ax bx cx dx si di bp ds es 2392 pushf 2393 cli 2394 call SystemRESET 2395 popf 2396 push cs 2397 pop ds 2398 mov ax,Apple 2399 mov es,ax 2400 assume es:Apple 2401 xor di,di 2402 mov cx,0C000h 2403 xor al,al 2404 cld 2405 rep stosb 2406 xor ax,ax 2407 mov bx,0C000h 2408 mov si,offset RA_FictiveName 2409 mov cx,102h 2410 call FileIsLoaded ; Reset done! 2411 mov bp,offset MemoryParams 2412 mov bl,M_Pos 2413 call Delete 2414 call S_Up 2415 mov bx,es:[0FFFCh] 2416 mov ax,TaskControl 2417 mov es,ax 2418 assume es:TaskControl 2419 mov es:r_PC,bx 2420 pop es ds bp di si dx cx bx ax 2421 ret 2422 ResetAppleII endp 2423 assume es:Emulate 2424 2425 2426 GoAppleII: push ax bx es 2427 xor bx,bx 2428 xchg bx,ActiveFlags 2429 call ShowAll 2430 ScreenIOservice _SHOWSCREEN 2431 mov ax,Emulate 2432 mov es,ax 2433 mov al,C050 2434 ScreenIOservice _SetScreen 2435 SwitchToProcess PID_EMULATOR 2436 mov ActiveFlags,bx 2437 pop es bx ax 2438 ret 2439 2440 FM ends 2441 2442 END