📄 moddtp.bas
字号:
Attribute VB_Name = "modDTP"
'****************************************************************************
'人人为我,我为人人
'枕善居收藏整理
'发布日期:2007/03/20
'描 述:软盘分析修复维护工具 Ver 1.3.0
'网 站:http://www.Mndsoft.com/ (VB6源码博客)
'网 站:http://www.VbDnet.com/ (VB.NET源码博客,主要基于.NET2005)
'e-mail :Mndsoft@163.com
'e-mail :Mndsoft@126.com
'OICQ :88382850
' 如果您有新的好的代码别忘记给枕善居哦!
'****************************************************************************
Option Explicit
'--------------------------------------Windows API Functions
Private Declare Function GetTickCount Lib "kernel32" () As Long
'-------------------------------------------Public Variables
Public mWork As Byte
Public SecCopy(1 To 2880) As Boolean
Public EditTrack As Byte
Public EditSide As Byte
Public EditSector As Byte
Public MarkBad As Boolean
Public Editting As Boolean
Public BkJump As Long
'------------------------------------------Private Variables
Private oldNsec As Byte
Private ReadTick As Long
Private StartTick As Long
Private SecList(1 To 2880, 1 To 512) As Byte
Private EOFdisk As Boolean
Private DepthScan As Boolean
Private StartSec As Long, CurrentSec As Long, EndSec As Long
'------------------------------------------Public Structures
Public Enum EditOperation
eoInit = 1
eoFormat = 2
eoOverwrite = 3
eoMarkBad = 4
eoUnmark = 5
eoReading = 6
eoMove = 7
eoResetPos = 8
eoEndEdit = 9
End Enum
'-----------------------------------------------CountSecCopy
Public Function CountSecCopy() As Long
Dim res As Long
Dim i As Long
res = 0
For i = 1 To 2880
If SecCopy(i) = False Then res = res + 1
Next i
CountSecCopy = res
End Function
'-----------------------------------------------SectorNumber
Public Function SectorNumber(ByVal Track As Byte, ByVal Side As Byte, ByVal Sector As Byte) As Long
SectorNumber = Track * 36 + Side * 18 + Sector
End Function
'-------------------------------------------------NumSectors
Public Function NumSectors() As Byte
Select Case mLightRead
Case 1: NumSectors = 18
Case 2: NumSectors = 9
Case 3: NumSectors = 3
Case 4: NumSectors = 1
End Select
End Function
'-----------------------------------------GetSideTrackInside
Public Function GetSideTrackInside(ByVal Track As Byte, ByVal Side As Byte, Optional Sector As Byte = 0) As SectorType
Dim num As Long
Dim Info As SectorType
Dim i As Byte
Dim nSec As Long
Info = 0
If Sector = 0 Then
For i = 1 To 18
num = SectorNumber(Track, Side, i)
If SectorInfo(num) > Info Then
Info = SectorInfo(num)
End If
Next i
Else
nSec = NumSectors() - 1
For i = Sector To Sector + nSec
num = SectorNumber(Track, Side, i)
If SectorInfo(num) > Info Then
Info = SectorInfo(num)
End If
Next i
End If
GetSideTrackInside = Info
End Function
'-----------------------------------------GetSideTrackSector
Public Function GetSideTrackSector(ByVal Track As Byte, ByVal Side As Byte) As StatType
Dim num As Long
Dim Info As StatType
Dim i As Byte
Info = 0
For i = 1 To 18
num = SectorNumber(Track, Side, i)
If SectorStat(num) > Info Then
Info = SectorStat(num)
End If
Next i
GetSideTrackSector = Info
End Function
'---------------------------------------------DisplaySurface
Public Sub DisplaySurface()
Dim Track As Byte
Dim Side As Byte
Dim Sector As Byte
Dim num As Long
Dim InfoSEC As SectorType
Dim InfoSTA As StatType
Call DisplayCentralSurface(mModWin)
Central.StartEnd.DrawCursor
For Track = 0 To 79
For Side = 0 To 1
If (mModWin = 1) Or (mModWin = 3) Then
For Sector = 1 To 18
num = SectorNumber(Track, Side, Sector)
If SectorInfo(num) <> IOempty Then
Call DisplaySectorInside(SectorInfo(num), Track, Side, Sector)
End If
If SectorStat(num) <> statNormal Then
Call DisplaySector(Track, Side, Sector, SectorStat(num))
End If
Next Sector
Else
InfoSEC = GetSideTrackInside(Track, Side)
InfoSTA = GetSideTrackSector(Track, Side)
num = SectorNumber(Track, 0, Side + 1)
If InfoSEC <> IOempty Then
Call DisplaySectorInside(InfoSEC, Track, 0, Side + 1)
End If
If InfoSTA <> statNormal Then
Call DisplaySector(Track, 0, Side + 1, InfoSTA)
End If
End If
Next Side
Next Track
End Sub
'----------------------------------------DisplaySectorInside
Public Sub DisplaySectorInside(ByVal Info As SectorType, ByVal Track As Byte, ByVal Side As Byte, ByVal Sector As Byte)
Dim X As Long
Dim Y As Long
X = 8 + Track * 7
Y = 18 + Side * 130 + (Sector - 1) * 7
Select Case Info
Case IOempty: Central.ForeColor = RGB(4, 54, 52)
Case IObad: Central.ForeColor = RGB(252, 2, 84)
Case IOboot: Central.ForeColor = RGB(252, 250, 4)
Case IOfat1: Central.ForeColor = RGB(4, 166, 252)
Case IOfat2: Central.ForeColor = RGB(4, 166, 4)
Case IOdir: Central.ForeColor = RGB(164, 166, 164)
Case IOdata: Central.ForeColor = RGB(4, 2, 4)
Case Else: Central.ForeColor = RGB(255, 255, 255)
End Select
Central.FillColor = Central.ForeColor
Central.FillStyle = 0
Central.Line (X, Y)-(X + 3, Y + 3), , BF
End Sub
'---------------------------------------------DisplaySectors
Public Sub DisplaySector(ByVal Track As Byte, ByVal Side As Byte, ByVal Sector As Byte, ByVal modo As StatType)
Dim X As Long
Dim Y As Long
X = 7 + Track * 7
Y = 17 + Side * 130 + (Sector - 1) * 7
Select Case modo
Case statError: Central.ForeColor = RGB(252, 250, 252)
Case statOk: Central.ForeColor = RGB(84, 86, 84)
Case statRead: Central.ForeColor = RGB(0, 150, 150)
Case statWrite: Central.ForeColor = RGB(150, 0, 0)
Case statVerify: Central.ForeColor = RGB(150, 150, 0)
Case statNormal: Central.ForeColor = RGB(4, 2, 4)
Case statEdit: Central.ForeColor = RGB(94, 128, 142)
End Select
Central.FillStyle = 1
Central.Line (X, Y)-(X + 5, Y + 5), , B
End Sub
Public Sub DisplaySectors(ByVal Track As Byte, ByVal Side As Byte, ByVal Sector As Byte, ByVal modo As StatType)
Dim i As Byte
Dim soma As Byte
soma = NumSectors() - 1
If (mModWin = 1) Or (mModWin = 3) Then
For i = Sector To Sector + soma
Call DisplaySector(Track, Side, i, modo)
Next i
Else
Call DisplaySector(Track, 0, Side + 1, GetSideTrackSector(Track, Side))
End If
End Sub
'-------------------------------------------------ReloadDisk
Public Sub ReloadDisk()
Dim i As Long
Call DiskSystemReset
For i = 1 To 2880
SecCopy(i) = False
Next i
Call ReadDiskDATA
Call DisplaySurface
End Sub
'------------------------------------------------PrepareDisk
Public Function PrepareDisk() As Boolean
Dim i As Long
If TestDiskChange = True Then
For i = 1 To 2880
SecCopy(i) = False
Next i
End If
If TestDiskReady = True Then
Call ReadDiskDATA
Call DisplaySurface
PrepareDisk = True
End If
End Function
'----------------------------------------------------JumpBad
Public Function JumpBad(ByVal Track As Byte, ByVal Side As Byte, ByVal Sector As Byte, ByVal Light As Boolean) As Boolean
Dim nSect As Byte
Dim i As Byte
Dim num As Long
If Light = False Then
JumpBad = False
Exit Function
End If
nSect = NumSectors() - 1
For i = Sector To Sector + nSect
num = SectorNumber(Track, Side, i)
If SectorInfo(num) <> IObad Then
JumpBad = False
Exit Function
End If
Next i
JumpBad = True
End Function
'-----------------------------------------------JumpOnlyData
Public Function JumpOnlyData(ByVal Track As Byte, ByVal Side As Byte, ByVal Sector As Byte, ByVal Light As Boolean) As Boolean
Dim nSect As Byte
Dim i As Byte
Dim num As Long
If Light = False Then
JumpOnlyData = False
Exit Function
End If
nSect = NumSectors() - 1
For i = Sector To Sector + nSect
num = SectorNumber(Track, Side, i)
If (SectorInfo(num) = IOdata) Or (SectorInfo(num) = IOboot) Or _
(SectorInfo(num) = IOdir) Or (SectorInfo(num) = IOfat1) Or _
(SectorInfo(num) = IOfat2) Then
JumpOnlyData = False
Exit Function
End If
Next i
JumpOnlyData = True
End Function
'----------------------------------------------AdvanceSector
Public Function AdvanceSector(ByRef Track As Byte, ByRef Side As Byte, ByRef Sector As Byte) As Boolean
AdvanceSector = True
Sector = Sector + NumSectors()
If NumSectors < 18 Then Central.TimedWave1.Add
If Sector > 18 Then
Sector = 1
Side = Side + 1
End If
If Side = 2 Then
Side = 0
Track = Track + 1
If NumSectors = 18 Then Central.TimedWave1.Add
End If
If (Track = 80) Or (Track = Central.StartEnd.EndPosition) Then
AdvanceSector = False
Track = Track - 1: Side = 1: Sector = 18 'set last sector
End If
End Function
'--------------------------------------------DisplayPosition
Public Sub DisplayPosition(ByVal Track As Byte, ByVal Side As Byte, ByVal Sector As Byte)
Call DigitalINT(Central, 550, 37 + Central.PicCentral.Top - 21, Track, 2, 2)
Call DigitalINT(Central, 538, 49 + Central.PicCentral.Top - 21, Side, 2, 1)
Call DigitalINT(Central, 550, 49 + Central.PicCentral.Top - 21, Sector, 2, 2)
Call DigitalINT(Central, 538, 61 + Central.PicCentral.Top - 21, SectorNumber(Track, Side, Sector), 2, 4)
End Sub
'----------------------------------------------DisplayTiming
Public Sub DisplayTiming()
Dim EndTick As Long
Dim TickLeft As Long
Dim CurrentTick As Long
Dim aux As Long
Dim TempT As Double
Const r1X = 337, r1Y = 43 'Ending
Const r2X = 431, r2Y = 43 'Left
Const r3X = 337, r3Y = 74 'Elapsed
Const r4X = 431, r4Y = 74 'Predicted
'calculate ticks
CurrentTick = GetTickCount()
If CurrentSec <> StartSec Then
TempT = (CurrentTick - StartTick) / (CurrentSec - StartSec)
If TempT > 30000 Then TempT = 30000 'overflow check
TickLeft = (EndSec - CurrentSec) * TempT
End If
EndTick = CurrentTick + TickLeft
'Ending time
aux = CalcNowSeconds(H24) + (EndTick - CurrentTick) / 1000
Call DigitalText(r1X, r1Y + Central.PicCentral.Top - 21, StrClock(aux), 3)
'Time left in seconds
aux = TickLeft / 1000
Call DigitalText(r2X, r2Y + Central.PicCentral.Top - 21, StrClock(aux), 3)
'Seconds elapsed
aux = (CurrentTick - StartTick) / 1000
Call DigitalText(r3X, r3Y + Central.PicCentral.Top - 21, StrClock(aux), 3)
'Predicted time
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -