Changeset 50


Ignore:
Timestamp:
Nov 2, 2023, 11:18:06 PM (14 months ago)
Author:
chronos
Message:
  • Added: Storage form.
  • Added: Dissasembler form.
  • Added: Debug and release build modes.
  • Added: Support for interface translation.
Location:
branches/ByteArray
Files:
9 added
2 deleted
19 edited

Legend:

Unmodified
Added
Removed
  • branches/ByteArray/ByteArray.lpi

    r48 r50  
    1414      <Icon Value="0"/>
    1515    </General>
     16    <i18n>
     17      <EnableI18N Value="True"/>
     18      <OutDir Value="Languages"/>
     19    </i18n>
    1620    <BuildModes>
    17       <Item Name="Default" Default="True"/>
     21      <Item Name="Debug" Default="True"/>
     22      <Item Name="Release">
     23        <CompilerOptions>
     24          <Version Value="11"/>
     25          <Target>
     26            <Filename Value="ByteArray"/>
     27          </Target>
     28          <SearchPaths>
     29            <IncludeFiles Value="$(ProjOutDir)"/>
     30            <OtherUnitFiles Value="Forms;Devices"/>
     31            <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
     32          </SearchPaths>
     33          <Parsing>
     34            <SyntaxOptions>
     35              <SyntaxMode Value="Delphi"/>
     36              <CStyleOperator Value="False"/>
     37              <AllowLabel Value="False"/>
     38              <CPPInline Value="False"/>
     39            </SyntaxOptions>
     40          </Parsing>
     41          <CodeGeneration>
     42            <SmartLinkUnit Value="True"/>
     43            <Optimizations>
     44              <OptimizationLevel Value="3"/>
     45            </Optimizations>
     46          </CodeGeneration>
     47          <Linking>
     48            <Debugging>
     49              <GenerateDebugInfo Value="False"/>
     50              <DebugInfoType Value="dsDwarf2Set"/>
     51              <UseExternalDbgSyms Value="True"/>
     52            </Debugging>
     53            <LinkSmart Value="True"/>
     54            <Options>
     55              <Win32>
     56                <GraphicApplication Value="True"/>
     57              </Win32>
     58            </Options>
     59          </Linking>
     60        </CompilerOptions>
     61      </Item>
     62      <SharedMatrixOptions Count="2">
     63        <Item1 ID="282404543287" Targets="Common" Modes="Debug" Value="-g -gl -gh -CirotR -O1"/>
     64        <Item2 ID="894445904508" Targets="Common" Modes="Release" Value="-CX -XX -O3"/>
     65      </SharedMatrixOptions>
    1866    </BuildModes>
    1967    <PublishOptions>
     
    171219        <Filename Value="Project.pas"/>
    172220        <IsPartOfProject Value="True"/>
     221      </Unit>
     222      <Unit>
     223        <Filename Value="Forms/FormStorage.pas"/>
     224        <IsPartOfProject Value="True"/>
     225        <ComponentName Value="FormStorage"/>
     226        <HasResources Value="True"/>
     227        <ResourceBaseClass Value="Form"/>
    173228      </Unit>
    174229    </Units>
     
    182237      <IncludeFiles Value="$(ProjOutDir)"/>
    183238      <OtherUnitFiles Value="Forms;Devices"/>
    184       <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
     239      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    185240    </SearchPaths>
    186241    <Parsing>
    187242      <SyntaxOptions>
    188243        <SyntaxMode Value="Delphi"/>
     244        <CStyleOperator Value="False"/>
    189245        <IncludeAssertionCode Value="True"/>
     246        <AllowLabel Value="False"/>
     247        <CPPInline Value="False"/>
    190248      </SyntaxOptions>
    191249    </Parsing>
  • branches/ByteArray/ByteArray.lpr

    r48 r50  
    1414  FormAssembler, Cpu, BigInt, Channel, Common.Memory, FrameBuffer, Device, Storage,
    1515  DeviceMapper, Machine, Disassembler, Instructions, Parser, Message, Assembler,
    16   Serial, Mouse, FormSourceEditor, FormMessages, FormMemory, Common
     16  Serial, Mouse, FormSourceEditor, FormMessages, FormMemory, FormStorage, Common
    1717  { you can add units after this };
    1818
  • branches/ByteArray/Cpu.pas

    r47 r50  
    4141
    4242  TInstructionEvent = procedure of object;
     43  TCpuThread = class;
    4344
    4445  { TCpu }
     
    4647  TCpu = class
    4748  private
    48     Instructions: array[TInstruction] of TInstructionEvent;
     49    FHalted: Boolean;
     50    FRunning: Boolean;
     51    FThread: TCpuThread;
     52    FInstructions: array[TInstruction] of TInstructionEvent;
     53    FTicks: QWord;
    4954    procedure Push(Value: TBigInt; Size: TBigIntSize);
    5055    function Pop(Size: TBigIntSize): TBigInt;
     
    8489    procedure InstructionDecSize;
    8590    procedure InitInstructions;
     91    procedure SetRunning(AValue: Boolean);
     92    procedure Run;
     93    procedure Step;
    8694  public
    8795    Regs: array[TRegIndex] of TBigInt;
    8896    PC: TBigInt;
    8997    SP: TBigInt;
    90     Terminated: Boolean;
    9198    DataWidth: TBigIntSize;
    9299    AddressWidth: TBigIntSize;
     
    99106    procedure WriteRegister(Reg: TRegIndex);
    100107    procedure Reset;
    101     procedure Run;
    102     procedure Step;
     108    procedure Start;
     109    procedure Stop;
    103110    constructor Create;
    104111    destructor Destroy; override;
     112    property Ticks: QWord read FTicks;
     113    property Running: Boolean read FRunning write SetRunning;
     114    property Halted: Boolean read FHalted;
    105115  end;
    106116
     117  { TCpuThread }
     118
     119  TCpuThread = class(TThread)
     120    Cpu: TCpu;
     121    procedure Execute; override;
     122  end;
     123
     124
    107125implementation
     126
     127{ TCpuThread }
     128
     129procedure TCpuThread.Execute;
     130begin
     131  repeat
     132    if not Cpu.Halted then Cpu.Step
     133      else Sleep(1);
     134    //Cpu.CheckInterreupts;
     135  until Terminated;
     136end;
    108137
    109138{ TCpu }
     
    128157procedure TCpu.InstructionHalt;
    129158begin
    130   Terminated := True;
     159  FHalted := True;
    131160end;
    132161
     
    443472procedure TCpu.InitInstructions;
    444473begin
    445   Instructions[inNop] := InstructionNop;
    446   Instructions[inHalt] := InstructionHalt;
    447   Instructions[inLoadConst] := InstructionLoadConst;
    448   Instructions[inLoadConstSize] := InstructionLoadConstSize;
    449   Instructions[inLoad] := InstructionLoad;
    450   Instructions[inLoadSize] := InstructionLoadSize;
    451   Instructions[inLoadMem] := InstructionLoadMem;
    452   Instructions[inLoadMemSize] := InstructionLoadMemSize;
    453   Instructions[inStoreMem] := InstructionStoreMem;
    454   Instructions[inStoreMemSize] := InstructionStoreMemSize;
    455   Instructions[inJump] := InstructionJump;
    456   Instructions[inJumpSize] := InstructionJumpSize;
    457   Instructions[inJumpNotZero] := InstructionJumpNotZero;
    458   Instructions[inJumpNotZeroSize] := InstructionJumpNotZeroSize;
    459   Instructions[inJumpZero] := InstructionJumpZero;
    460   Instructions[inJumpZeroSize] := InstructionJumpZeroSize;
    461   Instructions[inJumpRel] := InstructionJumpRel;
    462   Instructions[inJumpRelSize] := InstructionJumpRelSize;
    463   Instructions[inCall] := InstructionCall;
    464   Instructions[inCallSize] := InstructionCallSize;
    465   Instructions[inRet] := InstructionRet;
    466   Instructions[inRetSize] := InstructionRetSize;
    467   Instructions[inPush] := InstructionPush;
    468   Instructions[inPushSize] := InstructionPushSize;
    469   Instructions[inPop] := InstructionPop;
    470   Instructions[inPopSize] := InstructionPopSize;
    471   Instructions[inInput] := InstructionInput;
    472   Instructions[inInputSize] := InstructionInputSize;
    473   Instructions[inOutput] := InstructionOutput;
    474   Instructions[inOutputSize] := InstructionOutputSize;
    475   Instructions[inInc] := InstructionInc;
    476   Instructions[inIncSize] := InstructionIncSize;
    477   Instructions[inDec] := InstructionDec;
    478   Instructions[inDecSize] := InstructionDecSize;
     474  FInstructions[inNop] := InstructionNop;
     475  FInstructions[inHalt] := InstructionHalt;
     476  FInstructions[inLoadConst] := InstructionLoadConst;
     477  FInstructions[inLoadConstSize] := InstructionLoadConstSize;
     478  FInstructions[inLoad] := InstructionLoad;
     479  FInstructions[inLoadSize] := InstructionLoadSize;
     480  FInstructions[inLoadMem] := InstructionLoadMem;
     481  FInstructions[inLoadMemSize] := InstructionLoadMemSize;
     482  FInstructions[inStoreMem] := InstructionStoreMem;
     483  FInstructions[inStoreMemSize] := InstructionStoreMemSize;
     484  FInstructions[inJump] := InstructionJump;
     485  FInstructions[inJumpSize] := InstructionJumpSize;
     486  FInstructions[inJumpNotZero] := InstructionJumpNotZero;
     487  FInstructions[inJumpNotZeroSize] := InstructionJumpNotZeroSize;
     488  FInstructions[inJumpZero] := InstructionJumpZero;
     489  FInstructions[inJumpZeroSize] := InstructionJumpZeroSize;
     490  FInstructions[inJumpRel] := InstructionJumpRel;
     491  FInstructions[inJumpRelSize] := InstructionJumpRelSize;
     492  FInstructions[inCall] := InstructionCall;
     493  FInstructions[inCallSize] := InstructionCallSize;
     494  FInstructions[inRet] := InstructionRet;
     495  FInstructions[inRetSize] := InstructionRetSize;
     496  FInstructions[inPush] := InstructionPush;
     497  FInstructions[inPushSize] := InstructionPushSize;
     498  FInstructions[inPop] := InstructionPop;
     499  FInstructions[inPopSize] := InstructionPopSize;
     500  FInstructions[inInput] := InstructionInput;
     501  FInstructions[inInputSize] := InstructionInputSize;
     502  FInstructions[inOutput] := InstructionOutput;
     503  FInstructions[inOutputSize] := InstructionOutputSize;
     504  FInstructions[inInc] := InstructionInc;
     505  FInstructions[inIncSize] := InstructionIncSize;
     506  FInstructions[inDec] := InstructionDec;
     507  FInstructions[inDecSize] := InstructionDecSize;
     508end;
     509
     510procedure TCpu.SetRunning(AValue: Boolean);
     511begin
     512  if FRunning = AValue then Exit;
     513  if AValue then Start
     514    else Stop;
    479515end;
    480516
     
    516552  PC := 0;
    517553  SP := 0;
    518   Terminated := False;
     554  FHalted := False;
     555  FTicks := 0;
    519556end;
    520557
     
    522559begin
    523560  Reset;
    524   while not Terminated do
     561  while not FHalted do
    525562    Step;
    526563end;
     
    531568begin
    532569  Instruction := TInstruction(Byte(Read(1)));
    533   Instructions[Instruction];
     570  FInstructions[Instruction];
     571  Inc(FTicks);
     572end;
     573
     574procedure TCpu.Start;
     575begin
     576  if not Running then begin
     577    Reset;
     578    FThread := TCpuThread.Create(True);
     579    FThread.Cpu := Self;
     580    FThread.Start;
     581    FRunning := True;
     582  end;
     583end;
     584
     585procedure TCpu.Stop;
     586begin
     587  if Running then begin
     588    FHalted := True;
     589    FThread.Terminate;
     590    FThread.WaitFor;
     591    FreeAndNil(FThread);
     592    FRunning := False;
     593  end;
    534594end;
    535595
     
    544604destructor TCpu.Destroy;
    545605begin
     606  Stop;
    546607  FreeAndNil(Memory);
    547608  FreeAndNil(IO);
  • branches/ByteArray/Devices/Device.pas

    r48 r50  
    3333  end;
    3434
     35resourcestring
     36  SNone = 'None';
     37  SKeyboard = 'Keyboard';
     38  SMouse = 'Mouse';
     39  SStorage = 'Storage';
     40  SScreen = 'Screen';
     41  SConsole = 'Console';
     42  STimer = 'Timer';
     43
    3544const
    36   DeviceClassText: array[TDeviceClass] of string = ('None', 'Keyboard', 'Mouse', 'Storage', 'Screen', 'Console', 'Timer');
     45  DeviceClassText: array[TDeviceClass] of string = (SNone, SKeyboard, SMouse,
     46    SStorage, SScreen, SConsole, STimer);
    3747
    3848
  • branches/ByteArray/Devices/Memory.pas

    r47 r50  
    1717  public
    1818    Position: Integer;
     19    procedure Assign(Source: TMemory);
    1920    function Read(Address: TBigInt; ASize: TBigIntSize): TBigInt;
    2021    function ReadPos(ASize: Byte): TBigInt;
     
    2223    procedure WritePos(ASize: Byte; Value: TBigInt);
    2324    procedure WriteStringPos(Value: string);
     25    procedure WriteMemoryPos(Memory: TMemory);
    2426    function GetAddressCount: Integer; override;
    2527    procedure SetChannel(Channel: TChannel); override;
    2628    procedure Clean;
    2729    property Size: Integer read GetSize write SetSize;
     30    destructor Destroy; override;
    2831  end;
    2932
     
    4447begin
    4548  FData := ReAllocMem(FData, AValue);
     49end;
     50
     51procedure TMemory.Assign(Source: TMemory);
     52begin
     53  Size := Source.Size;
     54  if Size > 0 then
     55    Move(Source.FData[0], FData[0], Size);
     56  Position := Source.Position;
    4657end;
    4758
     
    90101end;
    91102
     103procedure TMemory.WriteMemoryPos(Memory: TMemory);
     104begin
     105  if Memory.Size > 0 then begin
     106    if Position + Memory.Size > Size then Size := Position + Memory.Size;
     107    Move(Memory.FData[0], FData[Position], Memory.Size);
     108    Inc(Position, Memory.Size);
     109  end;
     110end;
     111
    92112function TMemory.GetAddressCount: Integer;
    93113begin
     
    106126end;
    107127
     128destructor TMemory.Destroy;
     129begin
     130  Size := 0;
     131  inherited;
     132end;
     133
    108134end.
    109135
  • branches/ByteArray/Devices/Storage.pas

    r47 r50  
    1313  private
    1414    FFileName: string;
     15    function GetSize: Integer;
    1516    procedure SetFileName(AValue: string);
     17    procedure SetSize(AValue: Integer);
    1618  public
    1719    FFile: TFileStream;
     
    2426    destructor Destroy; override;
    2527    property FileName: string read FFileName write SetFileName;
     28    property Size: Integer read GetSize write SetSize;
    2629  end;
    2730
     
    4043      else FFile := TFileStream.Create(FFileName, fmCreate);
    4144  end;
     45end;
     46
     47function TStorage.GetSize: Integer;
     48begin
     49  Result := FFile.Size;
     50end;
     51
     52procedure TStorage.SetSize(AValue: Integer);
     53begin
     54  FFile.Size := AValue;
    4255end;
    4356
  • branches/ByteArray/Forms/FormAssembler.lfm

    r46 r50  
    11object FormAssembler: TFormAssembler
    2   Left = 509
     2  Left = 728
    33  Height = 719
    4   Top = 390
     4  Top = 384
    55  Width = 1106
    66  Caption = 'Assembler'
  • branches/ByteArray/Forms/FormConsole.lfm

    r45 r50  
    11object FormConsole: TFormConsole
    2   Left = 526
    3   Height = 655
    4   Top = 448
    5   Width = 947
     2  Left = 780
     3  Height = 689
     4  Top = 399
     5  Width = 1002
    66  Caption = 'Console'
    7   ClientHeight = 655
    8   ClientWidth = 947
     7  ClientHeight = 689
     8  ClientWidth = 1002
    99  DesignTimePPI = 144
    1010  LCLVersion = '2.2.6.0'
    1111  object Memo1: TMemo
    1212    Left = 0
    13     Height = 655
     13    Height = 689
    1414    Top = 0
    15     Width = 947
     15    Width = 1002
    1616    Align = alClient
    1717    Anchors = [akLeft, akRight, akBottom]
  • branches/ByteArray/Forms/FormDisassembler.lfm

    r46 r50  
    11object FormDisassembler: TFormDisassembler
    2   Left = 490
     2  Left = 491
    33  Height = 746
    4   Top = 300
     4  Top = 324
    55  Width = 1056
    66  Caption = 'Disassembler'
     
    88  ClientWidth = 1056
    99  DesignTimePPI = 144
    10   LCLVersion = '2.0.10.0'
     10  OnCreate = FormCreate
     11  OnDestroy = FormDestroy
     12  OnShow = FormShow
     13  LCLVersion = '2.2.6.0'
    1114  object MemoCode: TMemo
    1215    Left = 8
  • branches/ByteArray/Forms/FormDisassembler.pas

    r46 r50  
    44
    55uses
    6   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls;
     6  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Disassembler;
    77
    88type
     
    1212  TFormDisassembler = class(TForm)
    1313    MemoCode: TMemo;
     14    procedure FormCreate(Sender: TObject);
     15    procedure FormDestroy(Sender: TObject);
     16    procedure FormShow(Sender: TObject);
    1417  private
    1518
    1619  public
    17 
     20    Disassembler: TDisassembler;
    1821  end;
    1922
     
    2629{$R *.lfm}
    2730
     31{ TFormDisassembler }
     32
     33procedure TFormDisassembler.FormCreate(Sender: TObject);
     34begin
     35  Disassembler := TDisassembler.Create;
     36end;
     37
     38procedure TFormDisassembler.FormDestroy(Sender: TObject);
     39begin
     40  FreeAndNil(Disassembler);
     41end;
     42
     43procedure TFormDisassembler.FormShow(Sender: TObject);
     44begin
     45  Disassembler.Disassemble(MemoCode.Lines);
     46end;
     47
    2848end.
    2949
  • branches/ByteArray/Forms/FormMain.lfm

    r48 r50  
    11object FormMain: TFormMain
    2   Left = 599
    3   Height = 712
    4   Top = 501
    5   Width = 1014
     2  Left = 535
     3  Height = 993
     4  Top = 247
     5  Width = 1491
    66  Caption = 'ByteArray'
    77  DesignTimePPI = 144
     
    2323      Caption = 'View'
    2424      object MenuItemViewConsole: TMenuItem
    25         Caption = 'Console'
    26         OnClick = MenuItemViewConsoleClick
     25        Action = AConsole
    2726      end
    2827      object MenuItemViewScreen: TMenuItem
    29         Caption = 'Screen'
    30         OnClick = MenuItemViewScreenClick
     28        Action = AScreen
    3129      end
    3230      object MenuItemViewStorage: TMenuItem
    33         Caption = 'Storage'
     31        Action = AStorage
    3432      end
    3533      object MenuItem7: TMenuItem
     
    5048      object MenuItem5: TMenuItem
    5149        Action = ADebugger
     50      end
     51      object MenuItem8: TMenuItem
     52        Action = ADisassembler
    5253      end
    5354    end
     
    8283      ShortCut = 122
    8384    end
     85    object ADisassembler: TAction
     86      Caption = 'Disassembler'
     87      OnExecute = ADisassemblerExecute
     88    end
     89    object AStorage: TAction
     90      Caption = 'Storage'
     91      OnExecute = AStorageExecute
     92    end
     93    object AScreen: TAction
     94      Caption = 'Screen'
     95      OnExecute = AScreenExecute
     96    end
     97    object AConsole: TAction
     98      Caption = 'Console'
     99      OnExecute = AConsoleExecute
     100    end
    84101  end
    85102  object PersistentForm1: TPersistentForm
  • branches/ByteArray/Forms/FormMain.pas

    r48 r50  
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ActnList,
    77  FormConsole, FormScreen, Machine, Common.PersistentForm, FormSourceEditor,
    8   FormMemory, Common.FormEx;
     8  FormMemory, Common.FormEx, FormDisassembler, FormStorage;
    99
    1010type
     
    1313
    1414  TFormMain = class(TFormEx)
     15    AConsole: TAction;
     16    AScreen: TAction;
     17    AStorage: TAction;
     18    ADisassembler: TAction;
    1519    AFullscreen: TAction;
    1620    AMemory: TAction;
     
    2832    MenuItem6: TMenuItem;
    2933    MenuItem7: TMenuItem;
     34    MenuItem8: TMenuItem;
    3035    PersistentForm1: TPersistentForm;
    3136    Separator1: TMenuItem;
     
    3439    MenuItemViewStorage: TMenuItem;
    3540    MenuItemViewConsole: TMenuItem;
     41    procedure AConsoleExecute(Sender: TObject);
    3642    procedure ADebuggerExecute(Sender: TObject);
     43    procedure ADisassemblerExecute(Sender: TObject);
    3744    procedure AExitExecute(Sender: TObject);
    3845    procedure AFullscreenExecute(Sender: TObject);
    3946    procedure AMemoryExecute(Sender: TObject);
     47    procedure AScreenExecute(Sender: TObject);
    4048    procedure ASourceEditorExecute(Sender: TObject);
     49    procedure AStorageExecute(Sender: TObject);
    4150    procedure FormCreate(Sender: TObject);
    4251    procedure FormDestroy(Sender: TObject);
    4352    procedure FormShow(Sender: TObject);
    44     procedure MenuItemViewConsoleClick(Sender: TObject);
    45     procedure MenuItemViewScreenClick(Sender: TObject);
    4653  private
    4754    FormScreen: TFormScreen;
     
    4956    FormMemory: TFormMemory;
    5057    FormSourceEditor: TFormSourceEditor;
     58    FormDisassembler: TFormDisassembler;
     59    FormStorage: TFormStorage;
    5160    Machine: TMachine;
    5261    procedure InitMachine;
     
    7079begin
    7180  DockForm(FormScreen, Self);
    72   Machine.Run;
     81  Machine.PowerOn;
    7382end;
    7483
     
    8493end;
    8594
    86 procedure TFormMain.AExitExecute(Sender: TObject);
    87 begin
    88   Close;
    89 end;
    90 
    91 procedure TFormMain.AFullscreenExecute(Sender: TObject);
    92 begin
    93   PersistentForm1.SetFullScreen(not PersistentForm1.FormFullScreen);
    94 end;
    95 
    96 procedure TFormMain.AMemoryExecute(Sender: TObject);
    97 begin
    98   if not Assigned(FormMemory) then begin
    99     FormMemory := TFormMemory.Create(nil);
    100     FormMemory.Memory := Machine.Memory;
    101   end;
    102   FormMemory.Show;
    103 end;
    104 
    105 procedure TFormMain.ADebuggerExecute(Sender: TObject);
    106 begin
    107 
    108 end;
    109 
    110 procedure TFormMain.ASourceEditorExecute(Sender: TObject);
    111 begin
    112   if not Assigned(FormSourceEditor) then begin
    113     FormSourceEditor := TFormSourceEditor.Create(nil);
    114   end;
    115   FormSourceEditor.Show;
    116 end;
    117 
    11895procedure TFormMain.FormDestroy(Sender: TObject);
    11996begin
     
    12299  if Assigned(FormConsole) then FreeAndNil(FormConsole);
    123100  if Assigned(FormMemory) then FreeAndNil(FormMemory);
     101  if Assigned(FormDisassembler) then FreeAndNil(FormDisassembler);
     102  if Assigned(FormStorage) then FreeAndNil(FormStorage);
    124103  FreeAndNil(Machine);
    125104end;
    126105
    127 procedure TFormMain.MenuItemViewConsoleClick(Sender: TObject);
     106procedure TFormMain.AExitExecute(Sender: TObject);
     107begin
     108  Close;
     109end;
     110
     111procedure TFormMain.AFullscreenExecute(Sender: TObject);
     112begin
     113  PersistentForm1.SetFullScreen(not PersistentForm1.FormFullScreen);
     114end;
     115
     116procedure TFormMain.AMemoryExecute(Sender: TObject);
     117begin
     118  if not Assigned(FormMemory) then begin
     119    FormMemory := TFormMemory.Create(nil);
     120    FormMemory.Memory := Machine.Memory;
     121  end;
     122  FormMemory.Show;
     123end;
     124
     125procedure TFormMain.AScreenExecute(Sender: TObject);
     126begin
     127  FormScreen.Show;
     128end;
     129
     130procedure TFormMain.ADebuggerExecute(Sender: TObject);
     131begin
     132end;
     133
     134procedure TFormMain.AConsoleExecute(Sender: TObject);
    128135begin
    129136  FormConsole.Show;
    130137end;
    131138
    132 procedure TFormMain.MenuItemViewScreenClick(Sender: TObject);
    133 begin
    134   FormScreen.Show;
     139procedure TFormMain.ADisassemblerExecute(Sender: TObject);
     140begin
     141  if not Assigned(FormDisassembler) then
     142    FormDisassembler := TFormDisassembler.Create(nil);
     143  FormDisassembler.Disassembler.Memory := Machine.Memory;
     144  FormDisassembler.Show;
     145end;
     146
     147procedure TFormMain.ASourceEditorExecute(Sender: TObject);
     148begin
     149  if not Assigned(FormSourceEditor) then begin
     150    FormSourceEditor := TFormSourceEditor.Create(nil);
     151    FormSourceEditor.Machine := Machine;
     152  end;
     153  FormSourceEditor.Show;
     154end;
     155
     156procedure TFormMain.AStorageExecute(Sender: TObject);
     157begin
     158  if not Assigned(FormStorage) then begin
     159    FormStorage := TFormStorage.Create(nil);
     160    FormStorage.Storage := Machine.Storage;
     161  end;
     162  FormStorage.Show;
    135163end;
    136164
  • branches/ByteArray/Forms/FormMemory.lfm

    r46 r50  
    11object FormMemory: TFormMemory
    2   Left = 522
     2  Left = 706
    33  Height = 866
    4   Top = 256
     4  Top = 311
    55  Width = 1150
    66  Caption = 'Memory'
     
    88  ClientWidth = 1150
    99  DesignTimePPI = 144
     10  OnShow = FormShow
    1011  LCLVersion = '2.2.6.0'
    1112  object ListViewMemory: TListView
  • branches/ByteArray/Forms/FormMemory.pas

    r48 r50  
    1414    ListViewMemory: TListView;
    1515    Timer1: TTimer;
     16    procedure FormShow(Sender: TObject);
    1617    procedure ListViewMemoryData(Sender: TObject; Item: TListItem);
    1718    procedure Timer1Timer(Sender: TObject);
     
    5758end;
    5859
     60procedure TFormMemory.FormShow(Sender: TObject);
     61begin
     62  Reload;
     63end;
     64
    5965procedure TFormMemory.Timer1Timer(Sender: TObject);
    6066begin
  • branches/ByteArray/Forms/FormScreen.lfm

    r45 r50  
    11object FormScreen: TFormScreen
    2   Left = 527
     2  Left = 815
    33  Height = 676
    4   Top = 376
     4  Top = 406
    55  Width = 931
    66  Caption = 'Screen'
  • branches/ByteArray/Forms/FormSourceEditor.lfm

    r47 r50  
    11object FormSourceEditor: TFormSourceEditor
    2   Left = 591
     2  Left = 818
    33  Height = 681
    4   Top = 472
     4  Top = 403
    55  Width = 926
    66  Caption = 'Source editor'
     
    7070      end
    7171    end
     72    object MenuItem9: TMenuItem
     73      Caption = 'Run'
     74      object MenuItem11: TMenuItem
     75        Action = ACompile
     76      end
     77      object MenuItem10: TMenuItem
     78        Action = ARun
     79      end
     80      object MenuItem12: TMenuItem
     81        Action = APause
     82      end
     83      object MenuItem17: TMenuItem
     84        Action = AStop
     85      end
     86      object MenuItem13: TMenuItem
     87        Action = AStepIn
     88      end
     89      object MenuItem14: TMenuItem
     90        Action = AStepOver
     91      end
     92      object MenuItem15: TMenuItem
     93        Action = AStepOut
     94      end
     95      object MenuItem16: TMenuItem
     96        Action = ARunToCursor
     97      end
     98    end
    7299  end
    73100  object ActionList1: TActionList
     
    103130      OnExecute = ACloseExecute
    104131    end
     132    object ARun: TAction
     133      Caption = 'Run'
     134      OnExecute = ARunExecute
     135    end
     136    object ACompile: TAction
     137      Caption = 'Compile'
     138      OnExecute = ACompileExecute
     139    end
     140    object ARunToCursor: TAction
     141      Caption = 'Run to cursor'
     142    end
     143    object AStepIn: TAction
     144      Caption = 'Step in'
     145    end
     146    object AStepOut: TAction
     147      Caption = 'Step out'
     148    end
     149    object AStepOver: TAction
     150      Caption = 'Step over'
     151    end
     152    object APause: TAction
     153      Caption = 'Pause'
     154    end
     155    object AStop: TAction
     156      Caption = 'Stop'
     157      OnExecute = AStopExecute
     158    end
    105159  end
    106160end
  • branches/ByteArray/Forms/FormSourceEditor.pas

    r48 r50  
    55uses
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ExtCtrls, Menus,
    7   ActnList, FormMessages, FormAssembler, Project, Common.FormEx;
     7  ActnList, FormMessages, FormAssembler, Project, Common.FormEx, Assembler,
     8  Machine, Memory;
    89
    910type
     
    1314  TFormSourceEditor = class(TFormEx)
    1415    AClose: TAction;
     16    ACompile: TAction;
     17    AStop: TAction;
     18    APause: TAction;
     19    AStepOver: TAction;
     20    AStepOut: TAction;
     21    AStepIn: TAction;
     22    ARunToCursor: TAction;
     23    ARun: TAction;
    1524    ANew: TAction;
    1625    ASaveAs: TAction;
     
    2231    MainMenu1: TMainMenu;
    2332    MenuItem1: TMenuItem;
     33    MenuItem10: TMenuItem;
     34    MenuItem11: TMenuItem;
     35    MenuItem12: TMenuItem;
     36    MenuItem13: TMenuItem;
     37    MenuItem14: TMenuItem;
     38    MenuItem15: TMenuItem;
     39    MenuItem16: TMenuItem;
     40    MenuItem17: TMenuItem;
    2441    MenuItem2: TMenuItem;
    2542    MenuItem3: TMenuItem;
     
    2946    MenuItem7: TMenuItem;
    3047    MenuItem8: TMenuItem;
     48    MenuItem9: TMenuItem;
    3149    Separator1: TMenuItem;
    3250    PanelBottom: TPanel;
     
    3452    Splitter1: TSplitter;
    3553    procedure ACloseExecute(Sender: TObject);
     54    procedure ACompileExecute(Sender: TObject);
    3655    procedure AExitExecute(Sender: TObject);
    3756    procedure ANewExecute(Sender: TObject);
    3857    procedure AOpenExecute(Sender: TObject);
     58    procedure ARunExecute(Sender: TObject);
    3959    procedure ASaveAsExecute(Sender: TObject);
    4060    procedure ASaveExecute(Sender: TObject);
     61    procedure AStopExecute(Sender: TObject);
    4162    procedure FormCreate(Sender: TObject);
    4263    procedure FormDestroy(Sender: TObject);
    4364    procedure FormShow(Sender: TObject);
    4465  public
     66    Assembler: TAssembler;
    4567    FormMessages: TFormMessages;
    4668    FormAssembler: TFormAssembler;
    4769    Project: TProject;
     70    CompiledProgram: TMemory;
     71    Machine: TMachine;
    4872    procedure DockInit;
    4973    procedure UpdateInterface;
     
    6286procedure TFormSourceEditor.FormCreate(Sender: TObject);
    6387begin
     88  CompiledProgram := TMemory.Create;
     89  Assembler := TAssembler.Create;
    6490  FormMessages := TFormMessages.Create(nil);
    6591  FormAssembler := TFormAssembler.Create(nil);
     
    82108end;
    83109
     110procedure TFormSourceEditor.ACompileExecute(Sender: TObject);
     111begin
     112  AStop.Execute;
     113  with Assembler do begin
     114    Compile(FormAssembler.SynEdit1.Lines.Text);
     115    //Memory.SaveToFile('compiled.bin');
     116    CompiledProgram.Assign(Memory);
     117    Machine.Memory.Position := 0;
     118    Machine.Memory.WriteMemoryPos(CompiledProgram);
     119  end;
     120  if FormMessages.Visible then
     121    FormMessages.Reload;
     122end;
     123
    84124procedure TFormSourceEditor.AOpenExecute(Sender: TObject);
    85125var
     
    93133    OpenDialog.Free;
    94134  end;
     135end;
     136
     137procedure TFormSourceEditor.ARunExecute(Sender: TObject);
     138begin
     139  ACompile.Execute;
     140  Machine.PowerOn;
    95141end;
    96142
     
    113159end;
    114160
     161procedure TFormSourceEditor.AStopExecute(Sender: TObject);
     162begin
     163  Machine.PowerOff;
     164end;
     165
    115166procedure TFormSourceEditor.FormDestroy(Sender: TObject);
    116167begin
    117168  FreeAndNil(FormAssembler);
    118169  FreeAndNil(FormMessages);
     170  FreeAndNil(Assembler);
     171  FreeAndNil(CompiledProgram);
    119172end;
    120173
  • branches/ByteArray/Machine.pas

    r45 r50  
    1818    Serial: TSerial;
    1919    DeviceMapper: TDeviceMapper;
    20     procedure Run;
     20    procedure PowerOn;
     21    procedure PowerOff;
    2122    constructor Create;
    2223    destructor Destroy; override;
     
    2829{ TMachine }
    2930
    30 procedure TMachine.Run;
     31procedure TMachine.PowerOn;
    3132begin
    32   Cpu.Run;
     33  Cpu.Start;
     34end;
     35
     36procedure TMachine.PowerOff;
     37begin
     38  Cpu.Stop;
    3339end;
    3440
     
    5460  FreeAndNil(DeviceMapper);
    5561  FreeAndNil(FrameBuffer);
     62  FreeAndNil(Storage);
    5663  FreeAndNil(Memory);
    5764  FreeAndNil(Serial);
  • branches/ByteArray/Parser.pas

    r46 r50  
    5555implementation
    5656
     57resourcestring
     58  SUnknownCharacter = 'Unknown character %s';
     59
    5760{ TParserPos }
    5861
     
    153156        Break;
    154157      end else
    155         Error('Unknown character ' + C, Pos.Pos);
     158        Error(Format(SUnknownCharacter, [C]), Pos.Pos);
    156159    end else
    157160    if State = psIdentifier then begin
Note: See TracChangeset for help on using the changeset viewer.