Ignore:
Timestamp:
Jul 15, 2023, 12:51:15 AM (16 months ago)
Author:
chronos
Message:
  • Modified: Removed U prefix from unit names.
  • Fixed: Memory leaks.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • branches/CpuSingleSize/Core.pas

    r237 r238  
    1 unit UCore;
     1unit Core;
    22
    33interface
    44
    55uses
    6   Classes, SysUtils, ActnList, Controls, Forms, UMachine, UMemory, UMessages,
    7   UDisassembler, UAssembler;
     6  Classes, SysUtils, ActnList, Controls, Forms, Machine, Memory, Message,
     7  Disassembler, Assembler, FormCpu, FormDevices, FormHelp, FormMessages,
     8  FormMain, FormDisassembler;
    89
    910type
     
    3839    procedure DataModuleDestroy(Sender: TObject);
    3940  private
    40 
     41    FormCpu: TFormCpu;
     42    FormDevices: TFormDevices;
     43    FormHelp: TFormHelp;
     44    FormMain: TFormMain;
     45    FormDisassembler: TFormDisassembler;
    4146  public
    4247    Assembler: TAssembler;
     
    5560
    5661uses
    57   UFormScreen, UFormCpu, UFormAssembler, UFormConsole, UFormHelp,
    58   UFormDisassembler, UFormMessages, UFormDevices;
     62  FormScreen, FormAssembler, FormConsole;
    5963
    6064{ TCore }
     
    6771procedure TCore.AHelpExecute(Sender: TObject);
    6872begin
     73  if not Assigned(FormHelp) then
     74    FormHelp := TFormHelp.Create(nil);
    6975  FormHelp.Show;
    7076end;
     
    8793  Assembler := TAssembler.Create;
    8894  Disassembler := TDisassembler.Create;
     95  FormMain := TFormMain.Create(nil);
     96  FormMain.Show;
    8997end;
    9098
    9199procedure TCore.DataModuleDestroy(Sender: TObject);
    92100begin
     101  if Assigned(FormCpu) then FreeAndNil(FormCpu);
     102  if Assigned(FormDevices) then FreeAndNil(FormDevices);
     103  if Assigned(FormHelp) then FreeAndNil(FormHelp);
     104  if Assigned(FormDisassembler) then FreeAndNil(FormDisassembler);
     105  FreeAndNil(FormMain);
    93106  FreeAndNil(Disassembler);
    94107  FreeAndNil(Assembler);
     
    101114  AStop.Execute;
    102115  with Assembler do begin
    103     Compile(FormAssembler.SynEdit1.Lines.Text);
     116    Compile(FormMain.FormAssembler.SynEdit1.Lines.Text);
    104117    //Memory.SaveToFile('compiled.bin');
    105118    CompiledProgram.Assign(Memory);
     
    107120    Machine.Memory.WriteMemory(CompiledProgram);
    108121  end;
    109   if FormMessages.Visible then FormMessages.Reload;
     122  if FormMain.FormMessages.Visible then
     123    FormMain.FormMessages.Reload;
    110124end;
    111125
    112126procedure TCore.ACpuExecute(Sender: TObject);
    113127begin
     128  if not Assigned(FormCpu) then
     129    FormCpu := TFormCpu.Create(nil);
    114130  FormCpu.Cpu := Machine.Cpu;
    115131  FormCpu.Show;
     
    118134procedure TCore.ADevicesExecute(Sender: TObject);
    119135begin
     136  if not Assigned(FormDevices) then
     137    FormDevices := TFormDevices.Create(nil);
    120138  FormDevices.Devices := Machine.Devices;
    121139  FormDevices.Show;
     
    124142procedure TCore.ADisassemblerExecute(Sender: TObject);
    125143begin
     144  if not Assigned(FormDisassembler) then
     145    FormDisassembler := TFormDisassembler.Create(nil);
    126146  with Disassembler do begin
    127147    Memory := CompiledProgram;
Note: See TracChangeset for help on using the changeset viewer.