HDC.java
     1: //========================================================================================
     2: //  HDC.java
     3: //    en:SASI hard disk controller
     4: //    ja:SASIハードディスクコントローラ
     5: //  Copyright (C) 2003-2023 Makoto Kamada
     6: //
     7: //  This file is part of the XEiJ (X68000 Emulator in Java).
     8: //  You can use, modify and redistribute the XEiJ if the conditions are met.
     9: //  Read the XEiJ License for more details.
    10: //  https://stdkmd.net/xeij/
    11: //========================================================================================
    12: 
    13: //----------------------------------------------------------------------------------------
    14: //  0x00e96020  HDC SASI HDコントローラ
    15: //  0x00e96020  SPC 内蔵SCSIプロトコルコントローラ
    16: //----------------------------------------------------------------------------------------
    17: 
    18: package xeij;
    19: 
    20: import java.awt.event.*;  //ActionEvent,ActionListener,ComponentAdapter,ComponentEvent,ComponentListener,FocusAdapter,FocusEvent,FocusListener,InputEvent,KeyAdapter,KeyEvent,KeyListener,MouseAdapter,MouseEvent,MouseListener,MouseMotionAdapter,MouseWheelEvent,WindowAdapter,WindowEvent,WindowListener,WindowStateListener
    21: import java.io.*;  //BufferedInputStream,BufferedOutputStream,BufferedReader,BufferedWriter,File,FileInputStream,FileNotFoundException,FileReader,InputStream,InputStreamReader,IOException,OutputStreamWriter,RandomAccessFile
    22: import java.lang.*;  //Boolean,Character,Class,Comparable,Double,Exception,Float,IllegalArgumentException,Integer,Long,Math,Number,Object,Runnable,SecurityException,String,StringBuilder,System
    23: import java.util.*;  //ArrayList,Arrays,Calendar,GregorianCalendar,HashMap,Map,Map.Entry,Timer,TimerTask,TreeMap
    24: import java.util.zip.*;  //CRC32,Deflater,GZIPInputStream,GZIPOutputStream,ZipEntry,ZipInputStream
    25: import javax.swing.*;  //AbstractSpinnerModel,Box,ButtonGroup,DefaultListModel,ImageIcon,JButton,JCheckBox,JCheckBoxMenuItem,JDialog,JFileChooser,JFrame,JLabel,JList,JMenu,JMenuBar,JMenuItem,JPanel,JRadioButton,JScrollPane,JSpinner,JTextArea,JTextField,JTextPane,JViewport,ScrollPaneConstants,SpinnerListModel,SpinnerNumberModel,SwingConstants,SwingUtilities,UIManager,UIDefaults,UnsupportedLookAndFeelException
    26: 
    27: public class HDC {
    28: 
    29:   public static final boolean HDC_DEBUG_TRACE = false;
    30:   public static final boolean HDC_DEBUG_COMMAND = false;
    31:   public static final boolean HDC_DEBUG_UNIMPLEMENTED_COMMAND = true;
    32: 
    33:   public static final int HDC_BASE           = 0x00e96000;
    34:   public static final int HDC_DATA_PORT      = 0x00e96001;  //データポート
    35:   public static final int HDC_STATUS_PORT    = 0x00e96003;  //ステータスポート
    36:   public static final int HDC_RESET_PORT     = 0x00e96005;  //リセットポート
    37:   public static final int HDC_SELECTION_PORT = 0x00e96007;  //セレクションポート
    38: 
    39:   public static final int HDC_STATUS_MESSAGE = 0b10000;
    40:   public static final int HDC_STATUS_C_D     = 0b01000;
    41:   public static final int HDC_STATUS_COMMAND = 0b01000;
    42:   public static final int HDC_STATUS_DATA    = 0b00000;
    43:   public static final int HDC_STATUS_I_O     = 0b00100;
    44:   public static final int HDC_STATUS_OUTPUT  = 0b00000;
    45:   public static final int HDC_STATUS_INPUT   = 0b00100;
    46:   public static final int HDC_STATUS_BUSY    = 0b00010;
    47:   public static final int HDC_STATUS_FREE    = 0b00000;
    48:   public static final int HDC_STATUS_REQUEST = 0b00001;
    49: 
    50:   public static final String[] HDC_COMMAND_NAME = (
    51:     "TestDriveReady"                + "," +  //0x00
    52:     "Recalibrate"                   + "," +  //0x01
    53:     ""                              + "," +  //0x02
    54:     "RequestSenseStatus"            + "," +  //0x03
    55:     "FormatDrive"                   + "," +  //0x04
    56:     "CheckTrackFormat"              + "," +  //0x05
    57:     "FormatBlock"                   + "," +  //0x06
    58:     "BadTrackFormat"                + "," +  //0x07
    59:     "Read"                          + "," +  //0x08
    60:     ""                              + "," +  //0x09
    61:     "Write"                         + "," +  //0x0a
    62:     "Seek"                          + "," +  //0x0b
    63:     "InitializeDriveCharacteristic" + "," +  //0x0c
    64:     "LastCorrectedBurstLength"      + "," +  //0x0d
    65:     "AssignTrack"                   + "," +  //0x0e
    66:     "WriteSectorBuffer"             + "," +  //0x0f
    67:     "ReadSectorBuffer"              + "," +  //0x10
    68:     //123456789abcdef0123456789abcdef
    69:     ",,,,,,,,,,,,,,,"                     +  //0x11..0x1f
    70:     ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"    +  //0x20..0x3f
    71:     ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"    +  //0x40..0x5f
    72:     ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"    +  //0x60..0x7f
    73:     ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"    +  //0x80..0x9f
    74:     ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"    +  //0xa0..0xbf
    75:     ",,"                                  +  //0xc0..0xc1
    76:     "AssignDrive"                   + "," +  //0xc2
    77:     ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,"       +  //0xc3..0xdf
    78:     ",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,"        //0xe0..0xff
    79:     ).split (",", 256);  //splitで末尾の空要素が削除されるのでHDC_COMMAND_NAME[cmd]が存在しないとき""とみなす処理が必要
    80: 
    81: 
    82:   //メニュー
    83:   public static JMenu hdcMenu;
    84: 
    85:   //ファイルフィルタ
    86:   public static javax.swing.filechooser.FileFilter hdcFileFilter;  //java.io.FileFilterと紛らわしい
    87: 
    88:   //開くダイアログ
    89:   public static OpenDialog hdcOpenDialog;  //開くダイアログ。null=作る前
    90:   public static int hdcOpenUnit;  //開くユニットの番号
    91:   public static ArrayList<File[]> hdcOpenHistory;  //作る前に追加されたヒストリ
    92: 
    93:   //フォーマットダイアログ
    94:   public static JDialog hdcFormatDialog;  //ダイアログ
    95:   public static JFileChooser2 hdcFormatFileChooser;  //ファイルチューザー
    96:   public static HDMedia hdcFormatMedia;  //フォーマットするメディアの種類
    97:   public static boolean hdcFormatCopySystemFiles;  //true=システムファイルを転送する
    98: 
    99:   //ユニット
   100:   public static final HDUnit[] hdcUnitArray = new HDUnit[16];  //ユニットの配列
   101:   public static int hdcHDMax;  //現在挿入されているユニットのユニット番号の最大値+1。0~16。[0x00ed005a].b=SPC.spcSCSIINOn?0:hdcHDMax
   102: 
   103:   public static int hdcSelectedID;  //セレクションフェーズで選択されたID。0~7=有効,-1=選択されていない
   104:   public static int hdcSelectedLUN;  //コマンドフェーズで選択されたLUN。0~1=有効,-1=選択されていない
   105:   public static HDUnit hdcTargetUnit;  //バスを占有しているターゲットのユニット。hdcUnitArray[hdcSelectedID<<1|hdcSelectedLUN],null=フリー
   106:   public static int hdcBusStatus;  //バスステータス
   107: 
   108:   public static byte[] hdcReadHandle;  //転送(ターゲット→イニシエータ)の対象の配列。hdcStatusBuffer,hdcMessageBuffer,hdcSenseBuffer,hduImage
   109:   public static byte[] hdcWriteHandle;  //転送(イニシエータ→ターゲット)の対象の配列。hdcCommandBuffer,hduImage
   110:   public static int hdcIndex;  //次に転送する位置
   111:   public static int hdcLimit;  //転送を終了する位置
   112:   public static final byte[] hdcCommandBuffer = new byte[6];  //コマンドバッファ
   113:   public static final byte[] hdcStatusBuffer = new byte[1];  //ステータスバッファ
   114:   public static final byte[] hdcMessageBuffer = new byte[1];  //メッセージバッファ
   115:   public static final byte[] hdcSenseBuffer = new byte[4];  //センスバッファ
   116:   public static final byte[] hdcAssignDriveBuffer = new byte[10];  //ドライブパラメータバッファ
   117: 
   118:   public static int hdcLastFormatBlodkEnd;  //最後に実行したFormatBlockコマンドの終了位置(バイト)。-1=最後に実行したコマンドはFormatBlockではない
   119: 
   120:   public static JCheckBoxMenuItem hdcSASIMenuItem;
   121: 
   122:   //hdcInit ()
   123:   //  HDCを初期化する
   124:   public static void hdcInit () {
   125: 
   126:     //ファイルフィルタ
   127:     //  SASIハードディスクのイメージファイルかどうかを調べる
   128:     //  ファイルチューザーとドロップターゲットで使う
   129:     hdcFileFilter = new javax.swing.filechooser.FileFilter () {  //java.io.FileFilterと紛らわしい
   130:       @Override public boolean accept (File file) {
   131:         if (file.isDirectory ()) {  //ディレクトリがある
   132:           return true;
   133:         }
   134:         if (!file.isFile ()) {  //ファイルがない
   135:           return false;
   136:         }
   137:         String path = file.getPath ();
   138:         if (hdcIsInserted (path)) {  //既に挿入されている
   139:           return false;
   140:         }
   141:         long longLength = file.length ();
   142:         for (HDMedia media : HDMedia.HDM_ARRAY) {
   143:           if (media.humDiskEndByte == longLength) {  //ファイルサイズが一致
   144:             return true;
   145:           }
   146:         }
   147:         return false;
   148:       }
   149:       @Override public String getDescription () {
   150:         return (Multilingual.mlnJapanese ?
   151:                 "SASI ハードディスクのイメージファイル (*.HDF)" :
   152:                 "SASI hard disk image files (*.HDF)");
   153:       }
   154:     };
   155: 
   156:     //開くダイアログ
   157:     hdcOpenDialog = null;
   158:     hdcOpenUnit = 0;
   159:     hdcOpenHistory = new ArrayList<File[]> ();
   160:     for (int i = JFileChooser2.MAXIMUM_HISTORY_COUNT - 1; 0 <= i; i--) {
   161:       hdcAddHistory (JFileChooser2.pathsToFiles (Settings.sgsGetString ("sahistory" + i)));
   162:     }
   163: 
   164:     //ユニット
   165:     //  ダイアログが書き込み禁止でもパラメータは:Rを付けなければ書き込み禁止にしない
   166:     //hdcUnitArray = new HDUnit[16];
   167:     hdcHDMax = 0;
   168:     for (int u = 0; u < 16; u++) {
   169:       HDUnit unit = hdcUnitArray[u] = new HDUnit (u);
   170:       if (u == 0) {
   171:         unit.connect (false);  //ID 0は内蔵ドライブとするため切り離せない
   172:       }
   173:       String path = Settings.sgsGetString ("sa" + u);
   174:       String hdN = Settings.sgsGetString ("hd" + u);  //SASIまたはSCSI
   175:       if (!(hdN.equals ("") || hdN.equals ("none"))) {  //hdNが指定されている
   176:         String hdNWithoutR = hdN.endsWith (":R") || hdN.endsWith (":r") ? hdN.substring (0, hdN.length () - 2) : hdN;  //":R"を取り除く
   177:         int dotIndex = hdNWithoutR.lastIndexOf ('.');
   178:         String ext = dotIndex < 0 ? "" : hdNWithoutR.substring (dotIndex + 1);  //最後の'.'の後の文字列、なければ""
   179:         if (ext.equalsIgnoreCase ("HDF") ||
   180:             HDMedia.hdmPathToMedia (hdNWithoutR, null) != null) {  //hdNはSASI HDらしい
   181:           path = hdN;
   182:           Settings.sgsPutString ("hd" + u, "");  //消しておく
   183:         }
   184:       }
   185:       boolean userWriteProtect = false;
   186:       if (path.toUpperCase ().endsWith (":R")) {  //書き込み禁止モードで開く
   187:         path = path.substring (0, path.length () - 2);
   188:         userWriteProtect = true;
   189:       }
   190:       boolean hostWriteProtect = !new File (path).canWrite ();
   191:       if (path.length () != 0) {
   192:         unit.connect (true);  //接続されていなければ接続する
   193:         if (unit.insert (path,
   194:                          userWriteProtect || hostWriteProtect)) {  //挿入できた
   195:           hdcAddHistory (new File (path).getAbsoluteFile ());
   196:         }
   197:       }
   198:     }
   199: 
   200:     //フォーマットダイアログ
   201:     hdcFormatDialog = null;
   202:     hdcFormatFileChooser = null;
   203:     hdcFormatMedia = HDMedia.HDM_40MB;
   204:     hdcFormatCopySystemFiles = true;
   205: 
   206:     hdcSelectedID = -1;
   207:     hdcSelectedLUN = -1;
   208:     hdcTargetUnit = null;
   209:     hdcBusStatus = HDC_STATUS_FREE;
   210: 
   211:     hdcReadHandle = null;
   212:     hdcWriteHandle = null;
   213:     hdcIndex = 0;
   214:     hdcLimit = 0;
   215:     //hdcCommandBuffer = new byte[6];
   216:     //hdcStatusBuffer = new byte[1];
   217:     //hdcMessageBuffer = new byte[1];
   218:     //hdcSenseBuffer = new byte[4];
   219:     //hdcAssignDriveBuffer = new byte[10];
   220: 
   221:     hdcLastFormatBlodkEnd = -1;
   222: 
   223:   }  //hdcInit()
   224: 
   225:   //hdcTini ()
   226:   //  後始末
   227:   public static void hdcTini () {
   228: 
   229:     //イメージファイルに書き出す
   230:     for (HDUnit unit : hdcUnitArray) {
   231:       unit.hduTini ();
   232:     }
   233: 
   234:     //開くダイアログ
   235:     //  開くダイアログを作らなかったときはパラメータを更新しない
   236:     if (hdcOpenDialog != null) {
   237:       Settings.sgsPutOnOff ("sareadonly", hdcOpenDialog.getReadOnly ());
   238:       Settings.sgsPutOnOff ("saappreboot", hdcOpenDialog.getReboot ());
   239:       ArrayList<String> pathsList = hdcOpenDialog.getHistory ();
   240:       int n = pathsList.size ();
   241:       for (int i = 0; i < n; i++) {
   242:         Settings.sgsPutString ("sahistory" + i, pathsList.get (i));
   243:       }
   244:       for (int i = n; i < 16; i++) {
   245:         Settings.sgsPutString ("sahistory" + i, "");
   246:       }
   247:     }
   248: 
   249:     //ユニット
   250:     for (int u = 0; u < 16; u++) {
   251:       AbstractUnit unit = hdcUnitArray[u];
   252:       Settings.sgsPutString (
   253:         "sa" + u,
   254:         unit.abuConnected && unit.abuInserted ?
   255:         unit.abuWriteProtected ? unit.abuPath + ":R" : unit.abuPath :
   256:         "");
   257:     }
   258: 
   259:   }  //hdcTini()
   260: 
   261:   public static void hdcMakeMenu () {
   262: 
   263:     //アクションリスナー
   264:     ActionListener listener = new ActionListener () {
   265:       @Override public void actionPerformed (ActionEvent ae) {
   266:         Object source = ae.getSource ();
   267:         String command = ae.getActionCommand ();
   268:         switch (command) {
   269:         case "Create new SASI hard disk image files":  //SASIハードディスクのイメージファイルの新規作成
   270:           hdcOpenFormatDialog ();
   271:           break;
   272:         }
   273:       }
   274:     };
   275: 
   276:     //SASIメニュー
   277:     hdcMenu = ComponentFactory.createMenu ("SASI");  //横に長いとサブメニューを開きにくいので短くする
   278:     ComponentFactory.addComponents (
   279:       hdcMenu,
   280:       ComponentFactory.createHorizontalBox (
   281:         Multilingual.mlnText (
   282:           ComponentFactory.createLabel ("SASI hard disk"),
   283:           "ja", "SASI ハードディスク")),
   284:       ComponentFactory.createHorizontalSeparator ()
   285:       );
   286:     for (int u = 0; u < 16; u++) {
   287:       hdcMenu.add (hdcUnitArray[u].getMenuBox ());
   288:     }
   289:     ComponentFactory.addComponents (
   290:       hdcMenu,
   291:       ComponentFactory.createHorizontalSeparator (),
   292:       hdcSASIMenuItem = ComponentFactory.setEnabled (
   293:         Multilingual.mlnText (ComponentFactory.createCheckBoxMenuItem (!XEiJ.currentModel.isSCSI (), "Built-in SASI port", listener), "ja", "内蔵 SASI ポート"),
   294:         false),  //機種の指定で内蔵SASIと内蔵SCSIを切り替えるので操作できないことにする
   295:       ComponentFactory.createHorizontalSeparator (),
   296:       Multilingual.mlnText (ComponentFactory.createMenuItem ("Create new SASI hard disk image files", listener),
   297:                             "ja", "SASI ハードディスクのイメージファイルの新規作成")
   298:       );
   299: 
   300:   }
   301: 
   302:   //inserted = hdcIsInserted (path)
   303:   //  パスで指定したファイルが既に挿入されているか調べる
   304:   public static boolean hdcIsInserted (String path) {
   305:     for (HDUnit unit : hdcUnitArray) {
   306:       if (unit != null &&
   307:           unit.abuConnected &&  //接続されている
   308:           unit.abuInserted &&  //挿入されている
   309:           unit.abuPath.equals (path)) {  //パスが一致している
   310:         return true;  //既に挿入されている
   311:       }
   312:     }
   313:     return false;  //まだ挿入されていない
   314:   }  //hdcIsInserted(String)
   315: 
   316:   static class OpenDialog extends AbstractOpenDialog {
   317:     public OpenDialog () {
   318:       super (XEiJ.frmFrame,
   319:              "Open SASI hard disk image files",
   320:              "SASI ハードディスクのイメージファイルを開く",
   321:              false,  //ファイル
   322:              hdcFileFilter);
   323:     }
   324:     @Override public void openFiles (File[] files, boolean reboot) {
   325:       hdcOpenFiles (files, reboot);
   326:     }
   327:   }  //class OpenDialog
   328: 
   329:   //hdcOpenFiles (list, reset)
   330:   //  開くダイアログで選択されたファイルを開く
   331:   public static void hdcOpenFiles (File[] list, boolean reset) {
   332:     boolean success = true;
   333:     for (int u = hdcOpenUnit, k = 0; k < list.length; ) {
   334:       if (16 <= u) {  //ユニットが足りない
   335:         success = false;  //失敗
   336:         break;
   337:       }
   338:       HDUnit unit = hdcUnitArray[u];  //ユニット
   339:       if (!unit.abuConnected) {  //接続されていない
   340:         u++;
   341:         continue;
   342:       }
   343:       File file = list[k++];  //イメージファイル
   344:       if (!file.isFile ()) {  //イメージファイルが存在しない
   345:         success = false;  //失敗
   346:         continue;
   347:       }
   348:       if (!unit.insert (file.getPath (),
   349:                         hdcOpenDialog.getReadOnly () || !file.canWrite ())) {  //挿入できない
   350:         success = false;  //失敗
   351:         continue;
   352:       }
   353:       u++;
   354:     }
   355:     if (success) {  //すべて挿入できた
   356:       hdcAddHistory (list);  //ヒストリに追加する
   357:       if (reset) {  //ここから再起動
   358:         XEiJ.mpuReset (0x8000 | hdcOpenUnit << 8, -1);
   359:       }
   360:     }
   361:   }  //hdcOpenFiles(File[],boolean)
   362: 
   363:   //hdcMakeFormatDialog ()
   364:   //  フォーマットダイアログを作る
   365:   //  コマンドラインのみ
   366:   public static void hdcMakeFormatDialog () {
   367: 
   368:     //アクションリスナー
   369:     ActionListener listener = new ActionListener () {
   370:       @Override public void actionPerformed (ActionEvent ae) {
   371:         switch (ae.getActionCommand ()) {
   372:         case JFileChooser.APPROVE_SELECTION:
   373:         case "Start formatting":  //フォーマットを開始する
   374:           {
   375:             File[] list = hdcFormatFileChooser.getSelectedFiles ();
   376:             if (list.length > 0) {
   377:               hdcFormatDialog.setVisible (false);
   378:               if (!hdcFormatFiles (list)) {
   379:                 //!!! 失敗
   380:               }
   381:             }
   382:           }
   383:           break;
   384:         case JFileChooser.CANCEL_SELECTION:
   385:         case "Cancel":  //キャンセル
   386:           hdcFormatDialog.setVisible (false);
   387:           break;
   388:         case "10MB":
   389:           hdcFormatMedia = HDMedia.HDM_10MB;
   390:           break;
   391:         case "20MB":
   392:           hdcFormatMedia = HDMedia.HDM_20MB;
   393:           break;
   394:         case "40MB":
   395:           hdcFormatMedia = HDMedia.HDM_40MB;
   396:           break;
   397:         case "Copy system files":  //システムファイルを転送する
   398:           hdcFormatCopySystemFiles = ((JCheckBox) ae.getSource ()).isSelected ();
   399:           break;
   400:         }
   401:       }
   402:     };
   403: 
   404:     //ファイルチューザー
   405:     hdcMakeFormatFileChooser ();
   406:     hdcFormatFileChooser.setFileFilter (hdcFileFilter);
   407:     hdcFormatFileChooser.addActionListener (listener);
   408: 
   409:     //ダイアログ
   410:     ButtonGroup mediaGroup = new ButtonGroup ();
   411:     hdcFormatDialog = Multilingual.mlnTitle (
   412:       ComponentFactory.createModalDialog (
   413:         XEiJ.frmFrame,
   414:         "Create new SASI hard disk image files",
   415:         ComponentFactory.createBorderPanel (
   416:           0, 0,
   417:           ComponentFactory.createVerticalBox (
   418:             hdcFormatFileChooser,
   419:             ComponentFactory.createHorizontalBox (
   420:               Box.createHorizontalStrut (12),
   421:               Box.createHorizontalGlue (),
   422:               ComponentFactory.createRadioButtonMenuItem (mediaGroup, hdcFormatMedia == HDMedia.HDM_10MB,  "10MB", listener),
   423:               ComponentFactory.createRadioButtonMenuItem (mediaGroup, hdcFormatMedia == HDMedia.HDM_20MB,  "20MB", listener),
   424:               ComponentFactory.createRadioButtonMenuItem (mediaGroup, hdcFormatMedia == HDMedia.HDM_40MB,  "40MB", listener),
   425:               Box.createHorizontalGlue (),
   426:               Box.createHorizontalStrut (12)
   427:               ),
   428:             Box.createVerticalStrut (12),
   429:             ComponentFactory.createHorizontalBox (
   430:               Box.createHorizontalStrut (12),
   431:               Box.createHorizontalGlue (),
   432:               Multilingual.mlnText (ComponentFactory.createCheckBox (hdcFormatCopySystemFiles, "Copy system files", listener), "ja", "システムファイルを転送する"),
   433:               Box.createHorizontalGlue (),
   434:               Box.createHorizontalStrut (12),
   435:               Multilingual.mlnText (ComponentFactory.createButton ("Start formatting", KeyEvent.VK_F, listener), "ja", "フォーマットを開始する"),
   436:               Box.createHorizontalStrut (12),
   437:               Multilingual.mlnText (ComponentFactory.createButton ("Cancel", KeyEvent.VK_C, listener), "ja", "キャンセル"),
   438:               Box.createHorizontalStrut (12)
   439:               ),
   440:             Box.createVerticalStrut (12)
   441:             )
   442:           )
   443:         ),
   444:       "ja", "SASI ハードディスクのイメージファイルの新規作成");
   445: 
   446:   }  //hdcMakeFormatDialog()
   447: 
   448:   //hdcMakeFormatFileChooser ()
   449:   //  フォーマットファイルチューザーを作る
   450:   public static void hdcMakeFormatFileChooser () {
   451:     if (hdcFormatFileChooser == null) {
   452:       hdcFormatFileChooser = new JFileChooser2 ();
   453:       //hdcFormatFileChooser.setMultiSelectionEnabled (true);  //複数選択可能
   454:       hdcFormatFileChooser.setControlButtonsAreShown (false);  //デフォルトのボタンを消す
   455:     }
   456:   }
   457: 
   458:   //hdcOpenFormatDialog ()
   459:   //  フォーマットダイアログを開く
   460:   public static void hdcOpenFormatDialog () {
   461:     if (hdcFormatDialog == null) {
   462:       hdcMakeFormatDialog ();
   463:     }
   464:     hdcFormatDialog.setVisible (true);
   465:   }  //hdcOpenFormatDialog()
   466: 
   467:   //success = hdcFormatFiles (list)
   468:   //  SASIディスクをフォーマットする
   469:   //  コマンドラインのみ
   470:   public static boolean hdcFormatFiles (File[] list) {
   471:     boolean success = true;
   472:   format:
   473:     {
   474:       //SASIディスクのフォーマットデータを作る
   475:       byte[] bb = new byte[(int) hdcFormatMedia.humDiskEndByte];  //高々40MBなので丸ごと確保する
   476:       if (!hdcFormatMedia.hdmMakeFormatData (bb, hdcFormatCopySystemFiles)) {
   477:         success = false;  //失敗
   478:         break format;
   479:       }
   480:       //書き出す
   481:       int u = 0;
   482:       for (File file : list) {
   483:         String path = file.getPath ();
   484:         if (true) {
   485:           if (!path.toUpperCase ().endsWith (".HDF")) {  //適切な拡張子が指定されていない
   486:             path += path.endsWith (".") ? "hdf" : ".hdf";  //拡張子を付ける
   487:             file = new File (path);
   488:           }
   489:         }
   490:         if (hdcIsInserted (path)) {  //他のユニットに挿入されている
   491:           success = false;  //失敗
   492:           break format;
   493:         }
   494:         if (!XEiJ.rscPutFile (path, bb, 0, bb.length)) {  //書き出せない
   495:           success = false;  //失敗
   496:           break format;
   497:         }
   498:         //空いているユニットがあれば挿入する
   499:         while (u < 16) {
   500:           HDUnit unit = hdcUnitArray[u++];  //ユニット
   501:           if (unit.abuConnected &&  //接続されていて
   502:               !unit.abuInserted &&  //空いていて
   503:               unit.insert (path,
   504:                            false)) {  //挿入できた
   505:             //フォーマットしたディスクの書き込みを禁止しても意味がないのでここでは書き込みを禁止しない
   506:             break;
   507:           }
   508:         }
   509:       }
   510:     }  //format
   511:     if (success) {  //すべてフォーマットできた
   512:       hdcAddHistory (list);  //ヒストリに追加する
   513:     }
   514:     return success;
   515:   }  //hdcFormatFiles(File[])
   516: 
   517: 
   518:   //hdcAddHistory (file)
   519:   //  ファイルをヒストリに追加する
   520:   public static void hdcAddHistory (File file) {
   521:     hdcAddHistory (new File[] { file });
   522:   }
   523: 
   524:   //hdcAddHistory (files)
   525:   //  複数のファイルをヒストリに追加する
   526:   public static void hdcAddHistory (File[] files) {
   527:     if (hdcOpenDialog == null) {
   528:       hdcOpenHistory.add (files);
   529:     } else {
   530:       hdcOpenDialog.addHistory (files);
   531:     }
   532:     hdcMakeFormatFileChooser ();
   533:     hdcFormatFileChooser.addHistory (files);
   534:     hdcFormatFileChooser.selectLastFiles ();
   535:   }
   536: 
   537: 
   538:   //入出力
   539:   //
   540:   //     4   3   2   1   0
   541:   //    MSG C/D I/O BSY REQ | ACK SEL | DATA
   542:   //
   543:   //     0   0   0   0   0  |  0   0  |       バスフリーフェーズ
   544:   //
   545:   //     0   0   0   0   0  |  0   1  |  ID   イニシエータがセレクションフェーズを開始
   546:   //     0   0   0   1   0  |  0   1  |       ターゲットがバスを占有
   547:   //     0   0   0   1   0  |  0   0  |       イニシエータがセレクションフェーズを終了
   548:   //
   549:   //     0   1   0   1   0  |  0   0  |       ターゲットがコマンドフェーズ(イニシエータ→ターゲット)を開始
   550:   //     0   1   0   1   1  |  0   0  |       ターゲットがデータの受信を開始
   551:   //     0   1   0   1   1  |  1   0  |  XX   イニシエータがデータの送信を開始
   552:   //     0   1   0   1   0  |  1   0  |       ターゲットがデータの受信を終了
   553:   //     0   1   0   1   0  |  0   0  |       イニシエータがデータの送信を終了
   554:   //    繰り返す
   555:   //
   556:   //    データ転送フェーズが必要なとき
   557:   //     0   0   0   1   0  |  0   0  |       ターゲットがデータ転送フェーズ(イニシエータ→ターゲット)を開始
   558:   //     0   0   0   1   1  |  0   0  |       ターゲットがデータの受信を開始
   559:   //     0   0   0   1   1  |  1   0  |  XX   イニシエータがデータの送信を開始
   560:   //     0   0   0   1   0  |  1   0  |       ターゲットがデータの受信を終了
   561:   //     0   0   0   1   0  |  0   0  |       イニシエータがデータの送信を終了
   562:   //    繰り返す
   563:   //    または
   564:   //     0   0   1   1   0  |  0   0  |       ターゲットがデータ転送フェーズ(ターゲット→イニシエータ)を開始
   565:   //     0   0   1   1   1  |  0   0  |  XX   ターゲットがデータの送信を開始
   566:   //     0   0   1   1   1  |  1   0  |       イニシエータがデータを受信を開始
   567:   //     0   0   1   1   0  |  1   0  |       ターゲットがデータの送信を終了
   568:   //     0   0   1   1   0  |  0   0  |       イニシエータがデータの受信を終了
   569:   //    繰り返す
   570:   //
   571:   //     0   1   1   1   0  |  0   0  |       ターゲットがステータスフェーズ(ターゲット→イニシエータ)を開始
   572:   //     0   1   1   1   1  |  0   0  |  XX   ターゲットがデータの送信を開始
   573:   //     0   1   1   1   1  |  1   0  |       イニシエータがデータを受信を開始
   574:   //     0   1   1   1   0  |  1   0  |       ターゲットがデータの送信を終了
   575:   //     0   1   1   1   0  |  0   0  |       イニシエータがデータの受信を終了
   576:   //
   577:   //     1   1   1   1   0  |  0   0  |       ターゲットがメッセージフェーズ(ターゲット→イニシエータ)を開始
   578:   //     1   1   1   1   1  |  0   0  |  XX   ターゲットがデータの送信を開始
   579:   //     1   1   1   1   1  |  1   0  |       イニシエータがデータを受信を開始
   580:   //     1   1   1   1   0  |  1   0  |       ターゲットがデータの送信を終了
   581:   //     1   1   1   1   0  |  0   0  |       イニシエータがデータの受信を終了
   582:   //
   583:   //     0   0   0   0   0  |  0   0  |       ターゲットがバスを開放
   584:   //
   585:   //  SELはセレクションポートにIDを書き込むと1になり、ステータスポートに任意のデータを書き込むと0に戻る
   586:   //  ACKはREQ=1のときにデータポートを読み書きすると1になり、REQ=0で0に戻る
   587:   //  ACKはプログラムから見えないので厳密に実装する必要はない
   588:   //  DMAのREQ1はSICILIANのHDREQに接続されている。DMAのACK1はどこにも繋がっておらず、SICILIANがACKを作っている
   589: 
   590:   //d = hdcPeekStatus ()
   591:   //  pbz (0x00e96003)
   592:   public static int hdcPeekStatus () {
   593:     return hdcBusStatus;
   594:   }  //hdcPeekStatus()
   595: 
   596:   //d = hdcReadStatus ()
   597:   //  rbz (0x00e96003)
   598:   public static int hdcReadStatus () {
   599:     int d = hdcBusStatus;
   600:     if (HDC_DEBUG_TRACE) {
   601:       System.out.printf ("%08x hdcReadStatus(%d,%d)=%02x\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, d);
   602:     }
   603:     return d;
   604:   }  //hdcReadStatus()
   605: 
   606:   //hdcWriteSelect (d)
   607:   //  wb (0x00e96007, d)
   608:   public static void hdcWriteSelect (int d) {
   609:     d &= 255;
   610:     if (HDC_DEBUG_TRACE) {
   611:       System.out.printf ("%08x hdcWriteSelect(%02x)\n", XEiJ.regPC0, d);
   612:     }
   613:     if (d == 0) {  //選択されていない
   614:       return;
   615:     }
   616:     //セレクションフェーズに移行する
   617:     hdcSelectedID = Integer.numberOfTrailingZeros (d);
   618:     hdcSelectedLUN = -1;
   619:     hdcBusStatus = HDC_STATUS_BUSY;
   620:   }  //hdcWriteSelect(int)
   621: 
   622:   //hdcWriteCommand (d)
   623:   //  wb (0x00e96003, d)
   624:   public static void hdcWriteCommand (int d) {
   625:     d &= 255;
   626:     if (HDC_DEBUG_TRACE) {
   627:       System.out.printf ("%08x hdcWriteCommand(%d,%d,%02x)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, d);
   628:     }
   629:     //コマンドフェーズに移行する
   630:     hdcWriteHandle = hdcCommandBuffer;
   631:     hdcIndex = 0;
   632:     hdcLimit = 6;
   633:     hdcBusStatus = HDC_STATUS_COMMAND | HDC_STATUS_OUTPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST;
   634:     HD63450.dmaFallPCL (1);
   635:   }  //hdcWriteCommand(int)
   636: 
   637:   //hdcWriteReset (d)
   638:   //  wb (0x00e96005, d)
   639:   public static void hdcWriteReset (int d) {
   640:     d &= 255;
   641:     if (HDC_DEBUG_TRACE) {
   642:       System.out.printf ("%08x hdcWriteReset(%d,%d,%02x)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, d);
   643:     }
   644:     //バスフリーフェーズに移行する
   645:     hdcBusFreePhase ();
   646:   }  //hdcWriteReset(int)
   647: 
   648:   //d = hdcPeekData ()
   649:   //  pbz (0x00e96001)
   650:   public static int hdcPeekData () {
   651:     return (hdcReadHandle == null ? 0 :  //転送中でなければ無視する
   652:             hdcReadHandle[hdcIndex] & 255);
   653:   }  //hdcPeekData()
   654: 
   655:   //d = hdcReadData ()
   656:   //  rbz (0x00e96001)
   657:   public static int hdcReadData () {
   658:     if (hdcReadHandle == null) {  //転送中でなければ無視する
   659:       if (HDC_DEBUG_TRACE) {
   660:         System.out.printf ("%08x hdcReadData(%d,%d)=%02x\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, 0);
   661:       }
   662:       return 0;
   663:     }
   664:     int d = hdcReadHandle[hdcIndex++] & 255;
   665:     if (HDC_DEBUG_TRACE) {
   666:       System.out.printf ("%08x hdcReadData(%d,%d)=%02x\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, d);
   667:     }
   668:     if (hdcIndex < hdcLimit) {  //継続
   669:       HD63450.dmaFallPCL (1);
   670:     } else if (hdcBusStatus == (HDC_STATUS_INPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST)) {  //データ転送フェーズが終了した
   671:       //ステータスフェーズに移行する
   672:       hdcStatusPhase (0, 0);  //センスデータなし
   673:     } else if (hdcBusStatus == (HDC_STATUS_COMMAND | HDC_STATUS_INPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST)) {  //ステータスフェーズが終了した
   674:       //メッセージフェーズに移行する
   675:       hdcReadHandle = hdcMessageBuffer;
   676:       hdcWriteHandle = null;
   677:       hdcIndex = 0;
   678:       hdcLimit = 1;
   679:       hdcBusStatus = HDC_STATUS_MESSAGE | HDC_STATUS_COMMAND | HDC_STATUS_INPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST;
   680:       HD63450.dmaFallPCL (1);
   681:     } else {  //メッセージフェーズが終了した
   682:       //バスフリーフェーズに移行する
   683:       hdcBusFreePhase ();
   684:       IOInterrupt.ioiHdcFall ();
   685:       IOInterrupt.ioiHdcRise ();
   686:     }
   687:     return d;
   688:   }  //hdcReadData()
   689: 
   690:   //hdcWriteData (d)
   691:   //  wb (0x00e96001)
   692:   public static void hdcWriteData (int d) {
   693:     d &= 255;
   694:     if (HDC_DEBUG_TRACE) {
   695:       System.out.printf ("%08x hdcWriteData(%d,%d,%02x)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, d);
   696:     }
   697:     if (hdcWriteHandle == null) {  //転送中でなければ無視する
   698:       return;
   699:     }
   700:     hdcWriteHandle[hdcIndex++] = (byte) d;
   701:     if (hdcIndex < hdcLimit) {  //継続
   702:       HD63450.dmaFallPCL (1);
   703:     } else if (hdcBusStatus == (HDC_STATUS_OUTPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST)) {  //データ転送フェーズが終了した
   704:       if (hdcWriteHandle == hdcAssignDriveBuffer) {  //ASSIGN DRIVEのデータ転送フェーズが終了した
   705:         if (HDC_DEBUG_COMMAND) {
   706:           System.out.printf ("%08x SASI AssignDrive[", XEiJ.regPC0);
   707:           for (int i = 0; i < 10; i++) {
   708:             if (i > 0) {
   709:               System.out.print (',');
   710:             }
   711:             System.out.printf ("0x%02x", hdcAssignDriveBuffer[i] & 255);
   712:           }
   713:           System.out.println (']');
   714:         }
   715:         //!!!
   716:       }
   717:       //ステータスフェーズに移行する
   718:       hdcStatusPhase (0, 0);  //センスデータなし
   719:     } else {  //コマンドフェーズが終了した
   720:       int cmd = hdcCommandBuffer[0] & 255;  //コマンド番号
   721:       if (HDC_DEBUG_COMMAND) {
   722:         String name = cmd < HDC_COMMAND_NAME.length ? HDC_COMMAND_NAME[cmd] : "";
   723:         if (name.length () == 0) {
   724:           name = "???";
   725:         }
   726:         System.out.printf ("%08x SASI %s(", XEiJ.regPC0, name);
   727:         for (int i = 0; i < hdcLimit; i++) {
   728:           if (i > 0) {
   729:             System.out.print (',');
   730:           }
   731:           System.out.printf ("0x%02x", hdcCommandBuffer[i] & 255);
   732:         }
   733:         System.out.println (')');
   734:       }
   735:       hdcSelectedLUN = hdcCommandBuffer[1] >> 5 & 7;
   736:       if (hdcSelectedLUN > 1) {
   737:         //ステータスフェーズに移行する
   738:         hdcSenseBuffer[0] = 0x20;  //INVALID COMMAND
   739:         hdcStatusPhase (2, 0);  //センスデータあり
   740:         return;
   741:       }
   742:       hdcTargetUnit = hdcUnitArray[hdcSelectedID << 1 | hdcSelectedLUN];  //ユニット
   743:       if (!hdcTargetUnit.abuInserted) {  //挿入されていない
   744:         //ステータスフェーズに移行する
   745:         hdcSenseBuffer[0] = 0x20;  //INVALID COMMAND
   746:         hdcStatusPhase (2, 0);  //センスデータあり
   747:         return;
   748:       }
   749:       if (hdcLastFormatBlodkEnd >= 0 && cmd != 0x06) {  //一連のFormatBlockコマンドが終了した
   750:         HDMedia media = HDMedia.hdmLengthToMedia (hdcLastFormatBlodkEnd);
   751:         if (media != null) {
   752:           hdcTargetUnit.hduMedia = media;  //SASIハードディスクの容量を変更する
   753:           //!!! FORMAT.XはFormatBlockを行う前に指定されたサイズまでアクセスできるか確認しようとするので、容量を減らすことはできるが増やすことはできない
   754:         }
   755:         hdcLastFormatBlodkEnd = -1;
   756:       }
   757:       switch (cmd) {
   758:       case 0x00:  //TEST DRIVE READY
   759:         hdcDoTestDriveReady ();
   760:         break;
   761:       case 0x01:  //RECALIBRATE
   762:         hdcDoRecalibrate ();
   763:         break;
   764:       case 0x03:  //REQUEST SENSE STATUS
   765:         hdcDoRequestSenseStatus ();
   766:         break;
   767:       case 0x04:  //FORMAT DRIVE
   768:         hdcDoFormatDrive ();
   769:         break;
   770:       //case 0x05:  //CHECK TRACK FORMAT
   771:       case 0x06:  //FORMAT BLOCK
   772:         hdcDoFormatBlock ();
   773:         break;
   774:       //case 0x07:  //BAD TRACK FORMAT
   775:       case 0x08:  //READ
   776:         hdcDoRead ();
   777:         break;
   778:       case 0x0a:  //WRITE
   779:         hdcDoWrite ();
   780:         break;
   781:       case 0x0b:  //SEEK
   782:         hdcDoSeek ();
   783:         break;
   784:       //case 0x0c:  //INITIALIZE DRIVE CHARACTERISTICS
   785:       //case 0x0d:  //LAST CORRECTED BURST LENGTH
   786:       //case 0x0e:  //ASSIGN TRACK
   787:       //case 0x0f:  //WRITE SECTOR BUFFER
   788:       //case 0x10:  //READ SECTOR BUFFER
   789:       case 0xc2:  //ASSIGN DRIVE
   790:         hdcDoAssignDrive ();
   791:         break;
   792:       default:
   793:         if (HDC_DEBUG_UNIMPLEMENTED_COMMAND) {  //未実装コマンドを表示する
   794:           StringBuilder sb = new StringBuilder ();
   795:           String name = cmd < HDC_COMMAND_NAME.length ? HDC_COMMAND_NAME[cmd] : "";
   796:           if (name.length () == 0) {
   797:             name = "???";
   798:           }
   799:           sb.append (String.format ("%08x SASI %s(", XEiJ.regPC0, name));
   800:           for (int i = 0; i < hdcLimit; i++) {
   801:             if (i > 0) {
   802:               sb.append (',');
   803:             }
   804:             sb.append (String.format ("0x%02x", hdcCommandBuffer[i] & 255));
   805:           }
   806:           sb.append (')');
   807:           System.out.println (sb.toString ());
   808:         }
   809:         //ステータスフェーズに移行する
   810:         hdcSenseBuffer[0] = 0x20;  //INVALID COMMAND
   811:         hdcStatusPhase (2, 0);  //センスデータあり
   812:       }
   813:     }
   814:   }  //hdcWriteData(int)
   815: 
   816:   //hdcDoTestDriveReady ()
   817:   public static void hdcDoTestDriveReady () {
   818:     if (HDC_DEBUG_TRACE) {
   819:       System.out.printf ("%08x hdcDoTestDriveReady(%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN);
   820:     }
   821:     //ステータスフェーズに移行する
   822:     hdcStatusPhase (0, 0);  //センスデータなし
   823:   }  //hdcDoTestDriveReady()
   824: 
   825:   //hdcDoRecalibrate ()
   826:   public static void hdcDoRecalibrate () {
   827:     if (HDC_DEBUG_TRACE) {
   828:       System.out.printf ("%08x hdcDoRecalibrate(%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN);
   829:     }
   830:     //ステータスフェーズに移行する
   831:     hdcStatusPhase (0, 0);  //センスデータなし
   832:   }  //hdcDoRecalibrate()
   833: 
   834:   //hdcDoRequestSenseStatus ()
   835:   public static void hdcDoRequestSenseStatus () {
   836:     if (HDC_DEBUG_TRACE) {
   837:       System.out.printf ("%08x hdcDoRequestSenseStatus(%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN);
   838:     }
   839:     //データ転送フェーズ(ターゲット→イニシエータ)に移行する
   840:     hdcReadHandle = hdcSenseBuffer;
   841:     hdcIndex = 0;
   842:     hdcLimit = 4;
   843:     hdcBusStatus = HDC_STATUS_INPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST;
   844:     HD63450.dmaFallPCL (1);
   845:   }  //hdcDoRequestSenseStatus()
   846: 
   847:   //hdcDoFormatDrive ()
   848:   public static void hdcDoFormatDrive () {
   849:     if (HDC_DEBUG_TRACE) {
   850:       System.out.printf ("%08x hdcDoFormatDrive(%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN);
   851:     }
   852:     if (!hdcTargetUnit.abuInserted || hdcTargetUnit.hduMedia == null ||  //挿入されていない
   853:         hdcTargetUnit.abuWriteProtected) {  //書き込みが禁止されている
   854:       //ステータスフェーズに移行する
   855:       hdcSenseBuffer[0] = 0x20;  //INVALID COMMAND
   856:       hdcStatusPhase (2, 0);  //センスデータあり
   857:       return;
   858:     }
   859:     hdcTargetUnit.hduWritten = true;
   860:     //ディスクの全体をゼロクリアする
   861:     Arrays.fill (hdcTargetUnit.hduImage, 0, (int) hdcTargetUnit.hduMedia.humDiskEndByte, (byte) 0);
   862:     //ステータスフェーズに移行する
   863:     hdcStatusPhase (0, 0);  //センスデータなし
   864:   }  //hdcDoFormatDrive()
   865: 
   866:   //hdcDoFormatBlock ()
   867:   //  SASIコマンド$06 FormatBlock
   868:   public static void hdcDoFormatBlock () {
   869:     int i = (hdcCommandBuffer[1] & 31) << 16 | (char) (hdcCommandBuffer[2] << 8 | hdcCommandBuffer[3] & 255);  //開始セクタ
   870:     int n = 33;  //セクタ数
   871:     if (HDC_DEBUG_TRACE) {
   872:       System.out.printf ("%08x hdcDoFormatBlock(%d,%d,%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, i, n);
   873:     }
   874:     if (!hdcTargetUnit.abuInserted || hdcTargetUnit.hduMedia == null ||  //挿入されていない
   875:         hdcTargetUnit.abuWriteProtected) {  //書き込みが禁止されている
   876:       //ステータスフェーズに移行する
   877:       hdcSenseBuffer[0] = 0x20;  //INVALID COMMAND
   878:       hdcStatusPhase (2, 0);  //センスデータあり
   879:       return;
   880:     }
   881:     int l = i + n;  //終了セクタ+1
   882:     if (hdcTargetUnit.hduMedia.hdmDiskEndRecord < l) {
   883:       //ステータスフェーズに移行する
   884:       hdcSenseBuffer[0] = 0x21;  //INVALID SECTOR ADDRESS
   885:       hdcStatusPhase (2, 0);  //センスデータあり
   886:       return;
   887:     }
   888:     int begin = hdcTargetUnit.hduMedia.hdmBytesPerRecord * i;
   889:     int end = hdcTargetUnit.hduMedia.hdmBytesPerRecord * l;
   890:     hdcLastFormatBlodkEnd = end;
   891:     hdcTargetUnit.hduWritten = true;
   892:     //指定されたセクタをゼロクリアする
   893:     Arrays.fill (hdcTargetUnit.hduImage, begin, end, (byte) 0);
   894:     //ステータスフェーズに移行する
   895:     hdcStatusPhase (0, 0);  //センスデータなし
   896:   }  //hdcDoFormatBlock()
   897: 
   898:   //hdcDoRead ()
   899:   public static void hdcDoRead () {
   900:     int i = (hdcCommandBuffer[1] & 31) << 16 | (char) (hdcCommandBuffer[2] << 8 | hdcCommandBuffer[3] & 255);  //開始セクタ
   901:     int n = hdcCommandBuffer[4] & 255;  //セクタ数
   902:     if (n == 0) {
   903:       n = 256;
   904:     }
   905:     if (HDC_DEBUG_TRACE) {
   906:       System.out.printf ("%08x hdcDoRead(%d,%d,%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, i, n);
   907:     }
   908:     if (!hdcTargetUnit.abuInserted || hdcTargetUnit.hduMedia == null) {  //挿入されていない
   909:       //ステータスフェーズに移行する
   910:       hdcSenseBuffer[0] = 0x20;  //INVALID COMMAND
   911:       hdcStatusPhase (2, 0);  //センスデータあり
   912:       return;
   913:     }
   914:     int l = i + n;  //終了セクタ+1
   915:     if (hdcTargetUnit.hduMedia.hdmDiskEndRecord < l) {
   916:       //ステータスフェーズに移行する
   917:       hdcSenseBuffer[0] = 0x21;  //INVALID SECTOR ADDRESS
   918:       hdcStatusPhase (2, 0);  //センスデータあり
   919:       return;
   920:     }
   921:     //データ転送フェーズ(ターゲット→イニシエータ)に移行する
   922:     hdcReadHandle = hdcTargetUnit.hduImage;
   923:     hdcIndex = hdcTargetUnit.hduMedia.hdmBytesPerRecord * i;
   924:     hdcLimit = hdcTargetUnit.hduMedia.hdmBytesPerRecord * l;
   925:     hdcBusStatus = HDC_STATUS_INPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST;
   926:     HD63450.dmaFallPCL (1);
   927:   }  //hdcDoRead()
   928: 
   929:   //hdcDoWrite ()
   930:   public static void hdcDoWrite () {
   931:     int i = (hdcCommandBuffer[1] & 31) << 16 | (char) (hdcCommandBuffer[2] << 8 | hdcCommandBuffer[3] & 255);  //開始セクタ
   932:     int n = hdcCommandBuffer[4] & 255;  //セクタ数
   933:     if (n == 0) {
   934:       n = 256;
   935:     }
   936:     if (HDC_DEBUG_TRACE) {
   937:       System.out.printf ("%08x hdcDoWrite(%d,%d,%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, i, n);
   938:     }
   939:     if (!hdcTargetUnit.abuInserted || hdcTargetUnit.hduMedia == null ||  //挿入されていない
   940:         hdcTargetUnit.abuWriteProtected) {  //書き込みが禁止されている
   941:       //ステータスフェーズに移行する
   942:       hdcSenseBuffer[0] = 0x20;  //INVALID COMMAND
   943:       hdcStatusPhase (2, 0);  //センスデータあり
   944:       return;
   945:     }
   946:     int l = i + n;  //終了セクタ+1
   947:     if (hdcTargetUnit.hduMedia.hdmDiskEndRecord < l) {
   948:       //ステータスフェーズに移行する
   949:       hdcSenseBuffer[0] = 0x21;  //INVALID SECTOR ADDRESS
   950:       hdcStatusPhase (2, 0);  //センスデータあり
   951:       return;
   952:     }
   953:     hdcTargetUnit.hduWritten = true;
   954:     //データ転送フェーズ(イニシエータ→ターゲット)に移行する
   955:     hdcWriteHandle = hdcTargetUnit.hduImage;
   956:     hdcIndex = hdcTargetUnit.hduMedia.hdmBytesPerRecord * i;
   957:     hdcLimit = hdcTargetUnit.hduMedia.hdmBytesPerRecord * l;
   958:     hdcBusStatus = HDC_STATUS_OUTPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST;
   959:     HD63450.dmaFallPCL (1);
   960:   }  //hdcDoWrite()
   961: 
   962:   //hdcDoSeek ()
   963:   public static void hdcDoSeek () {
   964:     int i = (hdcCommandBuffer[1] & 31) << 16 | (char) (hdcCommandBuffer[2] << 8 | hdcCommandBuffer[3] & 255);  //開始セクタ
   965:     if (HDC_DEBUG_TRACE) {
   966:       System.out.printf ("%08x hdcDoSeek(%d,%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN, i);
   967:     }
   968:     if (!hdcTargetUnit.abuInserted || hdcTargetUnit.hduMedia == null) {  //挿入されていない
   969:       //ステータスフェーズに移行する
   970:       hdcSenseBuffer[0] = 0x20;  //INVALID COMMAND
   971:       hdcStatusPhase (2, 0);  //センスデータあり
   972:       return;
   973:     }
   974:     if (hdcTargetUnit.hduMedia.hdmDiskEndRecord <= i) {
   975:       //ステータスフェーズに移行する
   976:       hdcSenseBuffer[0] = 0x21;  //INVALID SECTOR ADDRESS
   977:       hdcStatusPhase (2, 0);  //センスデータあり
   978:       return;
   979:     }
   980:     //ステータスフェーズに移行する
   981:     hdcStatusPhase (0, 0);  //センスデータなし
   982:   }  //hdcDoSeek()
   983: 
   984:   //hdcDoAssignDrive ()
   985:   public static void hdcDoAssignDrive () {
   986:     if (HDC_DEBUG_TRACE) {
   987:       System.out.printf ("%08x hdcDoAssignDrive(%d,%d)\n", XEiJ.regPC0, hdcSelectedID, hdcSelectedLUN);
   988:     }
   989:     //データ転送フェーズ(イニシエータ→ターゲット)に移行する
   990:     hdcWriteHandle = hdcAssignDriveBuffer;
   991:     hdcIndex = 0;
   992:     hdcLimit = 10;
   993:     hdcBusStatus = HDC_STATUS_OUTPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST;
   994:     HD63450.dmaFallPCL (1);
   995:   }  //hdcDoAssignDrive()
   996: 
   997:   //hdcStatusPhase (status, message)
   998:   //  ステータスフェーズに移行する
   999:   //  status   2=センスデータあり。hdcSenseBufferを設定しておくこと
  1000:   //  message  常に0
  1001:   public static void hdcStatusPhase (int status, int message) {
  1002:     hdcStatusBuffer[0] = (byte) status;
  1003:     hdcMessageBuffer[0] = (byte) message;
  1004:     hdcReadHandle = hdcStatusBuffer;
  1005:     hdcWriteHandle = null;
  1006:     hdcIndex = 0;
  1007:     hdcLimit = 1;
  1008:     hdcBusStatus = HDC_STATUS_COMMAND | HDC_STATUS_INPUT | HDC_STATUS_BUSY | HDC_STATUS_REQUEST;
  1009:     HD63450.dmaFallPCL (1);
  1010:   }  //hdcStatusPhase(int,int)
  1011: 
  1012:   //hdcBusFreePhase ()
  1013:   //  バスフリーフェーズに移行する
  1014:   public static void hdcBusFreePhase () {
  1015:     hdcSelectedID = -1;
  1016:     hdcSelectedLUN = -1;
  1017:     hdcTargetUnit = null;
  1018:     hdcBusStatus = HDC_STATUS_FREE;
  1019:     hdcReadHandle = null;
  1020:     hdcWriteHandle = null;
  1021:     hdcIndex = 0;
  1022:     hdcLimit = 0;
  1023:     HD63450.dmaRisePCL (1);
  1024:   }  //hdcBusFreePhase()
  1025: 
  1026: 
  1027: 
  1028:   //========================================================================================
  1029:   //SASIフォーマットデータ
  1030:   //  無償公開されたHuman68k version 3.02のシステムディスクに入っているFORMAT.Xから抽出したデータを使う
  1031: 
  1032:   //----------------------------------------------------------------------------------------
  1033:   //SASIディスクIPL
  1034: /*
  1035:   public static final int[] HDC_DISK_IPL = {
  1036:     //  perl -e "do'sjdump.pl';$p=0;$m=4;$o=0x8aa;$l=0xcaa-$o;open IN,'HUMAN302.XDF'or die;binmode IN;seek IN,1024*592,0;read IN,$b,64;seek IN,1024*592+vec($b,15,32)+32*$m,0;read IN,$b,32;seek IN,1024*592+vec($b,7,32)+64+$o,0;read IN,$b,$l;close IN;sjdumpcode($b,0,$l,$p)"
  1037:     0x60,0x00,0x00,0xca,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00000000  `..ハ............
  1038:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00000010  ................
  1039:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00000020  ................
  1040:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00000030  ................
  1041:     0x1a,0x1b,0x5b,0x36,0x3b,0x33,0x32,0x48,0x58,0x36,0x38,0x30,0x30,0x30,0x20,0x48,  //00000040  ..[6;32HX68000 H
  1042:     0x41,0x52,0x44,0x20,0x44,0x49,0x53,0x4b,0x20,0x49,0x50,0x4c,0x20,0x4d,0x45,0x4e,  //00000050  ARD DISK IPL MEN
  1043:     0x55,0x1b,0x5b,0x32,0x35,0x3b,0x32,0x32,0x48,0x83,0x4a,0x81,0x5b,0x83,0x5c,0x83,  //00000060  U.[25;22Hカーソル
  1044:     0x8b,0x83,0x4c,0x81,0x5b,0x82,0xc5,0x91,0x49,0x91,0xf0,0x82,0xb5,0x82,0xc4,0x83,  //00000070   キーで選択してリ
  1045:     0x8a,0x83,0x5e,0x81,0x5b,0x83,0x93,0x83,0x4c,0x81,0x5b,0x82,0xf0,0x89,0x9f,0x82,  //00000080   ターンキーを押し
  1046:     0xb5,0x82,0xc4,0x82,0xad,0x82,0xbe,0x82,0xb3,0x82,0xa2,0x00,0x1b,0x5b,0x32,0x36,  //00000090   てください..[26
  1047:     0x3b,0x32,0x38,0x48,0x91,0x49,0x91,0xf0,0x82,0xb5,0x82,0xbd,0x82,0xe0,0x82,0xcc,  //000000a0  ;28H選択したもの
  1048:     0x82,0xf0,0x8e,0xa9,0x93,0xae,0x8b,0x4e,0x93,0xae,0x82,0xc6,0x82,0xb5,0x82,0xc4,  //000000b0  を自動起動として
  1049:     0x93,0x6f,0x98,0x5e,0x82,0xb5,0x82,0xdc,0x82,0xb7,0x00,0x00,0x4f,0xfa,0xff,0x32,  //000000c0  登録します..O..2
  1050:     0x42,0x85,0x20,0x3c,0x00,0x00,0x00,0x8e,0x4e,0x4f,0x1e,0x00,0xe1,0x47,0x74,0x04,  //000000d0  B. <...晒O..瓱t.
  1051:     0x26,0x3c,0x00,0x00,0x01,0x00,0x43,0xfa,0x02,0xc6,0x61,0x00,0x02,0x32,0x4a,0x00,  //000000e0  &<....C..ニa..2J.
  1052:     0x66,0x00,0x01,0x6a,0x43,0xfa,0x02,0xb8,0x47,0xfa,0xff,0x0a,0x0c,0x91,0x58,0x36,  //000000f0  f..jC..クG....噌6
  1053:     0x38,0x4b,0x66,0x00,0x01,0x6c,0x74,0x0e,0x42,0x43,0x42,0x44,0x42,0x86,0x43,0xe9,  //00000100  8Kf..lt.BCBDB.C.
  1054:     0x00,0x10,0x4a,0x11,0x67,0x16,0x52,0x46,0x26,0xc9,0x10,0x29,0x00,0x08,0x08,0x00,  //00000110  ..J.g.RF&ノ.)....
  1055:     0x00,0x00,0x66,0x08,0x52,0x43,0x4a,0x00,0x66,0x02,0x52,0x44,0x51,0xca,0xff,0xe0,  //00000120  ..f.RCJ.f.RDQハ.濳
  1056:     0x4a,0x43,0x67,0x00,0x01,0x42,0x72,0x0a,0x70,0x04,0x4e,0x4f,0x08,0x00,0x00,0x04,  //00000130   Cg..Br.p.NO....
  1057:     0x66,0x12,0x4a,0x44,0x67,0x0e,0x53,0x44,0x67,0x1c,0x43,0xfa,0xfe,0xf4,0x61,0x00,  //00000140  f.JDg.SDg.C...a.
  1058:     0x01,0xc4,0x60,0x28,0x43,0xfa,0xfe,0xea,0x61,0x00,0x01,0xba,0x43,0xfa,0xff,0x3e,  //00000150  .ト`(C..鸞..コC..>
  1059:     0x61,0x00,0x01,0xb2,0x60,0x14,0x47,0xfa,0xfe,0x9c,0x20,0x5b,0x24,0x28,0x00,0x08,  //00000160  a..イ`.G... [$(..
  1060:     0x4a,0x28,0x00,0x08,0x66,0xf4,0x60,0x00,0x00,0xbe,0x7a,0x02,0x42,0x43,0x45,0xfa,  //00000170  J(..f.`..セz.BCE.
  1061:     0xfe,0x84,0x22,0x52,0x10,0x29,0x00,0x08,0x67,0x0a,0xb0,0x05,0x67,0x06,0x72,0x02,  //00000180  .."R.)..g.ー.g.r.
  1062:     0x61,0x00,0x01,0x76,0x61,0x00,0x01,0x16,0x58,0x8a,0x52,0x43,0xb6,0x46,0x65,0xe2,  //00000190  a..va...X崖CカFe秡
  1063:     0x60,0x2a,0x61,0x00,0x01,0x06,0x61,0x00,0x00,0xf2,0xb0,0x3c,0x00,0x1d,0x67,0x3a,  //000001a0   *a...a...ー<..g:
  1064:     0xb0,0x3c,0x00,0x35,0x67,0x0c,0xb0,0x3c,0x00,0x3c,0x67,0x1a,0xb0,0x3c,0x00,0x3e,  //000001b0  ー<.5g.ー<.<g.ー<.>
  1065:     0x66,0xe4,0x61,0x00,0x00,0xe8,0x52,0x43,0xb6,0x46,0x65,0x02,0x42,0x43,0x61,0x00,  //000001c0  f臑..鏗CカFe.BCa.
  1066:     0x00,0xb2,0x66,0xf2,0x60,0xcc,0x61,0x00,0x00,0xd4,0x53,0x43,0x6a,0x04,0x36,0x06,  //000001d0  .イf.`フa..ヤSCj.6.
  1067:     0x53,0x43,0x61,0x00,0x00,0x9e,0x66,0xf2,0x60,0xb8,0x47,0xfa,0xfe,0x18,0xe5,0x43,  //000001e0  SCa..枅.`クG...蕕
  1068:     0x20,0x73,0x30,0x00,0x24,0x28,0x00,0x08,0x4a,0x05,0x67,0x3a,0x43,0xfa,0x01,0xb8,  //000001f0   s0.$(..J.g:C..ク
  1069:     0x72,0x0e,0x43,0xe9,0x00,0x10,0x4a,0x29,0xff,0xf8,0x67,0x12,0x20,0x11,0x08,0x00,  //00000200  r.C...J)..g. ...
  1070:     0x00,0x18,0x66,0x0a,0x42,0x11,0xb4,0x80,0x67,0x04,0x12,0xbc,0x00,0x02,0x51,0xc9,  //00000210  ..f.B.エ.g..シ..Qノ
  1071:     0xff,0xe2,0x2f,0x02,0x74,0x04,0x26,0x3c,0x00,0x00,0x01,0x00,0x43,0xfa,0x01,0x80,  //00000220  ../.t.&<....C...
  1072:     0x61,0x00,0x00,0xe8,0x24,0x1f,0xc4,0xbc,0x00,0xff,0xff,0xff,0x26,0x3c,0x00,0x00,  //00000230  a...$.トシ....&<..
  1073:     0x04,0x00,0x43,0xfa,0xfd,0xbc,0xd3,0xfc,0x00,0x00,0x04,0x00,0x61,0x00,0x00,0xd0,  //00000240  ..C..シモ.....a..ミ
  1074:     0x4a,0x00,0x66,0x08,0x0c,0x11,0x00,0x60,0x66,0x22,0x4e,0xd1,0x45,0xfa,0x00,0xda,  //00000250  J.f....`f"NムE..レ
  1075:     0x43,0xfa,0x00,0xcc,0x61,0x00,0x00,0xae,0x22,0x4a,0x61,0x00,0x00,0xa8,0x60,0xfe,  //00000260  C..フa..ョ"Ja..ィ`.
  1076:     0x45,0xfa,0x00,0xe3,0x60,0xea,0x45,0xfa,0x00,0xfa,0x60,0xe4,0x45,0xfa,0x01,0x11,  //00000270  E..總鵙...`胼...
  1077:     0x60,0xde,0x41,0xfa,0xfd,0x80,0x20,0x03,0xe5,0x40,0x20,0x70,0x00,0x00,0x10,0x28,  //00000280  `゙A... .蕁 p...(
  1078:     0x00,0x08,0xb0,0x05,0x67,0x02,0x4a,0x00,0x4e,0x75,0x42,0x80,0x4e,0x4f,0xe0,0x48,  //00000290  ..ー.g.J.NuB.NO潯
  1079:     0xb0,0x3c,0x00,0x4e,0x66,0x02,0x70,0x1d,0x4e,0x75,0x61,0x5a,0x43,0xfa,0xfd,0x56,  //000002a0  ー<.Nf.p.NuaZC..V
  1080:     0x30,0x03,0xe5,0x40,0x43,0xf1,0x00,0x00,0x72,0x24,0x74,0x09,0xd4,0x43,0x70,0x23,  //000002b0  0.蕁C...r$t.ヤCp#
  1081:     0x4e,0x4f,0x22,0x51,0x72,0x28,0x61,0x46,0x24,0x09,0x41,0xfa,0x00,0xe2,0x94,0x88,  //000002c0  NO"Qr(aF$.A..笏郁
  1082:     0xe8,0x8a,0x84,0xfc,0x00,0x0a,0xd4,0xbc,0x00,0x30,0x00,0x30,0x72,0x20,0xb4,0x7c,  //000002d0   割...ヤシ.0.0r エ|
  1083:     0x00,0x30,0x67,0x02,0x32,0x02,0x61,0x26,0x48,0x42,0x32,0x02,0x61,0x20,0x72,0x29,  //000002e0  .0g.2.a&HB2.a r)
  1084:     0x61,0x1c,0x72,0x20,0x61,0x18,0x74,0x07,0x42,0x41,0x12,0x19,0x61,0x10,0x51,0xca,  //000002f0  a.r a.t.BA..a.Qハ
  1085:     0xff,0xf8,0x72,0x03,0x60,0x02,0x72,0x0b,0x70,0x22,0x4e,0x4f,0x4e,0x75,0x70,0x20,  //00000300  ..r.`.r.p"NONup 
  1086:     0x4e,0x4f,0x4e,0x75,0x70,0x21,0x4e,0x4f,0x4e,0x75,0x70,0x45,0x60,0x02,0x70,0x46,  //00000310  NONup!NONupE`.pF
  1087:     0x48,0xe7,0x78,0x40,0x32,0x07,0x4e,0x4f,0x4c,0xdf,0x02,0x1e,0x4e,0x75,0x1a,0x1b,  //00000320  H輾@2.NOL゚..Nu..
  1088:     0x5b,0x31,0x36,0x3b,0x33,0x33,0x48,0x00,0x20,0x20,0x83,0x6e,0x81,0x5b,0x83,0x68,  //00000330  [16;33H.  ハード
  1089:     0x83,0x66,0x83,0x42,0x83,0x58,0x83,0x4e,0x82,0xaa,0x93,0xc7,0x82,0xdf,0x82,0xdc,  //00000340  ディスクが読めま
  1090:     0x82,0xb9,0x82,0xf1,0x00,0x20,0x20,0x8a,0xc7,0x97,0x9d,0x83,0x75,0x83,0x8d,0x83,  //00000350  せん.  管理ブロッ
  1091:     0x62,0x83,0x4e,0x82,0xaa,0x89,0xf3,0x82,0xea,0x82,0xc4,0x82,0xa2,0x82,0xdc,0x82,  //00000360   クが壊れています
  1092:     0xb7,0x00,0x20,0x20,0x8b,0x4e,0x93,0xae,0x89,0xc2,0x94,0x5c,0x82,0xc8,0x97,0xcc,  //00000370   .  起動可能な領
  1093:     0x88,0xe6,0x82,0xaa,0x82,0xa0,0x82,0xe8,0x82,0xdc,0x82,0xb9,0x82,0xf1,0x00,0x82,  //00000380  域がありません.I
  1094:     0x68,0x82,0x6f,0x82,0x6b,0x83,0x75,0x83,0x8d,0x83,0x62,0x83,0x4e,0x82,0xcc,0x93,  //00000390   PLブロックの内
  1095:     0xe0,0x97,0x65,0x82,0xaa,0x88,0xd9,0x8f,0xed,0x82,0xc5,0x82,0xb7,0x00,0x00,0x00,  //000003a0   容が異常です...
  1096:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000003b0  ................
  1097:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000003c0  ................
  1098:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000003d0  ................
  1099:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000003e0  ................
  1100:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000003f0  ................
  1101:   };
  1102: */
  1103:   //  perl misc/itob.pl xeij/HDC.java HDC_DISK_IPL
  1104:   public static final byte[] HDC_DISK_IPL = "`\0\0\312\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\32\33[6;32HX68000 HARD DISK IPL MENU\33[25;22H\203J\201[\203\\\203\213\203L\201[\202\305\221I\221\360\202\265\202\304\203\212\203^\201[\203\223\203L\201[\202\360\211\237\202\265\202\304\202\255\202\276\202\263\202\242\0\33[26;28H\221I\221\360\202\265\202\275\202\340\202\314\202\360\216\251\223\256\213N\223\256\202\306\202\265\202\304\223o\230^\202\265\202\334\202\267\0\0O\372\3772B\205 <\0\0\0\216NO\36\0\341Gt\4&<\0\0\1\0C\372\2\306a\0\0022J\0f\0\1jC\372\2\270G\372\377\n\f\221X68Kf\0\1lt\16BCBDB\206C\351\0\20J\21g\26RF&\311\20)\0\b\b\0\0\0f\bRCJ\0f\2RDQ\312\377\340JCg\0\1Br\np\4NO\b\0\0\4f\22JDg\16SDg\34C\372\376\364a\0\1\304`(C\372\376\352a\0\1\272C\372\377>a\0\1\262`\24G\372\376\234 [$(\0\bJ(\0\bf\364`\0\0\276z\2BCE\372\376\204\"R\20)\0\bg\n\260\5g\6r\2a\0\1va\0\1\26X\212RC\266Fe\342`*a\0\1\6a\0\0\362\260<\0\35g:\260<\0005g\f\260<\0<g\32\260<\0>f\344a\0\0\350RC\266Fe\2BCa\0\0\262f\362`\314a\0\0\324SCj\0046\6SCa\0\0\236f\362`\270G\372\376\30\345C s0\0$(\0\bJ\5g:C\372\1\270r\16C\351\0\20J)\377\370g\22 \21\b\0\0\30f\nB\21\264\200g\4\22\274\0\2Q\311\377\342/\2t\4&<\0\0\1\0C\372\1\200a\0\0\350$\37\304\274\0\377\377\377&<\0\0\4\0C\372\375\274\323\374\0\0\4\0a\0\0\320J\0f\b\f\21\0`f\"N\321E\372\0\332C\372\0\314a\0\0\256\"Ja\0\0\250`\376E\372\0\343`\352E\372\0\372`\344E\372\1\21`\336A\372\375\200 \3\345@ p\0\0\20(\0\b\260\5g\2J\0NuB\200NO\340H\260<\0Nf\2p\35NuaZC\372\375V0\3\345@C\361\0\0r$t\t\324Cp#NO\"Qr(aF$\tA\372\0\342\224\210\350\212\204\374\0\n\324\274\0000\0000r \264|\0000g\0022\2a&HB2\2a r)a\34r a\30t\7BA\22\31a\20Q\312\377\370r\3`\2r\13p\"NONup NONup!NONupE`\2pFH\347x@2\7NOL\337\2\36Nu\32\33[16;33H\0  \203n\201[\203h\203f\203B\203X\203N\202\252\223\307\202\337\202\334\202\271\202\361\0  \212\307\227\235\203u\203\215\203b\203N\202\252\211\363\202\352\202\304\202\242\202\334\202\267\0  \213N\223\256\211\302\224\\\202\310\227\314\210\346\202\252\202\240\202\350\202\334\202\271\202\361\0\202h\202o\202k\203u\203\215\203b\203N\202\314\223\340\227e\202\252\210\331\217\355\202\305\202\267\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes (XEiJ.ISO_8859_1);
  1105: 
  1106:   //----------------------------------------------------------------------------------------
  1107:   //SASIパーティションIPL
  1108: /*
  1109:   public static final int[] HDC_PARTITION_IPL = {
  1110:     //  perl -e "do'sjdump.pl';$p=0x2100;$m=4;$o=0x1126;$l=0x1526-$o;open IN,'HUMAN302.XDF'or die;binmode IN;seek IN,1024*592,0;read IN,$b,64;seek IN,1024*592+vec($b,15,32)+32*$m,0;read IN,$b,32;seek IN,1024*592+vec($b,7,32)+64+$o,0;read IN,$b,$l;close IN;sjdumpcode($b,0,$l,$p)"
  1111:     0x60,0x20,0x48,0x75,0x64,0x73,0x6f,0x6e,0x20,0x73,0x6f,0x66,0x74,0x20,0x32,0x2e,  //00002100  ` Hudson soft 2.
  1112:     0x30,0x30,0x04,0x00,0x01,0x02,0x00,0x01,0x02,0x00,0x27,0x72,0xf8,0x14,0x00,0x00,  //00002110  00........'r....
  1113:     0x00,0x00,0x4f,0xfa,0xff,0xdc,0x43,0xfa,0x01,0x34,0x61,0x00,0x01,0x2a,0x20,0x3c,  //00002120  ..O..ワC..4a..* <
  1114:     0x00,0x00,0x00,0x8e,0x4e,0x4f,0x12,0x00,0xe1,0x41,0x42,0x82,0x14,0x3a,0xff,0xdf,  //00002130  ...晒O..瓣B..:.゚
  1115:     0x42,0x80,0x10,0x3a,0xff,0xd1,0xc4,0xc0,0x42,0x80,0x30,0x3a,0xff,0xca,0xd4,0x80,  //00002140  B..:.ムトタB.0:.ハヤ.
  1116:     0xe5,0x82,0xd4,0xba,0xff,0xca,0x26,0x3c,0x00,0x00,0x04,0x00,0x43,0xfa,0x01,0x9a,  //00002150  蛯ヤコ.ハ&<....C..啾
  1117:     0x61,0x00,0x00,0xc8,0x4a,0x00,0x66,0x00,0x00,0xd0,0x43,0xfa,0x01,0x8c,0x3c,0x3c,  //00002160   ..ネJ.f..ミC...<<
  1118:     0x00,0x1f,0x24,0x49,0x47,0xfa,0x01,0x75,0x7e,0x0a,0x10,0x1a,0x80,0x3c,0x00,0x20,  //00002170  ..$IG..u~....<. 
  1119:     0xb0,0x1b,0x66,0x06,0x51,0xcf,0xff,0xf4,0x60,0x14,0xd3,0xfc,0x00,0x00,0x00,0x20,  //00002180  ー.f.Qマ..`.モ.... 
  1120:     0x51,0xce,0xff,0xe0,0x43,0xfa,0x00,0xc8,0x61,0x00,0x00,0xbc,0x60,0xfe,0x42,0x80,  //00002190  Qホ.澆..ネa..シ`.B.
  1121:     0x30,0x29,0x00,0x1a,0xe1,0x58,0x55,0x40,0x42,0x87,0x1e,0x3a,0xff,0x68,0xc0,0xc7,  //000021a0  0)..畊U@B..:.hタヌ
  1122:     0xe5,0x80,0xd4,0x80,0x42,0x80,0x30,0x3a,0xff,0x60,0xeb,0x80,0xd0,0xbc,0x00,0x00,  //000021b0  蛟ヤ.B.0:.`..ミシ..
  1123:     0x03,0xff,0xe0,0x88,0xe4,0x88,0xe5,0x80,0xd4,0x80,0x48,0xe7,0x60,0x00,0x43,0xfa,  //000021c0  ..煦艾蛟ヤ.H軈.C.
  1124:     0x01,0x28,0x26,0x3c,0x00,0x00,0x01,0x00,0x61,0x50,0x4c,0xdf,0x00,0x06,0x4a,0x00,  //000021d0  .(&<....aPL゚..J.
  1125:     0x66,0x56,0x43,0xfa,0x01,0x14,0x0c,0x59,0x48,0x55,0x66,0x56,0x54,0x89,0x0c,0x99,  //000021e0  fVC....YHUfVT...
  1126:     0x00,0x00,0x68,0x00,0x66,0x56,0x2f,0x19,0x26,0x19,0xd6,0x99,0x2f,0x03,0x2f,0x19,  //000021f0  ..h.fV/.&.ヨ././.
  1127:     0x22,0x7c,0x00,0x00,0x67,0xc0,0xd6,0xbc,0x00,0x00,0x00,0x40,0x61,0x1c,0x22,0x1f,  //00002200  "|..gタヨシ...@a.".
  1128:     0x24,0x1f,0x22,0x5f,0x4a,0x00,0x66,0x20,0x41,0xf9,0x00,0x00,0x68,0x00,0xd1,0xc2,  //00002210  $."_J.f A...h.ムツ
  1129:     0x53,0x81,0x65,0x04,0x42,0x18,0x60,0xf8,0x4e,0xd1,0x48,0xe7,0x78,0x40,0x70,0x46,  //00002220  S‘.B.`.NムH輾@pF
  1130:     0x4e,0x4f,0x4c,0xdf,0x02,0x1e,0x4e,0x75,0x43,0xfa,0x00,0x48,0x61,0x18,0x60,0x00,  //00002230  NOL゚..NuC..Ha.`.
  1131:     0xff,0x5c,0x43,0xfa,0x00,0x5d,0x61,0x0e,0x60,0x00,0xff,0x52,0x43,0xfa,0x00,0x75,  //00002240  .\C..]a.`..RC..u
  1132:     0x61,0x04,0x60,0x00,0xff,0x48,0x70,0x21,0x4e,0x4f,0x4e,0x75,0x1a,0x00,0x1b,0x5b,  //00002250  a.`..Hp!NONu...[
  1133:     0x31,0x36,0x3b,0x33,0x35,0x48,0x48,0x75,0x6d,0x61,0x6e,0x2e,0x73,0x79,0x73,0x20,  //00002260  16;35HHuman.sys 
  1134:     0x82,0xaa,0x20,0x8c,0xa9,0x82,0xc2,0x82,0xa9,0x82,0xe8,0x82,0xdc,0x82,0xb9,0x82,  //00002270  が 見つかりません
  1135:     0xf1,0x00,0x1b,0x5b,0x31,0x36,0x3b,0x33,0x38,0x48,0x83,0x66,0x83,0x42,0x83,0x58,  //00002280   ..[16;38Hディス
  1136:     0x83,0x4e,0x82,0xaa,0x81,0x40,0x93,0xc7,0x82,0xdf,0x82,0xdc,0x82,0xb9,0x82,0xf1,  //00002290  クが 読めません
  1137:     0x00,0x1b,0x5b,0x31,0x36,0x3b,0x33,0x36,0x48,0x48,0x75,0x6d,0x61,0x6e,0x2e,0x73,  //000022a0  ..[16;36HHuman.s
  1138:     0x79,0x73,0x20,0x82,0xaa,0x20,0x89,0xf3,0x82,0xea,0x82,0xc4,0x82,0xa2,0x82,0xdc,  //000022b0  ys が 壊れていま
  1139:     0x82,0xb7,0x00,0x1b,0x5b,0x31,0x36,0x3b,0x33,0x33,0x48,0x48,0x75,0x6d,0x61,0x6e,  //000022c0  す..[16;33HHuman
  1140:     0x2e,0x73,0x79,0x73,0x20,0x82,0xcc,0x20,0x83,0x41,0x83,0x68,0x83,0x8c,0x83,0x58,  //000022d0  .sys の アドレス
  1141:     0x82,0xaa,0x88,0xd9,0x8f,0xed,0x82,0xc5,0x82,0xb7,0x00,0x68,0x75,0x6d,0x61,0x6e,  //000022e0  が異常です.human
  1142:     0x20,0x20,0x20,0x73,0x79,0x73,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000022f0     sys..........
  1143:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002300  ................
  1144:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002310  ................
  1145:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002320  ................
  1146:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002330  ................
  1147:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002340  ................
  1148:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002350  ................
  1149:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002360  ................
  1150:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002370  ................
  1151:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002380  ................
  1152:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002390  ................
  1153:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000023a0  ................
  1154:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000023b0  ................
  1155:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000023c0  ................
  1156:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000023d0  ................
  1157:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000023e0  ................
  1158:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000023f0  ................
  1159:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002400  ................
  1160:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002410  ................
  1161:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002420  ................
  1162:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002430  ................
  1163:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002440  ................
  1164:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002450  ................
  1165:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002460  ................
  1166:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002470  ................
  1167:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002480  ................
  1168:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //00002490  ................
  1169:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000024a0  ................
  1170:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000024b0  ................
  1171:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000024c0  ................
  1172:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000024d0  ................
  1173:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000024e0  ................
  1174:     0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,  //000024f0  ................
  1175:   };
  1176: */
  1177:   //  perl misc/itob.pl xeij/HDC.java HDC_PARTITION_IPL
  1178:   public static final byte[] HDC_PARTITION_IPL = "` Hudson soft 2.00\4\0\1\2\0\1\2\0\'r\370\24\0\0\0\0O\372\377\334C\372\0014a\0\1* <\0\0\0\216NO\22\0\341AB\202\24:\377\337B\200\20:\377\321\304\300B\2000:\377\312\324\200\345\202\324\272\377\312&<\0\0\4\0C\372\1\232a\0\0\310J\0f\0\0\320C\372\1\214<<\0\37$IG\372\1u~\n\20\32\200<\0 \260\33f\6Q\317\377\364`\24\323\374\0\0\0 Q\316\377\340C\372\0\310a\0\0\274`\376B\2000)\0\32\341XU@B\207\36:\377h\300\307\345\200\324\200B\2000:\377`\353\200\320\274\0\0\3\377\340\210\344\210\345\200\324\200H\347`\0C\372\1(&<\0\0\1\0aPL\337\0\6J\0fVC\372\1\24\fYHUfVT\211\f\231\0\0h\0fV/\31&\31\326\231/\3/\31\"|\0\0g\300\326\274\0\0\0@a\34\"\37$\37\"_J\0f A\371\0\0h\0\321\302S\201e\4B\30`\370N\321H\347x@pFNOL\337\2\36NuC\372\0Ha\30`\0\377\\C\372\0]a\16`\0\377RC\372\0ua\4`\0\377Hp!NONu\32\0\33[16;35HHuman.sys \202\252 \214\251\202\302\202\251\202\350\202\334\202\271\202\361\0\33[16;38H\203f\203B\203X\203N\202\252\201@\223\307\202\337\202\334\202\271\202\361\0\33[16;36HHuman.sys \202\252 \211\363\202\352\202\304\202\242\202\334\202\267\0\33[16;33HHuman.sys \202\314 \203A\203h\203\214\203X\202\252\210\331\217\355\202\305\202\267\0human   sys\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0".getBytes (XEiJ.ISO_8859_1);
  1179: 
  1180: 
  1181: 
  1182:   //========================================================================================
  1183:   //$$HDU SASI HDユニット
  1184:   //  SASIハードディスクのユニット
  1185:   public static class HDUnit extends AbstractUnit {
  1186: 
  1187:     public HDMedia hduMedia;  //メディアの種類
  1188:     public byte[] hduImage;  //ディスクイメージ
  1189:     public boolean hduWritten;  //true=書き込みがあった
  1190: 
  1191:     //new HDUnit (number)
  1192:     //  コンストラクタ
  1193:     public HDUnit (int number) {
  1194:       super (number);
  1195:       hduImage = null;
  1196:       hduWritten = false;
  1197:     }
  1198: 
  1199:     //hduTini ()
  1200:     //  後始末
  1201:     //  イメージファイルに書き出す
  1202:     public void hduTini () {
  1203:       if (abuInserted) {
  1204:         hduFlush ();
  1205:       }
  1206:     }  //hduTini()
  1207: 
  1208:     //success = unit.hduFlush ()
  1209:     //  イメージファイルに書き出す
  1210:     public boolean hduFlush () {
  1211:       if (!hduWritten) {  //書き込みがない
  1212:         return true;
  1213:       }
  1214:       if (abuWriteProtected) {  //書き込みが許可されていない
  1215:         return false;
  1216:       }
  1217:       if (!XEiJ.rscPutFile (abuPath, hduImage, 0, (int) hduMedia.humDiskEndByte)) {
  1218:         return false;
  1219:       }
  1220:       hduWritten = false;
  1221:       return true;
  1222:     }  //hduFlush()
  1223: 
  1224:     //unit.connect (disconnectable)
  1225:     //  接続する
  1226:     @Override protected void connect (boolean disconnectable) {
  1227:       super.connect (disconnectable);
  1228:       hduImage = new byte[HDMedia.HDM_MAX_BYTES_PER_DISK];
  1229:       hduWritten = false;
  1230:     }
  1231: 
  1232:     //unit.disconnect ()
  1233:     //  切り離す
  1234:     @Override protected void disconnect () {
  1235:       super.disconnect ();
  1236:       hduImage = null;
  1237:     }
  1238: 
  1239:     //success = unit.eject ()
  1240:     //  イジェクトする
  1241:     @Override protected boolean eject () {
  1242:       if (!hduFlush ()) {  //イメージファイルに書き出す
  1243:         return false;
  1244:       }
  1245:       String path = abuPath;  //イジェクトされたイメージファイルのパス。super.eject()を呼び出す前にコピーすること
  1246:       if (!super.eject ()) {  //イジェクトする
  1247:         return false;
  1248:       }
  1249:       if (hduMedia != null) {  //挿入されていたとき
  1250:         hdcAddHistory (new File (path).getAbsoluteFile ());
  1251:         System.out.println (Multilingual.mlnJapanese ?
  1252:                             path + " を sa" + abuNumber + " から切り離しました" :
  1253:                             path + " was removed from sa" + abuNumber);
  1254:       }
  1255:       hduMedia = null;
  1256:       //hdcHDMaxを更新する
  1257:       if (hdcHDMax == abuNumber - 1) {
  1258:         int u = abuNumber - 1;
  1259:         while (u >= 0 && !hdcUnitArray[u].abuInserted) {  //挿入されている最後のユニットまで遡る
  1260:           u--;
  1261:         }
  1262:         hdcHDMax = u + 1;
  1263:       }
  1264:       return true;
  1265:     }
  1266: 
  1267:     //success = unit.open ()
  1268:     //  開くダイアログを開く
  1269:     @Override protected boolean open () {
  1270:       if (!super.open ()) {
  1271:         return false;
  1272:       }
  1273:       hdcOpenUnit = abuNumber;
  1274:       if (hdcOpenDialog == null) {
  1275:         hdcOpenDialog = new OpenDialog ();
  1276:         hdcOpenDialog.setReadOnly (Settings.sgsGetOnOff ("sareadonly"));
  1277:         hdcOpenDialog.setReboot (Settings.sgsGetOnOff ("saappreboot"));
  1278:         for (File[] files : hdcOpenHistory) {
  1279:           hdcOpenDialog.addHistory (files);
  1280:         }
  1281:         hdcOpenHistory.clear ();
  1282:       }
  1283:       hdcOpenDialog.rescanCurrentDirectory ();  //挿入されているファイルが変わると選択できるファイルも変わるのでリストを作り直す
  1284:       hdcOpenDialog.setVisible (true);
  1285:       return true;
  1286:     }  //unit.open()
  1287: 
  1288:     //success = unit.insert (path, writeProtected)
  1289:     //  挿入する
  1290:     @Override protected boolean insert (String path, boolean writeProtected) {
  1291:       if (hdcIsInserted (path)) {  //既に挿入されている
  1292:         return false;
  1293:       }
  1294:       if (!super.insert (path, writeProtected)) {  //挿入できなかった
  1295:         return false;
  1296:       }
  1297:       //hdcHDMaxを更新する
  1298:       if (hdcHDMax <= abuNumber) {
  1299:         hdcHDMax = abuNumber + 1;
  1300:       }
  1301:       return true;
  1302:     }  //unit.insert(String)
  1303: 
  1304:     //loaded = unit.load (path)
  1305:     //  読み込む
  1306:     @Override protected boolean load (String path) {
  1307:       hduMedia = HDMedia.hdmPathToMedia (path, hduImage);
  1308:       if (hduMedia == null) {  //読み込めない
  1309:         return false;
  1310:       }
  1311:       hduWritten = false;
  1312:       hdcAddHistory (new File (path).getAbsoluteFile ());
  1313:       System.out.println (Multilingual.mlnJapanese ?
  1314:                           path + " を sa" + abuNumber + " に接続しました" :
  1315:                           path + " was connected to sa" + abuNumber);
  1316:       return true;
  1317:     }
  1318: 
  1319:   }  //class HDUnit
  1320: 
  1321: 
  1322: 
  1323: }  //class HDC
  1324: 
  1325: 
  1326: