Changeset 175 for branches/virtualcpu4/UFormMain.pas
- Timestamp:
- Apr 12, 2019, 1:34:47 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/virtualcpu4/UFormMain.pas
r174 r175 21 21 ListViewRegisters: TListView; 22 22 Memo1: TMemo; 23 PaintBox1: TPaintBox; 23 24 Timer1: TTimer; 25 TimerDraw: TTimer; 24 26 procedure ButtonStartClick(Sender: TObject); 25 27 procedure ButtonStopClick(Sender: TObject); … … 30 32 procedure ListViewRegistersData(Sender: TObject; Item: TListItem); 31 33 procedure Memo1KeyPress(Sender: TObject; var Key: char); 34 procedure PaintBox1Paint(Sender: TObject); 35 procedure PaintBox1Resize(Sender: TObject); 32 36 procedure Timer1Timer(Sender: TObject); 37 procedure TimerDrawTimer(Sender: TObject); 33 38 private 34 39 procedure ReloadMemoryDump; … … 85 90 I: Integer; 86 91 begin 87 if Item.Index < Length(Machine.Memory)div ItemsPerLine then begin92 if Item.Index < Machine.MemorySize div ItemsPerLine then begin 88 93 Line := ''; 89 94 for I := 0 to ItemsPerLine - 1 do 90 Line := Line + IntToHex( Machine.Memory[Item.Index * ItemsPerLine + I], 2) + ' ';95 Line := Line + IntToHex(PByte(Machine.Memory + Item.Index * ItemsPerLine + I)^, 2) + ' '; 91 96 Item.Caption := IntToHex(Item.Index * ItemsPerLine, 8); 92 97 Item.SubItems.Add(Line); … … 118 123 end; 119 124 125 procedure TFormMain.PaintBox1Paint(Sender: TObject); 126 var 127 X, Y: Integer; 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; 140 end; 141 end; 142 end; 143 144 procedure TFormMain.PaintBox1Resize(Sender: TObject); 145 begin 146 Machine.Screen.Size := Point(PaintBox1.Width, PaintBox1.Height); 147 end; 148 120 149 procedure TFormMain.Timer1Timer(Sender: TObject); 121 150 begin … … 129 158 end; 130 159 160 procedure TFormMain.TimerDrawTimer(Sender: TObject); 161 begin 162 PaintBox1.Repaint; 163 end; 164 131 165 procedure TFormMain.ReloadMemoryDump; 132 166 begin 133 ListViewMemory.Items.Count := Length(Machine.Memory)div ItemsPerLine;167 ListViewMemory.Items.Count := Machine.MemorySize div ItemsPerLine; 134 168 ListViewMemory.Refresh; 135 169 end; … … 146 180 R2: Byte; 147 181 R3: Byte; 182 R4: Byte; 148 183 LabelStart: Integer; 149 184 LabelText: Integer; 150 185 LabelPrint: Integer; 186 LabelClearScreen: Integer; 151 187 begin 152 188 R1 := 1; 153 189 R2 := 2; 154 190 R3 := 3; 191 R4 := 4; 155 192 with InstructionWriter do begin 193 // Print Hello world text 156 194 LabelText := 200; 157 195 Loadi(R1, LabelText); 158 196 Loadi(R2, 12); 159 197 LabelPrint := IP; 160 DataPrefix8; LoadMem(R3, R1);198 DataPrefix8; LoadMem(R3, R1); 161 199 DataPrefix8; Output(0, R3); 162 200 Increment(R1); … … 165 203 JumpNotZero(LabelPrint); 166 204 205 // Draw to video memory 206 Loadi(R1, Machine.Screen.MemoryBase); 207 Loadi(R2, $10000); 208 Loadi(R3, $7f); 209 LabelClearScreen := IP; 210 DataPrefix8; StoreMem(R1, R3); 211 Increment(R1); 212 Decrement(R2); 213 Test(R2); 214 JumpNotZero(LabelClearScreen); 215 216 // Read keyboard and print to console 167 217 Loadi(R1, 100); 168 218 LabelStart := IP; 169 219 Increment(R1); 170 Loadi(R2, 100);220 Loadi(R2, $100); 171 221 DataPrefix8; StoreMem(R2, R1); 172 222 DataPrefix8; Input(R2, 0);
Note:
See TracChangeset
for help on using the changeset viewer.