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

📄 frmmain.frm

📁 简单的操作系统程序
💻 FRM
📖 第 1 页 / 共 4 页
字号:
        .Address = &H0
        .DataLong = &H40
        .MEMBeginAdd = &H2
        .Presence = True
        .ProcessorName = "Start No.2 Dvc"
    End With
    With DiskFiles(3)
        .Address = &H1C0
        .DataLong = &H40
        .MEMBeginAdd = &H2 + &H40
        .Presence = True
        .ProcessorName = "Start No.1 Dvc"
    End With
    With DiskFiles(4)
        .Address = &H200
        .DataLong = &H40
        .MEMBeginAdd = &H2 + &H40 + &H40
        .Presence = True
        .ProcessorName = "Start No.5 Dvc"
    End With
    With DiskFiles(5)
        .Address = &H240
        .DataLong = &H40
        .MEMBeginAdd = &H2 + &H40 + &H40 + &H40
        .Presence = True
        .ProcessorName = "Start No.3 Dvc"
    End With
    With DiskFiles(6)
        .Address = &H280
        .DataLong = &H40
        .MEMBeginAdd = &H2 + &H40 + &H40 + &H40 + &H40
        .Presence = True
        .ProcessorName = "Start No.4 Dvc"
    End With
    
    With DiskFiles(7)
        .Address = &H422
        .DataLong = &H1E2
        .MEMBeginAdd = &H2 + &H40 + &H40 + &H40 + &H40 + &H40
        .Presence = True
        .ProcessorName = "Start Many Dvc"
    End With
    
    With DiskFiles(10)
        .Address = &H1129
        .DataLong = &H109
        .MEMBeginAdd = &H2 + &H40 + &H40 + &H40 + &H40 + &H40
        .Presence = True
        .ProcessorName = "Start No1 3 5 Dvc"
    End With
    With DiskFiles(11)
        .Address = &HBA0
        .DataLong = &H108
        .MEMBeginAdd = &H2 + &H40 + &H40 + &H40 + &H40 + &H40 + &H109
        .Presence = True
        .ProcessorName = "Start No2 4 Dvc"
    End With
    
    With DiskFiles(8)
        .Address = &H1027
        .DataLong = &H70
        .MEMBeginAdd = &H2
        .Presence = True
        .ProcessorName = "1+2+...+9+10=55"
    End With

    
    With DiskFiles(1)
        .Address = &H60
        .DataLong = &H110
        .MEMBeginAdd = &H2
        .Presence = True
        .ProcessorName = "+ Overflow"
    End With
    With DiskFiles(2)
        .Address = &H192
        .DataLong = &H26
        .MEMBeginAdd = &H2 + &H110
        .Presence = True
        .ProcessorName = "- Overflow"
    End With

    With DiskFiles(9)
        .Address = &H1C02
        .DataLong = &H3FE
        .MEMBeginAdd = &H2
        .Presence = True
        .ProcessorName = "1KB Long Program"
    End With

    With DiskFiles(12)
        .Address = &H8A1
        .DataLong = &H2
        .MEMBeginAdd = 0
        .Presence = True
        .ProcessorName = "Idle"
    End With

    Dim i As Integer
    For i = 0 To 11
        If DiskFiles(i).Presence Then
            Dim count As Integer
            count = Showindex(DiskFiles(i).DataLong + DiskFiles(i).Address - 1)
            Dim ind As Integer
            ind = Showindex(DiskFiles(i).Address)
            Dim j As Integer
            For j = ind To count
                Found(j) = True
            Next
        End If
    Next i
End Sub

Private Sub PenRefresh()
    Dim i As Integer
    For i = 1 To 128
        If Found(i) Then
            Call Pen.Draw(i, RGB(0, 0, 255))
        End If
    Next
End Sub

Private Sub PenRefreshIndex(index As Integer)
    Call Pen.Draw(index, RGB(0, 0, 255))
End Sub

Private Sub Form_Load()

    Pen.TotalNumber = 128
    Pen.HeightNum = 8
    Pen.WidthNum = 16
    Pen.hDC = DiskPicture.hDC
    Call Pen.Create(364, 157)
    Pen.Style3D = True
    DiskPicture.Height = Pen.TrueY * 15
    DiskPicture.Width = Pen.TrueX * 15
    DiskPicture.Refresh
    
    DMAV.DMATimerCount = 0
    TimerLock = True
    
    TimmInterrupt = 1
    ProgressBar.Value = 1
    
    TimeInterruptCyc = 30
    
    ProgressBar.Max = TimeInterruptCyc
    
    Set Bus = New BusClass
    Set Timm = New clsXTimer
    Set CpuZ = New CPUClass
    Timm.Interval = 50
    
    HDConfig
    Dim i
    For i = 0 To 11
        Runcode(i).Caption = DiskFiles(i).ProcessorName
        Runcode(i).Enabled = DiskFiles(i).Presence
    Next
    PenRefresh
    
    With Runnings
        .PCBCount = 0
        .ReadyListCount = 0
        '.NowProcessorID = 255
        .ReadyListindex = 255
    End With
    
    For i = 0 To 4
        With Devicelists(i)
            .DeviceID = 2 ^ i
            '.ProcessorID = 255
            .Used = False
            .ReadyListindex = 255
        End With
    Next
    
    For i = 0 To 10
        With PCBs(i)
            .CPUregDR = 0
            .CPUregIR = 0
            .CPUregPC = 0
            .CPUregPSW = 0
            .CPUTime = 0
            .MemEndAdd = 0
            .MemStartAdd = 0
            .ProcessorID = 255
            .ProcessorName = ""
            .Presence = False
        End With
        With ReadyLists(i)
            .PCBindex = 255
            '.ProcessorID = 255
            .Halt = False
            .Presence = False
            .NeedDevice_indexOfDevicelist = 255
        End With
    Next
    Runcode_Click (12)
    Runnings.ReadyListindex = 0
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set Pen = Nothing
    Set HD = Nothing
    Set Bus = Nothing
    Set Timm = Nothing
    Set CpuZ = Nothing
    
    Unload Dialog
End Sub

Private Sub exit_Click()
    Unload Me
End Sub

Private Sub RlistTime()
    Dim i As Byte
    ReadyList.Text = ""
    ChokeList.Text = ""
    For i = 0 To 10
        If ReadyLists(i).Presence And ReadyLists(i).Halt = False Then '就绪列表
            ReadyList.Text = ReadyList.Text + PCBs(ReadyLists(i).PCBindex).ProcessorName + Chr$(13) + Chr$(10)
        End If
        If ReadyLists(i).Presence And ReadyLists(i).Halt Then '阻塞列表
            ChokeList.Text = ChokeList.Text + PCBs(ReadyLists(i).PCBindex).ProcessorName + Chr$(13) + Chr$(10)
        End If
    Next
    ExecuteList.Text = PCBs(ReadyLists(Runnings.ReadyListindex).PCBindex).ProcessorName
End Sub

Private Sub DlistTime()
    Dim i As Byte
    For i = 0 To 4
        If Devicelists(i).Used Then
            DevProT(i).Caption = PCBs(ReadyLists(Devicelists(i).ReadyListindex).PCBindex).ProcessorName
        Else
            DevProT(i).Caption = ""
        End If
    Next i
End Sub

Private Sub group_Click()
    frmTip.Show
End Sub

Private Sub menuabout_Click()
    frmAbout.Show
End Sub

Private Sub reset_Click()
    Dim i As Byte
    For i = 0 To 11
        Runcode(i).Enabled = True
    Next i
    MemC.Resets
    CpuZ.ResetCpu
    
    DMAV.DMATimerCount = 0
    TimerLock = True
    
    TimmInterrupt = 1
    ProgressBar.Value = 1
    
    TimeInterruptCyc = 30
    
    ProgressBar.Max = TimeInterruptCyc
    
    Set Bus = New BusClass
    Set Timm = New clsXTimer
    Set CpuZ = New CPUClass
    Timm.Interval = 50
    
    HDConfig

    For i = 0 To 11
        Runcode(i).Caption = DiskFiles(i).ProcessorName
        Runcode(i).Enabled = DiskFiles(i).Presence
    Next
    PenRefresh
    
    With Runnings
        .PCBCount = 0
        .ReadyListCount = 0
        '.NowProcessorID = 255
        .ReadyListindex = 255
    End With
    
    For i = 0 To 4
        With Devicelists(i)
            .DeviceID = 2 ^ i
            '.ProcessorID = 255
            .Used = False
            .ReadyListindex = 255
        End With
    Next
    
    For i = 0 To 10
        With PCBs(i)
            .CPUregDR = 0
            .CPUregIR = 0
            .CPUregPC = 0
            .CPUregPSW = 0
            .CPUTime = 0
            .MemEndAdd = 0
            .MemStartAdd = 0
            .ProcessorID = 255
            .ProcessorName = ""
            .Presence = False
        End With
        With ReadyLists(i)
            .PCBindex = 255
            '.ProcessorID = 255
            .Halt = False
            .Presence = False
            .NeedDevice_indexOfDevicelist = 255
        End With
    Next
    Runcode_Click (12)
    Runnings.ReadyListindex = 0
End Sub

Private Sub syscon_Click()
    Dialog.Show
End Sub

Private Sub Timm_Tick()
    ProgressBar.Value = TimmInterrupt
    If TimmInterrupt = TimeInterruptCyc Then
        TimmInterrupt = 0
        Bus.ControlBus = setHigh2(Bus.ControlBus, 32)
        Call RlistTime
        Call DlistTime
    End If
    TimmInterrupt = TimmInterrupt + 1
End Sub

Private Sub Option1_Click()
    If Option1.Value Then
        If timeInterruptProc Then
            CpuZ.Start
            MemC.GoOn
            Timm.Enabled = True
            Call RlistTime
        End If
    End If
End Sub

Private Sub Option2_Click()
    If Option2.Value Then
        Timm.Enabled = False
        MemC.Halt
        CpuZ.Halt
        CpuZ.ResetCpu
        '为cpu释放pcb的块
    End If
End Sub

Private Sub Runcode_Click(index As Integer)
    If Runnings.PCBCount < 12 And DMATimer.Enabled = False Then
    
        If index <> 12 Then
            Runcode(index).Enabled = False
            Call FileOS(index, False)
        End If
        Call DMA(DiskFiles(index).MEMBeginAdd, DiskFiles(index).Address, DiskFiles(index).DataLong)
        
        With PCBs(Runnings.PCBCount)
            .ProcessorID = index
            .ProcessorName = DiskFiles(index).ProcessorName
            .MemStartAdd = DiskFiles(index).MEMBeginAdd
            .MemEndAdd = DiskFiles(index).MEMBeginAdd + DiskFiles(index).DataLong - 1
            .CPUTime = 0
            .CPUregPSW = 0
            .CPUregPC = DiskFiles(index).MEMBeginAdd
            .CPUregIR = 0
            .CPUregDR = 0
            .Presence = True
        End With
        With ReadyLists(Runnings.ReadyListCount)
            .Halt = False
            '.ProcessorID = PCBs(Runnings.ProcessorBlockCount).ProcessorID
            .Presence = True
            .PCBindex = Runnings.PCBCount
        End With
        
        Runnings.PCBCount = Runnings.PCBCount + 1
        Runnings.ReadyListCount = Runnings.ReadyListCount + 1
    End If
End Sub

Private Function Showindex(Address As Integer) As Integer
    Showindex = Address \ 64 + 1
End Function

Private Sub DMA(MemAdd As Integer, HDAdd As Integer, DataLong As Integer) '硬盘数据传送到内存
    Timm.Enabled = False
    MemC.Halt
    DMAV.DMATimerCount = 0
    DMAV.DMACOUNT = DataLong
    DMAV.MemAdd = MemAdd
    DMAV.HDAdd = HDAdd
    DMATimer.Enabled = True
    HDreadoldAdd = Showindex(HDAdd)
End Sub


Private Sub CpuZ_CPUSETPEX()
    IRT.Text = Hex$(CpuZ.IR)
    DRT.Text = Hex$(CpuZ.DR)
    PCT.Text = Hex$(CpuZ.PC)
    PSWT.Text = Hex$(CpuZ.PSW)
    lblsum.Caption = CpuZ.DR
    lblmemno.Caption = CpuZ.PC
    Select Case CpuZ.IR
        Case &H48FF
            lblrun.Caption = "Rollback"
        Case &H20FF
            lblrun.Caption = "X++"
        Case &H10FF

⌨️ 快捷键说明

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