Changeset 32 for branches/UltimatOS/Forms
- Timestamp:
- Jul 10, 2022, 12:37:58 AM (2 years ago)
- Location:
- branches/UltimatOS
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UltimatOS
- Property svn:ignore
-
old new 2 2 UltimatOS.lps 3 3 UltimatOS.res 4 UltimatOS.dbg 4 5 lib
-
- Property svn:ignore
-
branches/UltimatOS/Forms/UFormMain.lfm
r30 r32 10 10 OnCreate = FormCreate 11 11 OnDestroy = FormDestroy 12 OnKeyUp = FormKeyUp 12 13 OnShow = FormShow 13 14 LCLVersion = '2.2.0.4' … … 17 18 Top = 8 18 19 Width = 640 20 OnMouseMove = PaintBox1MouseMove 19 21 OnPaint = PaintBox1Paint 20 22 end 21 object Button Run: TButton23 object ButtonStart: TButton 22 24 Left = 8 23 25 Height = 33 24 26 Top = 496 25 27 Width = 98 26 Caption = ' Run'27 OnClick = Button RunClick28 Caption = 'Start' 29 OnClick = ButtonStartClick 28 30 TabOrder = 0 29 31 end … … 44 46 end 45 47 object ButtonMemory: TButton 46 Left = 12848 Left = 550 47 49 Height = 33 48 50 Top = 496 … … 51 53 OnClick = ButtonMemoryClick 52 54 TabOrder = 2 55 end 56 object ButtonStop: TButton 57 Left = 112 58 Height = 33 59 Top = 496 60 Width = 98 61 Caption = 'Stop' 62 OnClick = ButtonStopClick 63 TabOrder = 3 64 end 65 object ButtonRestart: TButton 66 Left = 216 67 Height = 33 68 Top = 496 69 Width = 98 70 Caption = 'Restart' 71 OnClick = ButtonRestartClick 72 TabOrder = 4 73 end 74 object ButtonCompile: TButton 75 Left = 8 76 Height = 33 77 Top = 536 78 Width = 98 79 Caption = 'Compile' 80 OnClick = ButtonCompileClick 81 TabOrder = 5 53 82 end 54 83 object Timer1: TTimer -
branches/UltimatOS/Forms/UFormMain.pas
r30 r32 13 13 TFormMain = class(TForm) 14 14 ButtonMemory: TButton; 15 ButtonRun: TButton; 15 ButtonCompile: TButton; 16 ButtonStart: TButton; 17 ButtonStop: TButton; 18 ButtonRestart: TButton; 16 19 Label1: TLabel; 17 20 MemoCode: TMemo; 18 21 PaintBox1: TPaintBox; 19 22 Timer1: TTimer; 23 procedure ButtonCompileClick(Sender: TObject); 20 24 procedure ButtonMemoryClick(Sender: TObject); 21 procedure ButtonRunClick(Sender: TObject); 25 procedure ButtonRestartClick(Sender: TObject); 26 procedure ButtonStartClick(Sender: TObject); 27 procedure ButtonStopClick(Sender: TObject); 22 28 procedure FormCreate(Sender: TObject); 23 29 procedure FormDestroy(Sender: TObject); 30 procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState); 24 31 procedure FormShow(Sender: TObject); 32 procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, 33 Y: Integer); 25 34 procedure PaintBox1Paint(Sender: TObject); 26 35 procedure Timer1Timer(Sender: TObject); 27 36 private 28 37 procedure InitProgram; 38 procedure UpdateInterface; 29 39 public 30 40 Machine: TMachine; … … 40 50 41 51 uses 42 U InstructionWriter, UFormMemory;52 UAssembler, UFormMemory; 43 53 44 54 { TFormMain } … … 50 60 end; 51 61 52 procedure TFormMain.Button RunClick(Sender: TObject);62 procedure TFormMain.ButtonStartClick(Sender: TObject); 53 63 begin 54 64 Machine.Reset; 55 with TInstructionWriter.Create do56 try57 Memory := Machine.Cpu.Memory;58 Parse(MemoCode.Lines);59 finally 60 Free;61 end; 62 Machine. Cpu.Run;63 Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.ExecutedCount);65 ButtonCompile.Click; 66 Machine.Running := True; 67 UpdateInterface; 68 end; 69 70 procedure TFormMain.ButtonStopClick(Sender: TObject); 71 begin 72 Machine.Running := False; 73 UpdateInterface; 64 74 end; 65 75 … … 70 80 end; 71 81 82 procedure TFormMain.ButtonCompileClick(Sender: TObject); 83 begin 84 with TAssembler.Create do 85 try 86 Memory := Machine.Cpu.Memory; 87 Parse(MemoCode.Lines); 88 finally 89 Free; 90 end; 91 end; 92 93 procedure TFormMain.ButtonRestartClick(Sender: TObject); 94 begin 95 ButtonStop.Click; 96 ButtonStart.Click; 97 end; 98 72 99 procedure TFormMain.FormDestroy(Sender: TObject); 73 100 begin … … 75 102 end; 76 103 104 procedure TFormMain.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState 105 ); 106 begin 107 Machine.Keyboard.Press(Key); 108 end; 109 77 110 procedure TFormMain.FormShow(Sender: TObject); 78 111 begin 112 UpdateInterface; 113 end; 114 115 procedure TFormMain.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, 116 Y: Integer); 117 begin 118 Machine.Mouse.Move(X, Y); 79 119 end; 80 120 … … 99 139 PaintBox1.Repaint; 100 140 end; 141 Label1.Caption := 'Executed instructions: ' + IntToStr(Machine.Cpu.ExecutedCount) + LineEnding + 142 'Interrupts: ' + IntToStr(Machine.Cpu.InterruptCount); 101 143 end; 102 144 … … 106 148 end; 107 149 150 procedure TFormMain.UpdateInterface; 151 begin 152 ButtonStart.Enabled := not Machine.Running; 153 ButtonStop.Enabled := Machine.Running; 154 ButtonRestart.Enabled := not Machine.Running; 155 end; 156 108 157 end. 109 158
Note:
See TracChangeset
for help on using the changeset viewer.