Changeset 6


Ignore:
Timestamp:
Apr 19, 2026, 10:45:05 AM (8 days ago)
Author:
chronos
Message:
  • Modified: Execute instructions from array of methods instead of big case statement.
  • Added: Check which instructions are missing in InstructionInfo.
  • Added: Instruction generator.
Location:
trunk
Files:
5 added
2 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Core.lfm

    r5 r6  
    9696      OnExecute = AViewMessagesExecute
    9797    end
     98    object AInstructionSetGen: TAction
     99      Category = 'Tools'
     100      Caption = 'Generate instruction set'
     101      OnExecute = AInstructionSetGenExecute
     102    end
    98103  end
    99104  object ImageList1: TImageList
  • trunk/Core.pas

    r5 r6  
    1212
    1313  TCore = class(TDataModule)
     14    AInstructionSetGen: TAction;
    1415    AViewMessages: TAction;
    1516    AGoToAddress: TAction;
     
    3233    procedure AExitExecute(Sender: TObject);
    3334    procedure AGoToAddressExecute(Sender: TObject);
     35    procedure AInstructionSetGenExecute(Sender: TObject);
    3436    procedure APauseExecute(Sender: TObject);
    3537    procedure AResetExecute(Sender: TObject);
     
    7072
    7173uses
    72   CpuZ80, FormGoToAddress;
     74  Z80, FormGoToAddress, InstructionSetGen;
    7375
    7476{ TCore }
     
    104106end;
    105107
     108procedure TCore.AInstructionSetGenExecute(Sender: TObject);
     109var
     110  InstructionSetGen: TInstructionSetGen;
     111begin
     112  InstructionSetGen := TInstructionSetGen.Create;
     113  InstructionSetGen.Generate('Z80/InstructionSet.html');
     114  InstructionSetGen.Free;
     115end;
     116
    106117procedure TCore.APauseExecute(Sender: TObject);
    107118begin
     
    169180    FormDisassembler := TFormDisassembler.Create(nil);
    170181    FormDisassembler.Disassembler.Memory := SharpMz800.MappedMemory;
     182    SharpMz800.OnMemoryMappingChange := FormDisassembler.Disassemble;
    171183  end;
    172184  FormDisassembler.Show;
     185  FormMessages.AddMessage(FormDisassembler.Disassembler.InstructionSet.Check(SharpMz800.Cpu.Instructions));
    173186end;
    174187
  • trunk/Disassembler.pas

    r5 r6  
    44
    55uses
    6   Classes, SysUtils, CpuZ80, Instructions, StrUtils, Memory, Generics.Collections;
     6  Classes, SysUtils, Z80Instructions, Z80InstructionInfo, StrUtils, Memory,
     7  Generics.Collections;
    78
    89type
  • trunk/Forms/Base.pas

    r5 r6  
    1111  TMessageEvent = procedure (Text: string) of object;
    1212
     13
    1314implementation
    1415
  • trunk/Forms/FormCpu.pas

    r5 r6  
    55uses
    66  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ValEdit,
    7   ExtCtrls, CpuZ80;
     7  ExtCtrls, Z80;
    88
    99type
  • trunk/Forms/FormDisassembler.pas

    r5 r6  
    44
    55uses
    6   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, ComCtrls,
     6  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls,
    77  ExtCtrls, Disassembler;
    88
     
    2020  public
    2121    Disassembler: TDisassembler;
     22    procedure Disassemble(Sender: TObject);
    2223    procedure SelectAddress(Address: Word);
    2324    procedure ReloadList;
     
    5152procedure TFormDisassembler.FormShow(Sender: TObject);
    5253begin
    53   Disassembler.Disassemble;
    54   ReloadList;
     54  Disassemble(nil);
    5555end;
    5656
     
    6565    Item.SubItems.Add(Parameters);
    6666  end;
     67end;
     68
     69procedure TFormDisassembler.Disassemble;
     70begin
     71  Disassembler.Disassemble;
     72  ReloadList;
    6773end;
    6874
  • trunk/Forms/FormMain.lfm

    r5 r6  
    44  Top = 509
    55  Width = 1061
    6   Caption = 'SHARP MZ-800 emulator'
     6  Caption = 'MZXEmu'
    77  ClientHeight = 716
    88  ClientWidth = 1061
     
    126126      end
    127127    end
     128    object MenuItemTools: TMenuItem
     129      Caption = 'Tools'
     130      object MenuItem5: TMenuItem
     131        Action = Core.AInstructionSetGen
     132      end
     133    end
    128134  end
    129135end
  • trunk/Forms/FormMain.pas

    r5 r6  
    1414    MenuItem1: TMenuItem;
    1515    MenuItem2: TMenuItem;
     16    MenuItem5: TMenuItem;
     17    MenuItemTools: TMenuItem;
    1618    Separator1: TMenuItem;
    1719    MenuItemFile: TMenuItem;
     
    6870procedure TFormMain.DockInit;
    6971begin
     72  Core.Core.AViewMessages.Execute;
    7073  Core.Core.AViewCpu.Execute;
    7174  Core.Core.AViewScreen.Execute;
    7275  Core.Core.AViewDissssembler.Execute;
    73   Core.Core.AViewMessages.Execute;
    7476  DockForm(Core.Core.FormScreen, PanelCenter);
    7577  DockForm(Core.Core.FormCpu, PanelRight);
  • trunk/Memory.pas

    r5 r6  
    1313  private
    1414    function GetSize: Integer; virtual;
    15     procedure SetSize(AValue: Integer); virtual;
     15    procedure SetSize(AValue: Integer); virtual; abstract;
    1616  public
    1717    Title: string;
     
    213213end;
    214214
    215 procedure TMemory.SetSize(AValue: Integer);
    216 begin
    217 
    218 end;
    219 
    220215function TMemory.Read(Address: Word): Byte;
    221216begin
  • trunk/SharpMz800.pas

    r5 r6  
    44
    55uses
    6   Classes, SysUtils, CpuZ80, Memory, Base;
     6  Classes, SysUtils, Z80, Memory, Base;
    77
    88type
     
    1414  TSharpMz800 = class
    1515  private
     16    FOnMemoryMappingChange: TNotifyEvent;
    1617    WriteFormatRegister: Byte; // WF
    1718    ReadFormatRegister: Byte; // RF
     
    2728    procedure MesssageExecute(Text: string);
    2829    procedure UpdateMemoryMapping;
     30    procedure DoMemoryMappingChange;
    2931  public
    3032    Cpu: TCpuZ80;
     
    4143    destructor Destroy; override;
    4244    property OnMessage: TMessageEvent read FOnMessage write FOnMessage;
     45    property OnMemoryMappingChange: TNotifyEvent read FOnMemoryMappingChange
     46      write FOnMemoryMappingChange;
    4347  end;
    4448
     
    7579    end;
    7680    $e0..$e6: MemoryBankControl[Address - $e0] := Data;
     81    else MesssageExecute('Unsupported I/O port ' + IntToHex(Address, 4) + ' data ' + IntToHex(Data, 2));
    7782  end;
    7883end;
     
    102107  end;
    103108  MappedMemory.Areas.AddNew($0, Memory);
     109  if Assigned(Cpu) then
     110    TThread.Synchronize(Cpu.Thread, DoMemoryMappingChange);
     111end;
     112
     113procedure TSharpMz800.DoMemoryMappingChange;
     114begin
     115  if Assigned(OnMemoryMappingChange) then
     116    FOnMemoryMappingChange(nil);
    104117end;
    105118
     
    141154  MappedIO.Size := 8;
    142155  MappedIO.BasePort := $d0;
     156  MappedIO.OnInput := CpuInput;
     157  MappedIO.OnOutput := CpuOutput;
    143158  UpdateMemoryMapping;
    144159  Cpu := TCpuZ80.Create;
  • trunk/mzxemu.lpi

    r5 r6  
    2424          <SearchPaths>
    2525            <IncludeFiles Value="$(ProjOutDir)"/>
    26             <OtherUnitFiles Value="Forms"/>
     26            <OtherUnitFiles Value="Forms;Z80"/>
    2727            <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    2828          </SearchPaths>
     
    8585      </Unit>
    8686      <Unit>
    87         <Filename Value="CpuZ80.pas"/>
     87        <Filename Value="Z80/Z80.pas"/>
    8888        <IsPartOfProject Value="True"/>
    8989      </Unit>
     
    111111      </Unit>
    112112      <Unit>
    113         <Filename Value="Instructions.pas"/>
     113        <Filename Value="Z80/Z80InstructionInfo.pas"/>
    114114        <IsPartOfProject Value="True"/>
    115115      </Unit>
     
    143143        <IsPartOfProject Value="True"/>
    144144        <ComponentName Value="FormGoToAddress"/>
     145        <HasResources Value="True"/>
    145146        <ResourceBaseClass Value="Form"/>
    146147      </Unit>
     
    149150        <IsPartOfProject Value="True"/>
    150151        <ComponentName Value="FormMessages"/>
     152        <HasResources Value="True"/>
    151153        <ResourceBaseClass Value="Form"/>
    152154      </Unit>
    153155      <Unit>
    154156        <Filename Value="Forms/Base.pas"/>
     157        <IsPartOfProject Value="True"/>
     158      </Unit>
     159      <Unit>
     160        <Filename Value="Z80/Z80Instructions.pas"/>
     161        <IsPartOfProject Value="True"/>
     162      </Unit>
     163      <Unit>
     164        <Filename Value="Z80/InstructionSetGen.pas"/>
    155165        <IsPartOfProject Value="True"/>
    156166      </Unit>
     
    164174    <SearchPaths>
    165175      <IncludeFiles Value="$(ProjOutDir)"/>
    166       <OtherUnitFiles Value="Forms"/>
     176      <OtherUnitFiles Value="Forms;Z80"/>
    167177      <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)-$(BuildMode)"/>
    168178    </SearchPaths>
  • trunk/mzxemu.lpr

    r5 r6  
    1111  {$ENDIF}
    1212  SysUtils, Interfaces, // this includes the LCL widgetset
    13   Forms, FormMain, FormMemory, FormDisassembler, CpuZ80, SharpMz800, Memory,
    14   Core, Instructions, Disassembler, FormCpu, FormScreen, FormGoToAddress,
    15 FormMessages, Base
    16   { you can add units after this };
     13  Forms, FormMain, FormMemory, FormDisassembler, Z80, SharpMz800, Memory, Core,
     14  Z80InstructionInfo, Z80Instructions, Disassembler, FormCpu, FormScreen,
     15  FormGoToAddress, FormMessages, Base, InstructionSetGen;
    1716
    1817{$if declared(UseHeapTrace)}
Note: See TracChangeset for help on using the changeset viewer.