Ignore:
Timestamp:
Jul 14, 2022, 11:29:01 PM (2 years ago)
Author:
chronos
Message:
  • Added: Cpu state window.
Location:
branches/UltimatOS/Forms
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/UltimatOS/Forms/UFormMain.lfm

    r34 r35  
    9090    ParentColor = False
    9191  end
     92  object ButtonCpu: TButton
     93    Left = 512
     94    Height = 38
     95    Top = 571
     96    Width = 113
     97    Caption = 'CPU'
     98    OnClick = ButtonCpuClick
     99    TabOrder = 6
     100  end
    92101  object Timer1: TTimer
    93102    Interval = 20
  • branches/UltimatOS/Forms/UFormMain.pas

    r34 r35  
    55uses
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, StdCtrls,
    7   UMachine;
     7  UMachine, Math;
    88
    99type
     
    1414    ButtonMemory: TButton;
    1515    ButtonCompile: TButton;
     16    ButtonCpu: TButton;
    1617    ButtonStart: TButton;
    1718    ButtonStop: TButton;
     
    2425    Timer2: TTimer;
    2526    procedure ButtonCompileClick(Sender: TObject);
     27    procedure ButtonCpuClick(Sender: TObject);
    2628    procedure ButtonMemoryClick(Sender: TObject);
    2729    procedure ButtonRestartClick(Sender: TObject);
     
    5456
    5557uses
    56   UAssembler, UFormMemory;
     58  UAssembler, UFormMemory, UFormCpu;
    5759
    5860{ TFormMain }
     
    8082procedure TFormMain.ButtonMemoryClick(Sender: TObject);
    8183begin
     84  if not Assigned(FormMemory) then FormMemory := TFormMemory.Create(nil);
    8285  FormMemory.Memory := Machine.Memory;
    8386  FormMemory.Show;
     
    9396    Free;
    9497  end;
     98end;
     99
     100procedure TFormMain.ButtonCpuClick(Sender: TObject);
     101begin
     102  if not Assigned(FormCpu) then FormCpu := TFormCpu.Create(nil);
     103  FormCpu.Cpu := Machine.Cpu;
     104  FormCpu.Show;
    95105end;
    96106
     
    143153    PaintBox1.Repaint;
    144154  end;
    145   Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.ExecutedCount) + LineEnding +
     155  Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.Ticks) + LineEnding +
    146156    'Interrupts: ' + IntToStr(Machine.Cpu.InterruptCount);
    147157end;
    148158
    149159procedure TFormMain.Timer2Timer(Sender: TObject);
     160var
     161  TicksPerSecond: Int64;
    150162begin
    151   Label2.Caption := 'Ticks/s: ' + IntToStr(Machine.Cpu.ExecutedCount - LastTicks);
    152   LastTicks := Machine.Cpu.ExecutedCount;
     163  if Machine.Cpu.Ticks > LastTicks then TicksPerSecond := Machine.Cpu.Ticks - LastTicks
     164    else TicksPerSecond := Machine.Cpu.Ticks;
     165  Label2.Caption := 'Ticks/s: ' + IntToStr(TicksPerSecond);
     166  LastTicks := Machine.Cpu.Ticks;
    153167end;
    154168
Note: See TracChangeset for help on using the changeset viewer.