⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.asm

📁 功能强大的磁盘维护工具
💻 ASM
字号:
extern HighLight:far,HideCursor:far,Cls:far,GetKey:far,ShowCursor:far		;From Common
extern WarningTitle:byte,ConOKSel:byte		;From Sector
extern SinSector:far,MulSector:far,CMOS:far,Ascii:far,Color:far,Partition:far,LogDisk:far,PhyDisk:far	;From All Module
public _CurDisk,_MaxCylin,_MaxHead,_MaxSect,_MaxSectLH,_SectPerTrack,_SectSize,DiskBuffer,DrivePacket,_DriveCount,_DiskCount,_EInt13Ver,_EInt13API
public Dap,DapOffset,DapSegment,DapBlockNumLL,DapBlockNumLH
public MenuBar,State_Red,State_Black
public _HeadLineCode,_DriveSign,_TempDwordH,_TempDwordL

include MACRO.ASM

.model small
.stack
.data

;*** Define Drive Addresses Packets (DAP) Struct (16 Bytes) ***
	Dap label byte
	DapSize byte 16		;PacketSize byte
	DapReserved byte 0	;Reserved==0 byte
	DapBlockCount word 1	;BlockCount word
	DapOffset word 0	
	DapSegment word 0	;BufferAddress(Segment:Offset) dword
	DapBlockNumLL word 0	
	DapBlockNumLH word 0
	DapBlockNumH dword 0	;BlockNum qword

;*** Define Drive Parameters Packets (DPP) Struct (26 Bytes) ***
	Dpp label byte
        DppSize word 26         ;InfoSize word
        DppFlag word 0          ;Flags word
        _MaxCylin word 0
        _MaxCylinH word 0       ;MaxCylinders dword
        _MaxHead word 0
        _MaxHeadH word 0        ;MaxHeads dword
        _SectPerTrack word 0
        _SectPerTrackH word 0   ;SectorPerTrack dword
        _MaxSect word 0
        _MaxSectLH word 0
        _MaxSectH dword 0       ;MaxSectors qword
        _SectSize word 0         ;SectorSize word

	DiskBuffer byte 512 dup(0)
	DrivePacket byte 120 dup(0)
	
	SoftName byte 'Disk Assistant','$'
        MenuBar byte 'Disk   MBR   DBR   Others   Info   Help','$'
	State_Red byte "ESC","Alt+X",18h,19h,1bh,1ah,11h,0d9h,"F1","F3","F4","F5","F8","F9","PgUp","PgDn"
        State_Black byte "=Menu","=Exit","=Choose","=Select","=Edit","=ChangeCHS","=Save/Load File","=Back/Forward","=Move","=Cancel","=Text"
	WarningAbnormal1 byte "No HardDisk Found !","$"
	WarningAbnormal2 byte "or (Extend) Int 13H not Supported !","$"
	WarningAbnormal3 byte "or Running under NT Kernel System !","$"
	WarningAbnormalResult byte "All Functions not Enable !","$"
	DiskPacket byte "Hard Disk 1","$","Hard Disk 2","$","Hard Disk 3","$","Hard Disk 4","$"
	MBRDrives byte 24 dup("DPT Of ",00h,":","$")
	DBRDrives byte 24 dup("Boot Of ",00h,":","$")
        Menu2List1 byte " MBR ",'$'
        Menu3List1 byte " DBR ",'$'
	Menu4List1 byte " Physical Sector ","$"
	Menu4List2 byte " CMOS ","$"
	Menu5List1 byte " Disk Logical Info ","$"
	Menu5List2 byte " Disk Physical Info ","$"
	Menu5List3 byte " Partition Info ","$"
	Menu5List4 byte " ASCII Table ","$"
	Menu5List5 byte " Color Table ","$"
	Menu6List1 byte " Exit ","$"

	_TempDwordL word 0
	_TempDwordH word 0
	_EInt13Ver word 0
	_EInt13API word 0
	_HeadLineCode byte 0
	_CurDisk byte 80h
	_DiskCount byte 0
	_DriveSign byte 0
	_DriveCount byte 0
	_MenuID byte 1
	_MenuCount byte 6
	_SubMenuID byte 3
	_SubMenuCount byte 0
	_DiskMenuCount byte 0
	_DriveMenuCount byte 0
	b_MenuAct byte FALSE
	b_Normal byte TRUE

.code
.startup

Main proc far

	mov ax,@data
	mov es,ax
        Call HighLight
        Call HideCursor
        Call Cls
        OpenWin 0,0,79,0,9fh
        ShowString_DOS SoftName,33,0

	Call ResumeScreen
	Call State_Menu
	Call CheckDisk

KeyCheck:
        Call GetKey
        .if al==1bh && !b_MenuAct	;ESC With Non-Menu
        mov b_MenuAct,TRUE
	Call ChangeMenu
        .elseif al==1bh && b_MenuAct	;ESC With Menu
        mov b_MenuAct,FALSE
        Call State_Menu
	Call ResumeScreen
        .elseif al==2dh	&& !b_MenuAct		;Alt+X
        jmp Exit2DOS
        .elseif al==0dh && b_MenuAct	;Enter
		.if _MenuID==6 && _SubMenuID==3
		jmp Exit2Dos
		.endif
        mov b_MenuAct,FALSE
        Call MenuEnter
        .elseif al==0 && b_MenuAct
                Call GetKey
                .if al==48h             ;Up
                Call Up
                .elseif al==50h         ;Down
                Call Down
                .elseif al==4bh         ;Left
                Call Left
                .elseif al==4dh         ;Right
                Call Right
                .endif
        .endif
        jmp KeyCheck

Exit2DOS:
	Call Cls
        Call ShowCursor
        GotoXY 0,0
	.exit 0
Main endp


ResumeScreen proc near
        OpenWin 0,1,79,1,0f0h                   ;Menu Bar
        ShowString_DOS MenuBar,3,1
        GotoXY 0,2
        MulShowCharA 0b1h,9fh,1760
	ret
ResumeScreen endp


State_Menu proc near
        OpenWin 0,24,79,24,0f0h                 ;State Bar
        mov bp,offset State_Red
        ShowString_BIOS 3,2,24,0fch     
        add bp,3
        ShowString_BIOS 5,12,24,0fch
        mov bp,offset State_Black
        ShowString_BIOS 5,5,24,0f0h
        add bp,5
        ShowString_BIOS 5,17,24,0f0h
	ret
State_Menu endp


State_ActMenu proc near
        OpenWin 0,24,79,24,0f0h
        mov bp,offset State_Red
        ShowString_BIOS 3,2,24,0fch     
        add bp,8
        ShowString_BIOS 4,14,24,0fch
        add bp,4
        ShowString_BIOS 2,27,24,0fch

        mov bp,offset State_Black
        add bp,72
        ShowString_BIOS 7,5,24,0f0h
        sub bp,62
        ShowString_BIOS 7,18,24,0f0h
        add bp,7
        ShowString_BIOS 7,29,24,0f0h
	ret
State_ActMenu endp


CheckDisk proc near
	Call CheckDiskCount
	.if b_Normal==FALSE
	Call Abnormal
	ret
	.endif

	Call CheckExtend13
	.if b_Normal==FALSE
	Call Abnormal
	ret
	.endif

	Call GetDiskPara
	Call SearchDrives
	Call FillDriveMenu
	ret
CheckDisk endp


CheckDiskCount proc near
        mov ah,08h
        mov dl,_CurDisk
        int 13h
	.if ah!=0 || dl==0
	mov b_Normal,FALSE
	ret
	.endif
        mov _DiskCount,dl
	ret
CheckDiskCount endp


CheckExtend13 proc near
        mov ah,41h
        mov bx,55aah
        mov dl,_CurDisk
        int 13h
	.if Carry?
	mov b_Normal,FALSE
	.endif
	mov _EInt13Ver,ax
	mov _EInt13API,cx
	ret
CheckExtend13 endp


GetDiskPara proc near
        mov ah,48h
        mov dl,_CurDisk
        mov si,offset Dpp
        int 13h
	ret
GetDiskPara endp


SearchDrives proc near
	mov _DriveCount,0
	mov _DriveSign,43h
	ClearArr DapBlockNumLL,4
	ClearArr _TempDwordL,2
	mov di,offset DiskBuffer
	mov si,offset DrivePacket

SearchDrive:
	EInt13 42h,DiskBuffer
	mov ax,WORD ptr [di+1cah]
	mov _TempDwordL,ax
	mov ax,WORD ptr [di+1cch]
	mov _TempDwordH,ax
	.if _TempDwordL==0 && _TempDwordH==0
	ret
	.endif
	inc _DriveCount
	.if WORD ptr [di+1dah]==0 && WORD ptr [di+1dch]==0
	ret
	.endif
	EAdd DapBlockNumLH,DapBlockNumLL,_TempDwordH,_TempDwordL
	EAdd DapBlockNumLH,DapBlockNumLL,0,003fh
	mov al,_DriveSign
	add al,_DriveCount
	mov [si],al
	EMov [si+3],[si+1],DapBlockNumLH,DapBlockNumLL
	add si,5
	jmp SearchDrive
SearchDrives endp


FillDriveMenu proc near
	mov di,offset MBRDrives
	mov si,offset DBRDrives
	mov bl,44h
	xor cx,cx
	mov cl,_DriveCount

FillDriveSign:
	mov [di+7],bl
	mov [si+8],bl
	inc bl
	add di,10
	add si,11
	loop FillDriveSign
	ret
FillDriveMenu endp


ChangeMenu proc near
	Call State_ActMenu
        .if _MenuID==1
        Call Menu1
        .elseif _MenuID==2
        Call Menu2
        .elseif _MenuID==3
        Call Menu3
	.elseif _MenuID==4
	Call Menu4
	.elseif _MenuID==5
	Call Menu5
	.else
	Call Menu6
        .endif
	ret
ChangeMenu endp


Up proc near
        .if _SubMenuID!=3
        dec _SubMenuID
        .else
        mov al,_SubMenuCount
        mov _SubMenuID,al
        .endif
        Call ChangeMenu
	ret
Up endp


Down proc near
        mov al,_SubMenuCount
        .if _SubMenuID!=al
        inc _SubMenuID
        .else
        mov _SubMenuID,3
        .endif
        Call ChangeMenu
	ret
Down endp


Left proc near
        mov _SubMenuID,3
        .if _MenuID!=1
        dec _MenuID
        .else
        mov al,_MenuCount
        mov _MenuID,al
        .endif
        Call ChangeMenu
	ret
Left endp


Right proc near
        mov _SubMenuID,3
        mov al,_MenuCount
        .if _MenuID!=al
        inc _MenuID
        .else
        mov _MenuID,1
        .endif
        Call ChangeMenu
	ret
Right endp


MenuEnter proc near
        .if _MenuID==1 && b_Normal
	mov al,_SubMenuID
	sub al,3
	add al,80h
	mov _CurDisk,al
	Call ResumeScreen
	Call State_Menu
	Call CheckDisk

        .elseif _MenuID==2 && _SubMenuID==3 && b_Normal
	mov _TempDwordH,0
	mov _TempDwordL,0
	mov _HeadLineCode,00h
        Call SinSector

        .elseif _MenuID==2 && _SubMenuID>3 && b_Normal
	mov si,offset DrivePacket
	mov al,_SubMenuID
	sub al,4
	mov bl,5
	mul bl
	inc ax
	add si,ax
	mov ax,WORD ptr [si+2]
	mov _TempDwordH,ax
	mov ax,WORD ptr [si]
	mov _TempDwordL,ax
	mov al,[si-1]
	mov _HeadLineCode,01h
	mov _DriveSign,al
        Call SinSector

        .elseif _MenuID==3 && _SubMenuID==3 && b_Normal
        mov _TempDwordH,0
	mov _TempDwordL,63
	mov _HeadLineCode,10h
        Call SinSector

        .elseif _MenuID==3 && _SubMenuID>3 && b_Normal
	mov si,offset DrivePacket
	mov al,_SubMenuID
	sub al,4
	mov bl,5
	mul bl
	inc ax
	add si,ax
	mov ax,WORD ptr [si+2]
	mov _TempDwordH,ax
	mov ax,WORD ptr [si]
	mov _TempDwordL,ax
	EAdd _TempDwordH,_TempDwordL,0,63
	mov al,[si-1]
	mov _HeadLineCode,11h
	mov _DriveSign,al
        Call SinSector

	.elseif _MenuID==4 && _SubMenuID==3 && b_Normal
	Call MulSector

	.elseif _MenuID==4 && _SubMenuID==4
	Call CMOS

	.elseif _MenuID==5 && _SubMenuID==3 && b_Normal
	Call LogDisk

	.elseif _MenuID==5 && _SubMenuID==4 && b_Normal
	Call PhyDisk

	.elseif _MenuID==5 && _SubMenuID==5 && b_Normal
	Call Partition

	.elseif _MenuID==5 && _SubMenuID==6
	Call Ascii

	.elseif _MenuID==5 && _SubMenuID==7
	Call Color
        .endif

	Call ResumeScreen
	Call State_Menu
	ret
MenuEnter endp


Menu1 proc near
	Call ResumeScreen
        OpenWin 2,1,7,1,0fh
        ShowString_DOS MenuBar,3,1

	.if !b_Normal
	ret
	.endif

	mov _DiskMenuCount,3
	mov al,_DiskCount
	add _DiskMenuCount,al

	OpenWin 2,2,16,_DiskMenuCount,0f0h
        Rectangle 2,2,16,_DiskMenuCount,0f0h
        mov _SubMenuCount,3
	mov al,_DiskCount
	dec al
	add _SubMenuCount,al

        OpenWin 3,_SubMenuID,15,_SubMenuID,0fh

	mov bp,offset DiskPacket
	xor cx,cx
	mov cl,_DiskCount
	mov dh,3
DisplayDiskMenu:
	push cx
	ShowString_DOSNB 4,dh
	inc dh
	add bp,12
	pop cx
	loop DisplayDiskMenu

	ret
Menu1 endp


Menu2 proc near
	Call ResumeScreen
        OpenWin 9,1,13,1,0fh
        ShowString_DOS MenuBar,3,1

	.if !b_Normal
	ret
	.endif

	mov _DriveMenuCount,3
	mov al,_DriveCount
	add _DriveMenuCount,al

        OpenWin 9,2,21,_DriveMenuCount,0f0h
        Rectangle 9,2,21,_DriveMenuCount,0f0h
        mov _SubMenuCount,3
	mov al,_DriveCount
	dec al
	add _SubMenuCount,al

        OpenWin 10,_SubMenuID,20,_SubMenuID,0fh
        ShowString_DOS Menu2List1,10,3

	.if _DriveCount==1
	ret
	.endif
        
	mov bp,offset MBRDrives
	xor cx,cx
	mov cl,_DriveCount
	dec cl
	mov dh,4
DisplayMBRMenu:
	push cx
	ShowString_DOSNB 11,dh
	inc dh
	add bp,10
	pop cx
	loop DisplayMBRMenu

	ret
Menu2 endp


Menu3 proc near
	Call ResumeScreen
        OpenWin 15,1,19,1,0fh
        ShowString_DOS MenuBar,3,1

	.if !b_Normal
	ret
	.endif

	mov _DriveMenuCount,3
	mov al,_DriveCount
	add _DriveMenuCount,al

        OpenWin 15,2,28,_DriveMenuCount,0f0h
        Rectangle 15,2,28,_DriveMenuCount,0f0h
        mov _SubMenuCount,3
	mov al,_DriveCount
	dec al
	add _SubMenuCount,al

        OpenWin 16,_SubMenuID,27,_SubMenuID,0fh
        ShowString_DOS Menu3List1,16,3

	.if _DriveCount==1
	ret
	.endif

	mov bp,offset DBRDrives
	xor cx,cx
	mov cl,_DriveCount
	dec cl
	mov dh,4
DisplayDBRMenu:
	push cx
	ShowString_DOSNB 17,dh
	inc dh
	add bp,11
	pop cx
	loop DisplayDBRMenu

	ret
Menu3 endp


Menu4 proc near
       	Call ResumeScreen
	OpenWin 21,1,28,1,0fh
        ShowString_DOS MenuBar,3,1

	OpenWin 21,2,39,5,0f0h
        Rectangle 21,2,39,5,0f0h
        mov _SubMenuCount,4

        OpenWin 22,_SubMenuID,38,_SubMenuID,0fh
        ShowString_DOS Menu4List1,22,3
        ShowString_DOS Menu4List2,22,4
        ret
Menu4 endp


Menu5 proc near
       	Call ResumeScreen
        OpenWin 30,1,35,1,0fh
        ShowString_DOS MenuBar,3,1

	OpenWin 30,2,51,8,0f0h
        Rectangle 30,2,51,8,0f0h
        mov _SubMenuCount,7

        OpenWin 31,_SubMenuID,50,_SubMenuID,0fh
        ShowString_DOS Menu5List1,31,3
        ShowString_DOS Menu5List2,31,4
	ShowString_DOS Menu5List3,31,5
	ShowString_DOS Menu5List4,31,6
	ShowString_DOS Menu5List5,31,7
	ret
Menu5 endp


Menu6 proc near
       	Call ResumeScreen
        OpenWin 37,1,42,1,0fh
        ShowString_DOS MenuBar,3,1

	OpenWin 37,2,44,4,0f0h
        Rectangle 37,2,44,4,0f0h
        mov _SubMenuCount,3

        OpenWin 38,_SubMenuID,43,_SubMenuID,0fh
        ShowString_DOS Menu6List1,38,3
	ret
Menu6 endp


Abnormal proc near
	OpenWin 20,8,61,18,00h
	OpenWin 19,7,60,17,0cfh
	Rectangle 19,7,60,17
	OpenWin 19,7,60,7,0f4h
	OpenWin 20,13,59,13,0ceh

	ShowString_DOS WarningTitle,37,7
	ShowString_DOS WarningAbnormal1,31,9
	ShowString_DOS WarningAbnormal2,22,10
	ShowString_DOS WarningAbnormal3,22,11
	ShowString_DOS WarningAbnormalResult,28,13

	OpenWin 37,15,42,15,0f4h
	ShowString_DOS ConOKSel,37,15

DialogKeyCheck:
	Call GetKey
	.if al==1bh || al==0dh
	Call ResumeScreen
	ret
	.endif
	jmp DialogKeyCheck

Abnormal endp

end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -