Changeset 5
- Timestamp:
- Apr 18, 2026, 7:24:02 PM (9 days ago)
- Location:
- trunk
- Files:
-
- 5 added
- 15 edited
-
Core.lfm (modified) (2 diffs)
-
Core.pas (modified) (10 diffs)
-
CpuZ80.pas (modified) (13 diffs)
-
Disassembler.pas (modified) (2 diffs)
-
Forms/Base.pas (added)
-
Forms/FormCpu.pas (modified) (1 diff)
-
Forms/FormDisassembler.lfm (modified) (1 diff)
-
Forms/FormDisassembler.pas (modified) (1 diff)
-
Forms/FormGoToAddress.lfm (added)
-
Forms/FormGoToAddress.pas (added)
-
Forms/FormMain.lfm (modified) (8 diffs)
-
Forms/FormMain.pas (modified) (3 diffs)
-
Forms/FormMemory.lfm (modified) (3 diffs)
-
Forms/FormMemory.pas (modified) (4 diffs)
-
Forms/FormMessages.lfm (added)
-
Forms/FormMessages.pas (added)
-
Memory.pas (modified) (4 diffs)
-
SharpMz800.pas (modified) (5 diffs)
-
mzxemu.lpi (modified) (1 diff)
-
mzxemu.lpr (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Core.lfm
r2 r5 19 19 Category = 'View' 20 20 Caption = 'Memory' 21 ShortCut = 113 21 22 OnExecute = AViewMemoryExecute 22 ShortCut = 11323 23 end 24 24 object AViewDissssembler: TAction 25 25 Category = 'View' 26 26 Caption = 'Disassembler' 27 ShortCut = 114 27 28 OnExecute = AViewDissssemblerExecute 28 ShortCut = 11429 29 end 30 30 object AStepIn: TAction 31 Category = 'Debug' 31 32 Caption = 'Step in' 33 ShortCut = 118 32 34 OnExecute = AStepInExecute 33 ShortCut = 11834 35 end 35 36 object AStepOver: TAction 37 Category = 'Debug' 36 38 Caption = 'Step over' 39 ShortCut = 119 37 40 OnExecute = AStepOverExecute 38 ShortCut = 11939 41 end 40 42 object ARunToCursor: TAction 43 Category = 'Debug' 41 44 Caption = 'Run to cursor' 42 45 ShortCut = 115 43 46 end 44 47 object APause: TAction 48 Category = 'Debug' 45 49 Caption = 'Pause' 50 ShortCut = 16504 46 51 OnExecute = APauseExecute 47 ShortCut = 1650448 52 end 49 53 object ARun: TAction 54 Category = 'Debug' 50 55 Caption = 'Run' 56 ShortCut = 120 51 57 OnExecute = ARunExecute 52 ShortCut = 12053 58 end 54 59 object AStepOut: TAction 60 Category = 'Debug' 55 61 Caption = 'Step out' 62 ShortCut = 8311 56 63 OnExecute = AStepOutExecute 57 ShortCut = 831158 64 end 59 65 object AStop: TAction 66 Category = 'Debug' 60 67 Caption = 'Stop' 68 ShortCut = 8312 61 69 OnExecute = AStopExecute 62 ShortCut = 831263 70 end 64 71 object AViewCpu: TAction 65 72 Category = 'View' 66 73 Caption = 'CPU' 74 ShortCut = 116 67 75 OnExecute = AViewCpuExecute 68 ShortCut = 11669 76 end 70 77 object AViewScreen: TAction … … 72 79 Caption = 'Screen' 73 80 OnExecute = AViewScreenExecute 81 end 82 object AReset: TAction 83 Category = 'Debug' 84 Caption = 'Reset' 85 OnExecute = AResetExecute 86 end 87 object AGoToAddress: TAction 88 Category = 'Edit' 89 Caption = 'Go to address' 90 ShortCut = 16455 91 OnExecute = AGoToAddressExecute 92 end 93 object AViewMessages: TAction 94 Category = 'View' 95 Caption = 'Messages' 96 OnExecute = AViewMessagesExecute 74 97 end 75 98 end -
trunk/Core.pas
r4 r5 5 5 uses 6 6 Classes, SysUtils, ActnList, Controls, FormMain, Forms, ExtCtrls, FormMemory, 7 SharpMz800, FormDisassembler, FormCpu, FormScreen ;7 SharpMz800, FormDisassembler, FormCpu, FormScreen, FormMessages; 8 8 9 9 type … … 12 12 13 13 TCore = class(TDataModule) 14 AViewMessages: TAction; 15 AGoToAddress: TAction; 16 AReset: TAction; 14 17 AViewScreen: TAction; 15 18 AViewCpu: TAction; … … 28 31 TimerUpdate: TTimer; 29 32 procedure AExitExecute(Sender: TObject); 33 procedure AGoToAddressExecute(Sender: TObject); 30 34 procedure APauseExecute(Sender: TObject); 35 procedure AResetExecute(Sender: TObject); 31 36 procedure ARunExecute(Sender: TObject); 32 37 procedure AStepInExecute(Sender: TObject); … … 37 42 procedure AViewDissssemblerExecute(Sender: TObject); 38 43 procedure AViewMemoryExecute(Sender: TObject); 44 procedure AViewMessagesExecute(Sender: TObject); 39 45 procedure AViewScreenExecute(Sender: TObject); 40 46 procedure DataModuleCreate(Sender: TObject); … … 49 55 FormCpu: TFormCpu; 50 56 FormScreen: TFormScreen; 57 FormMessages: TFormMessages; 51 58 SharpMz800: TSharpMz800; 52 59 procedure UpdateDisassemblerPos; … … 63 70 64 71 uses 65 CpuZ80 ;72 CpuZ80, FormGoToAddress; 66 73 67 74 { TCore } … … 69 76 procedure TCore.DataModuleCreate(Sender: TObject); 70 77 begin 78 LastPc := $ffff; 71 79 SharpMz800 := TSharpMz800.Create; 72 80 // SharpMz800.PowerOn; … … 80 88 end; 81 89 90 procedure TCore.AGoToAddressExecute(Sender: TObject); 91 var 92 FormGoToAddress: TFormGoToAddress; 93 Address: LongInt; 94 begin 95 FormGoToAddress := TFormGoToAddress.Create(nil); 96 try 97 if FormGoToAddress.ShowModal = mrOk then begin 98 if TryStrToInt(FormGoToAddress.EditAddress.Text, Address) then 99 FormDisassembler.SelectAddress(Address); 100 end; 101 finally 102 FormGoToAddress.Free; 103 end; 104 end; 105 82 106 procedure TCore.APauseExecute(Sender: TObject); 83 107 begin 84 108 SharpMz800.Cpu.Running := False; 109 UpdateInterface; 110 end; 111 112 procedure TCore.AResetExecute(Sender: TObject); 113 var 114 IsRunning: Boolean; 115 begin 116 IsRunning := SharpMz800.Cpu.Running; 117 SharpMz800.Cpu.Running := False; 118 SharpMz800.Cpu.Reset; 119 SharpMz800.Cpu.Running := IsRunning; 85 120 UpdateInterface; 86 121 end; … … 142 177 if not Assigned(FormMemory) then begin 143 178 FormMemory := TFormMemory.Create(nil); 144 FormMemory.Size := SharpMz800.MappedMemory.Size; 145 FormMemory.Memory := SharpMz800.MappedMemory; 179 FormMemory.Areas.Add(SharpMz800.Memory); 180 FormMemory.Areas.Add(SharpMz800.BaseRom); 181 FormMemory.Areas.Add(SharpMz800.ExtendedRom); 182 FormMemory.Areas.Add(SharpMz800.VideoRam); 183 FormMemory.Areas.Add(SharpMz800.CharacterRom); 184 FormMemory.Areas.Add(SharpMz800.MappedIO); 146 185 end; 147 186 FormMemory.Show; 187 end; 188 189 procedure TCore.AViewMessagesExecute(Sender: TObject); 190 begin 191 if not Assigned(FormMessages) then begin 192 FormMessages := TFormMessages.Create(nil); 193 SharpMz800.OnMessage := FormMessages.AddMessage; 194 end; 195 FormMessages.Show; 148 196 end; 149 197 … … 162 210 if Assigned(FormMemory) then FreeAndNil(FormMemory); 163 211 if Assigned(FormScreen) then FreeAndNil(FormScreen); 212 if Assigned(FormMessages) then FreeAndNil(FormMessages); 164 213 FreeAndNil(FormMain); 165 214 FreeAndNil(SharpMz800); -
trunk/CpuZ80.pas
r2 r5 4 4 5 5 uses 6 Classes, SysUtils, Memory ;6 Classes, SysUtils, Memory, Base; 7 7 8 8 type 9 TReadEvent = function (Address: Word): Byte of object;10 TWriteEvent = procedure (Address: Word; Data: Byte) of object;11 12 9 TInstruction = (inNop = 0, inLdBcNn = $1, inLdBcIndirectA = $2, 13 10 inIncBc = $3, inIncB = $4, inDecB = $5, inLdBN = $6, inRlca = $7, … … 38 35 TRegBC = record 39 36 case Byte of 40 0: ( B, C: Byte);37 0: (C, B: Byte); 41 38 1: (Value: Word); 42 39 end; … … 44 41 TRegDE = record 45 42 case Byte of 46 0: ( D, E: Byte);43 0: (E, D: Byte); 47 44 1: (Value: Word); 48 45 end; … … 50 47 TRegHL = record 51 48 case Byte of 52 0: ( H, L: Byte);49 0: (L, H: Byte); 53 50 1: (Value: Word); 54 51 end; … … 61 58 private 62 59 FOnInput: TReadEvent; 60 FOnMessage: TMessageEvent; 63 61 FOnOutput: TWriteEvent; 64 62 FOnRead: TReadEvent; … … 67 65 FThread: TCpuThread; 68 66 Instruction: TInstruction; 67 MessageText: string; 69 68 procedure SetRunning(AValue: Boolean); 70 69 function DoRead(Address: Word): Byte; … … 72 71 function DoInput(Address: Word): Byte; 73 72 procedure DoOutput(Address: Word; Data: Byte); 73 procedure DoMessage(Text: string); 74 procedure DoMessageSync; 74 75 function ReadByte: Byte; 75 76 function ReadWord: Word; 76 procedure PushWord(Data: Word); inline; 77 function PopWord: Word; inline; 78 procedure Call(Address: Word); inline; 79 procedure Cp(Data: Byte); inline; 80 procedure Jr(Condition: Boolean); inline; 81 procedure Jp(Condition: Boolean); inline; 77 procedure PushWord(Data: Word); 78 function PopWord: Word; 79 procedure Call(Address: Word); 80 procedure Cp(Data: Byte); 81 procedure Jr(Condition: Boolean); 82 procedure Jp(Condition: Boolean); 83 procedure Halt; 82 84 public 83 85 A: Byte; … … 104 106 property OnInput: TReadEvent read FOnInput write FOnInput; 105 107 property OnOutput: TWriteEvent read FOnOutput write FOnOutput; 106 end; 108 property OnMessage: TMessageEvent read FOnMessage write FOnMessage; 109 end; 110 107 111 108 112 implementation … … 164 168 end; 165 169 170 procedure TCpuZ80.DoMessage(Text: string); 171 begin 172 MessageText := Text; 173 FThread.Synchronize(DoMessageSync); 174 MessageText := ''; 175 end; 176 177 procedure TCpuZ80.DoMessageSync; 178 begin 179 if Assigned(FOnMessage) then FOnMessage(MessageText); 180 end; 181 166 182 function TCpuZ80.ReadByte: Byte; 167 183 begin … … 206 222 procedure TCpuZ80.Jr(Condition: Boolean); 207 223 var 208 Temp: Byte;209 begin 210 Temp := ReadByte;224 Temp: ShortInt; 225 begin 226 Temp := ShortInt(ReadByte); 211 227 if Condition then 212 PC := PC + ShortInt(Temp);228 PC := PC + Temp; 213 229 end; 214 230 … … 219 235 Temp := ReadWord; 220 236 if Condition then PC := Temp; 237 end; 238 239 procedure TCpuZ80.Halt; 240 begin 241 FThread.Terminate; 221 242 end; 222 243 … … 293 314 inRst28: Call($28); 294 315 inRst30: Call($30); 295 inRst38: Call($ 08);316 inRst38: Call($38); 296 317 inDi: InterruptEnabled := False; 297 318 inEi: InterruptEnabled := True; … … 315 336 inJrNzD: Jr(not Zero); 316 337 inJrNcD: Jr(not Carry); 317 else raise Exception.Create('Unsupported instruction ' + IntToHex(Word(Instruction), 4)); 338 else begin 339 Dec(PC); 340 DoMessage('Unsupported instruction ' + IntToHex(Word(Instruction), 4) + ' on address ' + IntToHex(Word(PC), 4)); 341 Halt; 342 end; 318 343 end; 319 344 Ticks := Cardinal(Ticks + 1); -
trunk/Disassembler.pas
r2 r5 24 24 TDecodedInstructions = class(TObjectList<TDecodedInstruction>) 25 25 function SearchAddress(Address: Word): TDecodedInstruction; 26 function SearchAddressIndex(Address: Word): Integer; 26 27 end; 27 28 … … 52 53 if I < Count then Result := Items[I] 53 54 else Result := nil; 55 end; 56 57 function TDecodedInstructions.SearchAddressIndex(Address: Word): Integer; 58 var 59 I: Integer; 60 begin 61 I := 0; 62 while (I < Count) and (Items[I].Address <> Address) do Inc(I); 63 if I < Count then Result := I 64 else Result := -1; 54 65 end; 55 66 -
trunk/Forms/FormCpu.pas
r2 r5 20 20 end; 21 21 22 22 23 implementation 23 24 -
trunk/Forms/FormDisassembler.lfm
r2 r5 8 8 ClientWidth = 1056 9 9 DesignTimePPI = 144 10 LCLVersion = '4.6.0.0' 10 11 OnClose = FormClose 11 12 OnCreate = FormCreate 12 13 OnDestroy = FormDestroy 13 14 OnShow = FormShow 14 LCLVersion = '2.2.6.0'15 15 object ListView1: TListView 16 16 Left = 0 -
trunk/Forms/FormDisassembler.pas
r2 r5 71 71 Item: TListItem; 72 72 DecodedInstruction: TDecodedInstruction; 73 Index: Integer; 73 74 begin 74 DecodedInstruction := Disassembler.DecodedInstructions.SearchAddress(Address); 75 if Assigned(DecodedInstruction) then begin 76 Item := ListView1.Items[Disassembler.DecodedInstructions.IndexOf(DecodedInstruction)]; 75 Index := Disassembler.DecodedInstructions.SearchAddressIndex(Address); 76 if Index >= 0 then begin 77 DecodedInstruction := Disassembler.DecodedInstructions[Index]; 78 Item := ListView1.Items[Index]; 77 79 if Assigned(Item) then begin 78 80 Item.MakeVisible(False); 79 Item.Focused := True; 80 Item.Selected := True; 81 //Item.Focused := False; 82 //Item.Selected := False; 83 //Item.Focused := True; 84 //Item.Selected := True; 85 ListView1.ItemIndex := Index; 86 ListView1.Selected := ListView1.Items[Index]; 87 ListView1.Items[Index].Focused := True; 81 88 end; 82 89 end; -
trunk/Forms/FormMain.lfm
r2 r5 5 5 Width = 1061 6 6 Caption = 'SHARP MZ-800 emulator' 7 ClientHeight = 6827 ClientHeight = 716 8 8 ClientWidth = 1061 9 9 DesignTimePPI = 144 10 10 Menu = MainMenu1 11 LCLVersion = '4.6.0.0' 11 12 OnClose = FormClose 12 13 OnCreate = FormCreate 13 14 OnDestroy = FormDestroy 14 15 OnShow = FormShow 15 LCLVersion = '2.2.6.0'16 16 object PanelLeft: TPanel 17 17 Left = 0 18 Height = 68218 Height = 716 19 19 Top = 0 20 20 Width = 231 … … 25 25 object PanelRight: TPanel 26 26 Left = 806 27 Height = 68227 Height = 716 28 28 Top = 0 29 29 Width = 255 … … 34 34 object Splitter1: TSplitter 35 35 Left = 231 36 Height = 68236 Height = 716 37 37 Top = 0 38 38 Width = 8 … … 40 40 object Splitter2: TSplitter 41 41 Left = 798 42 Height = 68242 Height = 716 43 43 Top = 0 44 44 Width = 8 … … 48 48 object PanelCenter: TPanel 49 49 Left = 239 50 Height = 68250 Height = 716 51 51 Top = 0 52 52 Width = 559 53 53 Align = alClient 54 54 BevelOuter = bvNone 55 ClientHeight = 716 56 ClientWidth = 559 55 57 TabOrder = 4 58 object PanelBottom: TPanel 59 Left = 0 60 Height = 164 61 Top = 552 62 Width = 559 63 Align = alBottom 64 BevelOuter = bvNone 65 TabOrder = 0 66 end 56 67 end 57 68 object MainMenu1: TMainMenu 58 69 Left = 216 59 70 Top = 64 60 object MenuItem 1: TMenuItem71 object MenuItemFile: TMenuItem 61 72 Caption = 'File' 62 73 object MenuItem4: TMenuItem … … 64 75 end 65 76 end 66 object MenuItem5: TMenuItem 77 object MenuItemEdit: TMenuItem 78 Caption = 'Edit' 79 object MenuItem1: TMenuItem 80 Action = Core.AGoToAddress 81 end 82 end 83 object MenuItemView: TMenuItem 67 84 Caption = 'View' 68 85 object MenuItem6: TMenuItem … … 79 96 end 80 97 end 81 object MenuItem 2: TMenuItem98 object MenuItemDebug: TMenuItem 82 99 Caption = 'Debug' 83 100 object MenuItem3: TMenuItem … … 86 103 object MenuItem8: TMenuItem 87 104 Action = Core.APause 105 end 106 object MenuItem2: TMenuItem 107 Action = Core.AReset 108 end 109 object Separator1: TMenuItem 110 Caption = '-' 88 111 end 89 112 object MenuItem13: TMenuItem -
trunk/Forms/FormMain.pas
r2 r5 13 13 MainMenu1: TMainMenu; 14 14 MenuItem1: TMenuItem; 15 MenuItem2: TMenuItem; 16 Separator1: TMenuItem; 17 MenuItemFile: TMenuItem; 15 18 MenuItem10: TMenuItem; 16 19 MenuItem11: TMenuItem; … … 19 22 MenuItem14: TMenuItem; 20 23 MenuItem15: TMenuItem; 21 MenuItem2: TMenuItem; 24 MenuItemEdit: TMenuItem; 25 MenuItemDebug: TMenuItem; 22 26 MenuItem3: TMenuItem; 23 27 MenuItem4: TMenuItem; 24 MenuItem 5: TMenuItem;28 MenuItemView: TMenuItem; 25 29 MenuItem6: TMenuItem; 26 30 MenuItem7: TMenuItem; 27 31 MenuItem8: TMenuItem; 28 32 MenuItem9: TMenuItem; 33 PanelBottom: TPanel; 29 34 PanelLeft: TPanel; 30 35 PanelRight: TPanel; … … 66 71 Core.Core.AViewScreen.Execute; 67 72 Core.Core.AViewDissssembler.Execute; 73 Core.Core.AViewMessages.Execute; 68 74 DockForm(Core.Core.FormScreen, PanelCenter); 69 75 DockForm(Core.Core.FormCpu, PanelRight); 70 76 DockForm(Core.Core.FormDisassembler, PanelLeft); 77 DockForm(Core.Core.FormMessages, PanelBottom); 71 78 end; 72 79 -
trunk/Forms/FormMemory.lfm
r2 r5 8 8 ClientWidth = 1150 9 9 DesignTimePPI = 144 10 LCLVersion = '4.6.0.0' 11 OnCreate = FormCreate 12 OnDestroy = FormDestroy 10 13 OnShow = FormShow 11 LCLVersion = '2.2.6.0'12 14 object ListViewMemory: TListView 13 Left = 814 Height = 8 5015 Top = 816 Width = 11 3417 Align = alC lient15 Left = 0 16 Height = 810 17 Top = 48 18 Width = 1142 19 Align = alCustom 18 20 Anchors = [akTop, akLeft, akBottom] 19 21 BorderSpacing.Around = 8 … … 29 31 item 30 32 Caption = 'ASCII' 31 Width = 3 5633 Width = 364 32 34 end> 33 35 Font.Height = -20 … … 39 41 OnData = ListViewMemoryData 40 42 end 43 object Label1: TLabel 44 Left = 8 45 Height = 26 46 Top = 8 47 Width = 44 48 Caption = 'Area:' 49 end 50 object ComboBoxArea: TComboBox 51 Left = 104 52 Height = 42 53 Top = 0 54 Width = 334 55 ItemHeight = 0 56 Style = csDropDownList 57 TabOrder = 1 58 OnSelect = ComboBoxAreaSelect 59 end 41 60 object Timer1: TTimer 42 61 Interval = 500 -
trunk/Forms/FormMemory.pas
r2 r5 5 5 uses 6 6 Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, ExtCtrls, 7 Memory;7 StdCtrls, Memory, Generics.Collections; 8 8 9 9 type … … 13 13 14 14 TFormMemory = class(TForm) 15 ComboBoxArea: TComboBox; 16 Label1: TLabel; 15 17 ListViewMemory: TListView; 16 18 Timer1: TTimer; 19 procedure ComboBoxAreaSelect(Sender: TObject); 20 procedure FormCreate(Sender: TObject); 21 procedure FormDestroy(Sender: TObject); 17 22 procedure FormShow(Sender: TObject); 18 23 procedure ListViewMemoryData(Sender: TObject; Item: TListItem); 19 24 procedure Timer1Timer(Sender: TObject); 20 p ublic25 private 21 26 Memory: TMemory; 22 27 Size: Integer; 28 public 29 Areas: TObjectList<TMemory>; 30 procedure ReloadAreas; 23 31 procedure Reload; 24 32 end; … … 65 73 procedure TFormMemory.FormShow(Sender: TObject); 66 74 begin 75 ReloadAreas; 76 ComboBoxAreaSelect(nil); 77 end; 78 79 procedure TFormMemory.FormCreate(Sender: TObject); 80 begin 81 Areas := TObjectList<TMemory>.Create(False); 82 end; 83 84 procedure TFormMemory.ComboBoxAreaSelect(Sender: TObject); 85 begin 86 if ComboBoxArea.ItemIndex >= 0 then begin 87 Memory := TMemory(ComboBoxArea.Items.Objects[ComboBoxArea.ItemIndex]); 88 Size := Memory.Size; 89 end else begin 90 Memory := nil; 91 Size := 0; 92 end; 67 93 Reload; 94 end; 95 96 procedure TFormMemory.FormDestroy(Sender: TObject); 97 begin 98 FreeAndNil(Areas); 68 99 end; 69 100 … … 73 104 end; 74 105 106 procedure TFormMemory.ReloadAreas; 107 var 108 I: Integer; 109 begin 110 ComboBoxArea.Items.BeginUpdate; 111 try 112 while ComboBoxArea.Items.Count > Areas.Count do 113 ComboBoxArea.Items.Delete(ComboBoxArea.Items.Count - 1); 114 while ComboBoxArea.Items.Count < Areas.Count do 115 ComboBoxArea.Items.Add(''); 116 for I := 0 to Areas.Count - 1 do begin 117 ComboBoxArea.Items.Strings[I] := Areas[I].Title; 118 ComboBoxArea.Items.Objects[I] := Areas[I]; 119 end; 120 if (ComboBoxArea.ItemIndex = -1) and (ComboBoxArea.Items.Count > 0) then 121 ComboBoxArea.ItemIndex := 0; 122 finally 123 ComboBoxArea.Items.EndUpdate; 124 end; 125 end; 126 75 127 end. 76 128 -
trunk/Memory.pas
r2 r5 4 4 5 5 uses 6 Classes, SysUtils, Generics.Collections ;6 Classes, SysUtils, Generics.Collections, Base; 7 7 8 8 type … … 15 15 procedure SetSize(AValue: Integer); virtual; 16 16 public 17 Title: string; 17 18 Position: Integer; 18 19 function Read(Address: Word): Byte; virtual; … … 34 35 procedure Write(Address: Word; Data: Byte); override; 35 36 procedure LoadFromFile(FileName: string); override; 37 end; 38 39 { TMemoryIO } 40 41 TMemoryIO = class(TMemory) 42 private 43 FOnInput: TReadEvent; 44 FOnOutput: TWriteEvent; 45 FSize: Integer; 46 public 47 BasePort: Byte; 48 function GetSize: Integer; override; 49 procedure SetSize(AValue: Integer); override; 50 function Read(Address: Word): Byte; override; 51 procedure Write(Address: Word; Data: Byte); override; 52 property OnInput: TReadEvent read FOnInput write FOnInput; 53 property OnOutput: TWriteEvent read FOnOutput write FOnOutput; 36 54 end; 37 55 … … 166 184 end; 167 185 186 { TMemoryIO } 187 188 function TMemoryIO.GetSize: Integer; 189 begin 190 Result := FSize; 191 end; 192 193 procedure TMemoryIO.SetSize(AValue: Integer); 194 begin 195 FSize := AVAlue; 196 end; 197 198 function TMemoryIO.Read(Address: Word): Byte; 199 begin 200 if Assigned(FOnInput) then FOnInput(BasePort + Address); 201 end; 202 203 procedure TMemoryIO.Write(Address: Word; Data: Byte); 204 begin 205 if Assigned(FOnOutput) then FOnOutput(BasePort + Address, Data); 206 end; 207 168 208 { TMemory } 169 209 -
trunk/SharpMz800.pas
r4 r5 4 4 5 5 uses 6 Classes, SysUtils, CpuZ80, Memory ;6 Classes, SysUtils, CpuZ80, Memory, Base; 7 7 8 8 type 9 TMode = (md800, md700); 10 TResolution = (rs320x200, rs640x200); 11 9 12 { TSharpMz800 } 10 13 11 14 TSharpMz800 = class 12 15 private 16 WriteFormatRegister: Byte; // WF 17 ReadFormatRegister: Byte; // RF 18 DisplayModeRegister: Byte; // DMD 19 MemoryBankControl: array[0..6] of Byte; 20 FOnMessage: TMessageEvent; 21 Mode: TMode; 22 Resolution: TResolution; 23 procedure CpuWrite(Address: Word; Data: Byte); 24 function CpuRead(Address: Word): Byte; 25 function CpuInput(Address: Word): Byte; 26 procedure CpuOutput(Address: Word; Data: Byte); 27 procedure MesssageExecute(Text: string); 28 procedure UpdateMemoryMapping; 13 29 public 14 30 Cpu: TCpuZ80; … … 19 35 CharacterRom: TMemoryData; 20 36 MappedMemory: TMemoryMapped; 21 procedure CpuWrite(Address: Word; Data: Byte); 22 function CpuRead(Address: Word): Byte; 37 MappedIO: TMemoryIO; 23 38 procedure PowerOn; 24 39 procedure PowerOff; 25 40 constructor Create; 26 41 destructor Destroy; override; 42 property OnMessage: TMessageEvent read FOnMessage write FOnMessage; 27 43 end; 28 44 … … 42 58 end; 43 59 60 function TSharpMz800.CpuInput(Address: Word): Byte; 61 begin 62 Result := 0; 63 end; 64 65 procedure TSharpMz800.CpuOutput(Address: Word; Data: Byte); 66 begin 67 case Address of 68 $cc: WriteFormatRegister := Data; 69 $cd: ReadFormatRegister := Data; 70 $ce: begin 71 DisplayModeRegister := Data; 72 if (DisplayModeRegister and 8) <> 0 then Mode := md700 else Mode := md800; 73 if (DisplayModeRegister and 4) <> 0 then Resolution := rs320x200 else Resolution := rs640x200; 74 UpdateMemoryMapping; 75 end; 76 $e0..$e6: MemoryBankControl[Address - $e0] := Data; 77 end; 78 end; 79 80 procedure TSharpMz800.MesssageExecute(Text: string); 81 begin 82 if Assigned(FOnMessage) then FOnMessage(Text); 83 end; 84 85 procedure TSharpMz800.UpdateMemoryMapping; 86 begin 87 MappedMemory.Areas.Clear; 88 MappedMemory.Areas.AddNew($0, BaseRom); 89 case Mode of 90 md700: begin 91 MappedMemory.Areas.AddNew($d000, VideoRam); 92 VideoRam.Size := $1000; 93 MappedMemory.Areas.AddNew($e000, MappedIO); 94 MappedMemory.Areas.AddNew($e010, ExtendedRom); 95 end; 96 md800: begin 97 MappedMemory.Areas.AddNew($1000, CharacterRom); 98 MappedMemory.Areas.AddNew($8000, VideoRam); 99 VideoRam.Size := $1000; 100 MappedMemory.Areas.AddNew($e000, ExtendedRom); 101 end; 102 end; 103 MappedMemory.Areas.AddNew($0, Memory); 104 end; 105 44 106 procedure TSharpMz800.PowerOn; 45 107 begin … … 56 118 RomSubDir = 'ROM'; 57 119 begin 120 Mode := md800; 121 Resolution := rs320x200; 58 122 Memory := TMemoryData.Create; 123 Memory.Title := 'Main memory'; 59 124 Memory.Size := 65536; // $10000 60 125 BaseRom := TMemoryData.Create; 126 BaseRom.Title := 'Base ROM'; 61 127 BaseRom.LoadFromFile(RomSubDir + DirectorySeparator + 'MZ700A.ROM'); 62 128 ExtendedRom := TMemoryData.Create; 129 ExtendedRom.Title := 'Extended ROM'; 63 130 ExtendedRom.LoadFromFile(RomSubDir + DirectorySeparator + '9Z_504M.ROM'); 64 131 CharacterRom := TMemoryData.Create; 132 CharacterRom.Title := 'Character ROM (CGROM)'; 65 133 CharacterRom.LoadFromFile(RomSubDir + DirectorySeparator + 'CGROM.ROM'); 66 134 VideoRam := TMemoryData.Create; 135 VideoRam.Title := 'Video memory (VRAM)'; 67 136 VideoRam.Size := 4096; // $1000 68 137 MappedMemory := TMemoryMapped.Create; 69 138 MappedMemory.Size := $10000; 70 MappedMemory.Areas.AddNew($0, BaseRom); 71 MappedMemory.Areas.AddNew($1000, CharacterRom); 72 MappedMemory.Areas.AddNew($e000, ExtendedRom); 73 MappedMemory.Areas.AddNew($0, Memory); 139 MappedIO := TMemoryIO.Create; 140 MappedIO.Title := 'Mapped I/O'; 141 MappedIO.Size := 8; 142 MappedIO.BasePort := $d0; 143 UpdateMemoryMapping; 74 144 Cpu := TCpuZ80.Create; 75 145 Cpu.Memory := MappedMemory; 76 146 Cpu.OnRead := CpuRead; 77 147 Cpu.OnWrite := CpuWrite; 148 Cpu.OnInput := CpuInput; 149 Cpu.OnOutput := CpuOutput; 150 Cpu.OnMessage := MesssageExecute; 78 151 end; 79 152 … … 87 160 FreeAndNil(ExtendedRom); 88 161 FreeAndNil(Memory); 162 FreeAndNil(MappedIO); 89 163 inherited; 90 164 end; -
trunk/mzxemu.lpi
r3 r5 139 139 <ResourceBaseClass Value="Form"/> 140 140 </Unit> 141 <Unit> 142 <Filename Value="Forms/FormGoToAddress.pas"/> 143 <IsPartOfProject Value="True"/> 144 <ComponentName Value="FormGoToAddress"/> 145 <ResourceBaseClass Value="Form"/> 146 </Unit> 147 <Unit> 148 <Filename Value="Forms/FormMessages.pas"/> 149 <IsPartOfProject Value="True"/> 150 <ComponentName Value="FormMessages"/> 151 <ResourceBaseClass Value="Form"/> 152 </Unit> 153 <Unit> 154 <Filename Value="Forms/Base.pas"/> 155 <IsPartOfProject Value="True"/> 156 </Unit> 141 157 </Units> 142 158 </ProjectOptions> -
trunk/mzxemu.lpr
r3 r5 12 12 SysUtils, Interfaces, // this includes the LCL widgetset 13 13 Forms, FormMain, FormMemory, FormDisassembler, CpuZ80, SharpMz800, Memory, 14 Core, Instructions, Disassembler, FormCpu, FormScreen 14 Core, Instructions, Disassembler, FormCpu, FormScreen, FormGoToAddress, 15 FormMessages, Base 15 16 { you can add units after this }; 16 17
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/mzxemu/chrome/site/your_project_logo.png)