RasterBreakPoint.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.event.*;
16: import javax.swing.*;
17: import javax.swing.event.*;
18:
19: public class RasterBreakPoint {
20:
21: public static final boolean RBP_ON = true;
22:
23:
24: public static boolean rbpBreakEnabled;
25: public static int rbpBreakRaster;
26: public static int rbpActiveBreakRaster;
27: public static boolean rbpIRQBreakEnabled;
28: public static int rbpCountValue;
29: public static int rbpThresholdValue;
30:
31:
32: public static JFrame rbpFrame;
33: public static JCheckBox rbpEnabledCheckBox;
34: public static JCheckBox rbpIRQEnabledCheckBox;
35: public static JLabel rbpStatusLabel;
36: public static JTextField rbpCurrentRasterTextField;
37: public static JTextField rbpIRQRasterTextField;
38: public static SpinnerNumberModel rbpBreakModel;
39: public static SpinnerNumberModel rbpCountModel;
40: public static SpinnerNumberModel rbpThresholdModel;
41:
42:
43: public static final int RBP_INTERVAL = 10;
44: public static int rbpTimer;
45:
46:
47:
48: public static void rbpInit () {
49:
50: rbpBreakEnabled = false;
51: rbpBreakRaster = 0;
52: rbpActiveBreakRaster = -1;
53: rbpIRQBreakEnabled = false;
54: rbpCountValue = 0;
55: rbpThresholdValue = 0;
56:
57: rbpFrame = null;
58:
59: rbpTimer = 0;
60: }
61:
62:
63: public static void rbpStart () {
64: if (RestorableFrame.rfmGetOpened (Settings.SGS_RBP_FRAME_KEY)) {
65: rbpOpen ();
66: }
67: }
68:
69:
70:
71: public static void rbpOpen () {
72: if (rbpFrame == null) {
73: rbpMakeFrame ();
74: } else {
75: rbpUpdateFrame ();
76: }
77: XEiJ.dbgVisibleMask |= XEiJ.DBG_RBP_VISIBLE_MASK;
78: XEiJ.pnlExitFullScreen (false);
79: rbpFrame.setVisible (true);
80: }
81:
82:
83:
84:
85: public static void rbpMakeFrame () {
86:
87: ActionListener listener = new ActionListener () {
88: @Override public void actionPerformed (ActionEvent ae) {
89: Object source = ae.getSource ();
90: switch (ae.getActionCommand ()) {
91: case "Fixed raster ":
92: rbpSetBreakEnabled (((JCheckBox) source).isSelected ());
93: break;
94: case "IRQ raster ":
95: rbpSetIRQEnabled (((JCheckBox) source).isSelected ());
96: break;
97: case "Run to next raster":
98: if (XEiJ.mpuTask == null) {
99:
100: rbpSetBreakEnabled (false);
101:
102:
103:
104: rbpSetBreakRaster (CRTC.crtRasterNumber < CRTC.crtR04VFrontEndCurr ? CRTC.crtRasterNumber + 1 : 0);
105: rbpBreakModel.setValue (Integer.valueOf (rbpBreakRaster));
106:
107: rbpSetBreakEnabled (true);
108: rbpEnabledCheckBox.setSelected (true);
109:
110: rbpUpdateFrame ();
111:
112: XEiJ.mpuStart ();
113: }
114: break;
115: case "Run":
116: if (XEiJ.mpuTask == null) {
117:
118: XEiJ.mpuStart ();
119:
120:
121:
122: }
123: break;
124: }
125: }
126: };
127:
128: rbpFrame = Multilingual.mlnTitle (
129: ComponentFactory.createRestorableSubFrame (
130: Settings.SGS_RBP_FRAME_KEY,
131: "Raster break point",
132: null,
133: ComponentFactory.createVerticalBox (
134: Box.createVerticalStrut (4),
135: ComponentFactory.createHorizontalBox (
136: Box.createHorizontalStrut (12),
137: Box.createHorizontalGlue (),
138: rbpStatusLabel = ComponentFactory.createLabel (rbpMakeStatusText ()),
139: Box.createHorizontalGlue (),
140: Box.createHorizontalStrut (12)
141: ),
142: Box.createVerticalStrut (4),
143: ComponentFactory.createHorizontalBox (
144: Box.createHorizontalStrut (12),
145: Box.createHorizontalGlue (),
146: Multilingual.mlnText (ComponentFactory.createLabel ("Current raster "), "ja", "現在のラスタ "),
147: rbpCurrentRasterTextField = ComponentFactory.setEditable (
148: ComponentFactory.createNumberField (String.valueOf (CRTC.crtRasterNumber), 5),
149: false),
150: Box.createHorizontalStrut (12),
151: Box.createHorizontalGlue (),
152: rbpEnabledCheckBox = Multilingual.mlnText (ComponentFactory.createCheckBox (rbpBreakEnabled, "Fixed raster ", listener), "ja", "固定ラスタ "),
153: ComponentFactory.createNumberSpinner (rbpBreakModel = new SpinnerNumberModel (rbpBreakRaster, 0, 1023, 1), 5, new ChangeListener () {
154: @Override public void stateChanged (ChangeEvent ce) {
155: rbpSetBreakRaster (rbpBreakModel.getNumber ().intValue ());
156: }
157: }),
158: Box.createHorizontalStrut (12),
159: Box.createHorizontalGlue (),
160: rbpIRQEnabledCheckBox = Multilingual.mlnText (ComponentFactory.createCheckBox (rbpIRQBreakEnabled, "IRQ raster ", listener), "ja", "IRQ ラスタ "),
161: rbpIRQRasterTextField = ComponentFactory.setEditable (
162: ComponentFactory.createNumberField (String.valueOf (CRTC.crtR09IRQRasterCurr), 5),
163: false),
164: Box.createHorizontalGlue (),
165: Box.createHorizontalStrut (12)
166: ),
167: Box.createVerticalStrut (4),
168: ComponentFactory.createHorizontalBox (
169: Box.createHorizontalStrut (12),
170: Box.createHorizontalGlue (),
171: Multilingual.mlnText (ComponentFactory.createLabel ("Count "), "ja", "回数 "),
172: ComponentFactory.createNumberSpinner (rbpCountModel = new SpinnerNumberModel (rbpCountValue, 0, 99999999, 1), 8, new ChangeListener () {
173: @Override public void stateChanged (ChangeEvent ce) {
174: rbpCountValue = rbpCountModel.getNumber ().intValue ();
175: }
176: }),
177: Box.createHorizontalStrut (12),
178: Multilingual.mlnText (ComponentFactory.createLabel ("Threshold "), "ja", "閾値 "),
179: ComponentFactory.createNumberSpinner (rbpThresholdModel = new SpinnerNumberModel (rbpThresholdValue, 0, 99999999, 1), 8, new ChangeListener () {
180: @Override public void stateChanged (ChangeEvent ce) {
181: rbpThresholdValue = rbpThresholdModel.getNumber ().intValue ();
182: }
183: }),
184: Box.createHorizontalStrut (12),
185: Box.createHorizontalGlue (),
186: XEiJ.mpuAddButtonStopped (Multilingual.mlnText (ComponentFactory.createButton ("Run to next raster", listener), "ja", "次のラスタまで実行")),
187: Box.createHorizontalStrut (12),
188: XEiJ.mpuAddButtonStopped (Multilingual.mlnText (ComponentFactory.createButton ("Run", listener), "ja", "実行")),
189: Box.createHorizontalGlue (),
190: Box.createHorizontalStrut (12)
191: ),
192: Box.createVerticalStrut (4)
193: )
194: ),
195: "ja", "ラスタブレークポイント");
196:
197: ComponentFactory.addListener (
198: rbpFrame,
199: new WindowAdapter () {
200: @Override public void windowClosing (WindowEvent we) {
201: XEiJ.dbgVisibleMask &= ~XEiJ.DBG_RBP_VISIBLE_MASK;
202: }
203: });
204: }
205:
206:
207: public static String rbpMakeStatusText () {
208: StringBuilder sb = new StringBuilder ();
209: return (Multilingual.mlnJapanese ? sb.
210: append ("帰線期間 0-").append (CRTC.crtR05VSyncEndCurr).
211: append (" バックポーチ ").append (CRTC.crtR05VSyncEndCurr + 1).append ("-").append (CRTC.crtR06VBackEndCurr).
212: append (" 映像期間 ").append (CRTC.crtR06VBackEndCurr + 1).append ("-").append (CRTC.crtR07VDispEndCurr).
213: append (" フロントポーチ ").append (CRTC.crtR07VDispEndCurr + 1).append ("-").append (CRTC.crtR04VFrontEndCurr)
214: : sb.
215: append ("Blanking period 0-").append (CRTC.crtR05VSyncEndCurr).
216: append (" Back porch ").append (CRTC.crtR05VSyncEndCurr + 1).append ("-").append (CRTC.crtR06VBackEndCurr).
217: append (" Video period ").append (CRTC.crtR06VBackEndCurr + 1).append ("-").append (CRTC.crtR07VDispEndCurr).
218: append (" Front porch ").append (CRTC.crtR07VDispEndCurr + 1).append ("-").append (CRTC.crtR04VFrontEndCurr)
219: ).toString ();
220: }
221:
222:
223:
224:
225: public static void rbpUpdateFrame () {
226: rbpStatusLabel.setText (rbpMakeStatusText ());
227: rbpCurrentRasterTextField.setText (String.valueOf (CRTC.crtRasterNumber));
228: rbpIRQRasterTextField.setText (String.valueOf (CRTC.crtR09IRQRasterCurr));
229: rbpTimer = RBP_INTERVAL;
230: }
231:
232:
233:
234: public static void rbpSetBreakEnabled (boolean enabled) {
235: rbpBreakEnabled = enabled;
236: rbpActiveBreakRaster = rbpBreakEnabled ? rbpBreakRaster : -1;
237: if (CRTC.CRT_RASTER_HASH_ON) {
238: CRTC.crtUpdateRasterHash ();
239: }
240: }
241:
242:
243:
244: public static void rbpSetBreakRaster (int raster) {
245: rbpBreakRaster = raster;
246: rbpActiveBreakRaster = rbpBreakEnabled ? rbpBreakRaster : -1;
247: if (CRTC.CRT_RASTER_HASH_ON) {
248: CRTC.crtUpdateRasterHash ();
249: }
250: }
251:
252:
253:
254: public static void rbpSetIRQEnabled (boolean enabled) {
255: rbpIRQBreakEnabled = enabled;
256: }
257:
258:
259:
260: public static void rbpCheckIRQ () {
261: int irq = CRTC.crtRasterNumber == CRTC.crtR09IRQRasterCurr ? 0 : MC68901.MFP_GPIP_RINT_MASK;
262: if (irq != MC68901.mfpGpipRint) {
263: if (irq == 0) {
264: if (RBP_ON) {
265: if (rbpIRQBreakEnabled) {
266: rbpFire ();
267: }
268: }
269: MC68901.mfpRintFall ();
270: } else {
271: MC68901.mfpRintRise ();
272: }
273: }
274: }
275:
276:
277:
278:
279: public static void rbpFire () {
280: if (XEiJ.mpuTask == null) {
281: return;
282: }
283:
284: rbpCountValue++;
285:
286: if ((XEiJ.dbgVisibleMask & XEiJ.DBG_RBP_VISIBLE_MASK) != 0) {
287: rbpUpdateFrame ();
288: rbpCountModel.setValue (Integer.valueOf (rbpCountValue));
289: }
290:
291: if (rbpThresholdValue <= rbpCountValue) {
292:
293: if (CRTC.crtDirtyY0 >= 0) {
294: int dirtyY0 = CRTC.crtDirtyY0;
295: CRTC.crtUpdateScreen ();
296: CRTC.crtDirtyY0 = dirtyY0;
297: }
298:
299: if ((XEiJ.dbgVisibleMask & XEiJ.DBG_DDP_VISIBLE_MASK) == 0) {
300: DisassembleList.ddpOpen (-1, -1, false);
301: }
302:
303: XEiJ.mpuStop (null);
304: }
305: }
306:
307: public static void rbpTrace () {
308: System.out.println (new StringBuilder ().
309: append ("backEnd=").append (CRTC.crtR06VBackEndCurr).append (",").
310: append ("dispEnd=").append (CRTC.crtR07VDispEndCurr).append (",").
311: append ("frontEnd=").append (CRTC.crtR04VFrontEndCurr).append (",").
312: append ("IRQ=").append (CRTC.crtR09IRQRasterCurr).append (",").
313: append ("break=").append (rbpBreakRaster).append (",").
314: append ("raster=").append (CRTC.crtRasterNumber).toString ());
315: }
316:
317: }
318:
319:
320: