-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfrmCPUWin.pas
271 lines (237 loc) · 6.01 KB
/
frmCPUWin.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
{
Grundy NewBrain Emulator Pro Made by Despsoft
Copyright (c) 2004, Despoinidis Chris
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON A
NY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}
unit frmCPUWin;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,Math;
type
TfCPUWin = class(TForm)
FlagBox: TGroupBox;
FL1: TLabel;
FL2: TLabel;
FL3: TLabel;
FL4: TLabel;
FL5: TLabel;
FL6: TLabel;
FL7: TLabel;
FL8: TLabel;
GroupBox1: TGroupBox;
LAF: TLabel;
LBC: TLabel;
LDE: TLabel;
LHL: TLabel;
LIX: TLabel;
LIY: TLabel;
LIR: TLabel;
LSP: TLabel;
LPC: TLabel;
EDAF: TEdit;
EDBC: TEdit;
EDDE: TEdit;
EDHL: TEdit;
EDIX: TEdit;
EDIY: TEdit;
EDIR: TEdit;
EDSP: TEdit;
EDPC: TEdit;
EDAF2: TEdit;
EDBC2: TEdit;
EDDE2: TEdit;
EDHL2: TEdit;
Timer1: TTimer;
Label1: TLabel;
EdIF1: TEdit;
EdIF2: TEdit;
Label2: TLabel;
EdIRQV: TEdit;
EdIRQL: TEdit;
Label3: TLabel;
EdHLT: TEdit;
procedure FormCreate(Sender: TObject);
procedure FLClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure Timer1Timer(Sender: TObject);
private
AF: WORD;
BC: WORD;
DE: WORD;
HL: WORD;
AF2: WORD;
BC2: WORD;
DE2: WORD;
HL2: WORD;
IX: WORD;
IY: WORD;
IR: WORD;
SP: WORD;
PC: WORD;
IF1: WORD;
IF2: WORD;
IRQV: WORD;
IRQL: WORD;
HLT: WORD;
procedure ShowFlag;
procedure ShowRegisters;
function GetFLAG: Byte;
{ Private declarations }
public
procedure GetRegisters;
property FLAG: Byte read GetFLAG;
{ Public declarations }
end;
var
fCPUWin: TfCPUWin;
implementation
USES z80baseclass,unbmemory,jclLogic,new;
{$R *.dfm}
Function NBLow(W:Word):Byte;
Begin
Result:=W Mod 256;
end;
Function NBHigh(W:Word):Byte;
Begin
Result:= W div 256;
end;
procedure TfCPUWin.FormCreate(Sender: TObject);
begin
Application.HintHidePause:=6500;
Left:=10;
Top:=10;
end;
procedure TfCPUWin.FLClick(Sender: TObject);
CONST MYUPPER=['C','N','P','X','H','Z','S'];
Var lx:String;
b:Byte;
begin
lx:=(Sender as TLabel).Caption;
if lx[1] in MYUPPER then
SetBit(GetFlag,Byte((Sender as TLabel).Tag))
Else
ClearBit(GetFlag,Byte((Sender as TLabel).Tag));
end;
procedure TfCPUWin.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
canclose:=tag>0;
Timer1.Enabled:=not canclose;
end;
function TfCPUWin.GetFLAG: Byte;
begin
AF := z80_get_reg(Z80_REG_AF);
Result:=NBLow(AF);
end;
procedure TfCPUWin.GetRegisters;
begin
AF := z80_get_reg(Z80_REG_AF);
BC := z80_get_reg(Z80_REG_BC);
DE := z80_get_reg(Z80_REG_DE);
HL := z80_get_reg(Z80_REG_HL);
AF2 := z80_get_reg(Z80_REG_AF2);
BC2 := z80_get_reg(Z80_REG_BC2);
DE2 := z80_get_reg(Z80_REG_DE2);
HL2 := z80_get_reg(Z80_REG_HL2);
IX := z80_get_reg(Z80_REG_IX);
IY := z80_get_reg(Z80_REG_IY);
IR := z80_get_reg(Z80_REG_IR);
SP := z80_get_reg(Z80_REG_SP);
PC := z80_get_reg(Z80_REG_PC);
IF1 := z80_get_reg(Z80_REG_IFF1);
IF2 := z80_get_reg(Z80_REG_IFF2);
IRQV := z80_get_reg(Z80_REG_IRQVector);
IRQL := z80_get_reg(Z80_REG_IRQLine);
HLT := z80_get_reg(Z80_REG_HALTED);
end;
procedure TfCPUWin.ShowFlag;
Var f:Byte;
Begin
f:=GetFLAG;
if TestBit(f,0) then
FL1.Caption:='C'
Else
FL1.Caption:='c';
if TestBit(f,1) then
FL2.Caption:='N'
Else
FL2.Caption:='n';
if TestBit(f,2) then
FL3.Caption:='P'
Else
FL3.Caption:='p';
if TestBit(f,3) then
FL4.Caption:='X'
Else
FL4.Caption:='x';
if TestBit(f,4) then
FL5.Caption:='H'
Else
FL5.Caption:='h';
if TestBit(f,5) then
FL6.Caption:='X'
Else
FL6.Caption:='x';
if TestBit(f,6) then
FL7.Caption:='Z'
Else
FL7.Caption:='z';
if TestBit(f,7) then
FL8.Caption:='S'
Else
FL8.Caption:='s';
end;
procedure TfCPUWin.ShowRegisters;
Procedure ShowRegister(Txt:TEdit;v:Word);
Begin
Txt.Text:=inttohex(v,4);
Txt.Hint:=Format('%d (Hi:%d,Lo:%d)',[v,NBHigh(v),NBLow(v)]);
Txt.ShowHint:=True;
End;
Begin
ShowRegister(EDAF,AF);
ShowRegister(EDBC,BC);
ShowRegister(EDDE,DE);
ShowRegister(EDHL,HL);
ShowRegister(EDAF2,AF2);
ShowRegister(EDBC2,BC2);
ShowRegister(EDDE2,DE2);
ShowRegister(EDHL2,HL2);
ShowRegister(EDIX,IX);
ShowRegister(EDIY,IY);
ShowRegister(EDIR,IR);
ShowRegister(EDSP,SP);
ShowRegister(EDPC,PC);
ShowRegister(EDIF1,IF1);
ShowRegister(EDIF2,IF2);
ShowRegister(EDIRQV,IRQV);
ShowRegister(EDIRQL,IRQL);
ShowRegister(EDHLT,HLT);
end;
procedure TfCPUWin.Timer1Timer(Sender: TObject);
begin
GetRegisters;
ShowRegisters;
ShowFlag;
end;
end.