Raw File
1 ; _____________________________________________
2 ; | |
3 ; | Project: APPLER |
4 ; | File: DM.ASM |
5 ; | Compiler: 16-bit TASM (2.5) |
6 ; | |
7 ; | Subject: Disk Manager |
8 ; | |
9 ; | Author: Emil Dotchevski |
10 ; |_____________________________________________|
11
12 include GLOBALS.INC
13 include INTERFAC.INC
14 include CONIO.INC
15 include DM.INC
16
17 G_DIRECTORY = 0
18 G_PATH_FILTER = 1
19 G_IMAGE = 2
20 G_D1 = 3
21 G_D2 = 4
22
23 DM segment public
24 assume cs:DM,ds:DM,es:Emulate
25
26 ManagerState db MS_NORMAL
27 GetLineBuf db 80h dup (0)
28
29 GetLineParams GL_ParamStruc <?,0,1,1,5,0,0,20h,40h,0,?,?,0Bh,1,0,GetLineUser,?,?,?,?>
30 ScreenIOParams SIO_ParamStruc <1,DM,0,0,offset Screen,seg Screen,1,0,1,1>
31 GetKeyParams RK_ParamStruc <1,Fkey,1,Alt_Key,0,?,ShowAll,0 >
32
33 disk1_ptr dd CurrentDrive
34 disk2_ptr dd OtherDrive
35 set_ptrs: push ax bx ds
36 pushf
37 mov ds,word ptr cs:disk1_ptr[2]
38 assume ds:seg CurrentDrive
39 cmp ds:CurrentDrive.ID,0
40 mov ax,offset CurrentDrive
41 mov bx,offset OtherDrive
42 jz set_ptrs_1
43 xchg ax,bx
44 set_ptrs_1: mov word ptr cs:disk1_ptr[0],ax
45 mov word ptr cs:disk2_ptr[0],bx
46 popf
47 pop ds bx ax
48 ret
49
50 assume es:seg CurrentDrive
51 present1: push bp es
52 les bp,disk1_ptr
53 cmp es:[bp].FileHandle,0FFFFh
54 pop es bp
55 ret
56
57 present2: push bp es
58 les bp,disk2_ptr
59 cmp es:[bp].FileHandle,0FFFFh
60 pop es bp
61 ret
62 assume es:Emulate
63
64 DMInInit proc far
65 call DM_InInitP
66 call UnSetBreaks
67 ret
68 DMInInit endp
69
70 DMOutInit proc far
71 push ax es
72 call DM_OutInitP
73 mov ax,seg T_Iflags
74 mov es,ax
75 assume es:seg T_Iflags
76 mov byte ptr es:T_Iflags,00000010b
77 assume es:Emulate,ds:DM
78 call AppleKeysOn
79 call SetBreaks
80 pop es ax
81 ret
82 DMOutInit endp
83
84 DM_InInitP proc near
85 cli
86 push ax bx ds es
87 mov ax,Emulate
88 mov es,ax
89 mov al,es:[C000]
90 mov cs:KeyPressed,al
91 mov es:[C000],0
92 call DebugKeysOn
93 call set_ptrs
94 mov ax,CONio
95 mov ds,ax
96 assume ds:CONio
97 mov GL_ParamsOfs, offset GetLineParams
98 mov GL_ParamsSeg, seg GetLineParams
99 mov SIO_ParamsOfs, offset ScreenIOParams
100 mov SIO_ParamsSeg, seg ScreenIOParams
101 mov RK_ParamsOfs, offset GetKeyParams
102 mov RK_ParamsSeg, seg GetKeyParams
103 assume ds:DM
104 pop es ds bx ax
105 sti
106 ret
107 DM_InInitP endp
108
109 KeyPressed db 0
110 DM_OutInitP proc near
111 cli
112 push ax es
113 mov ax,Emulate
114 mov es,ax
115 mov al,cs:KeyPressed
116 mov es:[C000],al
117 assume es:Emulate
118 pop es ax
119 ret
120 DM_OutInitP endp
121
122
123
124 GoWhere? dw G_D1
125 DM_FirstFlag db 1
126 DM_MainRet: push cs
127 pop ds
128 cmp DM_FirstFlag,0
129 jz BigLoop
130 mov DM_FirstFlag,0
131 call ShowAll
132 mov DirectoryParams.S_MaxLength,0
133 call ReadDir
134 BigLoop: mov GetLineParams.GL_Color,0Bh
135 mov GetLineParams.GL_CX,80*2
136 mov di,GoWhere?
137 shl di,1
138 mov GoWhere?,G_D1
139 call CmndAddress[di]
140 call ShowAll
141 jmp BigLoop
142
143 CmndAddress dw Directory,S_PathFilter,Image,D1,D2
144
145 I_Current db 0
146 I_CurrentSVD db 0
147 I_FirstTime? db 1
148 I_CH db 15,15,15,16,17,17,17,19,19,19,20,21,21,21,22
149 I_CL db 29,32,35,29,29,32,35,29,32,35,29,29,32,35,29
150 I_Keys db '0123456789abcdef'
151 db 5,6,7,8,1,2,20h
152 db 0Ch,18h,7Fh
153 I_Procs dw I_Num,I_Num,I_Num,I_Num,I_Num,I_Num,I_Num,I_Num
154 dw I_Num,I_Num,I_Num,I_Num,I_Num,I_Num,I_Num,I_Num
155 dw I_Left,I_Right,I_Up,I_Down,I_Home,I_End,I_Space
156 dw I_Esc,I_Enter,I_7Fh
157 Image: push es
158 mov ScreenIOparams.CursorColor,40h
159 mov ScreenIOparams.CursorFlag,1
160 mov ScreenIOparams.CursorLen,4
161 mov cs:ActiveFlags,0000000000010000b
162 mov I_FirstTime?,1
163 mov bx,seg SectorImage
164 mov es,bx
165 assume es:seg SectorImage
166 xor bx,bx
167 mov bl,I_CurrentSVD
168 mov I_Current,bl
169 I_Loop: xor bx,bx
170 mov bl,I_Current
171 mov ch,I_CH[bx]
172 mov cl,I_CL[bx]
173 dec cl
174 call ReadKey
175 mov di,offset I_Keys
176 mov cx,offset I_Procs - offset I_Keys
177 call CalcCommand
178 jc I_Loop
179 shl di,1
180 xor bx,bx
181 mov bl,I_Current
182 call I_Procs[di]
183 jnc I_Loop
184 pop es
185 mov bl,I_Current
186 mov I_CurrentSvd,bl
187 ret
188
189 I_OffsetAddr db AddressProlog,AddressProlog+1,AddressProlog+2
190 db AddressCheckSum
191 db AddressEpilog,AddressEpilog+1,AddressEpilog+2
192 db DataProlog, DataProlog+1, DataProlog+2
193 db DataCheckSum
194 db DataEpilog, DataEpilog+1, DataEpilog+2
195 db EndByte
196 I_Num: mov bl,I_OffsetAddr[bx]
197 xor bh,bh
198 shr di,1
199 mov ax,di
200 cmp cs:I_FirstTime?,0
201 jz I_NumByte_1
202 mov byte ptr es:SectorImage[bx],0
203 I_NumByte_1: shl byte ptr es:SectorImage[bx],4
204 or byte ptr es:SectorImage[bx],al
205 clc
206 mov I_FirstTime?,0
207 ret
208
209 I_Left: dec I_Current
210 jns I_LeftOk
211 mov I_Current,size SectorImage_S - 1
212 I_LeftOk: clc
213 mov I_FirstTime?,1
214 ret
215
216 I_SpaceFlags db 0,1,1,1,1,1,1,0,1,1,1,1,1,1,1
217 I_Space: cmp I_SpaceFlags[bx],0
218 jz I_SpcRet
219 mov bl,I_OffsetAddr[bx]
220 xor bh,bh
221 xor byte ptr es:SectorImageF[bx],0FFh
222 cmp cs:I_FirstTime?,1
223 I_SpcRet: clc
224 ret
225
226 I_Enter:
227 I_Right: inc I_Current
228 cmp I_Current,size SectorImage_S
229 jb I_RightOk
230 mov I_Current,0
231 I_RightOk: clc
232 mov I_FirstTime?,1
233 ret
234
235 I_Ups db 14,12,13,0,3,1,2,4,5,6,7,10,8,9,11
236 I_Up: mov al,I_Ups[bx]
237 mov I_Current,al
238 clc
239 mov I_FirstTime?,1
240 ret
241
242 I_Downs db 3,5,6,4,7,8,9,10,12,13,11,14,1,2,0
243 I_Down: mov al,I_Downs[bx]
244 mov I_Current,al
245 clc
246 mov I_FirstTime?,1
247 ret
248
249 I_Home: mov I_Current,0
250 clc
251 mov I_FirstTime?,1
252 ret
253
254 I_End: mov I_Current,size SectorImage_S - 1
255 clc
256 mov I_FirstTime?,1
257 ret
258
259 I_Esc: call GoAppleII
260 clc
261 ret
262
263 I_7Fh: stc
264 ret
265
266
267 assume es:Emulate
268 S_ParamsStruc struc
269 S_MaxLength db 0
270 S_BegPrint db ?
271 S_Pos db ?
272 S_CX dw ?
273 S_LinesNum db ?
274 S_Buffer db ?
275 S_ParamsStruc ends
276 DirectoryParams S_ParamsStruc <0,0,0,0B2Ah,13>
277 db 100h * size DiskDescription dup (0)
278
279 S_Commands db 'ta',18h
280 db 7,8,3,4,1,2,0Ch
281 S_Subrt dw S_Type,S_Access,S_Enter
282 dw S_Up,S_Down,S_PgUp,S_PgDn,S_Home,S_End,GoAppleII
283 S_CallIfZero? db 0,0,0,0,0,0,0,0,0
284 Directory: xor bx,bx
285 mov SHL_Flag,1
286 mov GetLineParams.GL_AllowSpc,0
287 gotoxy 2,0
288 mov GetLineParams.GL_CX,cx
289 mov ActiveFlags,0000000000000010b
290 mov FkeysFlags,1111111111b
291 mov ScreenIOparams.CursorFlag,0
292 mov cx,DirectoryParams.S_CX
293 call ReadKey
294 cmp al,7Fh
295 je SelectRet
296 mov di,offset S_Commands
297 mov cx,offset S_Subrt- offset S_Commands
298 call CalcCommand
299 jc Directory
300 cmp DirectoryParams.S_MaxLength,0
301 jnz S_ok1
302 test S_CallIfZero?[di],1
303 jz Directory
304 S_ok1: shl di,1
305 call S_Subrt[di]
306 jmp Directory
307 SelectRet: GetLineService _GL_CLRBUFF
308 ret
309
310 S_Up: push ax
311 mov al,DirectoryParams.S_Pos
312 or al,al
313 jz S_UpRet
314 dec al
315 mov ah,al
316 sub ah,DirectoryParams.S_BegPrint
317 cmp ah,2
318 jae S_UpOk1
319 cmp DirectoryParams.S_BegPrint,0
320 jz S_UpOk1
321 dec DirectoryParams.S_BegPrint
322 inc byte ptr DirectoryParams.S_CX[1]
323 S_UpOk1: dec byte ptr DirectoryParams.S_CX[1]
324 S_UpRet: mov DirectoryParams.S_Pos,al
325 pop ax
326 ret
327
328 S_Down: push ax
329 mov al,DirectoryParams.S_Pos
330 mov ah,DirectoryParams.S_MaxLength
331 dec ah
332 cmp al,ah
333 je S_DownRet
334 inc al
335 mov ah,al
336 sub ah,DirectoryParams.S_BegPrint
337 add ah,2
338 cmp ah,DirectoryParams.S_LinesNum
339 jb S_DownOk1
340 mov ah,DirectoryParams.S_BegPrint
341 add ah,DirectoryParams.S_LinesNum
342 jc S_DownOk1
343 cmp ah,DirectoryParams.S_MaxLength
344 jae S_DownOk1
345 inc DirectoryParams.S_BegPrint
346 dec byte ptr DirectoryParams.S_CX[1]
347 S_DownOk1: inc byte ptr DirectoryParams.S_CX[1]
348 S_DownRet: mov DirectoryParams.S_Pos,al
349 pop ax
350 ret
351
352 S_PgUp: push cx
353 xor ch,ch
354 mov cl,DirectoryParams.S_LinesNum
355 dec cx
356 S_PgUpLoop: call S_Up
357 loop S_PgUpLoop
358 pop cx
359 ret
360
361 S_PgDn: push cx
362 xor ch,ch
363 mov cl,DirectoryParams.S_LinesNum
364 dec cx
365 S_PgDnLoop: call S_Down
366 loop S_PgDnLoop
367 pop cx
368 ret
369
370 S_Home: push cx
371 mov cx,100h
372 dec cx
373 S_HomeLoop: call S_Up
374 loop S_HomeLoop
375 pop cx
376 ret
377
378 S_End: push cx
379 mov cx,100h
380 dec cx
381 S_EndLoop: call S_Down
382 loop S_EndLoop
383 pop cx
384 ret
385
386 S_Access: push bx di
387 mov bl,DirectoryParams.S_Pos
388 call CalcBuffer
389 test DirectoryParams.S_Buffer[di].FileFlag,FF_DAMAGED?
390 jnz S_AccessRet
391 xor DirectoryParams.S_Buffer[di].FileFlag,FF_READ_ONLY?
392 S_AccessRet: pop di bx
393 ret
394
395 S_TypeNewVal db FD_Directory,FD_DOS33,FD_Nibble
396 S_Type: push ax bx di
397 mov bl,DirectoryParams.S_Pos
398 call CalcBuffer
399 mov al,DirectoryParams.S_Buffer[di].FileFlag
400 test al ,FF_DAMAGED?
401 jnz S_TypeRet
402 test al,FF_MODIFYTYPE?
403 jz S_TypeRet
404 xor bx,bx
405 mov bl,DirectoryParams.S_Buffer[di].FileType
406 mov bl,S_TypeNewVal[bx]
407 mov DirectoryParams.S_Buffer[di].FileType,bl
408 S_TypeRet: pop di bx ax
409 ret
410
411 S_EnterProcs dw SE_Directory,SE_Nibble,SE_DOS33
412 S_Enter: push ax bx cx dx si di ds es
413 cmp ManagerState,MS_NORMAL
414 jne S_EnterRet
415 cmp DirectoryParams.S_MaxLength,0
416 jz S_EnterRet
417 mov bl,DirectoryParams.S_Pos
418 call CalcBuffer
419 test DirectoryParams.S_Buffer[di].FileFlag,FF_DAMAGED?
420 jnz S_EnterRet
421 xor bx,bx
422 mov bl,DirectoryParams.S_Buffer[di].FileType
423 mov si,bx
424 mov bx,di
425 call LinkName
426 shl si,1
427 mov dx,offset Path
428 call S_EnterProcs[si]
429 call UnLinkName
430 S_EnterRet: pop es ds di si dx cx bx ax
431 ret
432
433 SE_Directory: mov bx,LN_BX
434 mov byte ptr Path[bx],'\'
435 mov byte ptr Path[bx+1],0
436 call ReadDir
437 ret
438
439 SE_DOS33:
440 SE_Nibble: test ActiveFlags,0000000000001000b
441 mov ax,offset Fkey_InsertB
442 jnz SE_1
443 mov ax,offset Fkey_InsertA
444 SE_1: call ax
445 ret
446
447
448
449 D1: mov DN,0
450 mov ActiveFlags,0000000000000100b
451 jmp Drive
452
453 D2: mov DN,1
454 mov ActiveFlags,0000000000001000b
455 jmp Drive
456
457 D_Chars db 'av'
458 db 7,8,3,4,1,2,18h,0Ch
459 D_Procs dw D_Access,D_Volume
460 dw S_Up,S_Down,S_PgUp,S_PgDn,S_Home,S_End,S_Enter,GoAppleII
461 D_CallIfZero? db 0,0,1,1,1,1,1,1,1,1
462 DN db ?
463 Drive: push es
464 D_Loop: call ReadKey
465 cmp al,7Fh
466 je D_Ret
467 cmp DN,0
468 mov dx,offset SDA_Filename
469 mov bx,offset present1
470 les bp,disk1_ptr
471 jz D_ok1
472 mov dx,offset SDA_Filename
473 mov bx,offset present2
474 les bp,disk2_ptr
475 assume es:seg CurrentDrive
476 D_ok1: mov di,offset D_Chars
477 mov cx,offset D_Procs - offset D_Chars
478 call CalcCommand
479 jc D_Loop
480 call bx
481 jnz D_ok2
482 cmp D_CallIfZero?[di],0
483 jz D_Loop
484 D_ok2: shl di,1
485 call D_Procs[di]
486 jmp D_Loop
487 D_Ret: pop es
488 ret
489
490 D_Access: push ax cx
491 call Prepare4DOS
492 mov ax,4300h
493 int 21h
494 jc D_AccessError
495 mov ax,4301h
496 xor cx,1
497 int 21h
498 jc D_AccessError
499 xor es:[bp].WriteProtect,0FFh
500 D_AccessExit: call SOD4eraperP
501 pop cx ax
502 ret
503
504 D_RemoveDisk dw Fkey_RemoveA,Fkey_RemoveB
505 D_AccessError: xor bh,bh
506 mov bl,DN
507 shl bx,1
508 call D_RemoveDisk[bx]
509 jmp D_AccessExit
510
511
512 D_VolCXs dw 622h,0B22h
513 D_Vol_First? db ?
514 D_VolNums db '0123456789abcdef'
515 D_Volume: push word ptr [GetKeyParams.RK_AltFlag]
516 cmp es:[bp].DiskType,0
517 jz D_VolRet
518 mov ScreenIOparams.CursorColor,40h
519 mov ScreenIOparams.CursorFlag,1
520 mov ScreenIOparams.CursorLen,4
521 mov SHL_Flag,0
522 mov GetKeyParams.RK_AltFlag,0
523 mov D_Vol_First?,1
524 D_VolLoop: xor bh,bh
525 mov bl,DN
526 shl bx,1
527 mov cx,D_VolCXs[bx]
528 call ReadKey
529 cmp al,0Ch
530 je D_VolRet
531 cmp al,18h
532 je D_VolRet
533 mov di,offset D_VolNums
534 mov cx,16
535 call CalcCommand
536 jc D_VolLoop
537 mov bl,es:[bp].Volume
538 cmp D_Vol_First?,0
539 jz D_VolNotFirst
540 xor bl,bl
541 mov D_Vol_First?,bl
542 D_VolNotFirst: shl bl,4
543 or bx,di
544 mov es:[bp].Volume,bl
545 jmp D_VolLoop
546 D_VolRet: mov ScreenIOparams.CursorFlag,0
547 mov SHL_Flag,1
548 pop word ptr [GetKeyParams.RK_AltFlag]
549 ret
550 assume es:Emulate
551
552
553 S_PathFilter: push word ptr cs:[ScreenIOparams.CursorFlag]
554 push word ptr cs:[GetKeyParams.RK_AltFlag]
555 mov SHL_Flag,0
556 mov GetKeyParams.RK_AltFlag,0
557 mov GetLineParams.GL_AllowSpc,0
558 mov ActiveFlags,0000000000000001b
559 mov FkeysFlags,0000000101b
560 mov ScreenIOparams.CursorFlag,1
561 mov GetLineParams.GL_Buffer,offset PathFilter
562 mov GetLineParams.GL_Pos,0
563 mov GetLineParams.GL_BegPrint,0
564 mov GetLineParams.GL_MaxLength,67+20h
565 mov GetLineParams.GL_MaxPrint,35
566 mov ScreenIOparams.CursorLen,1
567 call LinkPathFilter
568 mov GetLineParams.GL_Length,bl
569 gotoxy 5,42
570 GetLineService _GETLINE
571 call GetPathFilter
572 call ReadDir
573 pop word ptr cs:[GetKeyParams.RK_AltFlag]
574 pop word ptr cs:[ScreenIOparams.CursorFlag]
575 mov SHL_Flag,1
576 GetLineService _GL_CLRBUFF
577 clc
578 ret
579
580 LinkPathFilter: push ax si di es
581 xor bx,bx
582 push cs
583 pop es
584 mov si,offset Path
585 mov di,offset PathFilter
586 cld
587 LPF_Loop1: lodsb
588 or al,al
589 jz LPF_Filter
590 stosb
591 inc bx
592 jmp LPF_Loop1
593 LPF_Filter: mov si,offset Filter
594 LPF_Loop2: lodsb
595 stosb
596 inc bx
597 or al,al
598 jnz LPF_Loop2
599 dec bx
600 pop es di si ax
601 ret
602
603
604
605 GetPathFilter: push ax cx dx si di es
606 push cs
607 pop es
608 xor al,al
609 mov di,offset PathFilter
610 cld
611 mov cx,20h+67
612 repne scasb
613 dec di
614 mov si,di
615 std
616 GPF_Loop1: cmp si,offset PathFilter
617 jna GPF_NoPath
618 lodsb
619 cmp al,'\'
620 jne GPF_Loop1
621 add si,2
622 mov dx,si
623 mov si,offset PathFilter
624 mov di,offset Path
625 cld
626 GPF_Loop2: lodsb
627 stosb
628 cmp si,dx
629 jna GPF_Loop2
630 dec si
631 dec di
632 xor al,al
633 stosb
634 mov Path[67],0
635 GPF_NoPath: cld
636 mov di,offset Filter
637 xor cx,cx
638 GPF_Loop3: lodsb
639 stosb
640 cmp cx,20h
641 je GPF_LongFilt
642 inc cx
643 or al,al
644 jnz GPF_Loop3
645 cmp cx,1
646 je GPF_NoFilter
647 GPF_Ret: pop es di si dx cx ax
648 ret
649
650 GPF_LongFilt: dec di
651 xor ax,ax
652 stosb
653 jmp GPF_Ret
654
655 GPF_DefaultFilt db '*.DSK,*.NBL',0
656 GPF_NoFilter: mov si,offset PathFilter
657 mov di,offset Path
658 cld
659 GPF_Loop4: lodsb
660 stosb
661 or al,al
662 jnz GPF_Loop4
663 mov si,offset GPF_DefaultFilt
664 mov di,offset Filter
665 mov cx,offset GPF_NoFilter - offset GPF_DefaultFilt
666 rep movsb
667 jmp GPF_Ret
668
669
670
671 ; -- Read Directory ------------------
672
673 RD_GetDirs? db 1
674 Path db '.\',66 dup (0) ; Current Path
675 Filter db '*.DSK,*.NBL',020h dup (0) ; Scan Filter
676 PathFilter db 67+20h dup (0) ; Path&Filter
677 WildCard db 0Dh dup (0) ; Temp
678 WC_AnyFile db '*.*',0 ; For SubDirs scanning
679
680 BufPtr dw 0
681 RD_0OfsSvd dw 0
682 DTA DTA_S <0,0,0,0,0,0>
683
684 ReadDirectory proc near
685 push ax bx cx dx si di es
686 call Prepare4DOS
687 mov si,offset Path
688 mov di,si
689 push ds
690 pop es
691 mov ah,60h
692 int 21h
693 mov dx,offset DTA
694 mov ah,1Ah
695 int 21h
696
697 xor bx,bx
698 RD_SearchFor0: cmp Path[bx],0
699 jz RD_0Found
700 inc bx
701 jmp RD_SearchFor0
702 RD_0Found: or bx,bx
703 jz RD_PathOK
704 cmp Path[bx-1],'\'
705 je RD_PathOK
706 mov Path[bx],'\'
707 inc bx
708 mov Path[bx],0
709 RD_PathOK: xor si,si
710 mov RD_0OfsSvd,bx
711
712 cmp RD_GetDirs?,0
713 jz RD_GetFiles
714
715 RD_CopyWC1: mov al,WC_AnyFile[si]
716 mov Path[bx],al
717 inc si
718 inc bx
719 cmp al,0
720 jnz RD_CopyWC1
721 mov bx,BufPtr
722 mov dx,offset Path
723 mov cx,FA_DIRECTORY
724 FindFirst
725 jc RD_GetFiles
726 RD_GetDirLoop: test DTA.Attributes,FA_DIRECTORY
727 jz RD_GD_Next
728 cmp DirectoryParams.S_MaxLength,0FEh
729 je RD_NoMoreFiles
730 call RD_PutFile
731 inc DirectoryParams.S_MaxLength
732 add bx,size DiskDescription
733 RD_GD_Next: FindNext
734 jnc RD_GetDirLoop
735 mov BufPtr,bx
736
737 RD_GetFiles: mov bx,RD_0OfsSvd
738 xor si,si
739 RD_CopyWC2: mov al,WildCard[si]
740 mov Path[bx],al
741 inc si
742 inc bx
743 cmp al,0
744 jnz RD_CopyWC2
745 mov bx,BufPtr
746 mov dx,offset Path
747 mov cx,FA_ARCHIVE or FA_READ_ONLY
748 FindFirst
749 jc RD_NoMoreFiles
750 RD_GetFilesLoop: cmp DirectoryParams.S_MaxLength,0FEh
751 je RD_NoMoreFiles
752 call RD_PutFile
753 inc DirectoryParams.S_MaxLength
754 add bx,size DiskDescription
755 FindNext
756 jnc RD_GetFilesLoop
757
758 RD_NoMoreFiles: mov si,RD_0OfsSvd
759 mov byte ptr Path[si],0
760 mov BufPtr,bx
761 call SOD4eraperP
762 pop es di si dx cx bx ax
763 ret
764 ReadDirectory endp
765
766
767
768 PF_FileExts db 'NBLDSK'
769 PF_FileTypes db FD_Nibble,FD_DOS33
770 PF_Addr dw PF_Directory,PF_Nibble,PF_DOS33
771 PF_NameLength dw ?
772 RD_PutFile proc near
773 push ax cx dx si di bp es
774 xor si,si
775 PF_GetNameLoop: mov al,DTA.FileSpec[si]
776 mov DirectoryParams.S_Buffer[bx].FileName[si],al
777 inc si
778 or al,al
779 jnz PF_GetNameLoop
780 mov PF_NameLength,si
781
782 or bx,bx
783 jz PF_Cont1
784 xor bp,bp
785 PF_Cmp0: xor di,di
786 PF_Cmp1: mov al,DirectoryParams.S_Buffer[bp].FileName[di]
787 cmp al,DirectoryParams.S_Buffer[bx].FileName[di]
788 jne PF_NotMatch
789 inc di
790 or al,al
791 jnz PF_Cmp1
792 PF_Error: sub bx,size DiskDescription
793 dec DirectoryParams.S_MaxLength
794 jmp PF_Ret
795 PF_NotMatch: add bp,size DiskDescription
796 cmp bp,bx
797 jne PF_Cmp0
798
799 PF_Cont1: mov DirectoryParams.S_Buffer[bx].FileFlag,0
800 test DTA.Attributes,FA_DIRECTORY
801 jz PF_NotDir
802 mov DirectoryParams.S_Buffer[bx].FileType,FD_DIRECTORY
803 jmp PF_Ret
804
805 PF_NotDir: push cs
806 pop es
807 cld
808 lea di,DirectoryParams.S_Buffer[bx].FileName
809 inc di
810 mov al,'.'
811 mov cx,PF_NameLength
812 repne scasb
813 xor dl,dl
814 jcxz PF_PokeType
815 mov bp,di
816 mov si,offset PF_FileExts
817 mov dh,2
818 PF_CmpExtLoop: mov di,bp
819 mov cx,3
820 repe cmpsb
821 je PF_PokeType
822 PF_3: inc si
823 loop PF_3
824 inc dl
825 dec dh
826 jnz PF_CmpExtLoop
827 xor dl,dl
828 PF_PokeType: xor dh,dh
829 mov di,dx
830 xor ax,ax
831 mov al,PF_FileTypes[di]
832 mov DirectoryParams.S_Buffer[bx].FileType,al
833 mov di,ax
834 shl di,1
835 call PF_Addr[di]
836 and DirectoryParams.S_Buffer[bx].FileFlag,not FF_READ_ONLY?
837 test DTA.Attributes,FA_READ_ONLY
838 jz PF_Ret
839 or DirectoryParams.S_Buffer[bx].FileFlag,FF_READ_ONLY?
840 PF_Ret: pop es bp di si dx cx ax
841 ret
842 RD_PutFile endp
843
844 PF_Directory: mov DirectoryParams.S_Buffer[bx].FileFlag,0
845 ret
846
847 PF_DOS33: mov DirectoryParams.S_Buffer[bx].FileFlag,FF_MODIFYTYPE?
848 ret
849
850 PF_Nibble: mov DirectoryParams.S_Buffer[bx].FileFlag,FF_MODIFYTYPE?
851 ret
852
853
854 RD_NewDisk db 1,0Fh,'<New Disk>',0
855 ReadDir proc near
856 push ax bx si di
857 mov GetKeyParams.RK_ErrPtr,offset SMS_ReadDir
858 xor ax,ax
859 mov DirectoryParams.S_MaxLength,al
860 mov BufPtr,ax
861 mov DirectoryParams.S_BegPrint,al
862 mov DirectoryParams.S_Pos,al
863 mov DirectoryParams.S_CX,0B2Ah
864 mov RD_GetDirs?,1
865 xor si,si
866 RD1_Loop0: xor di,di
867 RD1_Cloop: mov al,Filter[si]
868 or al,al
869 jz RD1_CallRead
870 cmp al,','
871 je RD1_CallRead
872 mov WildCard[di],al
873 inc si
874 inc di
875 cmp di,0Ch
876 jb RD1_Cloop
877 RD1_CallRead: mov WildCard[di],0
878 call ReadDirectory
879 mov RD_GetDirs?,0
880 cmp Filter[si],0
881 jz RD1_Done
882 RD1_Ignore: inc si
883 cmp Filter[si],','
884 je RD1_Ignore
885 jmp RD1_Loop0
886 RD1_Done: mov GetKeyParams.RK_ErrPtr,0
887 mov bl,DirectoryParams.S_MaxLength
888 inc DirectoryParams.S_MaxLength
889 call CalcBuffer
890 xor bx,bx
891 RD_CopyNewName: mov al,RD_NewDisk[bx]
892 mov DirectoryParams.S_Buffer[di].FileName[bx],al
893 inc bx
894 or al,al
895 jnz RD_CopyNewName
896 mov DirectoryParams.S_Buffer[di].FileFlag,FF_MODIFYTYPE?
897 mov DirectoryParams.S_Buffer[di].FileType,FD_DOS33
898 call LinkPathFilter
899 call CheckInsertion
900 pop di si bx ax
901 ret
902 ReadDir endp
903
904
905 CheckInsertion: push ax bx cx di bp ds es
906 pushf
907 push cs
908 pop ds
909 cmp DirectoryParams.S_MaxLength,0
910 jz CI_Quit
911 call set_ptrs
912 xor cx,cx
913 mov bl,cl
914 call CalcBuffer
915 CI_Loop: mov bx,di
916 call LinkName
917 xor bx,bx
918 call present1
919 jz CI_NodiskA
920 CI_Loop1: mov al,SDA_Filename[bx]
921 or al,al
922 jz CI_L1exit
923 inc bx
924 cmp al,Path-1[bx]
925 je CI_Loop1
926 CI_L1exit: mov al,FF_INSERTED1?
927 je CI_ok1
928 CI_NodiskA: xor al,al
929 CI_ok1: and DirectoryParams.S_Buffer[di].FileFlag,not(FF_INSERTED1? or FF_INSERTED2?)
930 or DirectoryParams.S_Buffer[di].FileFlag,al
931 xor bx,bx
932 call present2
933 jz CI_NodiskB
934 CI_Loop2: mov al,SDB_Filename[bx]
935 or al,al
936 jz CI_L2exit
937 inc bx
938 cmp al,Path-1[bx]
939 je CI_Loop2
940 CI_L2exit: mov al,FF_INSERTED2?
941 je CI_ok2
942 CI_NodiskB: xor al,al
943 CI_ok2: or DirectoryParams.S_Buffer[di].FileFlag,al
944 mov bl,cl
945 inc cl
946 add di,size DiskDescription
947 cmp bl,DirectoryParams.S_MaxLength
948 jb CI_Loop
949 call UnLinkName
950 CI_Quit: popf
951 pop es ds bp di cx bx ax
952 ret
953 assume es:Emulate
954
955
956 LN_BX dw ?
957 LinkName: pushf
958 push ax bx si di
959 mov si,bx
960 lea si,DirectoryParams.S_Buffer[si]
961 mov di,cs:RD_0OfsSvd
962 xor bx,bx
963 LN_Loop: mov al,cs:[si].FileName[bx]
964 mov cs:Path[di][bx],al
965 inc bx
966 or al,al
967 jnz LN_Loop
968 dec bx
969 add bx,di
970 mov cs:LN_BX,bx
971 pop di si bx ax
972 popf
973 ret
974
975
976
977 UnLinkName: pushf
978 push bx
979 mov bx,cs:RD_0OfsSvd
980 mov cs:Path[bx],0
981 pop bx
982 popf
983 ret
984
985
986
987 Upcase: cmp al,'A'
988 jb UPCSret
989 cmp al,'Z'
990 ja UPCSret
991 or al,20h
992 UPCSret: ret
993
994
995
996 CalcBuffer: push ax
997 mov al,size DiskDescription
998 mul bl
999 mov di,ax
1000 pop ax
1001 ret
1002
1003
1004 CalcCommand: push ax bx cx es ; Returns number of a command
1005 push cs ; Input:
1006 pop es ; di -> offset Commands
1007 call Upcase ; al -> search command
1008 cld ; cx -> commands count
1009 mov bx,di
1010 repne scasb ; Output:
1011 stc ; di <- Number of the command
1012 jne CC_end ; cf <- 1 if not found
1013 sub di,bx
1014 dec di
1015 clc
1016 CC_end: pop es cx bx ax
1017 ccc label byte
1018 ret
1019
1020
1021
1022 ; -- Hook INT 24h ----------------------
1023
1024 DOSflag db 0
1025 OldFlags dw 0
1026 Prepare4DOS: saveall
1027 pushf
1028 xor ax,ax
1029 mov cs:SHL_Flag,al
1030 xchg ax,cs:ActiveFlags
1031 mov cs:OldFlags,ax
1032 mov cs:DOSflag,1
1033 call ShowAll
1034 ScreenIOservice _SHOWSCREEN
1035 call far ptr SystemTINI
1036 popf
1037 restoreall
1038 ret
1039
1040
1041
1042 ; -- Unhook INT 24h --------------------
1043
1044 SOD4eraperP: saveall
1045 pushf
1046 mov ax,cs:OldFlags
1047 mov cs:ActiveFlags,ax
1048 mov cs:SHL_Flag,1
1049 mov ax,Emulate
1050 mov es,ax
1051 mov byte ptr [C000],0
1052 call far ptr SystemINIT
1053 mov cs:DOSflag,0
1054 popf
1055 restoreall
1056 ret
1057
1058
1059
1060 ; *******************************************************************
1061 ; ** **
1062 ; ** **
1063 ; ** S H O W A L L **
1064 ; ** **
1065 ; ** **
1066 ; *******************************************************************
1067
1068 ActiveFlags dw 0
1069 ShowAll proc far
1070 push ds bp
1071 push word ptr [ScreenIOparams.CursorColor]
1072 push word ptr [ScreenIOparams.CursorLen]
1073 push word ptr [ScreenIOparams.CursorFlag]
1074 push cs
1075 pop ds
1076 mov ScreenIOparams.CursorLen,14 ;36
1077 mov ScreenIOparams.CursorColor,10h
1078 mov ScreenIOparams.CursorFlag,1
1079 call InitFlags
1080 ScreenIOservice _CLEARSCREEN
1081 call ShowPathFilter
1082 call ShowDirectory
1083 call ShowDiskA
1084 call ShowDiskB
1085 call ShowImage
1086 call ShowFuncKeys
1087 call ShowError
1088 call ShowMessage
1089 ScreenIOservice _SHOWLINE
1090 call ShowHilights
1091 call ShowTitle
1092 pop word ptr [ScreenIOparams.CursorFlag]
1093 pop word ptr [ScreenIOparams.CursorLen]
1094 pop word ptr [ScreenIOparams.CursorColor]
1095 pop bp ds
1096 ret
1097 ShowAll endp
1098
1099
1100 ; -- Draw box --------------------------
1101 ; Entry:
1102 ; AH = Active Flag Bit
1103 ; CX = HTAB & VTAB
1104 ; BX = Offset of the strings
1105 ; DL = Length of the box line - 1
1106 ; DH = Number of lines - 1
1107 ; Destroy:
1108 ; AX,BX,CX,DX
1109 DB_CX dw ?
1110 DrawBox: push ax
1111 mov ax,cx
1112 add ax,80 * 2
1113 mov cs:DB_CX,ax
1114 pop ax
1115 test ActiveFlags,ax
1116 mov ah,7
1117 jz DB_ok1
1118 mov ah,0Eh
1119 DB_ok1: ScreenIOservice _STRINGPRINT
1120 mov bx,ScreenIOparams.SP_bx
1121 dec dh
1122 mov al,dh
1123 mov dx,cs:DB_CX
1124 DB_Loop1: mov cx,dx
1125 add dx,80 * 2
1126 ScreenIOservice _STRINGPRINT
1127 dec al
1128 jnz DB_Loop1
1129 mov cx,dx
1130 mov bx,ScreenIOparams.SP_bx
1131 ScreenIOservice _STRINGPRINT
1132 ret
1133
1134
1135 IF_Procs dw IFP_F1,IFP_F2,IFP_F3,IFP_F4,IFP_F5
1136 dw IFP_F6,IFP_F7,IFP_F8,IFP_F9,IFP_F0
1137 InitFlags: push ax bx si di bp
1138 mov bl,DirectoryParams.S_Pos
1139 call CalcBuffer
1140 xor si,si
1141 cmp SHL_Flag,0
1142 mov FkeysFlags,0000000100b
1143 jz IF_0
1144 IF_Loop: call IF_Procs[si]
1145 add si,2
1146 cmp si,20
1147 jb IF_Loop
1148 IF_0: cmp DOSflag,0
1149 jnz IF_1
1150 cmp ActiveFlags,0
1151 jnz IF_Ret
1152 IF_1: mov FkeysFlags,0
1153 IF_Ret: pop bp di si bx ax
1154 ret
1155
1156 IFP_F1: cmp ManagerState,MS_NORMAL
1157 jne IFP_F1ret
1158 or FkeysFlags,0000000001b
1159 mov SFK_Reboot[1],06Fh
1160 cmp DirectoryParams.S_Buffer[di].FileType,FD_DIRECTORY
1161 je IFP_F1ret
1162 test DirectoryParams.S_Buffer[di].FileFlag,FF_INSERTED1? or FF_INSERTED2? or FF_DAMAGED?
1163 jnz IFP_F1ret
1164 mov SFK_Reboot[1],01Fh
1165 IFP_F1ret: ret
1166
1167 IFP_F2_D1 dw Fkey_InsertA,Fkey_RemoveA
1168 IFP_F2_D2 dw Fkey_InsertB,Fkey_RemoveB
1169 IFP_F2: or FkeysFlags,00000010b
1170 test ActiveFlags,0000000000001000b
1171 mov bx,offset IFP_F2_D1
1172 mov ax,offset present1
1173 jz IFP_F2_1
1174 mov bx,offset IFP_F2_D2
1175 mov ax,offset present2
1176 IFP_F2_1: call ax
1177 mov ax,[bx][2]
1178 mov SFK_FkeysMain[2],offset SFK_Remove
1179 jnz IFP_F2_2
1180 mov ax,[bx][0]
1181 mov SFK_FkeysMain[2],offset SFK_Insert
1182 cmp DirectoryParams.S_Buffer[di].FileType,FD_DIRECTORY
1183 je IFP_F2_12
1184 test DirectoryParams.S_Buffer[di].FileFlag,FF_INSERTED1? or FF_INSERTED2? or FF_DAMAGED?
1185 jz IFP_F2_2
1186 IFP_F2_12: and FkeysFlags,11111101b
1187 IFP_F2_2: mov Fkeys_Main[2],ax
1188 ret
1189
1190 IFP_F3: or FkeysFlags,0000000100b
1191 cmp ManagerState,MS_NORMAL
1192 mov SFK_FkeysMain[2*2],offset SFK_Apple
1193 mov Fkeys_Main[2*2],offset Fkey_Apple
1194 je IFP_F3_1
1195 mov SFK_FkeysMain[2*2],offset SFK_Resume
1196 mov Fkeys_Main[2*2],offset Fkey_Resume
1197 IFP_F3_1: ret
1198
1199 IFP_F4: cmp ManagerState,MS_NORMAL
1200 mov SFK_FkeysMain[3*2],offset SFK_None
1201 mov Fkeys_Main[3*2],offset Fkey_None
1202 je IFP_F4_1
1203 or FkeysFlags,0000001000b
1204 mov SFK_FkeysMain[3*2],offset SFK_Abort
1205 mov Fkeys_Main[3*2],offset Fkey_Abort
1206 IFP_F4_1: ret
1207
1208 IFP_F5:
1209 IFP_F6:
1210 IFP_F7:
1211 IFP_F8:
1212 IFP_F9: ret
1213
1214 IFP_F0: or FkeysFlags,1100000000b
1215 test ActiveFlags,1
1216 jz IFP0_Ret
1217 mov FkeysFlags,0000000101b
1218 IFP0_Ret: ret
1219
1220
1221 ST_Str db ' APPLER DISK MANAGER ',0
1222 ShowTitle: push ax bx cx
1223 gotoxy 1,0
1224 mov ah,6Fh
1225 mov bx,offset ST_Str
1226 ScreenIOservice _STRINGPRINT
1227 gotoxy 2,0
1228 xor ah,ah
1229 ScreenIOservice _STRINGPRINT
1230 pop cx bx ax
1231 ret
1232
1233
1234 SP_Str db 'ÚPath&FilterÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿',0
1235 db '³ ³',0
1236 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ',0
1237 ShowPathFilter: push ax bx cx dx
1238 gotoxy 3,40
1239 mov bx,offset SP_Str
1240 mov dh,3
1241 mov ax,0000000000000001b
1242 call DrawBox
1243 mov bx,35
1244 xor al,al
1245 xchg PathFilter[bx],al
1246 mov bx,offset PathFilter
1247 mov ah,0Bh
1248 gotoxy 5,42
1249 ScreenIOservice _StringPrint
1250 mov bx,35
1251 xchg PathFilter[bx],al
1252 SPF_Ret: pop dx cx bx ax
1253 ret
1254
1255
1256 SD_Str db 'ÚDirectoryÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿',0
1257 db '³ ³',0
1258 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ',0
1259
1260 SD_Antet0 db 1,07h,'ÄÄÄÄÄÄÄÄÄÄÄÄ ÄÄÄÄÄÄ ÄÄÄÄÄÄÄÄÄÄ',0
1261 SD_Antet1 db 1,07h,'Filename Type Access',0
1262 SD_Antet2 db 1,07h,'Filename ',1,0Fh,'T',1,07h,'ype ',1,0Fh,'A',1,07h,'ccess',0
1263 SD_NotFndMsg db 1,7,'No Matching Files in Directory',0
1264 SD_AntetAddr dw SD_Antet1,SD_Antet1,SD_Antet2,SD_Antet1
1265 dw SD_Antet1,SD_Antet1,SD_Antet2,SD_Antet1
1266
1267 ShowDirectory: push ax bx cx dx di
1268 gotoxy 7,40
1269 mov bx,offset SD_Str
1270 mov dh,17
1271 mov ax,0000000000000010b
1272 call DrawBox
1273 cmp DirectoryParams.S_MaxLength,0
1274 jnz SD_ok2
1275 gotoxy 9,2Bh
1276 mov bx,offset SD_NotFndMsg
1277 ScreenIOservice _STRINGPRINT
1278 jmp SD_Ret
1279 SD_ok2: mov bl,DirectoryParams.S_Pos
1280 call CalcBuffer
1281 xor bx,bx
1282 mov bl,DirectoryParams.S_Buffer[di].FileFlag
1283 test bl,11111000b
1284 jnz SD_ok25
1285 and bl,00000111b
1286 shl bx,1
1287 mov bx,SD_AntetAddr[bx]
1288 cmp SHL_Flag,0
1289 jz SD_ok25
1290 test ActiveFlags,0000000000000010b
1291 jnz SD_ok3
1292 SD_ok25: mov bx,offset SD_Antet1
1293 SD_ok3: gotoxy 9,43
1294 ScreenIOservice _STRINGPRINT
1295 mov bx,offset SD_Antet0
1296 gotoxy 10,43
1297 ScreenIOservice _STRINGPRINT
1298 mov bl,DirectoryParams.S_BegPrint
1299 mov dx,13
1300 mov di,offset DirectoryParams.S_Buffer
1301 gotoxy 11,43
1302 mov ah,7
1303 SD_Loop0: call OneFile
1304 add cx,80 * 2
1305 inc bl
1306 cmp bl,DirectoryParams.S_MaxLength
1307 je SD_Ret0
1308 dec dx
1309 jnz SD_Loop0
1310 SD_Ret0: cmp NameEntering,0
1311 jnz SD_Ret
1312 mov cx,DirectoryParams.S_CX
1313 ScreenIOservice _SHOWCURSOR
1314 SD_Ret: pop di dx cx bx ax
1315 ret
1316
1317
1318 SDA_Str db 'ÚDrive 1ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ',0
1319 db '³ ³ ',0
1320 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ',0
1321 SDA_NoDisk db 1,0Fh,'NO DISK IN DRIVE',0
1322 SDA_File db 1,7,'Name: ',0
1323 SDA_Type db 1,7,'Type: ',0
1324 SDA_Access db 'A',1,7,'ccess: ',0
1325 SDA_Volume db 'V',1,7,'olume: ',0
1326 SDA_Track db 1,7,'Track:',1,0Fh,0
1327 SDA_DOS33 db 1,0Bh,'DOS 3.3',0
1328 SDA_Nibble db 1,0Bh,'Nibblized',0
1329 SDA_ReadOnly db 1,0Bh,'R',0
1330 SDA_RW db 1,0Bh,'R/W',0
1331 SDA_Color db ?
1332 SDA_Filename db 80h dup (0)
1333 ShowDiskA: push ax bx cx dx si es
1334 gotoxy 3,0
1335 mov bx,offset SDA_Str
1336 mov dh,4
1337 mov ax,0000000000000100b
1338 call DrawBox
1339 les si,disk1_ptr
1340 assume es:seg CurrentDrive
1341 cmp es:[si].FileHandle,0FFFFh
1342 jne SDA_Show
1343 mov bx,offset SDA_NoDisk
1344 gotoxy 5,11
1345 ScreenIOservice _STRINGPRINT
1346 jmp SDA_Ret
1347 SDA_Show: mov SDA_Color,7
1348 cmp SHL_Flag,0
1349 jz SDA_LoLight
1350 test ActiveFlags,0000000000000100b
1351 jz SDA_LoLight
1352 mov SDA_Color,0Fh
1353 SDA_LoLight: gotoxy 5,2
1354 mov bx,offset SDA_File
1355 ScreenIOservice _STRINGPRINT
1356 mov bx,offset SDA_Filename
1357 call ShowFilename
1358 gotoxy 6,2
1359 mov bx,offset SDA_Type
1360 mov ah,SDA_Color
1361 ScreenIOservice _STRINGPRINT
1362 cmp es:[si].DiskType,0
1363 mov bx,offset SDA_Nibble
1364 jz SDA_Print
1365 mov bx,offset SDA_DOS33
1366 SDA_Print: ScreenIOservice _STRINGPRINT
1367 gotoxy 5,26
1368 mov bx,offset SDA_Access
1369 mov ah,SDA_Color
1370 ScreenIOservice _STRINGPRINT
1371 cmp es:[si].WriteProtect,0
1372 mov bx,offset SDA_RW
1373 jz SDA_ok1
1374 mov bx,offset SDA_ReadOnly
1375 SDA_ok1: ScreenIOservice _STRINGPRINT
1376 cmp es:[si].DiskType,0
1377 jz SDA_Ret
1378 gotoxy 6,26
1379 mov bx,offset SDA_Volume
1380 mov ah,SDA_Color
1381 ScreenIOservice _STRINGPRINT
1382 mov ah,0Bh
1383 mov al,es:[si].Volume
1384 ScreenIOservice _BYTEPRINT
1385 SDA_Ret: gotoxy 3,30
1386 mov bx,offset SDA_Track
1387 ScreenIOservice _STRINGPRINT
1388 mov al,es:[si].Track
1389 mov ah,0Fh
1390 ScreenIOservice _BYTEPRINT
1391 pop es si dx cx bx ax
1392 ret
1393 assume es:Emulate
1394
1395
1396 SDB_Str db 'ÚDrive 2ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ',0
1397 db '³ ³ ',0
1398 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ',0
1399 SDB_Type db 0
1400 SDB_Filename db 80h dup (0)
1401 ShowDiskB: push ax bx cx dx si es
1402 gotoxy 8,0
1403 mov bx,offset SDB_Str
1404 mov dh,4
1405 mov ax,0000000000001000b
1406 call DrawBox
1407 les si,disk2_ptr
1408 assume es:seg CurrentDrive
1409 cmp es:[si].FileHandle,0FFFFh
1410 jne SDB_Show
1411 mov bx,offset SDA_NoDisk
1412 gotoxy 10,11
1413 ScreenIOservice _STRINGPRINT
1414 jmp SDB_Ret
1415 SDB_Show: mov SDA_Color,7
1416 cmp SHL_Flag,0
1417 jz SDB_LoLight
1418 test ActiveFlags,0000000000001000b
1419 jz SDB_LoLight
1420 mov SDA_Color,0Fh
1421 SDB_LoLight: gotoxy 10,2
1422 mov bx,offset SDA_File
1423 ScreenIOservice _STRINGPRINT
1424 mov bx,offset SDB_Filename
1425 call ShowFilename
1426 gotoxy 11,2
1427 mov bx,offset SDA_Type
1428 mov ah,SDA_Color
1429 ScreenIOservice _STRINGPRINT
1430 cmp es:[si].DiskType,0
1431 mov bx,offset SDA_Nibble
1432 jz SDB_Print
1433 mov bx,offset SDA_DOS33
1434 SDB_Print: ScreenIOservice _STRINGPRINT
1435 gotoxy 10,26
1436 mov bx,offset SDA_Access
1437 mov ah,SDA_Color
1438 ScreenIOservice _STRINGPRINT
1439 cmp es:[si].WriteProtect,0
1440 mov bx,offset SDA_RW
1441 jz SDB_ok1
1442 mov bx,offset SDA_ReadOnly
1443 SDB_ok1: ScreenIOservice _STRINGPRINT
1444 cmp es:[si].DiskType,0
1445 jz SDB_Ret
1446 gotoxy 11,26
1447 mov bx,offset SDA_Volume
1448 mov ah,SDA_Color
1449 ScreenIOservice _STRINGPRINT
1450 mov ah,0Bh
1451 mov al,es:[si].Volume
1452 ScreenIOservice _BYTEPRINT
1453 SDB_Ret: gotoxy 8,30
1454 mov bx,offset SDA_Track
1455 ScreenIOservice _STRINGPRINT
1456 mov al,es:[si].Track
1457 mov ah,0Fh
1458 ScreenIOservice _BYTEPRINT
1459 pop es si dx cx bx ax
1460 ret
1461 assume es:Emulate
1462
1463
1464 ShowFilename: push ax si di es
1465 push cx
1466 cmp byte ptr ds:[bx],0
1467 stc
1468 jz SF_Ret
1469 mov di,bx
1470 mov ax,ds
1471 mov es,ax
1472 mov cx,0FFh
1473 xor al,al
1474 cld
1475 repne scasb
1476 std
1477 mov si,di
1478 dec si
1479 SF_Loop1: lodsb
1480 cmp al,'\'
1481 je SF_ok
1482 cmp si,bx
1483 jae SF_Loop1
1484 dec si
1485 SF_ok: mov bx,si
1486 add bx,2
1487 mov ah,3
1488 clc
1489 pop cx
1490 pushf
1491 ScreenIOservice _STRINGPRINT
1492 popf
1493 SF_Ret: pop es di si ax
1494 ret
1495
1496
1497 SI_Str db 'ÚDOS 3.3 Sector ImageÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ',0
1498 db '³ ³ ',0
1499 db 'ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ',0
1500 SI_AdrP db 1,7,'Address Field Prolog: ',0
1501 SI_AdrChecksum db 1,7,'Address Field Checksum: ',0
1502 SI_AdrE db 1,7,'Address Field Epilog: ',0
1503 SI_DataP db 1,7,'Data Field Prolog: ',0
1504 SI_DataChecksum db 1,7,'Data Field Checksum: ',0
1505 SI_DataE db 1,7,'Data Field Epilog: ',0
1506 SI_EOS db 1,7,'End-Of-Sector Byte: ',0
1507 SI_Texts dw SI_AdrP,?,?
1508 dw SI_AdrChecksum
1509 dw SI_AdrE,?,?
1510 dw SI_DataP,?,?
1511 dw SI_DataChecksum
1512 dw SI_DataE,?,?
1513 dw SI_EOS,?
1514 SI_TextFlags db 1,0,0,1,1,0,0,1,0,0,1,1,0,0,1
1515 ShowImage: push ax bx cx dx si di ds
1516 gotoxy 13,0
1517 mov bx,offset SI_Str
1518 mov dh,10
1519 mov ax,0000000000010000b
1520 call DrawBox
1521 mov ax,seg SectorImage
1522 mov ds,ax
1523 mov si,offset SectorImage
1524 mov dx,offset SectorImageF
1525 cld
1526 xor di,di
1527 SI_Loop: cmp cs:SI_TextFlags[di],0
1528 jz SI_Dont
1529 mov ch,cs:I_CH[di]
1530 dec ch
1531 mov al,ch
1532 mov ah,80 * 2
1533 mul ah
1534 add ax,2*2
1535 mov cx,ax
1536 shl di,1
1537 mov bx,cs:SI_Texts[di]
1538 shr di,1
1539 ScreenIOservice _STRINGPRINT
1540 SI_Dont: xchg dx,si
1541 lodsb
1542 xchg dx,si
1543 or al,al
1544 mov ah,3
1545 jz SI_ok1
1546 mov ah,0Bh
1547 SI_ok1: lodsb
1548 ScreenIOservice _BYTEPRINT
1549 add cx,2
1550 inc di
1551 cmp di,size SectorImage_S
1552 jb SI_Loop
1553 pop ds di si dx cx bx ax
1554 ret
1555
1556
1557 SMS_ReadDir db 'Accessing Disk Directory...',0
1558 SMS_DecodeErr db 1,8Ch,'Drive ',3
1559 dw DM_DriveNum
1560 db ': Error Decoding Track Data',0
1561 SMS_EnterFilename db 'Enter Filename (<Esc> cancel)',0
1562 ShowMessage: push ax bx cx
1563 cmp GetKeyParams.RK_ErrPtr,0
1564 jz SMS_Ret
1565 gotoxy 18h,1
1566 mov bx,GetKeyParams.RK_ErrPtr
1567 mov ah,0Ah
1568 ScreenIOservice _STRINGPRINT
1569 SMS_Ret: pop cx bx ax
1570 ret
1571
1572
1573
1574 SFK_Str db '1 2 3 4 5 '
1575 db '6 7 8 9 10 ',0
1576 FkeysFlags dw 1010000111b
1577 SFK_FkeysMain dw SFK_Reboot,SFK_Insert,SFK_Apple,SFK_None,SFK_None
1578 dw SFK_None,SFK_None,SFK_None,SFK_PathFilter,SFK_Rescan
1579 SFK_Reboot db 1,6Fh,'Reboot',0
1580 SFK_Apple db 1,6Fh,'Apple ',0
1581 SFK_Resume db 1,6Fh,'Resume',0
1582 SFK_Abort db 1,6Fh,'Abort ',0
1583 SFK_Insert db 1,6Fh,'Insert',0
1584 SFK_Remove db 1,6Fh,'Remove',0
1585 SFK_PathFilter db 1,6Fh,'Path&F',0
1586 SFK_Rescan db 1,6Fh,'Rescan',0
1587 SFK_None db 1,6Fh,' ',0
1588
1589 ShowFuncKeys: push ax bx cx dx si
1590 gotoxy 19h,0
1591 mov bx,offset SFK_Str
1592 mov ah,7
1593 ScreenIOservice _STRINGPRINT
1594 gotoxy 19h,1
1595 xor si,si
1596 mov dx,FkeysFlags
1597 SFK_Loop0: shr dx,1
1598 mov ah,8
1599 jnc SFK_Next0
1600 mov ah,0Fh
1601 SFK_Next0: mov bx,SFK_FkeysMain[si]
1602 and byte ptr [bx+1],0F0h
1603 or byte ptr [bx+1],ah
1604 ScreenIOservice _STRINGPRINT
1605 add cx,4
1606 add si,2
1607 cmp si,20
1608 jb SFK_Loop0
1609 pop si dx cx bx ax
1610 ret
1611
1612
1613 SE_BadAdrChk db 'Bad address checksum: ',3
1614 dw DM_BadData,0
1615 SE_BadAdrEpi db 'Bad address epilog, S:',3
1616 dw DM_Sector,0
1617 SE_BadTrack db 'Wrong track number: ',3
1618 dw DM_BadData
1619 db ', S:',3
1620 dw DM_Sector,0
1621 SE_BadSector db 'Sector number not allowed: ',3
1622 dw DM_BadData,0
1623 SE_MisingData db 'Data field not found, S:',3
1624 dw DM_Sector,0
1625 SE_DuplicateSec db 'Sector found twice: ',3
1626 dw DM_BadData
1627 db ', S:',3
1628 dw DM_Sector,0
1629 SE_BadDataChk db 'Bad data checksum: ',3
1630 dw DM_BadData
1631 db ', S:',3
1632 dw DM_Sector,0
1633 SE_BadDataImg db 'Bad nibble byte, S:',3
1634 dw DM_Sector,0
1635 SE_BadDataEpi db 1,8Ch,'Bad data epilog, S:',3
1636 dw DM_Sector,0
1637 SE_BadEnd db 'Bad end-of-sector byte, S:',3
1638 dw DM_Sector,0
1639 SE_MissingSec db 'Can''t find sector: ',3
1640 dw DM_BadData,0
1641 SE_WriteAttempt db 'Write protected',0
1642 SE_ErrorAddress dw SE_BadAdrChk
1643 dw SE_BadAdrEpi
1644 dw SE_BadTrack
1645 dw SE_BadSector
1646 dw SE_MisingData
1647 dw SE_DuplicateSec
1648 dw SE_BadDataChk
1649 dw SE_BadDataImg
1650 dw SE_BadDataEpi
1651 dw SE_BadEnd
1652 dw SE_MissingSec
1653 dw SE_WriteAttempt
1654 ShowError: push ax bx cx
1655 cmp ManagerState,MS_NORMAL
1656 je SE_Ret
1657 cmp DM_DriveNum,1
1658 gotoxy 4,2
1659 je SE_ok1
1660 gotoxy 9,2
1661 SE_ok1: xor bx,bx
1662 mov bl,DM_ErrorCode
1663 shl bx,1
1664 mov bx,SE_ErrorAddress[bx]
1665 mov ah,0Ch
1666 ScreenIOservice _STRINGPRINT
1667 SE_Ret: pop cx bx ax
1668 ret
1669
1670 SHL_Flag db 1
1671 ShowHilights: cmp SHL_Flag,0
1672 jz SHL_Ret
1673 push ax cx
1674 gotoxy 13,16
1675 mov ax,0E00h+'I'
1676 ScreenIOservice _SYMBPRINT
1677 gotoxy 3,7
1678 mov al,'1'
1679 ScreenIOservice _SYMBPRINT
1680 gotoxy 8,7
1681 mov al,'2'
1682 ScreenIOservice _SYMBPRINT
1683 gotoxy 3,41
1684 mov al,'P'
1685 ScreenIOservice _SYMBPRINT
1686 gotoxy 7,41
1687 mov al,'D'
1688 ScreenIOservice _SYMBPRINT
1689 SHL_Exit: pop cx ax
1690 SHL_Ret: ret
1691
1692
1693 OF_CX dw ?
1694 OF_Types dw OF_Directory,OF_Nibble,OF_DOS33
1695 OF_Directory db 1,7,'<DIR>',0
1696 OF_DOS33 db 'DOS3.3',0
1697 OF_Nibble db 'Nibble',0
1698 OF_RO db 'Read Only ',0
1699 OF_RW db 'Read/Write',0
1700 OF_DirAccess db 1,7,' ---- ',0
1701 OF_Inserted1 db 1,0Fh,'Inserted in Drive 1',0
1702 OF_Inserted2 db 1,0Fh,'Inserted in Drive 2',0
1703 OF_Base dw ?
1704 OF_Color db ?
1705 comment %
1706 push ax dx ds
1707 mov ax,4d9h
1708 mov ds,ax
1709 mov dx,103h
1710 mov ax,2509h
1711 int 21h
1712 pop ds dx ax
1713 int 3
1714 %
1715 OneFile: push ax bx cx dx di
1716 mov OF_Base,di
1717 mov OF_CX,cx
1718 call CalcBuffer
1719 mov bp,OF_Base
1720 lea bx,ds:[bp][di].FileName
1721 test ds:[bp][di].FileFlag,FF_DAMAGED?
1722 mov OF_Color,0Bh
1723 jz OF_hop1
1724 mov ah,0Ch
1725 mov OF_Color,ah
1726 OF_hop1: ScreenIOservice _STRINGPRINT
1727 mov cx,OF_CX
1728 add cx,2*15
1729 mov bp,OF_Base
1730 test ds:[bp][di].FileFlag,FF_INSERTED1? or FF_INSERTED2?
1731 jz OF_NotInserted
1732 test ds:[bp][di].FileFlag,FF_INSERTED1?
1733 mov bx,offset OF_Inserted1
1734 jnz OF_id1
1735 mov bx,offset OF_Inserted2
1736 OF_id1: ScreenIOservice _STRINGPRINT
1737 jmp OF_Ret
1738 OF_NotInserted: xor bx,bx
1739 push bp
1740 mov al,ds:[bp][di].FileType
1741 mov bl,al
1742 shl bx,1
1743 mov bx,OF_Types[bx]
1744 mov ah,OF_Color
1745 ScreenIOservice _STRINGPRINT
1746 cmp al,FD_DIRECTORY
1747 mov bx,offset OF_DirAccess
1748 pop bp
1749 je OF_hop2
1750 test ds:[bp][di].FileFlag,FF_READ_ONLY?
1751 mov bx,offset OF_RO
1752 jnz OF_hop2
1753 mov bx,offset OF_RW
1754 OF_hop2: mov cx,OF_CX
1755 add cx,2*24
1756 ScreenIOservice _STRINGPRINT
1757 OF_Ret: pop di dx cx bx ax
1758 ret
1759
1760
1761
1762
1763 ; *******************************************************************
1764 ; ** **
1765 ; ** **
1766 ; ** K E Y B O A R D S E R V I C E S **
1767 ; ** **
1768 ; ** **
1769 ; *******************************************************************
1770
1771 Alt_Keys db 'ipd12'
1772 Alt_Procs dw Alt_Image,Alt_PathFilter,Alt_Directory,Alt_D1,Alt_D2
1773 Alt_Key proc far
1774 push cx si di ds
1775 mov di,offset Alt_Keys
1776 mov cx,offset Alt_Procs- offset Alt_Keys
1777 call CalcCommand
1778 jc Alt_Ret
1779 Alt_ok: shl di,1
1780 call cs:Alt_Procs[di]
1781 mov al,7Fh
1782 Alt_Ret: pop ds di si cx
1783 ret
1784
1785 Alt_PathFilter proc near
1786 mov cs:GoWhere?,G_PATH_FILTER
1787 ret
1788 Alt_PathFilter endp
1789
1790 Alt_Directory proc near
1791 mov cs:GoWhere?,G_DIRECTORY
1792 ret
1793 Alt_Directory endp
1794
1795 Alt_Image proc near
1796 mov cs:GoWhere?,G_IMAGE
1797 ret
1798 Alt_Image endp
1799
1800 Alt_D1 proc near
1801 mov cs:GoWhere?,G_D1
1802 ret
1803 Alt_D1 endp
1804
1805 Alt_D2 proc near
1806 mov cs:GoWhere?,G_D2
1807 ret
1808 Alt_D2 endp
1809
1810 Alt_Key endp
1811
1812
1813
1814 FkeysMasks dw 1b,10b,100b,1000b,10000b,100000b,1000000b,10000000b,100000000b,1000000000b
1815 Fkeys_Main dw Fkey_Reboot,Fkey_None,Fkey_Apple,Fkey_InsertA,Fkey_InsertB
1816 dw Fkey_None,Fkey_None,Fkey_None,Fkey_PathFilter,Fkey_Rescan
1817 Fkey proc far
1818 push ax bx cx dx si di bp ds es
1819 push cs
1820 pop ds
1821 push word ptr ds:[ScreenIOparams.CursorLen]
1822 push word ptr ds:[ScreenIOparams.CursorFlag]
1823 push ds:[GetLineParams.GL_Buffer]
1824 push ds:[GetLineParams.GL_CX]
1825 push [ActiveFlags]
1826 push [FkeysFlags]
1827 mov bx,Emulate
1828 mov es,bx
1829 xor bx,bx
1830 mov bl,al
1831 shl bx,1
1832 mov si,bx
1833 mov ax,FkeysMasks[si]
1834 test FkeysFlags,ax
1835 jz Fkey_Ret
1836 xor bx,bx
1837 call Fkeys_Main[si]
1838 mov cx,DirectoryParams.S_CX
1839 Fkey_Ret: pop [FkeysFlags]
1840 pop [ActiveFlags]
1841 pop ds:[GetLineParams.GL_CX]
1842 pop ds:[GetLineParams.GL_Buffer]
1843 pop word ptr ds:[ScreenIOparams.CursorFlag]
1844 pop word ptr ds:[ScreenIOparams.CursorLen]
1845 pop es ds bp di si dx cx bx ax
1846 ret
1847 Fkey endp
1848
1849 Fkey_InsertA: clc
1850 call InsertDisk
1851 ret
1852
1853 Fkey_InsertB: stc
1854 call InsertDisk
1855 ret
1856
1857 ; Entry:
1858 ; CF -- 0 - Disk1, 1 - Disk2
1859 ID_Flags db ?
1860 ID_Rescan? db ?
1861 ID_Ext db '.DSK',0
1862 InsertDisk: mov ID_Rescan?,0
1863 mov si,offset SDA_Filename
1864 jnc ID_Disk1
1865 mov si,offset SDB_Filename
1866 ID_Disk1: lahf
1867 mov ID_Flags,ah
1868 cmp DirectoryParams.S_MaxLength,0
1869 jz ID_Ret
1870 mov bl,DirectoryParams.S_Pos
1871 call CalcBuffer
1872 test DirectoryParams.S_Buffer[di].FileFlag,FF_INSERTED1? or FF_INSERTED2?
1873 jnz ID_Ret
1874 cmp DirectoryParams.S_Buffer[di].FileType,FD_DIRECTORY
1875 je ID_Ret
1876 cmp DirectoryParams.S_Buffer[di].FileName[0],1
1877 jne ID_NotNew
1878 mov ID_Rescan?,1
1879 add di,size DiskDescription
1880 call EnterFilename
1881 jc ID_Quit
1882 push si di
1883 lea di,DirectoryParams.S_Buffer[di].FileName
1884 mov si,offset ID_Ext
1885 call AddExt
1886 pop di si
1887 mov DirectoryParams.S_Buffer[di].FileType,FD_NIBBLE
1888 jc ID_NotDOS33
1889 mov DirectoryParams.S_Buffer[di].FileType,FD_DOS33
1890 ID_NotDOS33: mov bx,di
1891 call CreateDisk
1892 jc ID_Err
1893 ID_NotNew: mov bx,di
1894 call LinkName
1895 xor bx,bx
1896 ID_Loop: mov al,Path[bx]
1897 mov [si][bx],al
1898 inc bx
1899 or al,al
1900 jnz ID_Loop
1901 call UnlinkName
1902 mov dx,si
1903 mov bl,DirectoryParams.S_Buffer[di].FileType
1904 dec bl
1905 mov bh,0FEh
1906 test DirectoryParams.S_Buffer[di].FileFlag,FF_READ_ONLY?
1907 mov al,1
1908 jnz ID_1
1909 xor al,al
1910 ID_1: mov ah,ID_Flags
1911 sahf
1912 call OpenDiskFile
1913 jc ID_Err
1914 and DirectoryParams.S_Buffer[di].FileFlag,not FF_DAMAGED?
1915 clc
1916 jmp ID_Ret
1917 ID_Err: or DirectoryParams.S_Buffer[di].FileFlag,FF_DAMAGED?
1918 mov ah,ID_Flags
1919 sahf
1920 call CloseDiskFile
1921 stc
1922 ID_Ret: cmp ID_Rescan?,0
1923 jz ID_Quit
1924 call ReadDir
1925 ID_Quit: ret
1926
1927 CreateDisk: push ax bx dx cx
1928 call LinkName
1929 mov dx,offset Path
1930 mov ah,3Ch
1931 xor cx,cx
1932 int 21h
1933 jc CD_Err
1934 mov bx,ax
1935 mov ah,3Eh
1936 int 21h
1937 CD_Err: call UnlinkName
1938 pop cx dx bx ax
1939 ret
1940
1941
1942 Fkey_RemoveA: call CloseDiskFile1
1943 mov cs:SDA_Filename[0],0
1944 ret
1945
1946 Fkey_RemoveB: call CloseDiskFile2
1947 mov cs:SDB_Filename[0],0
1948 ret
1949
1950 Fkey_Reboot: call Fkey_InsertA
1951 jc FR_Ret
1952 call ResetAppleII
1953 call GoAppleII
1954 FR_Ret: ret
1955
1956 Fkey_PathFilter: call S_PathFilter
1957 ret
1958
1959 Fkey_Rescan: call ReadDir
1960 ret
1961
1962 Fkey_Apple: call GoAppleII
1963 ret
1964
1965 Fkey_Resume: clc
1966 jmp DMentry_Exit
1967 Fkey_Abort: stc
1968 jmp DMentry_Exit
1969
1970 Fkey_None:
1971 ret
1972
1973
1974 NameEntering db 0
1975 EnterFilename: push ax bx cx dx di
1976 mov NameEntering,1
1977 push word ptr [GetKeyParams.RK_AltFlag]
1978 push word ptr [FkeysFlags]
1979 push word ptr [SHL_Flag]
1980 mov GetLineParams.GL_Color,0Bh
1981 mov GetKeyParams.RK_AltFlag,0
1982 mov SHL_Flag,0
1983 mov FkeysFlags,0000000100b
1984 mov ScreenIOparams.CursorFlag,1
1985 lea bx,DirectoryParams.S_Buffer[di].FileName
1986 mov GetLineParams.GL_Buffer,bx
1987 mov GetLineParams.GL_Pos,0
1988 mov GetLineParams.GL_BegPrint,0
1989 mov GetLineParams.GL_MaxLength,0Ch
1990 mov GetLineParams.GL_MaxPrint,0Dh
1991 mov GetLineParams.GL_Length,0
1992 mov ScreenIOparams.CursorLen,1
1993 mov cx,DirectoryParams.S_CX
1994 dec ch
1995 inc cl
1996 mov al,80 * 2
1997 mul ch
1998 xor bx,bx
1999 mov bl,cl
2000 shl bx,1
2001 add ax,bx
2002 mov cx,ax
2003 mov GetKeyParams.RK_ErrPtr,offset SMS_EnterFilename
2004 GetLineService _GETLINE
2005 pop word ptr [SHL_Flag]
2006 pop word ptr [FkeysFlags]
2007 pop word ptr [GetKeyParams.RK_AltFlag]
2008 gotoxy 2,0
2009 mov GetLineParams.GL_CX,cx
2010 mov NameEntering,0
2011 pop di dx cx bx ax
2012 ret
2013
2014
2015
2016
2017 GetLineUser proc far
2018 ret
2019 GetLineUser endp
2020
2021
2022 GoAppleII: push ax bx es
2023 xor bx,bx
2024 xchg bx,ActiveFlags
2025 call ShowAll
2026 ScreenIOservice _SHOWSCREEN
2027 mov ax,Emulate
2028 mov es,ax
2029 mov al,C050
2030 ScreenIOservice _SetScreen
2031 SwitchToProcess PID_EMULATOR
2032 mov ActiveFlags,bx
2033 pop es bx ax
2034 ret
2035
2036
2037 ; Entry:
2038 ; DS:DX^ -- Filename
2039 ; AL -- Access Mode: 0 - Don't Change, else Read Only
2040 ; BL -- Type: 0 - Nibble, 1 - DOS 3.3
2041 ; BH -- Volume (for DOS 3.3 type only)
2042 ; CF -- 0 - Disk1, 1 - Disk2
2043 ; Exit:
2044 ; CF -- Cleared if successfull
2045 assume es:seg CurrentDrive
2046 OpenDiskFile proc far
2047 push ax bx cx dx si di bp ds es
2048 call set_ptrs
2049 mov cl,al
2050 les bp,cs:disk1_ptr
2051 mov di,offset SDA_Filename
2052 jnc ODF_Continue
2053 les bp,cs:disk2_ptr
2054 mov di,offset SDB_Filename
2055 ODF_Continue: call CloseDiskFIle
2056 mov ax,3D02h
2057 int 21h
2058 jnc ODF_1
2059 mov ax,3D00h
2060 int 21h
2061 jc ODF_Quit
2062 stc
2063 ODF_1: mov es:[bp].FileHandle,ax
2064 mov es:[bp].DiskType,bl
2065 mov es:[bp].Volume,bh
2066 mov bl,0FFh
2067 jc ODF_2
2068 xor bl,bl
2069 ODF_2: or cl,cl
2070 jz ODF_3
2071 mov bl,0FFh
2072 ODF_3: mov es:[bp].WriteProtect,bl
2073 mov si,dx
2074 mov bx,es:[bp].FileHandle
2075 mov cx,1
2076 mov dx,1000h
2077 mov ax,4200h
2078 int 21h
2079 jc ODF_Ret
2080 push ds
2081 push cs
2082 pop ds
2083 mov cx,40h
2084 mov dx,offset ODF_TempBuffer
2085 mov ah,3Fh
2086 int 21h
2087 jc ODF_Ret
2088 cmp ax,cx
2089 jne ODF_Ret
2090 cmp ODF_TempBuffer[3],3
2091 jne ODF_Ret
2092 cmp ODF_TempBuffer[35h],10h
2093 jne ODF_Ret
2094 cmp word ptr ODF_TempBuffer[36h],100h
2095 jne ODF_Ret
2096 mov al,ODF_TempBuffer[6]
2097 mov es:[bp].Volume,al
2098 ODF_Ret: pop ds
2099 push cs
2100 pop es
2101 mov ah,60h
2102 int 21h
2103 clc
2104 call CheckInsertion
2105 ODF_Quit: pop es ds bp di si dx cx bx ax
2106 ret
2107 ODF_TempBuffer db 40h dup (?)
2108 OpenDiskFile endp
2109
2110 ; Entry:
2111 ; CF -- 0 - Disk1, 1 - Disk2
2112 CloseDiskFile proc near
2113 push ax bx bp es
2114 call set_ptrs
2115 les bp,cs:disk1_ptr
2116 jnc CDF_Disk1
2117 les bp,cs:disk2_ptr
2118 assume es:seg CurrentDrive
2119 CDF_Disk1: mov bx,es:[bp].FileHandle
2120 inc bx
2121 jz CDF_NoDisk
2122 dec bx
2123 cmp cs:ManagerState,MS_NORMAL
2124 jne CDF_FlushOK ; Don't flush while in error
2125 cmp bp,offset CurrentDrive
2126 jne CDF_FlushOK ; Flush only if close current
2127 call FlushBuffer
2128 CDF_FlushOK: mov ah,3Eh
2129 int 21h
2130 jc CDF_Ret
2131 mov es:[bp].FileHandle,0FFFFh
2132 call CheckInsertion
2133 CDF_Ret: clc
2134 CDF_Quit: pop es bp bx ax
2135 ret
2136 CDF_NoDisk: stc
2137 jmp CDF_Quit
2138 CloseDiskFile endp
2139
2140 OpenDiskFile1 proc far
2141 push ax bx dx bp ds es
2142 call set_ptrs
2143 push cs
2144 pop ds
2145 les bp,disk1_ptr
2146 mov dx,offset SDA_Filename
2147 cmp SDA_Filename[0],0
2148 jz ODF1_NoFile
2149 mov bl,es:[bp].DiskType
2150 mov bh,es:[bp].Volume
2151 mov al,es:[bp].WriteProtect
2152 clc
2153 call OpenDiskFile
2154 jnc ODF1_Ret
2155 ODF1_NoFile: mov es:[bp].FileHandle,0FFFFh
2156 call CheckInsertion
2157 ODF1_Ret: pop es ds bp dx bx ax
2158 ret
2159 OpenDiskFile1 endp
2160
2161 OpenDiskFile2 proc far
2162 push ax bx dx bp ds es
2163 call set_ptrs
2164 push cs
2165 pop ds
2166 les bp,disk2_ptr
2167 mov dx,offset SDB_Filename
2168 cmp SDB_Filename[0],0
2169 jz ODF2_NoFile
2170 mov bl,es:[bp].DiskType
2171 mov bh,es:[bp].Volume
2172 mov al,es:[bp].WriteProtect
2173 stc
2174 call OpenDiskFile
2175 jnc ODF2_Ret
2176 ODF2_NoFile: mov es:[bp].FileHandle,0FFFFh
2177 call CheckInsertion
2178 ODF2_Ret: pop es ds bp dx bx ax
2179 ret
2180 OpenDiskFile2 endp
2181
2182 CloseDiskFile1 proc far
2183 clc
2184 call CloseDiskFile
2185 jnc CDF1_Ret
2186 mov cs:SDA_Filename[0],0
2187 CDF1_Ret: ret
2188 CloseDiskFile1 endp
2189
2190 CloseDiskFile2 proc far
2191 stc
2192 call CloseDiskFile
2193 jnc CDF2_Ret
2194 mov cs:SDB_Filename[0],0
2195 CDF2_Ret: ret
2196 CloseDiskFile2 endp
2197 assume es:Emulate
2198
2199 ; Entry:
2200 ; DL <-- Sector (0FFh if an invalid sector number)
2201 ; AH <-- Error Code
2202 ; AL <-- Bad Data
2203 ; Exit:
2204 ; CF --> 0 - Retry, 1 - Abort
2205 OldEnableTask db ?
2206 DM_ScreenMode db ?
2207 DMentry_SP dw ?
2208 DM_ErrorCode db ?
2209 DM_BadData db ?
2210 DM_DriveNum db ?
2211 DM_Sector db ?
2212 DM_OldKeyTable dw ?
2213 DM_old_gl dd ?
2214 DM_old_sio dd ?
2215 DM_old_rk dd ?
2216 DM_SwapFlag db ?
2217 DMentry proc far
2218 SaveAll
2219 push word ptr cs:[GetKeyParams.RK_AltFlag]
2220
2221 mov bx,seg k_Table ; Save Current Key Table
2222 mov ds,bx
2223 assume ds:seg k_Table
2224 mov bx,ds:k_Table
2225 mov cs:DM_OldKeyTable,bx
2226
2227 mov bx,CONio ; Save Current CONIO Params
2228 mov ds,bx
2229 assume ds:CONio
2230 mov bx,ds:GL_ParamsOfs
2231 mov word ptr cs:DM_old_gl[0],bx
2232 mov bx,ds:GL_ParamsSeg
2233 mov word ptr cs:DM_old_gl[2],bx
2234 mov bx,ds:SIO_ParamsOfs
2235 mov word ptr cs:DM_old_sio[0],bx
2236 mov bx,ds:SIO_ParamsSeg
2237 mov word ptr cs:DM_old_sio[2],bx
2238 mov bx,ds:RK_ParamsOfs
2239 mov word ptr cs:DM_old_rk[0],bx
2240 mov bx,ds:RK_ParamsSeg
2241 mov word ptr cs:DM_old_rk[2],bx
2242
2243 call DM_InInitP
2244 mov bx,seg SwapFlag
2245 mov ds,bx
2246 assume ds:seg SwapFlag
2247 mov al,1
2248 xchg al,ds:SwapFlag
2249 mov cs:DM_SwapFlag,al
2250 mov bx,seg EnableTaskSwitch
2251 mov ds,bx
2252 assume ds:seg EnableTaskSwitch
2253 xor bl,bl
2254 xchg ds:EnableTaskSwitch,bl
2255 mov cs:OldEnableTask,bl
2256 mov bx,seg CurrentDrive
2257 mov ds,bx
2258 assume ds:seg CurrentDrive
2259 mov cl,ds:CurrentDrive.ID
2260 push cs
2261 pop ds
2262 assume DS:DM
2263 mov ScreenIOparams.CursorFlag,0
2264 mov DM_ErrorCode,ah
2265 mov DM_Sector,dl
2266 mov DM_BadData,al
2267 inc cl
2268 mov DM_DriveNum,cl
2269 dec cl
2270 mov ActiveFlags,0000000000000100b
2271 mov GoWhere?,G_D1
2272 jz DMentry_1
2273 mov ActiveFlags,0000000000001000b
2274 mov GoWhere?,G_D2
2275 DMentry_1: mov ah,0Fh
2276 int 10h
2277 mov DM_ScreenMode,al
2278 mov I_CurrentSVD,0
2279 mov ManagerState,MS_ERROR
2280 mov DMentry_SP,sp
2281 mov GetKeyParams.RK_ErrPtr,offset SMS_DecodeErr
2282 jmp DM_MainRet
2283 ; ---------------------
2284 DMentry_Exit: mov sp,DMentry_SP
2285 pushf
2286 mov ManagerState,MS_NORMAL
2287 mov ax,seg EnableTaskSwitch
2288 mov ds,ax
2289 assume ds:seg EnableTaskSwitch
2290 mov al,cs:OldEnableTask
2291 mov ds:EnableTaskSwitch,al
2292 call DM_OutInitP
2293
2294 mov ax,seg k_Table ; Restore Entry Key Table
2295 mov ds,ax
2296 assume ds:seg k_Table
2297 mov ax,cs:DM_OldKeyTable
2298 mov ds:k_Table,ax
2299
2300 mov ax,CONio ; Restore Entry CONIO Params
2301 mov ds,ax
2302 assume ds:CONio
2303 mov ax,word ptr cs:DM_old_gl[0]
2304 mov ds:GL_ParamsOfs,ax
2305 mov ax,word ptr cs:DM_old_gl[2]
2306 mov ds:GL_ParamsSeg,ax
2307 mov ax,word ptr cs:DM_old_sio[0]
2308 mov ds:SIO_ParamsOfs,ax
2309 mov ax,word ptr cs:DM_old_sio[2]
2310 mov ds:SIO_ParamsSeg,ax
2311 mov ax,word ptr cs:DM_old_rk[0]
2312 mov ds:RK_ParamsOfs,ax
2313 mov ax,word ptr cs:DM_old_rk[2]
2314 mov ds:RK_ParamsSeg,ax
2315
2316 cmp cs:DM_ScreenMode,3
2317 jne DM_Entry_2
2318 cmp cs:DM_SwapFlag,0
2319 jz DM_Entry_2
2320 ScreenIOservice _SHOWSCREEN
2321 jmp DM_Entry_3
2322 DM_Entry_2: mov ax,seg C050
2323 mov es,ax
2324 assume es:seg C050
2325 mov al,es:C050
2326 ScreenIOservice _SetScreen
2327 DM_Entry_3: popf
2328 pop word ptr cs:[GetKeyParams.RK_AltFlag]
2329 RestoreAll
2330 ret
2331 DMentry endp
2332 assume es:Emulate
2333
2334 DM ends
2335 END
2336
Generated by GNU Enscript 1.6.6, and GophHub 1.3.