unit FormCpu;

interface

uses
  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ValEdit,
  ExtCtrls, Z80;

type

  { TFormCpu }

  TFormCpu = class(TForm)
    GroupBox1: TGroupBox;
    Timer1: TTimer;
    ValueListEditor1: TValueListEditor;
    procedure FormCreate(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  private
    FReloadPending: Boolean;
  public
    Cpu: TCpuZ80;
    procedure Reload;
  end;


implementation

{$R *.lfm}

{ TFormCpu }

procedure TFormCpu.Timer1Timer(Sender: TObject);
begin
  if FReloadPending then begin
    FReloadPending := False;
    ValueListEditor1.Values['AF'] := IntToHex(Cpu.AF.Value, 4);
    ValueListEditor1.Values['BC'] := IntToHex(Cpu.BC.Value, 4);
    ValueListEditor1.Values['DE'] := IntToHex(Cpu.DE.Value, 4);
    ValueListEditor1.Values['HL'] := IntToHex(Cpu.HL.Value, 4);
    ValueListEditor1.Values['PC'] := IntToHex(Cpu.PC, 4);
    ValueListEditor1.Values['SP'] := IntToHex(Cpu.SP, 4);
    ValueListEditor1.Values['IX'] := IntToHex(Cpu.IX, 4);
    ValueListEditor1.Values['IY'] := IntToHex(Cpu.IY, 4);
    ValueListEditor1.Values['R'] := IntToHex(Cpu.RegR, 2);
    ValueListEditor1.Values['I'] := IntToHex(Cpu.RegI, 2);
    ValueListEditor1.Values['IM'] := IntToStr(Cpu.InterruptMode);
    ValueListEditor1.Values['EI'] := IntToStr(Byte(Cpu.InterruptEnabled));
    ValueListEditor1.Values['Cycles'] := IntToStr(Cpu.Cycles);
    ValueListEditor1.Values['Ticks'] := IntToStr(Cpu.Ticks);
  end;
end;

procedure TFormCpu.FormCreate(Sender: TObject);
begin
  end;

procedure TFormCpu.FormShow(Sender: TObject);
begin
  Reload;
end;

procedure TFormCpu.Reload;
begin
  FReloadPending := True;
end;

end.

