📄 sector.asm
字号:
ShowString_BIOS 16,3ch,dh,9fh
pop cx
inc dh
add bp,16
loop DisplayAsciiCodes
ret
DisplayBuffer endp
DisplayPara proc near
.if _FuncSign==01h
Hex2Bcd 0,_CurCylin,BcdChs,12,5
Hex2Bcd 0,_CurHead,BcdChs,23,3
Hex2Bcd 0,_CurSector,BcdChs,35,2
ShowString_DOS BcdChs,7,20
.endif
Hex2Bcd dapBlockNumLH,dapBlockNumLL,BcdLbaSect,20,9
ShowString_DOS BcdLbaSect,51,20
ret
DisplayPara endp
PgUp_Sin proc near ;===[ Sin下PageUp键的处理 ]
.if b_2ndPage
mov _OffsetBuffer,offset OffsetBuffer1
mov _HexBuffer,offset HexBuffer1
mov _AsciiBuffer,offset AsciiBuffer1
mov b_2ndPage,FALSE
Call DisplayBuffer
Call State_Sin
.endif
ret
PgUp_Sin endp
PgDn_Sin proc near ;===[ Sin下PageDown键的处理 ]
.if !b_2ndPage
mov _OffsetBuffer,offset OffsetBuffer2
mov _HexBuffer,offset HexBuffer2
mov _AsciiBuffer,offset AsciiBuffer2
mov b_2ndPage,TRUE
Call DisplayBuffer
Call State_Sin
.endif
ret
PgDn_Sin endp
PgUp_Mul proc near
.if !b_2ndPage
dec _CurSector
mov ax,_SectPerTrack
mov bx,_MaxHead
dec bx
mov cx,_MaxCylin
dec cx
.if _CurSector==0 && _CurHead!=0
dec _CurHead
mov _CurSector,ax
.elseif _CurSector==0 && _CurHead==0 && _CurCylin!=0
dec _CurCylin
mov _CurHead,bx
mov _CurSector,ax
.elseif _CurSector==0 && _CurHead==0 && _CurCylin==0
mov _CurCylin,cx
mov _CurHead,bx
mov _CurSector,ax
.endif
mov _OffsetBuffer,offset OffsetBuffer2
mov _HexBuffer,offset HexBuffer2
mov _AsciiBuffer,offset AsciiBuffer2
mov b_2ndPage,TRUE
Call ReadSector
Call ConvertBuffer
Call DisplayBuffer
Call DisplayPara
ret
.endif
mov _OffsetBuffer,offset OffsetBuffer1
mov _HexBuffer,offset HexBuffer1
mov _AsciiBuffer,offset AsciiBuffer1
mov b_2ndPage,FALSE
Call DisplayBuffer
ret
PgUp_Mul endp
PgDn_Mul proc near
.if b_2ndPage
inc _CurSector
mov ax,_SectPerTrack
inc ax
mov bx,_MaxHead
dec bx
mov cx,_MaxCylin
dec cx
.if _CurSector==ax && _CurHead!=bx
inc _CurHead
mov _CurSector,1
.elseif _CurSector==ax && _CurHead==bx && _CurCylin!=cx
inc _CurCylin
mov _CurHead,0
mov _CurSector,1
.elseif _CurSector==ax && _CurHead==bx && _CurCylin==cx
mov _CurCylin,0
mov _CurHead,0
mov _CurSector,1
.endif
mov _OffsetBuffer,offset OffsetBuffer1
mov _HexBuffer,offset HexBuffer1
mov _AsciiBuffer,offset AsciiBuffer1
mov b_2ndPage,FALSE
Call ReadSector
Call ConvertBuffer
Call DisplayBuffer
Call DisplayPara
ret
.endif
mov _OffsetBuffer,offset OffsetBuffer2
mov _HexBuffer,offset HexBuffer2
mov _AsciiBuffer,offset AsciiBuffer2
mov b_2ndPage,TRUE
Call DisplayBuffer
ret
PgDn_Mul endp
EditUp proc near ;===[ 编辑状态下上键的处理 ]
.if _CurY!=4
dec _CurY
GotoXY _CurX,_CurY
.endif
ret
EditUp endp
EditDown proc near ;===[ 编辑状态下下键的处理 ]
.if _CurY!=19
inc _CurY
GotoXY _CurX,_CurY
.endif
ret
EditDown endp
EditLeft proc near ;===[ 编辑状态下左键的处理 ]
.if _CurX==11 && _CurY!=4
mov _CurX,57
dec _CurY
GotoXY _CurX,_CurY
.elseif _CurX!=11
dec _CurX
Div3
.if ah==1
dec _CurX
.endif
GotoXY _CurX,_CurY
.endif
ret
EditLeft endp
EditRight proc near ;===[ 编辑状态下右键的处理 ]
.if _CurX==57 && _CurY!=19
mov _CurX,11
inc _CurY
.elseif _CurX!=57
inc _CurX
Div3
.if ah==1
inc _CurX
.endif
.endif
GotoXY _CurX,_CurY
ret
EditRight endp
EditInput proc near ;===[ 编辑状态下的输入0-9,A-f,a-f的处理 ]
.if !b_Modify
mov b_Modify,TRUE ;置修改标志位
.endif
mov al,_TempByte
MulShowCharA al,7fh,1 ;在十六进制数表中显示十六进制
Ascii2Hex al
push ax
Div3 ;判断当前输入的位置是光标所在十六进制数的1位还是16位,并跳到对应的处理模块上
.if ah==0
jmp SinDigit
.elseif ah==2
jmp TenDigit
.else
pop ax
inc _CurX
GotoXY _CurX,_CurY
ret
.endif
SinDigit: ;1位处理模块
sub al,4
mov dl,al ;因为第一列十六进制数的1位数字列坐标为12,故把1位数字的坐标除以3后得到的商再减去4便得到该十六进制数在DiskBuffer内的相对偏移地址
.if !b_2ndPage
mov bp,offset TempBuffer1
.else
mov bp,offset TempBuffer2 ;根据页面置修改缓冲的开始地址
.endif
xor ax,ax
mov al,_CurY
sub al,4 ;因为第一行十六进制数的行坐标为4,故把行坐标减去4后得到的差就是该行十六进制数在Diskbuffer内的相对段地址
mov cx,4
shl al,cl ;根据不同的行计算不同的相对段地址
add al,dl
mov si,ax ;把两个地址加起来则得到当前输入位置所在的十六进制数在DiskBuffer内的绝对偏移地址
pop ax
mov ah,[bp+si]
and ah,0f0h
or ah,al
mov [bp+si],ah ;在Diskbuffer内读出数值和输入的数进行与和替代并放入临时缓冲内
mov _TempByte,ah
add dl,60
GotoXY dl,_CurY ;置输入点在屏幕上对应ASCII码的位置
MulShowCharA _TempByte,4fh,1 ;把替代后的数在对应ASCII码的位置上替换显示
Call EditRight
ret
TenDigit: ;16位处理模块
sub al,3
mov dl,al
.if !b_2ndPage
mov bp,offset TempBuffer1
.else
mov bp,offset TempBuffer2
.endif
xor ax,ax
mov al,_CurY
sub al,4
mov cx,4
shl al,cl
add al,dl
mov si,ax
pop ax
mov cx,4
shl al,cl
mov ah,[bp+si]
and ah,0fh
or ah,al
mov [bp+si],ah
mov _TempByte,ah
add dl,60
GotoXY dl,_CurY
MulShowCharA _TempByte,4fh,1
Call EditRight
ret
EditInput endp
Edit proc near ;===[ 编辑主处理 ]
;---[ 初始化 ]
mov cx,000fh
mov ah,1
int 10h ;设置光标显示类型
mov _CurX,11
mov _CurY,4
mov b_Modify,FALSE
Call State_Edit
GotoXY _CurX,_CurY
;---[ 按键检测 ]
EditKeyCheck:
Call GetKey
.if al==1bh && b_Modify ;ESC With Modify
Call Modify
ret
.elseif al==1bh && !b_Modify ;ESC With Non-Modify
Call HideCursor
Call State
ret
.elseif (al>=30h && al<=39h) || (al>=41h && al<=46h) ;0-9,A-F
mov _TempByte,al
Call EditInput
.elseif al>=61h && al<=66h ;a-f
sub al,20h
mov _TempByte,al
Call EditInput
.elseif al==0
Call GetKey
.if al==3fh ;F5
Call Modify
ret
.elseif al==48h ;Up
Call EditUp
.elseif al==50h ;Down
Call EditDown
.elseif al==4bh ;Left
Call EditLeft
.elseif al==4dh ;Right
Call EditRight
.endif
.endif
jmp EditKeyCheck
Edit endp
Modify proc near ;===[ 扇区被修改的处理 ]
mov _DialogSign,00h
mov b_SelectFalse,TRUE
Call Dialog
.if b_SelectFalse==FALSE
.if _FuncSign==10h
Call WriteCMOS
Call ReadCMOS
.else
Call WriteSector
Call ReadSector
.endif
Call ConvertBuffer
.endif
mov b_Modify,FALSE
Call DisplayBuffer
Call State
ret
Modify endp
S_LFile proc near
OpenWin 19,9,62,13,00h
OpenWin 18,8,61,12,0b0h
Rectangle 18,8,61,12,0b0h
OpenWin 32,10,58,10,0fh
OpenWin 18,8,61,8,0f4h
.if b_SaveFile
ShowString_DOS SaveTitle,34,8
.else
ShowString_DOS LoadTitle,33,8
.endif
ShowString_DOS FileName,21,10
.if _FuncSign==00h
.if _HeadLineCode==00h
ShowString_DOS DefaultNameMBR,32,10
mov si,offset DefaultNameMBR
mov cx,7
.elseif _HeadLineCode==10h
ShowString_DOS DefaultNameDBR,32,10
mov si,offset DefaultNameDBR
mov cx,7
.elseif _HeadLineCode==01h
ShowString_DOS DefaultNameDPT,32,10
mov si,offset DefaultNameDPT
mov cx,9
.elseif _HeadLineCode==11h
ShowString_DOS DefaultNameBoot,32,10
mov si,offset DefaultNameBoot
mov cx,10
.endif
.elseif _FuncSign==01h
ShowString_DOS DefaultNameRandom,32,10
mov si,offset DefaultNameRandom
mov cx,10
.else
ShowString_DOS DefaultCMOS,32,10
mov si,offset DefaultCMOS
mov cx,8
.endif
mov di,offset EnterBuffer
push di
push cx
cld
rep movsb
Call ShowCursor
pop cx
pop di
add di,cx
InputKeyCheck:
Call GetKey
.if al==1bh
jmp ExitFile
.elseif al==0dh && cl!=0 && b_SaveFile
Call SaveFile
jmp ExitFile
.elseif al==0dh && cl!=0 && !b_SaveFile
Call LoadFile
Call ConvertBuffer
jmp ExitFile
.elseif al==0
Call GetKey
jmp InputKeyCheck
.elseif al>=20h && al<=7eh && cl!=27
mov [di],al
inc di
ShowChar_DOS al
inc cx
.elseif al==08h && cl!=0
ShowChar_DOS al
push cx
MulShowChar 0,1
pop cx
dec di
dec cx
.endif
jmp InputKeyCheck
ExitFile:
OpenWin 3,4,76,19,9eh
Call HideCursor
Call DisplayBuffer
ret
S_LFile endp
SaveFile proc near
mov byte ptr [di],0
Call CheckFile
.if b_SelectFalse==TRUE
ret
.endif
Call CreatFile
.if _DialogSign!=30h
Call WriteFile
Call CloseFile
.endif
ret
SaveFile endp
LoadFile proc near
mov byte ptr [di],0
Call OpenFile
.if _DialogSign!=31h
Call ReadFile
.if _DiaLogSign!=32h
mov di,offset TempBuffer1
mov si,offset DiskBuffer
mov cx,512
cld
rep movsb
.endif
Call CloseFile
.endif
ret
LoadFile endp
CreatFile proc near
mov dx,offset EnterBuffer
mov cx,0
mov ah,3ch
int 21h
.if Carry?
mov _DialogSign,30h
Call Dialog
ret
.endif
mov _FileHandle,ax
ret
CreatFile endp
WriteFile proc near
mov bx,_FileHandle
mov dx,offset TempBuffer1
.if _FuncSign==10h
mov cx,128
.else
mov cx,512
.endif
mov ah,40h
int 21h
.if Carry?
mov _DialogSign,33h
Call Dialog
.endif
ret
WriteFile endp
OpenFile proc near
mov dx,offset EnterBuffer
mov ax,3d00h
int 21h
.if Carry?
mov _DialogSign,31h
Call Dialog
ret
.endif
mov _FileHandle,ax
ret
OpenFile endp
ReadFile proc near
mov bx,_FileHandle
mov dx,offset DiskBuffer
.if _FuncSign==10h
mov cx,128
.else
mov cx,512
.endif
mov ah,3fh
int 21h
.if Carry?
mov _DialogSign,32h
Call Dialog
.endif
ret
ReadFile endp
CloseFile proc near
mov bx,_FileHandle
mov ah,3eh
int 21h
.if Carry?
mov _DialogSign,14h
Call Dialog
.endif
ret
CloseFile endp
CheckFile proc near
mov dx,offset EnterBuffer
mov ax,3d00h
int 21h
.if !Carry?
mov b_SelectFalse,TRUE
mov _DialogSign,03h
Call Dialog
.endif
mov b_SelectFalse,FALSE
ret
CheckFile endp
Dialog proc near
Call HideCursor
OpenWin 24,9,57,14,00h
OpenWin 23,8,56,13,0cfh
Rectangle 23,8,56,13
OpenWin 23,8,56,8,0f4h
.if _DialogSign<20h
ShowString_DOS WarningTitle,37,8
.if _DialogSign==00h
ShowString_DOS WarningModifyMsg,26,10
.elseif _DialogSign==03h
ShowString_DOS WarningOverWriteMsg,29,10
.endif
.else
ShowString_DOS ErrorTitle,38,8
.if _DialogSign==22h
ShowString_DOS ErrorReadMsg,30,10
.elseif _DialogSign==23h
ShowString_DOS ErrorWriteMsg,30,10
.elseif _DialogSign==30h
ShowString_DOS ErrorCreatFileMsg,31,10
.elseif _DialogSign==31h
ShowString_DOS ErrorOpenFileMsg,32,10
.elseif _DialogSign==32h
ShowString_DOS ErrorReadFileMsg,31,10
.elseif _DialogSign==33h
ShowString_DOS ErrorWriteFileMsg,31,10
.endif
.endif
DisplayChoice:
.if _DialogSign<20h
.if !b_SelectFalse
OpenWin 29,12,35,12,0f4h
ShowString_DOS ConYesSel,29,12
OpenWin 45,12,50,12,74h
ShowString_DOS ConNo,45,12
.else
OpenWin 29,12,35,12,74h
ShowString_DOS ConYes,29,12
OpenWin 45,12,50,12,0f4h
ShowString_DOS ConNoSel,45,12
.endif
.else
OpenWin 37,12,42,12,0f4h
ShowString_DOS ConOKSel,37,12
.endif
DialogKeyCheck:
Call GetKey
.if al==1bh
mov b_SelectFalse,TRUE
ret
.elseif al==0dh
ret
.elseif al==0
Call GetKey
.if al==4bh && b_SelectFalse
mov b_SelectFalse,FALSE
jmp DisplayChoice
.elseif al==4dh && !b_SelectFalse
mov b_SelectFalse,TRUE
jmp DisplayChoice
.endif
.endif
jmp DialogKeyCheck
Dialog endp
TextPart proc near
OpenWin 9,6,72,18,00h
OpenWin 8,5,71,17,0cfh
Rectangle 8,5,71,17
Call State_ROnly
mov _CurX,28
ShowString_DOS TextPartHeader,28,6
ShowString_DOS TextPartBootState,10,7
ShowString_DOS TextPartType,10,8
ShowString_DOS TextPartBCylin,10,9
ShowString_DOS TextPartBHead,10,10
ShowString_DOS TextPartBSector,10,11
ShowString_DOS TextPartECylin,10,12
ShowString_DOS TextPartEHead,10,13
ShowString_DOS TextPartESector,10,14
ShowString_DOS TextPartBootSector,10,15
ShowString_DOS TextPartTSectors,10,16
mov bp,offset DiskBuffer
add bp,1beh
mov cx,4
Display4Part:
push cx
.if byte ptr [bp]==80h
ShowString_DOS TextYes,_CurX,7
.else
ShowString_DOS TextNo,_CurX,7
.endif
.if byte ptr [bp+4]==06h
ShowString_DOS TextFAT16,_CurX,8
.elseif byte ptr [bp+4]==0bh
ShowString_DOS TextFAT32,_CurX,8
.elseif byte ptr [bp+4]==05h
ShowString_DOS TextFAT16E,_CurX,8
.elseif byte ptr [bp+4]==0fh
ShowString_DOS TextFAT32E,_CurX,8
.elseif byte ptr [bp+4]==0
ShowString_DOS TextUnused,_CurX,8
.else
ShowString_DOS TextUnknown,_CurX,8
.endif
DivCySe [bp+2],[bp+3],_TempCylin,byte ptr _TempSector
Hex2BCD 0,_TempCylin,CHSBuffer,4,5
GotoXY _CurX,9
mov di,offset CHSBuffer
mov cx,5
TrimBCylin:
mov al,[di]
.if al!=0
ShowChar_DOS al
.endif
inc di
loop TrimBCylin
mov al,[bp+1]
mov byte ptr _TempHead,al
Hex2BCD 0,_TempHead,CHSBuffer,2,3
GotoXY _CurX,10
mov di,offset CHSBuffer
mov cx,3
TrimBHead:
mov al,[di]
.if al!=0
ShowChar_DOS al
.endif
inc di
loop TrimBHead
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -