Changeset 176 for branches/virtualcpu4
- Timestamp:
- Apr 12, 2019, 11:43:24 AM (6 years ago)
- Location:
- branches/virtualcpu4
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtualcpu4
- Property svn:ignore
-
old new 4 4 *.lps 5 5 *.res 6 heaptrclog.trc
-
- Property svn:ignore
-
branches/virtualcpu4/UFormMain.lfm
r175 r176 1 1 object FormMain: TFormMain 2 Left = 3 503 Height = 9484 Top = 2475 Width = 1 7182 Left = 313 3 Height = 790 4 Top = 150 5 Width = 1432 6 6 Caption = 'VirtCpu4' 7 ClientHeight = 9488 ClientWidth = 1 7189 DesignTimePPI = 1 447 ClientHeight = 790 8 ClientWidth = 1432 9 DesignTimePPI = 120 10 10 OnCreate = FormCreate 11 11 OnDestroy = FormDestroy … … 13 13 LCLVersion = '2.0.0.4' 14 14 object ButtonStart: TButton 15 Left = 118116 Height = 3 717 Top = 1018 Width = 11315 Left = 984 16 Height = 31 17 Top = 8 18 Width = 94 19 19 Caption = 'Start' 20 20 OnClick = ButtonStartClick … … 23 23 end 24 24 object ButtonStop: TButton 25 Left = 118126 Height = 3 727 Top = 5828 Width = 11325 Left = 984 26 Height = 31 27 Top = 48 28 Width = 94 29 29 Caption = 'Stop' 30 30 OnClick = ButtonStopClick … … 33 33 end 34 34 object Label1: TLabel 35 Left = 118136 Height = 2 637 Top = 11538 Width = 4835 Left = 984 36 Height = 20 37 Top = 96 38 Width = 35 39 39 Caption = 'Ticks:' 40 40 ParentColor = False … … 42 42 end 43 43 object ListViewRegisters: TListView 44 Left = 1045 Height = 92246 Top = 1047 Width = 3 7444 Left = 8 45 Height = 769 46 Top = 8 47 Width = 312 48 48 Anchors = [akTop, akLeft, akBottom] 49 49 Columns = < 50 50 item 51 51 Caption = 'Register' 52 Width = 1 2052 Width = 100 53 53 end 54 54 item 55 Width = 23955 Width = 199 56 56 end> 57 Font.Height = - 2057 Font.Height = -17 58 58 Font.Name = 'Liberation Mono' 59 59 OwnerData = True … … 64 64 end 65 65 object ListViewMemory: TListView 66 Left = 3 9467 Height = 92268 Top = 1069 Width = 77866 Left = 328 67 Height = 769 68 Top = 8 69 Width = 648 70 70 Anchors = [akTop, akLeft, akBottom] 71 71 Columns = < 72 72 item 73 73 Caption = 'Address' 74 Width = 1 2074 Width = 100 75 75 end 76 76 item 77 Width = 64377 Width = 536 78 78 end> 79 Font.Height = - 2079 Font.Height = -17 80 80 Font.Name = 'Liberation Mono' 81 81 OwnerData = True … … 86 86 end 87 87 object Memo1: TMemo 88 Left = 118189 Height = 34490 Top = 1 9291 Width = 51888 Left = 984 89 Height = 287 90 Top = 160 91 Width = 432 92 92 OnKeyPress = Memo1KeyPress 93 93 ParentFont = False … … 96 96 end 97 97 object Label2: TLabel 98 Left = 118199 Height = 2 6100 Top = 1 63101 Width = 7398 Left = 984 99 Height = 20 100 Top = 136 101 Width = 56 102 102 Caption = 'Console:' 103 103 ParentColor = False 104 104 ParentFont = False 105 105 end 106 object PaintBox1: TPaintBox 107 Left = 1181 108 Height = 374 109 Top = 552 110 Width = 518 111 OnPaint = PaintBox1Paint 112 OnResize = PaintBox1Resize 106 object Image1: TImage 107 Left = 984 108 Height = 321 109 Top = 457 110 Width = 432 113 111 end 114 112 object Timer1: TTimer 115 113 Interval = 100 116 114 OnTimer = Timer1Timer 117 left = 115118 top = 1 73115 left = 96 116 top = 144 119 117 end 120 118 object TimerDraw: TTimer 121 119 OnTimer = TimerDrawTimer 122 left = 104123 top = 304120 left = 87 121 top = 253 124 122 end 125 123 end -
branches/virtualcpu4/UFormMain.pas
r175 r176 16 16 ButtonStart: TButton; 17 17 ButtonStop: TButton; 18 Image1: TImage; 18 19 Label1: TLabel; 19 20 Label2: TLabel; … … 21 22 ListViewRegisters: TListView; 22 23 Memo1: TMemo; 23 PaintBox1: TPaintBox;24 24 Timer1: TTimer; 25 25 TimerDraw: TTimer; … … 32 32 procedure ListViewRegistersData(Sender: TObject; Item: TListItem); 33 33 procedure Memo1KeyPress(Sender: TObject; var Key: char); 34 procedure PaintBox1Paint(Sender: TObject);34 procedure ScreenRepaing; 35 35 procedure PaintBox1Resize(Sender: TObject); 36 36 procedure Timer1Timer(Sender: TObject); … … 83 83 begin 84 84 LoadProgram; 85 PaintBox1Resize(Self); 85 86 end; 86 87 … … 123 124 end; 124 125 125 procedure TFormMain.PaintBox1Paint(Sender: TObject); 126 var 127 X, Y: Integer; 126 procedure TFormMain.ScreenRepaing; 127 var 128 128 B: Byte; 129 MemorySizeTmp: Integer; 130 Addr: Integer; 131 begin 132 MemorySizeTmp := Machine.MemorySize; 133 with Machine, Screen do 134 for Y := 0 to Size.Y - 1 do 135 for X := 0 to Size.X - 1 do begin 136 Addr := MemoryBase + Y * Size.X + X; 137 if Addr < MemorySizeTmp then begin 138 B := PByte(Memory + Addr)^; 139 PaintBox1.Canvas.Pixels[X, Y] := B * $010101; 129 P: Integer; 130 begin 131 with Machine, Screen do begin 132 if ChangedAreaFrom < ChangedAreaTo then begin 133 if (Image1.Picture.Bitmap.Width <> Image1.Width) or 134 (Image1.Picture.Bitmap.Height <> Image1.Height) then 135 Image1.Picture.Bitmap.SetSize(Image1.Width, Image1.Height); 136 Image1.Picture.Bitmap.BeginUpdate(True); 137 P := ChangedAreaFrom; 138 while P <= ChangedAreaTo do begin 139 B := PByte(Memory + MemoryBase + P)^; 140 Image1.Canvas.Pixels[P mod Size.X, P div Size.X] := B * $010101; 141 Inc(P); 142 end; 143 ChangedAreaTo := MemoryBase; 144 ChangedAreaFrom := MemoryBase + MemorySize; 145 Image1.Picture.Bitmap.EndUpdate; 140 146 end; 141 147 end; … … 144 150 procedure TFormMain.PaintBox1Resize(Sender: TObject); 145 151 begin 146 Machine.Screen.Size := Point( PaintBox1.Width, PaintBox1.Height);152 Machine.Screen.Size := Point(Image1.Width, Image1.Height); 147 153 end; 148 154 … … 160 166 procedure TFormMain.TimerDrawTimer(Sender: TObject); 161 167 begin 162 PaintBox1.Repaint;168 ScreenRepaing; 163 169 end; 164 170 … … 196 202 Loadi(R2, 12); 197 203 LabelPrint := IP; 198 204 DataPrefix8; LoadMem(R3, R1); 199 205 DataPrefix8; Output(0, R3); 200 206 Increment(R1); … … 213 219 Test(R2); 214 220 JumpNotZero(LabelClearScreen); 221 222 // Update screen area 223 Loadi(R1, 0); 224 Output(4, R1); 225 Loadi(R1, $10000); 226 Output(5, R1); 215 227 216 228 // Read keyboard and print to console -
branches/virtualcpu4/UMachine.pas
r175 r176 12 12 Size: TPoint; 13 13 MemoryBase: Integer; 14 MemorySize: Integer; 15 ChangedAreaFrom: Integer; 16 ChangedAreaTo: Integer; 14 17 end; 15 18 … … 18 21 TMachine = class 19 22 private 23 FMemorySize: Integer; 20 24 function CpuInput(Port: TAddress): TRegister; 21 25 procedure CpuOutput(Port: TAddress; Value: TRegister); … … 128 132 bw64: Screen.MemoryBase := Value.Q; 129 133 end; 134 4: case Cpu.DataSize of 135 bw8: Screen.ChangedAreaFrom := Value.B; 136 bw16: Screen.ChangedAreaFrom := Value.W; 137 bw32: Screen.ChangedAreaFrom := Value.D; 138 bw64: Screen.ChangedAreaFrom := Value.Q; 139 end; 140 5: case Cpu.DataSize of 141 bw8: Screen.ChangedAreaTo := Value.B; 142 bw16: Screen.ChangedAreaTo := Value.W; 143 bw32: Screen.ChangedAreaTo := Value.D; 144 bw64: Screen.ChangedAreaTo := Value.Q; 145 end; 130 146 end; 131 147 end; … … 133 149 function TMachine.GetMemorySize: Integer; 134 150 begin 135 Result := MemSize(Memory);151 Result := FMemorySize; 136 152 end; 137 153 138 154 procedure TMachine.SetMemorySize(AValue: Integer); 139 155 begin 140 Memory := ReAllocMem(Memory, AValue); 156 if FMemorySize = AValue then Exit; 157 FMemorySize := AValue; 158 Memory := ReAllocMem(Memory, FMemorySize); 141 159 end; 142 160 -
branches/virtualcpu4/virtucpu4.lpr
r174 r176 5 5 uses 6 6 {$IFDEF UNIX} 7 cthreads, 7 cthreads, clocale, 8 8 {$ENDIF} 9 9 Interfaces, // this includes the LCL widgetset 10 Forms, UFormMain, UCpu, UMachine10 SysUtils, Forms, UFormMain, UCpu, UMachine 11 11 { you can add units after this }; 12 12 13 13 {$R *.res} 14 14 15 {$if declared(UseHeapTrace)} 16 const 17 HeapTraceLog = 'heaptrclog.trc'; 18 {$ENDIF} 19 15 20 begin 21 {$if declared(UseHeapTrace)} 22 // Heap trace 23 DeleteFile(ExtractFilePath(ParamStr(0)) + HeapTraceLog); 24 SetHeapTraceOutput(ExtractFilePath(ParamStr(0)) + HeapTraceLog); 25 {$ENDIF} 26 16 27 RequireDerivedFormResource:=True; 17 28 Application.Scaled:=True;
Note:
See TracChangeset
for help on using the changeset viewer.