Changeset 57


Ignore:
Timestamp:
Nov 23, 2023, 10:42:57 PM (12 months ago)
Author:
chronos
Message:
  • Added: Settings form.
  • Added: Configurable theme and interface language.
  • Modified: Improved user interface.
  • Added: Allow to select what should be visible as main start up form.
Location:
branches/ByteArray
Files:
9 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/ByteArray/ByteArray.lpi

    r50 r57  
    227227        <ResourceBaseClass Value="Form"/>
    228228      </Unit>
     229      <Unit>
     230        <Filename Value="Forms/FormSettings.pas"/>
     231        <IsPartOfProject Value="True"/>
     232        <ComponentName Value="FormSettings"/>
     233        <HasResources Value="True"/>
     234        <ResourceBaseClass Value="Form"/>
     235      </Unit>
     236      <Unit>
     237        <Filename Value="Core.pas"/>
     238        <IsPartOfProject Value="True"/>
     239        <ComponentName Value="Core"/>
     240        <ResourceBaseClass Value="DataModule"/>
     241      </Unit>
     242      <Unit>
     243        <Filename Value="Forms/FormDebugger.pas"/>
     244        <IsPartOfProject Value="True"/>
     245        <ComponentName Value="FormDebugger"/>
     246        <ResourceBaseClass Value="Form"/>
     247      </Unit>
    229248    </Units>
    230249  </ProjectOptions>
  • branches/ByteArray/ByteArray.lpr

    r50 r57  
    11program ByteArray;
    2 
    3 {$mode objfpc}{$H+}
    42
    53uses
    64  {$IFDEF UNIX}
    7   cthreads,
     5  cthreads, clocale,
    86  {$ENDIF}
    97  {$IFDEF HASAMIGA}
     
    1210  Interfaces, SysUtils,// this includes the LCL widgetset
    1311  Forms, FormMain, FormConsole, FormDevice, FormScreen, FormDisassembler,
    14   FormAssembler, Cpu, BigInt, Channel, Common.Memory, FrameBuffer, Device, Storage,
    15   DeviceMapper, Machine, Disassembler, Instructions, Parser, Message, Assembler,
    16   Serial, Mouse, FormSourceEditor, FormMessages, FormMemory, FormStorage, Common
     12  FormAssembler, Cpu, BigInt, Channel, Common.Memory, FrameBuffer, Device,
     13  Storage, DeviceMapper, Machine, Disassembler, Instructions, Parser, Message,
     14  Assembler, Serial, Mouse, FormSourceEditor, FormMessages, FormMemory,
     15  FormStorage, Common, FormSettings, Core, FormDebugger
    1716  { you can add units after this };
    1817
     
    3433  Application.Scaled:=True;
    3534  Application.Initialize;
     35  Application.CreateForm(TCore, Core.Core);
    3636  Application.CreateForm(TFormMain, FormMain.FormMain);
    3737  Application.Run;
  • branches/ByteArray/Cpu.pas

    r56 r57  
    9494    procedure InstructionOr;
    9595    procedure InstructionOrSize;
     96    procedure InstructionAdd;
     97    procedure InstructionAddSize;
     98    procedure InstructionSub;
     99    procedure InstructionSubSize;
    96100    procedure InitInstructions;
    97101    procedure SetRunning(AValue: Boolean);
     
    541545  RegIndex2 := ReadRegIndex;
    542546  Regs[RegIndex] := Regs[RegIndex].Copy(DataSize) or Regs[RegIndex2].Copy(DataSize);
     547end;
     548
     549procedure TCpu.InstructionAdd;
     550var
     551  RegIndex: TRegIndex;
     552  RegIndex2: TRegIndex;
     553begin
     554  RegIndex := ReadRegIndex;
     555  RegIndex2 := ReadRegIndex;
     556  Regs[RegIndex] := Regs[RegIndex] + Regs[RegIndex2];
     557end;
     558
     559procedure TCpu.InstructionAddSize;
     560var
     561  DataSize: TBigIntSize;
     562  RegIndex: TRegIndex;
     563  RegIndex2: TRegIndex;
     564begin
     565  DataSize := ReadSize;
     566  RegIndex := ReadRegIndex;
     567  RegIndex2 := ReadRegIndex;
     568  Regs[RegIndex] := Regs[RegIndex].Copy(DataSize) + Regs[RegIndex2].Copy(DataSize);
     569end;
     570
     571procedure TCpu.InstructionSub;
     572var
     573  RegIndex: TRegIndex;
     574  RegIndex2: TRegIndex;
     575begin
     576  RegIndex := ReadRegIndex;
     577  RegIndex2 := ReadRegIndex;
     578  Regs[RegIndex] := Regs[RegIndex] - Regs[RegIndex2];
     579end;
     580
     581procedure TCpu.InstructionSubSize;
     582var
     583  DataSize: TBigIntSize;
     584  RegIndex: TRegIndex;
     585  RegIndex2: TRegIndex;
     586begin
     587  DataSize := ReadSize;
     588  RegIndex := ReadRegIndex;
     589  RegIndex2 := ReadRegIndex;
     590  Regs[RegIndex] := Regs[RegIndex].Copy(DataSize) + Regs[RegIndex2].Copy(DataSize);
    543591end;
    544592
     
    585633  FInstructions[inOr] := InstructionOr;
    586634  FInstructions[inOrSize] := InstructionOrSize;
     635  FInstructions[inAdd] := InstructionAdd;
     636  FInstructions[inAddSize] := InstructionAddSize;
     637  FInstructions[inSub] := InstructionSub;
     638  FInstructions[inSubSize] := InstructionSubSize;
    587639end;
    588640
  • branches/ByteArray/Forms/FormMain.lfm

    r50 r57  
    11object FormMain: TFormMain
    2   Left = 535
     2  Left = 534
    33  Height = 993
    4   Top = 247
     4  Top = 223
    55  Width = 1491
    66  Caption = 'ByteArray'
     
    4343    object MenuItem2: TMenuItem
    4444      Caption = 'Tools'
     45      object MenuItem10: TMenuItem
     46        Action = ASettings
     47      end
     48      object Separator2: TMenuItem
     49        Caption = '-'
     50      end
    4551      object MenuItem3: TMenuItem
    4652        Action = ASourceEditor
     
    5359      end
    5460    end
     61    object MenuItem11: TMenuItem
     62      Caption = 'Help'
     63      object MenuItem12: TMenuItem
     64        Action = AAbout
     65      end
     66    end
    5567  end
    5668  object ActionList1: TActionList
    5769    Left = 448
    58     Top = 80
     70    Top = 79
    5971    object ASourceEditor: TAction
    6072      Caption = 'Source editor'
     
    99111      OnExecute = AConsoleExecute
    100112    end
    101   end
    102   object PersistentForm1: TPersistentForm
    103     MinVisiblePart = 50
    104     EntireVisible = False
    105     Left = 640
    106     Top = 79
     113    object ASettings: TAction
     114      Caption = 'Settings'
     115      OnExecute = ASettingsExecute
     116    end
     117    object AAbout: TAction
     118      Caption = 'About'
     119      OnExecute = AAboutExecute
     120    end
    107121  end
    108122end
  • branches/ByteArray/Forms/FormMain.lrj

    r50 r57  
    44{"hash":380871,"name":"tformmain.menuitem1.caption","sourcebytes":[86,105,101,119],"value":"View"},
    55{"hash":5989939,"name":"tformmain.menuitem2.caption","sourcebytes":[84,111,111,108,115],"value":"Tools"},
     6{"hash":322608,"name":"tformmain.menuitem11.caption","sourcebytes":[72,101,108,112],"value":"Help"},
    67{"hash":215450690,"name":"tformmain.asourceeditor.caption","sourcebytes":[83,111,117,114,99,101,32,101,100,105,116,111,114],"value":"Source editor"},
    78{"hash":194763106,"name":"tformmain.adebugger.caption","sourcebytes":[68,101,98,117,103,103,101,114],"value":"Debugger"},
     
    1314{"hash":179734405,"name":"tformmain.astorage.caption","sourcebytes":[83,116,111,114,97,103,101],"value":"Storage"},
    1415{"hash":94014398,"name":"tformmain.ascreen.caption","sourcebytes":[83,99,114,101,101,110],"value":"Screen"},
    15 {"hash":174433893,"name":"tformmain.aconsole.caption","sourcebytes":[67,111,110,115,111,108,101],"value":"Console"}
     16{"hash":174433893,"name":"tformmain.aconsole.caption","sourcebytes":[67,111,110,115,111,108,101],"value":"Console"},
     17{"hash":213582195,"name":"tformmain.asettings.caption","sourcebytes":[83,101,116,116,105,110,103,115],"value":"Settings"},
     18{"hash":4691652,"name":"tformmain.aabout.caption","sourcebytes":[65,98,111,117,116],"value":"About"}
    1619]}
  • branches/ByteArray/Forms/FormMain.pas

    r56 r57  
    55uses
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, Menus, ActnList,
    7   FormConsole, FormScreen, Machine, Common.PersistentForm, FormSourceEditor,
    8   FormMemory, Common.FormEx, FormDisassembler, FormStorage;
     7  FormConsole, FormScreen, Common.PersistentForm, FormSourceEditor,
     8  FormMemory, Common.FormEx, FormDisassembler, FormStorage, FormDebugger;
    99
    1010type
     
    1414  TFormMain = class(TFormEx)
    1515    AConsole: TAction;
     16    AAbout: TAction;
     17    ASettings: TAction;
    1618    AScreen: TAction;
    1719    AStorage: TAction;
     
    2628    MainMenu1: TMainMenu;
    2729    MenuItem1: TMenuItem;
     30    MenuItem10: TMenuItem;
     31    MenuItem11: TMenuItem;
     32    MenuItem12: TMenuItem;
     33    Separator2: TMenuItem;
    2834    MenuItem2: TMenuItem;
    2935    MenuItem3: TMenuItem;
     
    3339    MenuItem7: TMenuItem;
    3440    MenuItem8: TMenuItem;
    35     PersistentForm1: TPersistentForm;
    3641    Separator1: TMenuItem;
    3742    MenuItem9: TMenuItem;
     
    3944    MenuItemViewStorage: TMenuItem;
    4045    MenuItemViewConsole: TMenuItem;
     46    procedure AAboutExecute(Sender: TObject);
    4147    procedure AConsoleExecute(Sender: TObject);
    4248    procedure ADebuggerExecute(Sender: TObject);
    4349    procedure ADisassemblerExecute(Sender: TObject);
    4450    procedure AExitExecute(Sender: TObject);
     51    procedure ASettingsExecute(Sender: TObject);
    4552    procedure AFullscreenExecute(Sender: TObject);
    4653    procedure AMemoryExecute(Sender: TObject);
     
    5865    FormDisassembler: TFormDisassembler;
    5966    FormStorage: TFormStorage;
    60     Machine: TMachine;
    61     procedure InitMachine;
    62   public
     67    FormDebugger: TFormDebugger;
    6368  end;
    6469
     
    7277
    7378uses
    74   Cpu, BigInt, Common;
     79  Core, Common, FormSettings, Common.FormAbout;
    7580
    7681{ TFormMain }
     
    7883procedure TFormMain.FormShow(Sender: TObject);
    7984begin
    80   DockForm(FormScreen, Self);
    81   Machine.PowerOn;
     85  if Core.Core.StartUpForm = 'Screen' then begin
     86    AScreen.Execute;
     87    DockForm(FormScreen, Self);
     88  end;
     89  if Core.Core.StartUpForm = 'Source editor' then begin
     90    ASourceEditor.Execute;
     91    DockForm(FormSourceEditor, Self);
     92  end;
     93  if Core.Core.StartUpForm = 'Debugger' then begin
     94    ADebugger.Execute;
     95    DockForm(FormDebugger, Self);
     96  end;
     97  if Core.Core.AutoStartMachine then
     98    Core.Core.Machine.PowerOn;
    8299end;
    83100
    84101procedure TFormMain.FormCreate(Sender: TObject);
    85102begin
    86   Machine := TMachine.Create;
    87   InitMachine;
    88   FormScreen := TFormScreen.Create(nil);
    89   FormConsole := TFormConsole.Create(nil);
    90   Machine.Serial.OnWrite := FormConsole.ConsoleWrite;
    91   FormScreen.FrameBuffer := Machine.FrameBuffer;
    92   Machine.FrameBuffer.OnChange := FormScreen.ScreenChange;
    93103end;
    94104
     
    101111  if Assigned(FormDisassembler) then FreeAndNil(FormDisassembler);
    102112  if Assigned(FormStorage) then FreeAndNil(FormStorage);
    103   FreeAndNil(Machine);
     113  if Assigned(FormDebugger) then FreeAndNil(FormDebugger);
    104114end;
    105115
     
    109119end;
    110120
     121procedure TFormMain.ASettingsExecute(Sender: TObject);
     122var
     123  FormSettings: TFormSettings;
     124begin
     125  FormSettings := TFormSettings.Create(nil);
     126  try
     127    FormSettings.ShowModal;
     128  finally
     129    FormSettings.Free;
     130  end;
     131end;
     132
    111133procedure TFormMain.AFullscreenExecute(Sender: TObject);
    112134begin
    113   PersistentForm1.SetFullScreen(not PersistentForm1.FormFullScreen);
     135  Core.Core.PersistentForm1.SetFullScreen(not Core.Core.PersistentForm1.FormFullScreen);
    114136end;
    115137
     
    118140  if not Assigned(FormMemory) then begin
    119141    FormMemory := TFormMemory.Create(nil);
    120     FormMemory.Memory := Machine.Memory;
     142    FormMemory.Memory := Core.Core.Machine.Memory;
    121143  end;
    122144  FormMemory.Show;
     
    125147procedure TFormMain.AScreenExecute(Sender: TObject);
    126148begin
     149  if not Assigned(FormScreen) then begin
     150    FormScreen := TFormScreen.Create(nil);
     151    FormScreen.FrameBuffer := Core.Core.Machine.FrameBuffer;
     152    Core.Core.Machine.FrameBuffer.OnChange := FormScreen.ScreenChange;
     153  end;
    127154  FormScreen.Show;
    128155end;
     
    130157procedure TFormMain.ADebuggerExecute(Sender: TObject);
    131158begin
     159  if not Assigned(FormDebugger) then begin
     160    FormDebugger := TFormDebugger.Create(nil);
     161  end;
     162  FormDebugger.Show;
    132163end;
    133164
    134165procedure TFormMain.AConsoleExecute(Sender: TObject);
    135166begin
     167  if not Assigned(FormConsole) then begin
     168    FormConsole := TFormConsole.Create(nil);
     169    Core.Core.Machine.Serial.OnWrite := FormConsole.ConsoleWrite;
     170  end;
    136171  FormConsole.Show;
     172end;
     173
     174procedure TFormMain.AAboutExecute(Sender: TObject);
     175var
     176  FormAbout: TFormAbout;
     177begin
     178  FormAbout := TFormAbout.Create(nil);
     179  try
     180    FormAbout.ApplicationInfo := Core.Core.ApplicationInfo1;
     181    FormAbout.ShowModal;
     182  finally
     183    FreeAndNil(FormAbout);
     184  end;
    137185end;
    138186
     
    141189  if not Assigned(FormDisassembler) then
    142190    FormDisassembler := TFormDisassembler.Create(nil);
    143   FormDisassembler.Disassembler.Memory := Machine.Memory;
     191  FormDisassembler.Disassembler.Memory := Core.Core.Machine.Memory;
    144192  FormDisassembler.Show;
    145193end;
     
    149197  if not Assigned(FormSourceEditor) then begin
    150198    FormSourceEditor := TFormSourceEditor.Create(nil);
    151     FormSourceEditor.Machine := Machine;
     199    FormSourceEditor.Machine := Core.Core.Machine;
    152200  end;
    153201  FormSourceEditor.Show;
     
    158206  if not Assigned(FormStorage) then begin
    159207    FormStorage := TFormStorage.Create(nil);
    160     FormStorage.Storage := Machine.Storage;
     208    FormStorage.Storage := Core.Core.Machine.Storage;
    161209  end;
    162210  FormStorage.Show;
    163211end;
    164212
    165 procedure TFormMain.InitMachine;
    166 var
    167   Loop: TBigInt;
    168 begin
    169   with Machine.Cpu do begin
    170     Reset;
    171 
    172     // LD A, 'A'
    173     WriteInstruction(inLoadConst);
    174     WriteRegister(riA);
    175     Write(DataWidth, Ord('A'));
    176 
    177     // LD B, 8
    178     WriteInstruction(inLoadConst);
    179     WriteRegister(riB);
    180     Write(DataWidth, Machine.Serial.BaseAddress);
    181 
    182     // OUT (B), A
    183     WriteInstruction(inOutput);
    184     WriteRegister(riB);
    185     WriteRegister(riA);
    186 
    187     // LD B,
    188     WriteInstruction(inLoadConst);
    189     WriteRegister(riB);
    190     Write(DataWidth, Machine.FrameBuffer.BaseAddress);
    191 
    192     WriteInstruction(inLoadConst);
    193     WriteRegister(riC);
    194     Write(DataWidth, 10);
    195 
    196     Loop := PC;
    197 
    198     WriteInstruction(inOutput);
    199     WriteRegister(riB);
    200     WriteRegister(riA);
    201 
    202     WriteInstruction(inInc);
    203     WriteRegister(riA);
    204 
    205     WriteInstruction(inDec);
    206     WriteRegister(riC);
    207 
    208     WriteInstruction(inJumpNotZero);
    209     WriteRegister(riC);
    210     Write(AddressWidth, Loop);
    211 
    212     WriteInstruction(inHalt);
    213   end;
    214 end;
    215 
    216213end.
    217214
  • branches/ByteArray/Languages/ByteArray.cs.po

    r56 r57  
    9090msgstr "Neznámý znak %s"
    9191
     92#: tcore.applicationinfo1.description
     93msgid "Virtual machine and development environment"
     94msgstr "Virtuální počítač a vývojové prostředí"
     95
     96#: tformdebugger.caption
     97#, fuzzy
     98msgctxt "tformdebugger.caption"
     99msgid "Debugger"
     100msgstr "Ladič"
     101
     102#: tformmain.aabout.caption
     103msgid "About"
     104msgstr "O aplikaci"
     105
    92106#: tformmain.aconsole.caption
    93107msgctxt "tformmain.aconsole.caption"
     
    96110
    97111#: tformmain.adebugger.caption
     112msgctxt "tformmain.adebugger.caption"
    98113msgid "Debugger"
    99114msgstr "Ladič"
     
    126141msgstr "Obrazovka"
    127142
     143#: tformmain.asettings.caption
     144msgctxt "tformmain.asettings.caption"
     145msgid "Settings"
     146msgstr "Nastavení"
     147
    128148#: tformmain.asourceeditor.caption
    129149msgctxt "tformmain.asourceeditor.caption"
     
    144164msgstr "Pohled"
    145165
     166#: tformmain.menuitem11.caption
     167msgid "Help"
     168msgstr "Nápověda"
     169
    146170#: tformmain.menuitem2.caption
    147171msgid "Tools"
     
    173197msgstr "ASCII"
    174198
     199#: tformsettings.buttoncancel.caption
     200msgid "Cancel"
     201msgstr "Zrušit"
     202
     203#: tformsettings.buttonok.caption
     204msgid "OK"
     205msgstr "OK"
     206
     207#: tformsettings.caption
     208msgctxt "tformsettings.caption"
     209msgid "Settings"
     210msgstr "Nastavení"
     211
     212#: tformsettings.checkboxautostartmachine.caption
     213msgid "Auto start machine"
     214msgstr "Automatický start stroje"
     215
     216#: tformsettings.label1.caption
     217msgid "Startup form:"
     218msgstr "Startovaní okno:"
     219
     220#: tformsettings.label2.caption
     221msgid "Theme:"
     222msgstr "Téma:"
     223
     224#: tformsettings.label3.caption
     225msgid "Language:"
     226msgstr "Jazyk:"
     227
    175228#: tformsourceeditor.aclose.caption
    176229msgid "Close"
  • branches/ByteArray/Languages/ByteArray.pot

    r56 r57  
    8080msgstr ""
    8181
     82#: tcore.applicationinfo1.description
     83msgid "Virtual machine and development environment"
     84msgstr ""
     85
     86#: tformdebugger.caption
     87msgctxt "tformdebugger.caption"
     88msgid "Debugger"
     89msgstr ""
     90
     91#: tformmain.aabout.caption
     92msgid "About"
     93msgstr ""
     94
    8295#: tformmain.aconsole.caption
    8396msgctxt "tformmain.aconsole.caption"
     
    8699
    87100#: tformmain.adebugger.caption
     101msgctxt "tformmain.adebugger.caption"
    88102msgid "Debugger"
    89103msgstr ""
     
    116130msgstr ""
    117131
     132#: tformmain.asettings.caption
     133msgctxt "tformmain.asettings.caption"
     134msgid "Settings"
     135msgstr ""
     136
    118137#: tformmain.asourceeditor.caption
    119138msgctxt "tformmain.asourceeditor.caption"
     
    134153msgstr ""
    135154
     155#: tformmain.menuitem11.caption
     156msgid "Help"
     157msgstr ""
     158
    136159#: tformmain.menuitem2.caption
    137160msgid "Tools"
     
    163186msgstr ""
    164187
     188#: tformsettings.buttoncancel.caption
     189msgid "Cancel"
     190msgstr ""
     191
     192#: tformsettings.buttonok.caption
     193msgid "OK"
     194msgstr ""
     195
     196#: tformsettings.caption
     197msgctxt "tformsettings.caption"
     198msgid "Settings"
     199msgstr ""
     200
     201#: tformsettings.checkboxautostartmachine.caption
     202msgid "Auto start machine"
     203msgstr ""
     204
     205#: tformsettings.label1.caption
     206msgid "Startup form:"
     207msgstr ""
     208
     209#: tformsettings.label2.caption
     210msgid "Theme:"
     211msgstr ""
     212
     213#: tformsettings.label3.caption
     214msgid "Language:"
     215msgstr ""
     216
    165217#: tformsourceeditor.aclose.caption
    166218msgid "Close"
  • branches/ByteArray/Sample.asm

    r56 r57  
    1212  JNZ C, Loop
    1313  HALT
     14
     15WriteStr:
     16    PUSH R2
     17    PUSH R3
     18    PUSH R4
     19    SET  R3, ConsoleWriteChar
     20    SET  R4, DeviceConsole
     21WriteStrLoop:
     22    LD   R2, (R0)
     23    OUT  (R4: R3), R2
     24    INC  R0
     25    DEC  R1
     26    JNZ  R1, WriteStrLoop
     27    POP  R4
     28    POP  R3
     29    POP  R2
     30    RET
     31
     32ClearScreen:
     33    PUSH R0
     34    PUSH R1
     35    PUSH R2
     36    PUSH R3
     37    SET  R0, ScreenSetAddr
     38    SET  R1, 0
     39    SET  R3, DeviceScreen
     40    OUT  (R3: R0), R1
     41    SET  R0, ScreenGetWidth
     42    IN   R1, (R3: R0)
     43    SET  R0, ScreenGetHeight
     44    IN   R2, (R3: R0)
     45    MUL  R2, R1
     46    SET  R0, ScreenWrite
     47    SET  R1, 120
     48ClearScreenLoop:
     49    OUT  (R3: R0), R1
     50    DEC  R2
     51    JNZ  R2, ClearScreenLoop
     52    POP  R3
     53    POP  R2
     54    POP  R1
     55    POP  R0
     56    RET
     57
     58Hello:
     59    DB   'Hello friend'
Note: See TracChangeset for help on using the changeset viewer.