/trunk/HT46F47.pas |
---|
7,10 → 7,13 |
TRom = array[0..$FF] of byte; |
TWaitEvent = procedure(milliseconds: integer) of object; |
THT46F47 = class(TObject) |
strict private |
procedure WaitMs(milliseconds: integer); |
strict protected |
FOnWait: TWaitEvent; |
// ROM |
// Registers |
FPC: byte; |
52,6 → 55,7 |
property PWM: Nibble read FPWM; |
property PortOut: Nibble read FPortOut; |
// Functions |
property OnWait: TWaitEvent read FOnWait write FOnWait; |
constructor Create; |
procedure Step; |
procedure Reset; |
538,15 → 542,11 |
end; |
procedure THT46F47.WaitMs(milliseconds: integer); |
var |
i: integer; |
begin |
for i := 0 to milliseconds div 10 do |
begin |
Sleep(10); |
Application.ProcessMessages; |
if Application.Terminated then break; |
if Assigned(FOnWait) then |
FOnWait(milliseconds) |
else |
Sleep(milliseconds); |
end; |
end; |
end. |
/trunk/MainForm.dfm |
---|
1,6 → 1,8 |
object Form2: TForm2 |
Left = 0 |
Top = 0 |
BorderIcons = [biSystemMenu, biMinimize] |
BorderStyle = bsSingle |
Caption = 'HT46F47 Simulator' |
ClientHeight = 662 |
ClientWidth = 851 |
10,10 → 12,8 |
Font.Height = -11 |
Font.Name = 'Tahoma' |
Font.Style = [] |
OldCreateOrder = False |
Position = poScreenCenter |
OnShow = FormShow |
PixelsPerInch = 96 |
TextHeight = 13 |
object Label20: TLabel |
Left = 24 |
/trunk/MainForm.pas |
---|
57,6 → 57,7 |
private |
PleaseStop: boolean; |
procedure ResetGui; |
procedure WaitMs(milliseconds: integer); |
end; |
var |
74,6 → 75,18 |
{ TForm2 } |
procedure TForm2.WaitMs(milliseconds: integer); |
var |
i: integer; |
begin |
for i := 0 to milliseconds div 10 do |
begin |
Sleep(10); |
Application.ProcessMessages; |
if PleaseStop or Application.Terminated then break; |
end; |
end; |
procedure TForm2.BtnStartClick(Sender: TObject); |
var |
x: THT46F47; |
89,12 → 102,18 |
BtnRandom.Enabled := false; |
x := THT46F47.Create; |
try |
x.OnWait := WaitMs; |
s := ''; |
ci := 0; |
for i := 1 to Length(Memo2.Text) do |
begin |
{$IFDEF UNICODE} |
if CharInSet(Memo2.Text[i], ['a'..'f', 'A'..'F', '0'..'9']) then |
{$ELSE} |
if Memo2.Text[i] in ['a'..'f', 'A'..'F', '0'..'9'] then |
{$ENDIF} |
begin |
s := s + Memo2.Text[i]; |
end; |
150,11 → 169,13 |
BtnRandom.Enabled := true; |
BtnStart.Enabled := true; |
ResetGui; |
finally |
FreeAndNil(x); |
end; |
end; |
procedure TForm2.BtnStopClick(Sender: TObject); |
begin |
// TODO: actually we need to inform the THT46F47 object, so it can break out of a possible waiting loop |
BtnStop.Enabled := false; |
PleaseStop := true; |
end; |