SRAM.java
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13: package xeij;
14:
15: import java.awt.event.*;
16: import java.io.*;
17: import java.util.*;
18: import javax.swing.*;
19:
20: public class SRAM {
21:
22: public static int smrSramSizeRequest;
23: public static int smrSramCurrentSize;
24:
25: public static String smrSramName;
26:
27: public static int smrBootDevice;
28: public static int smrROMBootHandle;
29: public static int smrRAMBootAddress;
30:
31: public static int smrRepeatDelay;
32: public static int smrRepeatInterval;
33: public static boolean smrWriteEnableOn;
34:
35:
36: public static boolean smrROMDBOn;
37:
38:
39: public static boolean smrModifyMemorySizeOn;
40:
41:
42: public static boolean smrSRAMBusErrorOn;
43:
44: public static JMenu smrRepeatDelayMenu;
45: public static JMenu smrRepeatIntervalMenu;
46: public static JMenuItem smrROMDBMenuItem;
47: public static JMenuItem smrModifyMemorySizeMenuItem;
48: public static JMenu smrMenu;
49: public static JMenu smrBootMenu;
50: public static JRadioButtonMenuItem smrSTDMenuItem;
51:
52:
53:
54: public static void smrInit () {
55:
56:
57: int sizeKB = Settings.sgsGetInt ("sramsize");
58: smrSramSizeRequest = (sizeKB == 16 ||
59: sizeKB == 32 ||
60: sizeKB == 64 ? sizeKB << 10 : 16 << 10);
61: smrSramCurrentSize = smrSramSizeRequest;
62: System.out.printf (Multilingual.mlnJapanese ?
63: "SRAM のサイズは %dKB です\n" :
64: "SRAM size is %dKB\n",
65: smrSramSizeRequest >> 10);
66:
67: boolean initialized = false;
68:
69:
70: smrSramName = "";
71: if (!initialized) {
72: smrSramName = Settings.sgsGetString ("sram");
73: if (smrSramName.length () != 0) {
74: byte[] array = XEiJ.rscGetFile (smrSramName, smrSramSizeRequest);
75: if (array != null) {
76: System.arraycopy (array, 0, MainMemory.mmrM8, 0x00ed0000, smrSramSizeRequest);
77: if (smrSramSizeRequest < 64 << 10) {
78: Arrays.fill (MainMemory.mmrM8, 0x00ed0000 + smrSramSizeRequest, 0x00ed0000 + (64 << 10), (byte) 0);
79: }
80: initialized = true;
81: }
82: }
83: }
84:
85:
86:
87: if (!initialized) {
88: byte[] array = Settings.sgsGetData ("sramdata");
89: if (array.length != 0) {
90: System.out.println (Multilingual.mlnJapanese ?
91: "SRAM のデータを復元します" :
92: "SRAM data is restored");
93: System.arraycopy (array, 0, MainMemory.mmrM8, 0x00ed0000, Math.min (array.length, smrSramSizeRequest));
94: if (array.length < smrSramSizeRequest) {
95: Arrays.fill (MainMemory.mmrM8, 0x00ed0000 + array.length, 0x00ed0000 + smrSramSizeRequest, (byte) 0);
96: }
97: if (smrSramSizeRequest < 64 << 10) {
98: Arrays.fill (MainMemory.mmrM8, 0x00ed0000 + smrSramSizeRequest, 0x00ed0000 + (64 << 10), (byte) 0);
99: }
100: initialized = true;
101: }
102: }
103:
104: if (!initialized) {
105: System.out.println (Multilingual.mlnJapanese ?
106: "SRAM をゼロクリアします" :
107: "SRAM is zero-cleared");
108: Arrays.fill (MainMemory.mmrM8, 0x00ed0000, 0x00ed0000 + (64 << 10), (byte) 0);
109: initialized = true;
110: }
111:
112:
113: int repeatDelay = Settings.sgsGetInt ("keydly");
114: smrRepeatDelay = -1 <= repeatDelay && repeatDelay <= 15 ? repeatDelay : -1;
115:
116:
117: int repeatInterval = Settings.sgsGetInt ("keyrep");
118: smrRepeatInterval = -1 <= repeatInterval && repeatInterval <= 15 ? repeatInterval : -1;
119:
120:
121: smrROMDBOn = Settings.sgsGetOnOff ("romdb");
122:
123:
124: smrModifyMemorySizeOn = Settings.sgsGetOnOff ("modifymemorysize");
125:
126:
127: smrSRAMBusErrorOn = Settings.sgsGetOnOff ("srambuserror");
128:
129:
130: smrParseBootDevice (Settings.sgsGetString ("boot"));
131:
132: }
133:
134:
135:
136: public static void smrTini () {
137:
138:
139: Settings.sgsPutInt ("sramsize", smrSramSizeRequest >> 10);
140:
141:
142: Settings.sgsPutString ("sram", smrSramName);
143:
144:
145:
146:
147: Settings.sgsPutData ("sramdata", MainMemory.mmrM8, 0x00ed0000, 64 << 10);
148:
149:
150: Settings.sgsPutInt ("keydly", smrRepeatDelay);
151:
152:
153: Settings.sgsPutInt ("keyrep", smrRepeatInterval);
154:
155:
156: Settings.sgsPutOnOff ("romdb", smrROMDBOn);
157:
158:
159: Settings.sgsPutOnOff ("modifymemorysize", smrModifyMemorySizeOn);
160:
161:
162: Settings.sgsPutOnOff ("srambuserror", smrSRAMBusErrorOn);
163:
164:
165: Settings.sgsPutString ("boot",
166: smrBootDevice == -1 ? "default" :
167: smrBootDevice == 0x0000 ? "std" :
168: (smrBootDevice & 0xf000) == 0x9000 ? "fd" + (smrBootDevice >> 8 & 3) :
169: (smrBootDevice & 0xf000) == 0x8000 ? "hd" + (smrBootDevice >> 8 & 15) :
170: smrBootDevice == 0xa000 ?
171: (smrROMBootHandle & ~(7 << 2)) == SPC.SPC_HANDLE_EX ? "sc" + (smrROMBootHandle >> 2 & 7) :
172: (smrROMBootHandle & ~(7 << 2)) == SPC.SPC_HANDLE_IN ? "sc" + (smrROMBootHandle >> 2 & 7) :
173: smrROMBootHandle == HFS.HFS_BOOT_HANDLE ? "hf" + HFS.hfsBootUnit :
174: String.format ("rom$%08X", smrROMBootHandle) :
175: smrBootDevice == 0xb000 ? String.format ("ram$%08X", smrRAMBootAddress) :
176: "");
177:
178: }
179:
180: public static void smrMakeMenu () {
181:
182:
183: ActionListener listener = new ActionListener () {
184: @Override public void actionPerformed (ActionEvent ae) {
185: Object source = ae.getSource ();
186: String command = ae.getActionCommand ();
187: switch (command) {
188:
189: case "ROM debugger start flag":
190: smrROMDBOn = ((JCheckBoxMenuItem) source).isSelected ();
191: break;
192:
193: case "Modify the memory size in SRAM":
194: smrModifyMemorySizeOn = ((JCheckBoxMenuItem) source).isSelected ();
195: break;
196:
197: case "Zero-clear":
198: smrClear ();
199: break;
200: case "Import":
201: smrLoad ();
202: break;
203: case "Export":
204: smrSave ();
205: break;
206: case "16KB":
207: smrSramSizeRequest = 16384;
208: break;
209: case "32KB":
210: smrSramSizeRequest = 32768;
211: break;
212: case "64KB":
213: smrSramSizeRequest = 65536;
214: break;
215: case "Bus error when writing to SRAM":
216: smrSRAMBusErrorOn = ((JCheckBoxMenuItem) source).isSelected ();
217: break;
218: default:
219: System.out.println ("unknown action command " + command);
220: }
221: }
222: };
223:
224:
225: ActionListener delayListener = new ActionListener () {
226: @Override public void actionPerformed (ActionEvent ae) {
227: String command = ae.getActionCommand ();
228: switch (command) {
229: case "Follow settings in SWITCH.X":
230: smrRepeatDelay = -1;
231: Keyboard.kbdSetRepeatDelay (MainMemory.mmrRbs (0x00ed003a));
232: break;
233: case (200 + 100 * 0) + "ms":
234: case (200 + 100 * 1) + "ms":
235: case (200 + 100 * 2) + "ms":
236: case (200 + 100 * 3) + "ms":
237: case (200 + 100 * 4) + "ms":
238: case (200 + 100 * 5) + "ms":
239: case (200 + 100 * 6) + "ms":
240: case (200 + 100 * 7) + "ms":
241: case (200 + 100 * 8) + "ms":
242: case (200 + 100 * 9) + "ms":
243: case (200 + 100 * 10) + "ms":
244: case (200 + 100 * 11) + "ms":
245: case (200 + 100 * 12) + "ms":
246: case (200 + 100 * 13) + "ms":
247: case (200 + 100 * 14) + "ms":
248: case (200 + 100 * 15) + "ms":
249: {
250: int ms = Integer.parseInt (command.substring (0, command.length () - 2));
251:
252:
253: smrRepeatDelay = (ms - 200) * 1311 >>> 17;
254: Keyboard.kbdSetRepeatDelay (smrRepeatDelay);
255: MainMemory.mmrWb (0x00ed003a, smrRepeatDelay);
256: }
257: break;
258: default:
259: System.out.println ("unknown action command " + command);
260: }
261: }
262: };
263: ButtonGroup delayGroup = new ButtonGroup ();
264: smrRepeatDelayMenu =
265: Multilingual.mlnText (
266: ComponentFactory.createMenu (
267: "Repeat delay",
268: Multilingual.mlnText (
269: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == -1, "Follow settings in SWITCH.X", delayListener),
270: "ja", "SWITCH.X の設定に従う"),
271: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 0, (200 + 100 * 0) + "ms", delayListener),
272: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 1, (200 + 100 * 1) + "ms", delayListener),
273: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 2, (200 + 100 * 2) + "ms", delayListener),
274: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 3, (200 + 100 * 3) + "ms", delayListener),
275: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 4, (200 + 100 * 4) + "ms", delayListener),
276: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 5, (200 + 100 * 5) + "ms", delayListener),
277: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 6, (200 + 100 * 6) + "ms", delayListener),
278: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 7, (200 + 100 * 7) + "ms", delayListener),
279: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 8, (200 + 100 * 8) + "ms", delayListener),
280: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 9, (200 + 100 * 9) + "ms", delayListener),
281: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 10, (200 + 100 * 10) + "ms", delayListener),
282: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 11, (200 + 100 * 11) + "ms", delayListener),
283: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 12, (200 + 100 * 12) + "ms", delayListener),
284: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 13, (200 + 100 * 13) + "ms", delayListener),
285: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 14, (200 + 100 * 14) + "ms", delayListener),
286: ComponentFactory.createRadioButtonMenuItem (delayGroup, smrRepeatDelay == 15, (200 + 100 * 15) + "ms", delayListener)
287: ),
288: "ja", "リピート開始");
289:
290:
291: ActionListener intervalListener = new ActionListener () {
292: @Override public void actionPerformed (ActionEvent ae) {
293: String command = ae.getActionCommand ();
294: switch (command) {
295: case "Follow settings in SWITCH.X":
296: smrRepeatInterval = -1;
297: Keyboard.kbdSetRepeatInterval (MainMemory.mmrRbs (0x00ed003b));
298: break;
299: case (30 + 5 * 0 * 0) + "ms":
300: case (30 + 5 * 1 * 1) + "ms":
301: case (30 + 5 * 2 * 2) + "ms":
302: case (30 + 5 * 3 * 3) + "ms":
303: case (30 + 5 * 4 * 4) + "ms":
304: case (30 + 5 * 5 * 5) + "ms":
305: case (30 + 5 * 6 * 6) + "ms":
306: case (30 + 5 * 7 * 7) + "ms":
307: case (30 + 5 * 8 * 8) + "ms":
308: case (30 + 5 * 9 * 9) + "ms":
309: case (30 + 5 * 10 * 10) + "ms":
310: case (30 + 5 * 11 * 11) + "ms":
311: case (30 + 5 * 12 * 12) + "ms":
312: case (30 + 5 * 13 * 13) + "ms":
313: case (30 + 5 * 14 * 14) + "ms":
314: case (30 + 5 * 15 * 15) + "ms":
315: {
316: int ms = Integer.parseInt (command.substring (0, command.length () - 2));
317:
318:
319: smrRepeatInterval = (int) Math.sqrt ((double) ((ms - 30) * 1639 >>> 13));
320: Keyboard.kbdSetRepeatInterval (smrRepeatInterval);
321: MainMemory.mmrWb (0x00ed003b, smrRepeatInterval);
322: }
323: break;
324: default:
325: System.out.println ("unknown action command " + command);
326: }
327: }
328: };
329: ButtonGroup intervalGroup = new ButtonGroup ();
330: smrRepeatIntervalMenu =
331: Multilingual.mlnText (
332: ComponentFactory.createMenu (
333: "Repeat interval",
334: Multilingual.mlnText (
335: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == -1, "Follow settings in SWITCH.X", intervalListener),
336: "ja", "SWITCH.X の設定に従う"),
337: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 0, (30 + 5 * 0 * 0) + "ms", intervalListener),
338: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 1, (30 + 5 * 1 * 1) + "ms", intervalListener),
339: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 2, (30 + 5 * 2 * 2) + "ms", intervalListener),
340: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 3, (30 + 5 * 3 * 3) + "ms", intervalListener),
341: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 4, (30 + 5 * 4 * 4) + "ms", intervalListener),
342: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 5, (30 + 5 * 5 * 5) + "ms", intervalListener),
343: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 6, (30 + 5 * 6 * 6) + "ms", intervalListener),
344: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 7, (30 + 5 * 7 * 7) + "ms", intervalListener),
345: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 8, (30 + 5 * 8 * 8) + "ms", intervalListener),
346: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 9, (30 + 5 * 9 * 9) + "ms", intervalListener),
347: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 10, (30 + 5 * 10 * 10) + "ms", intervalListener),
348: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 11, (30 + 5 * 11 * 11) + "ms", intervalListener),
349: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 12, (30 + 5 * 12 * 12) + "ms", intervalListener),
350: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 13, (30 + 5 * 13 * 13) + "ms", intervalListener),
351: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 14, (30 + 5 * 14 * 14) + "ms", intervalListener),
352: ComponentFactory.createRadioButtonMenuItem (intervalGroup, smrRepeatInterval == 15, (30 + 5 * 15 * 15) + "ms", intervalListener)
353: ),
354: "ja", "リピート間隔");
355:
356:
357: smrROMDBMenuItem =
358: Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (smrROMDBOn, "ROM debugger start flag", listener), "ja", "ROM デバッガ起動フラグ");
359:
360:
361: smrModifyMemorySizeMenuItem =
362: Multilingual.mlnText (
363: ComponentFactory.createCheckBoxMenuItem (smrModifyMemorySizeOn, "Modify the memory size in SRAM", listener),
364: "ja", "SRAM にあるメモリサイズを修正する");
365:
366:
367: ButtonGroup sizeGroup = new ButtonGroup ();
368: smrMenu =
369: ComponentFactory.createMenu (
370: "SRAM",
371: Multilingual.mlnText (
372: ComponentFactory.createMenuItem ("Zero-clear", listener),
373: "ja", "ゼロクリア"),
374: Multilingual.mlnText (
375: ComponentFactory.createMenuItem ("Import", listener),
376: "ja", "インポート"),
377: Multilingual.mlnText (
378: ComponentFactory.createMenuItem ("Export", listener),
379: "ja", "エクスポート"),
380: ComponentFactory.createHorizontalSeparator (),
381: Multilingual.mlnText (
382: ComponentFactory.createRadioButtonMenuItem (sizeGroup, smrSramSizeRequest >> 10 == 16, "16KB", listener),
383: "ja", "16KB"),
384: Multilingual.mlnText (
385: ComponentFactory.createRadioButtonMenuItem (sizeGroup, smrSramSizeRequest >> 10 == 32, "32KB", listener),
386: "ja", "32KB"),
387: Multilingual.mlnText (
388: ComponentFactory.createRadioButtonMenuItem (sizeGroup, smrSramSizeRequest >> 10 == 64, "64KB", listener),
389: "ja", "64KB"),
390: ComponentFactory.createHorizontalSeparator (),
391: Multilingual.mlnText (
392: ComponentFactory.createCheckBoxMenuItem (smrSRAMBusErrorOn, "Bus error when writing to SRAM", listener),
393: "ja", "SRAM への書き込み時のバスエラー")
394: );
395:
396:
397: ButtonGroup bootGroup = new ButtonGroup ();
398: ActionListener bootListener = new ActionListener () {
399: @Override public void actionPerformed (ActionEvent ae) {
400: String command = ae.getActionCommand ();
401: smrParseBootDevice (
402: command.startsWith ("FDD ") ? "fd" + command.substring (4) :
403: command.startsWith ("SASI ") ? "hd" + command.substring (5) :
404: command.startsWith ("SCSI ") ? "sc" + command.substring (5) :
405: command.startsWith ("HFS ") ? "hf" + command.substring (4) :
406: command.equals ("STD") ? "std" :
407: "default");
408: if (smrBootDevice != -1) {
409: XEiJ.mpuSavedBootDevice = -1;
410: XEiJ.mpuSavedROMBootHandle = -1;
411: }
412: }
413: };
414: JMenu bootMenuFDD = ComponentFactory.createMenu ("FDD");
415: for (int u = 0; u < FDC.FDC_MAX_UNITS; u++) {
416: bootMenuFDD.add (ComponentFactory.createRadioButtonMenuItem (
417: bootGroup, smrBootDevice == 0x9070 + (u << 8),
418: "FDD " + u, bootListener));
419: }
420: JMenu bootMenuSASI = ComponentFactory.createMenu ("SASI");
421: for (int u = 0; u < 16; u++) {
422: bootMenuSASI.add (ComponentFactory.createRadioButtonMenuItem (
423: bootGroup, smrBootDevice == 0x8000 + (u << 8),
424: "SASI " + u, bootListener));
425: }
426: JMenu bootMenuSCSI = ComponentFactory.createMenu ("SCSI");
427: for (int u = 0; u < 8; u++) {
428: bootMenuSCSI.add (ComponentFactory.createRadioButtonMenuItem (
429: bootGroup, smrBootDevice == 0xa000 && (smrROMBootHandle == SPC.SPC_HANDLE_EX + (u << 2) ||
430: smrROMBootHandle == SPC.SPC_HANDLE_IN + (u << 2)), "SCSI " + u, bootListener));
431: }
432: JMenu bootMenuHFS = ComponentFactory.createMenu ("HFS");
433: for (int u = 0; u < HFS.HFS_MAX_UNITS; u++) {
434: bootMenuHFS.add (ComponentFactory.createRadioButtonMenuItem (
435: bootGroup, smrBootDevice == 0xa000 && smrROMBootHandle == HFS.HFS_BOOT_HANDLE && HFS.hfsBootUnit == u,
436: "HFS " + u, bootListener));
437: }
438: smrBootMenu =
439: Multilingual.mlnText (
440: ComponentFactory.createMenu (
441: "Boot device",
442: Multilingual.mlnText (
443: ComponentFactory.createRadioButtonMenuItem (bootGroup, smrBootDevice == -1, "Follow settings in SWITCH.X", bootListener),
444: "ja", "SWITCH.X の設定に従う"),
445: smrSTDMenuItem = ComponentFactory.createRadioButtonMenuItem (bootGroup, smrBootDevice == 0x0000, "STD", bootListener),
446: bootMenuFDD,
447: bootMenuSASI,
448: bootMenuSCSI,
449: bootMenuHFS
450: ),
451: "ja", "起動デバイス");
452:
453: }
454:
455:
456:
457: public static void smrParseBootDevice (String boot) {
458: smrBootDevice = -1;
459: smrROMBootHandle = -1;
460: smrRAMBootAddress = -1;
461: boot = boot.toLowerCase ();
462: if (boot.equals ("std")) {
463: smrBootDevice = 0x0000;
464: } else if (boot.startsWith ("fd")) {
465: int u = XEiJ.fmtParseInt (boot, 2, 0, FDC.FDC_MAX_UNITS - 1, FDC.FDC_MAX_UNITS);
466: if (u < FDC.FDC_MAX_UNITS) {
467: smrBootDevice = 0x9070 + (u << 8);
468: }
469: } else if (boot.startsWith ("hd")) {
470: int u = XEiJ.fmtParseInt (boot, 2, 0, 15, 16);
471: if (u < 16) {
472: smrBootDevice = 0x8000 + (u << 8);
473: }
474: } else if (boot.startsWith ("sc")) {
475: int u = XEiJ.fmtParseInt (boot, 2, 0, 7, 8);
476: if (u < 8) {
477: smrBootDevice = 0xa000;
478: smrROMBootHandle = SPC.SPC_HANDLE_EX + ((u & 7) << 2);
479: }
480: } else if (boot.startsWith ("hf")) {
481: int u = XEiJ.fmtParseInt (boot, 2, 0, HFS.HFS_MAX_UNITS - 1, HFS.HFS_MAX_UNITS);
482: if (u < HFS.HFS_MAX_UNITS) {
483: HFS.hfsBootUnit = u;
484: smrBootDevice = 0xa000;
485: smrROMBootHandle = HFS.HFS_BOOT_HANDLE;
486: }
487: } else if (boot.startsWith ("rom$")) {
488: int handle = XEiJ.fmtParseIntRadix (boot, 3, 0, 0x00ffffff, 0x01000000, 16);
489: if (handle < 0x01000000) {
490: smrBootDevice = 0xa000;
491: smrROMBootHandle = handle;
492: }
493: } else if (boot.startsWith ("ram$")) {
494: int handle = XEiJ.fmtParseIntRadix (boot, 3, 0, 0x00ffffff, 0x01000000, 16);
495: if (handle < 0x01000000) {
496: smrBootDevice = 0xb000;
497: smrRAMBootAddress = handle;
498: }
499: }
500: }
501:
502:
503:
504:
505:
506:
507: public static void smrReset () {
508: smrWriteEnableOn = false;
509:
510:
511: {
512: smrSramCurrentSize = smrSramSizeRequest;
513: XEiJ.busSuper (MemoryMappedDevice.MMD_SMR, 0x00ed0000, 0x00ed0000 + smrSramSizeRequest);
514: if (smrSramSizeRequest < 65536) {
515: XEiJ.busSuper (MemoryMappedDevice.MMD_NUL, 0x00ed0000 + smrSramSizeRequest, 0x00ed0000 + 65536);
516: }
517: System.out.printf (Multilingual.mlnJapanese ?
518: "SRAM の容量は %dKB ($%08X-$%08X) です\n" :
519: "Capacity of SRAM is %dKB ($%08X-$%08X)\n",
520: smrSramCurrentSize >> 10, 0x00ed0000, 0x00ed0000 + smrSramCurrentSize - 1);
521: }
522:
523:
524:
525:
526:
527:
528:
529:
530:
531:
532:
533:
534:
535:
536:
537:
538:
539:
540:
541:
542:
543: if ((smrROMBootHandle & ~(7 << 2)) == SPC.SPC_HANDLE_IN && !SPC.spcSCSIINOn) {
544: if (SPC.spcSCSIEXOn) {
545: smrROMBootHandle = SPC.SPC_HANDLE_EX + (smrROMBootHandle & (7 << 2));
546:
547: } else {
548: smrROMBootHandle = 0x00e80400;
549: if (smrBootDevice == 0xa000) {
550: smrBootDevice = 0x0000;
551: smrSTDMenuItem.setSelected (true);
552: }
553: }
554: }
555: if ((smrROMBootHandle & ~(7 << 2)) == SPC.SPC_HANDLE_EX && !SPC.spcSCSIEXOn) {
556: if (SPC.spcSCSIINOn) {
557: smrROMBootHandle = SPC.SPC_HANDLE_IN + (smrROMBootHandle & (7 << 2));
558:
559: } else {
560: smrROMBootHandle = 0x00e80400;
561: if (smrBootDevice == 0xa000) {
562: smrBootDevice = 0x0000;
563: smrSTDMenuItem.setSelected (true);
564: }
565: }
566: }
567: if (smrROMBootHandle == HFS.HFS_BOOT_HANDLE &&
568: (!HFS.hfsUnitArray[HFS.hfsBootUnit].abuConnected ||
569: !HFS.hfsUnitArray[HFS.hfsBootUnit].abuInserted)) {
570: smrROMBootHandle = 0x00e80400;
571: if (smrBootDevice == 0xa000) {
572: smrBootDevice = 0x0000;
573: smrSTDMenuItem.setSelected (true);
574: }
575: }
576:
577: if ((XEiJ.mpuROMBootHandle & ~(7 << 2)) == SPC.SPC_HANDLE_IN && !SPC.spcSCSIINOn) {
578: if (SPC.spcSCSIEXOn) {
579: XEiJ.mpuROMBootHandle = SPC.SPC_HANDLE_EX + (XEiJ.mpuROMBootHandle & (7 << 2));
580:
581: } else {
582: XEiJ.mpuROMBootHandle = 0x00e80400;
583: if (XEiJ.mpuBootDevice == 0xa000) {
584: XEiJ.mpuBootDevice = 0x0000;
585: }
586: }
587: }
588: if ((XEiJ.mpuROMBootHandle & ~(7 << 2)) == SPC.SPC_HANDLE_EX && !SPC.spcSCSIEXOn) {
589: if (SPC.spcSCSIINOn) {
590: XEiJ.mpuROMBootHandle = SPC.SPC_HANDLE_IN + (XEiJ.mpuROMBootHandle & (7 << 2));
591:
592: } else {
593: XEiJ.mpuROMBootHandle = 0x00e80400;
594: if (XEiJ.mpuBootDevice == 0xa000) {
595: XEiJ.mpuBootDevice = 0x0000;
596: }
597: }
598: }
599: if (XEiJ.mpuROMBootHandle == HFS.HFS_BOOT_HANDLE &&
600: (!HFS.hfsUnitArray[HFS.hfsBootUnit].abuConnected ||
601: !HFS.hfsUnitArray[HFS.hfsBootUnit].abuInserted)) {
602: XEiJ.mpuROMBootHandle = 0x00e80400;
603: if (XEiJ.mpuBootDevice == 0xa000) {
604: XEiJ.mpuBootDevice = 0x0000;
605: }
606: }
607:
608: smrOverride ();
609:
610: }
611:
612:
613:
614:
615: public static void smrOverride () {
616: if (MainMemory.mmrRls (0x00ed0000) == 0x82773638 &&
617: MainMemory.mmrRls (0x00ed0004) == 0x30303057) {
618:
619: if (smrModifyMemorySizeOn) {
620: int memorySizeAddress = 0x00ed0008;
621: int memorySizeOld = MainMemory.mmrRls (memorySizeAddress);
622: int memorySizeNew = MainMemory.mmrMemorySizeCurrent;
623: if (memorySizeOld != memorySizeNew) {
624: MainMemory.mmrWl (memorySizeAddress, memorySizeNew);
625: System.out.printf (Multilingual.mlnJapanese ?
626: "SRAM にあるメモリサイズを %dMB から %dMB に変更しました\n" :
627: "Changed the memory size in SRAM from %dMB to %dMB\n",
628: memorySizeOld >> 20,
629: memorySizeNew >> 20);
630: }
631: }
632:
633: int romHandleAddress = 0x00ed000c;
634: int romHandleOld = MainMemory.mmrRls (romHandleAddress);
635: int romHandleNew = XEiJ.mpuROMBootHandle != -1 ? XEiJ.mpuROMBootHandle : smrROMBootHandle;
636: if (romHandleNew != -1 &&
637: romHandleOld != romHandleNew) {
638: MainMemory.mmrWl (romHandleAddress, romHandleNew);
639: System.out.printf (Multilingual.mlnJapanese ?
640: "SRAM にある ROM 起動ハンドルを $%08X から $%08X に変更しました\n" :
641: "Changed the ROM boot handle in SRAM from $%08X to $%08X\n",
642: romHandleOld,
643: romHandleNew);
644: }
645:
646: int ramAddressAddress = 0x00ed0010;
647: int ramAddressOld = MainMemory.mmrRls (ramAddressAddress);
648: int ramAddressNew = smrRAMBootAddress;
649: if (ramAddressNew != -1 &&
650: ramAddressOld != ramAddressNew) {
651: MainMemory.mmrWl (ramAddressAddress, ramAddressNew);
652: System.out.printf (Multilingual.mlnJapanese ?
653: "SRAM にある RAM 起動アドレスを $%08X から $%08X に変更しました\n" :
654: "Changed the RAM boot address in SRAM from $%08X to $%08X\n",
655: ramAddressOld,
656: ramAddressNew);
657: }
658:
659: int deviceAddress = 0x00ed0018;
660: int deviceOld = MainMemory.mmrRwz (deviceAddress);
661: int deviceNew = XEiJ.mpuBootDevice != -1 ? XEiJ.mpuBootDevice : smrBootDevice;
662: if (deviceNew != -1 &&
663: deviceOld != deviceNew) {
664: MainMemory.mmrWw (deviceAddress, deviceNew);
665: System.out.printf (Multilingual.mlnJapanese ?
666: "SRAM にある起動デバイスを %s から %s に変更しました\n" :
667: "Changed the boot device in SRAM from %s to %s\n",
668: smrBootDescription (romHandleOld, ramAddressOld, deviceOld),
669: smrBootDescription (romHandleNew, ramAddressNew, deviceNew));
670: }
671:
672: int repeatDelayAddress = 0x00ed003a;
673: int repeatDelayOld = MainMemory.mmrRbz (repeatDelayAddress);
674: int repeatDelayNew = smrRepeatDelay;
675: if (repeatDelayNew != -1 &&
676: repeatDelayOld != repeatDelayNew) {
677: MainMemory.mmrWb (repeatDelayAddress, repeatDelayNew);
678: System.out.printf (Multilingual.mlnJapanese ?
679: "SRAM にあるリピート開始を %dms から %dms に変更しました\n" :
680: "Changed the repeat delay in SRAM from %dms to %dms\n",
681: 200 + 100 * (repeatDelayOld & 15),
682: 200 + 100 * (repeatDelayNew & 15));
683: }
684:
685: int repeatIntervalAddress = 0x00ed003b;
686: int repeatIntervalOld = MainMemory.mmrRbz (repeatIntervalAddress);
687: int repeatIntervalNew = smrRepeatInterval;
688: if (repeatIntervalNew != -1 &&
689: repeatIntervalOld != repeatIntervalNew) {
690: MainMemory.mmrWb (repeatIntervalAddress, repeatIntervalNew);
691: System.out.printf (Multilingual.mlnJapanese ?
692: "SRAM にあるリピート間隔を %dms から %dms に変更しました\n" :
693: "Changed the repeat interval in SRAM from %dms to %dms\n",
694: 30 + 5 * (repeatDelayOld & 15),
695: 30 + 5 * (repeatDelayNew & 15));
696: }
697:
698: int romdbAddress = 0x00ed0058;
699: int romdbOld = MainMemory.mmrRbz (romdbAddress);
700: int romdbNew = ((XEiJ.currentModel.getIPLROM () == 130 &&
701: !(XEiJ.currentAccelerator == XEiJ.ACCELERATOR_060TURBO ||
702: XEiJ.currentAccelerator == XEiJ.ACCELERATOR_060TURBOPRO) &&
703: !ROM.romIPLROM16On &&
704: ROM.romROM30Data == null) ? 0x00 :
705: smrROMDBOn ? 0xff : 0x00);
706: if (romdbOld != romdbNew) {
707: MainMemory.mmrWb (romdbAddress, romdbNew);
708: if (romdbNew == 0x00) {
709: System.out.printf (Multilingual.mlnJapanese ?
710: "SRAM にある ROM デバッガ起動フラグを OFF にしました\n" :
711: "Turned off the ROM debugger startup flag in SRAM\n");
712: } else {
713: System.out.printf (Multilingual.mlnJapanese ?
714: "SRAM にある ROM デバッガ起動フラグを ON にしました\n" :
715: "Turned on the ROM debugger startup flag in SRAM\n");
716: }
717: }
718:
719: int hdMaxAddress = 0x00ed005a;
720: int hdMaxOld = MainMemory.mmrRbz (hdMaxAddress);
721: int sasiFlag = MainMemory.mmrRbz (0x00ed006f) == 'V' ? MainMemory.mmrRbz (0x00ed0071) : 0;
722: int hdMaxNew = SPC.spcSCSIINOn ? 2 * (32 - Integer.numberOfLeadingZeros (sasiFlag)) : HDC.hdcHDMax;
723: if (hdMaxOld != hdMaxNew) {
724: MainMemory.mmrWb (hdMaxAddress, hdMaxNew);
725: System.out.printf (Multilingual.mlnJapanese ?
726: "SRAM にある SASI ハードディスクの最大数を %d から %d に変更しました\n" :
727: "Changed the maximum number of SASI hard disks in SRAM from %d to %d\n",
728: hdMaxOld, hdMaxNew);
729: }
730: }
731:
732:
733:
734: }
735:
736:
737:
738:
739:
740:
741:
742:
743:
744:
745:
746: public static String smrBootDescription (int romHandle, int ramAddress, int device) {
747: switch (device & 0xf000) {
748: case 0x8000:
749: return "HD" + (device >> 8 & 15);
750: case 0x9000:
751: return "2HD" + (device >> 8 & 3);
752: case 0xa000:
753: return ((romHandle & ~(7 << 2)) == SPC.SPC_HANDLE_IN ? "SCSI" + ((romHandle >> 2) & 7) :
754: (romHandle & ~(7 << 2)) == SPC.SPC_HANDLE_EX ? "SCSI" + ((romHandle >> 2) & 7) :
755: "ROM$" + XEiJ.fmtHex6 (romHandle));
756: case 0xb000:
757: return "RAM$" + XEiJ.fmtHex6 (ramAddress);
758: default:
759: return "STD";
760: }
761: }
762:
763:
764:
765: public static void smrClear () {
766: XEiJ.pnlExitFullScreen (true);
767: if (JOptionPane.showConfirmDialog (
768: XEiJ.frmFrame,
769: Multilingual.mlnJapanese ? "SRAM をクリアしますか?" : "Do you want to clear SRAM?",
770: Multilingual.mlnJapanese ? "確認" : "Confirmation",
771: JOptionPane.YES_NO_OPTION,
772: JOptionPane.PLAIN_MESSAGE) == JOptionPane.YES_OPTION) {
773: Arrays.fill (MainMemory.mmrM8, 0x00ed0000, 0x00ed0000 + 65536, (byte) 0x00);
774: }
775: }
776:
777:
778:
779: public static void smrLoad () {
780: JFileChooser2 fileChooser = new JFileChooser2 ();
781: fileChooser.setFileFilter (new javax.swing.filechooser.FileFilter () {
782: @Override public boolean accept (File file) {
783: String name = file.getName ();
784: String upperName = name.toUpperCase ();
785: return (file.isDirectory () ||
786: (file.isFile () &&
787: upperName.startsWith ("SRAM")));
788: }
789: @Override public String getDescription () {
790: return (Multilingual.mlnJapanese ?
791: "SRAM データファイル (SRAM*.*)" :
792: "SRAM data files (SRAM*.*)");
793: }
794: });
795: if (fileChooser.showOpenDialog (null) == JFileChooser.APPROVE_OPTION) {
796: File file = fileChooser.getSelectedFile ();
797: String name = file.getPath ();
798: if (!smrLoadData (name)) {
799: XEiJ.pnlExitFullScreen (true);
800: JOptionPane.showMessageDialog (null,
801: Multilingual.mlnJapanese ?
802: name + " のサイズが違います" :
803: name + " has wrong size");
804: return;
805: }
806: }
807: }
808:
809:
810:
811: public static boolean smrLoadData (String name) {
812: byte[] array = XEiJ.rscGetFile (name, smrSramSizeRequest);
813: if (array != null) {
814: System.arraycopy (array, 0, MainMemory.mmrM8, 0x00ed0000, smrSramSizeRequest);
815: if (smrSramSizeRequest < 65536) {
816: Arrays.fill (MainMemory.mmrM8, 0x00ed0000 + smrSramSizeRequest, 0x00ed0000 + 65536, (byte) 0x00);
817: }
818: return true;
819: }
820: return false;
821: }
822:
823:
824:
825: public static void smrSave () {
826: JFileChooser2 fileChooser = new JFileChooser2 ();
827: fileChooser.setFileFilter (new javax.swing.filechooser.FileFilter () {
828: @Override public boolean accept (File file) {
829: String name = file.getName ();
830: String upperName = name.toUpperCase ();
831: return (file.isDirectory () ||
832: (file.isFile () &&
833: upperName.startsWith ("SRAM")));
834: }
835: @Override public String getDescription () {
836: return (Multilingual.mlnJapanese ?
837: "SRAM データファイル (SRAM*.*)" :
838: "SRAM data files (SRAM*.*)");
839: }
840: });
841: if (fileChooser.showSaveDialog (null) == JFileChooser.APPROVE_OPTION) {
842: XEiJ.rscPutFile (fileChooser.getSelectedFile ().getPath (), MainMemory.mmrM8, 0x00ed0000, smrSramSizeRequest);
843: }
844: }
845:
846: }