-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainform.pas
146 lines (116 loc) · 3.16 KB
/
mainform.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
unit MainForm;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, BitGridEngine, BitGridUtil;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
ButtonDumpContents: TButton;
ButtonRunCycle: TButton;
ButtonPassThrough: TButton;
ButtonPhaseA: TButton;
ButtonPhaseB: TButton;
CheckBox1: TCheckBox;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure ButtonDumpContentsClick(Sender: TObject);
procedure ButtonRunCycleClick(Sender: TObject);
procedure ButtonPassThroughClick(Sender: TObject);
procedure ButtonPhaseAClick(Sender: TObject);
procedure ButtonPhaseBClick(Sender: TObject);
procedure CheckBox1Change(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
public
ButtonChecked : Boolean;
end;
var
Form1: TForm1;
Grid1 : TBitGrid;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
Grid1.Init(10,10);
Form1.Memo1.Append('10x10 grid created');
ButtonChecked := Checkbox1.Checked;
Grid1.IOtest.Source := @Form1.ButtonChecked;
end;
procedure TForm1.ButtonDumpContentsClick(Sender: TObject);
var
x,y : integer;
s : string;
begin
memo1.Append('Program Dump: ');
for y := 0 to Grid1.Height-1 do
begin
s := IntToStr(Y)+': ';
for x := 0 to Grid1.Width-1 do
s := s + IntToHex(Grid1.Cells[x,y].lookup,16) + ' ';
memo1.Append(s);
end;
memo1.Append('inputs: ');
for y := 0 to Grid1.Height-1 do
begin
s := ' ' + IntToStr(Y)+': ';
for x := 0 to Grid1.Width-1 do
s := s + IntToHex(Grid1.Cells[x,y].input,1) + ' ';
memo1.Append(s);
end;
memo1.Append('outputs: ');
for y := 0 to Grid1.Height-1 do
begin
s := ' ' + IntToStr(Y)+': ';
for x := 0 to Grid1.Width-1 do
s := s + IntToHex(Grid1.Cells[x,y].output,1) + ' ';
memo1.Append(s);
end;
memo1.Append('Allbits = '+IntToHex(AllBits,16));
memo1.Append(' '+IntToStr(Grid1.CycleCount) + ' cycles executed');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Append(DumpCode(PassThrough));
end;
procedure TForm1.ButtonRunCycleClick(Sender: TObject);
begin
Grid1.DoClock;
end;
procedure TForm1.ButtonPassThroughClick(Sender: TObject);
var
x,y : integer;
begin
for y := 0 to Grid1.Height-1 do
for x := 0 to Grid1.Width-1 do
Grid1.Cells[x,y].lookup := Passthrough;
Grid1.Cells[Grid1.Width-1,0].lookup:= $0000000088888888;
For x := 0 to Grid1.Width-2 do
Grid1.Cells[x,0].lookup := $FF08FF0877807780;
For x := 0 to Grid1.Width-1 do
Grid1.Cells[x,Grid1.Height-1].lookup := $4444000044440000; // reflect down, otherwise 0
end;
procedure TForm1.ButtonPhaseAClick(Sender: TObject);
begin
Grid1.DoPhaseA;
Form1.Memo1.Append('phase A executed');
end;
procedure TForm1.ButtonPhaseBClick(Sender: TObject);
begin
Grid1.DoPhaseB;
Form1.Memo1.Append('phase B executed');
end;
procedure TForm1.CheckBox1Change(Sender: TObject);
begin
ButtonChecked := Checkbox1.Checked;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Grid1.Done;
Form1.Memo1.Append('grid done');
end;
begin
end.