MemoryMappedDevice.java
     1: //========================================================================================
     2: //  MemoryMappedDevice.java
     3: //    en:Memory mapped device
     4: //    ja:メモリマップトデバイス
     5: //  Copyright (C) 2003-2024 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: //  デバイスにアクセスするためのメソッドをenum bodyに記述する
    15: //    mmdPbs,mmdPbz,mmdPws,mmdPwz,mmdPls  ピーク
    16: //    mmdRbs,mmdRbz,mmdRws,mmdRwz,mmdRls  リード
    17: //    mmdWb,mmdWw,mmdWl                   ライト
    18: //  ピーク、リード、ライトの命名規則
    19: //    4文字目  P=ピーク,R=リード,W=ライト
    20: //    5文字目  b=バイト,w=ワード,l=ロング
    21: //    6文字目  s=符号拡張,z=ゼロ拡張
    22: //  ピークとリードの返却値の型はmmdPbsとmmdRbsだけbyte、他はint
    23: //  ピークはSRAMスイッチの読み取りやデバッガなどで使用する
    24: //  ピークはMPUやデバイスの状態を変化させず、例外もスローしない
    25: //  リードとライトはMPUやDMAによる通常のアクセスで使用する
    26: //  リードとライトはバスエラーをスローする場合がある
    27: //  アドレスの未使用ビットはデバイスに渡る前にすべてクリアされていなければならない
    28: //    バスエラーは未使用ビットがクリアされたアドレスで通知されることになる
    29: //  異なるデバイスに跨るアクセスはデバイスに渡る前に分割されていなければならない
    30: //  奇数アドレスに対するワードアクセスはデバイスに渡る前に分割または排除されていなければならない
    31: //  4の倍数でないアドレスに対するロングアクセスはデバイスに渡る前に分割または排除されていなければならない
    32: //  デバイスのメソッドを直接呼び出すときはアドレスのマスクや分割を忘れないこと
    33: //----------------------------------------------------------------------------------------
    34: 
    35: package xeij;
    36: 
    37: import java.lang.*;  //Boolean,Character,Class,Comparable,Double,Exception,Float,IllegalArgumentException,Integer,Long,Math,Number,Object,Runnable,SecurityException,String,StringBuilder,System
    38: import java.util.*;  //ArrayList,Arrays,Calendar,GregorianCalendar,HashMap,Map,Map.Entry,Timer,TimerTask,TreeMap
    39: 
    40: public enum MemoryMappedDevice {
    41: 
    42:   //--------------------------------------------------------------------------------
    43:   //MMD_MMR メインメモリ
    44:   MMD_MMR {
    45:     @Override public String toString () {
    46:       return Multilingual.mlnJapanese ? "メインメモリ" : "Main Memory";
    47:     }
    48:     //ピーク
    49:     @Override protected byte mmdPbs (int a) {
    50:       a &= XEiJ.BUS_MOTHER_MASK;
    51:       return MainMemory.mmrM8[a];
    52:     }
    53:     @Override protected int mmdPbz (int a) {
    54:       a &= XEiJ.BUS_MOTHER_MASK;
    55:       return MainMemory.mmrM8[a] & 0xff;
    56:     }
    57:     @Override protected int mmdPws (int a) {
    58:       a &= XEiJ.BUS_MOTHER_MASK;
    59:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
    60:         return MainMemory.mmrBuffer.getShort (a);
    61:       } else {
    62:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
    63:       }
    64:     }
    65:     @Override protected int mmdPwz (int a) {
    66:       a &= XEiJ.BUS_MOTHER_MASK;
    67:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
    68:         return MainMemory.mmrBuffer.getChar (a);
    69:       } else {
    70:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
    71:       }
    72:     }
    73:     @Override protected int mmdPls (int a) {
    74:       a &= XEiJ.BUS_MOTHER_MASK;
    75:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
    76:         return MainMemory.mmrBuffer.getInt (a);
    77:       } else {
    78:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
    79:       }
    80:     }
    81:     //リード
    82:     @Override protected byte mmdRbs (int a) throws M68kException {
    83:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
    84:        a &= XEiJ.BUS_MOTHER_MASK;
    85:        return MainMemory.mmrM8[a];
    86:      }
    87:     @Override protected int mmdRbz (int a) throws M68kException {
    88:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
    89:        a &= XEiJ.BUS_MOTHER_MASK;
    90:        return MainMemory.mmrM8[a] & 0xff;
    91:      }
    92:     @Override protected int mmdRws (int a) throws M68kException {
    93:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
    94:        a &= XEiJ.BUS_MOTHER_MASK;
    95:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
    96:          return MainMemory.mmrBuffer.getShort (a);
    97:        } else {
    98:          return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
    99:        }
   100:      }
   101:     @Override protected int mmdRwz (int a) throws M68kException {
   102:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   103:        a &= XEiJ.BUS_MOTHER_MASK;
   104:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
   105:          return MainMemory.mmrBuffer.getChar (a);
   106:        } else {
   107:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
   108:        }
   109:      }
   110:     @Override protected int mmdRls (int a) throws M68kException {
   111:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ramlong;
   112:        a &= XEiJ.BUS_MOTHER_MASK;
   113:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
   114:          return MainMemory.mmrBuffer.getInt (a);
   115:        } else {
   116:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
   117:        }
   118:      }
   119:     //ライト
   120:     @Override protected void mmdWb (int a, int d) throws M68kException {
   121:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   122:        a &= XEiJ.BUS_MOTHER_MASK;
   123:        MainMemory.mmrM8[a    ] = (byte)  d;
   124:      }
   125:     @Override protected void mmdWw (int a, int d) throws M68kException {
   126:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   127:        a &= XEiJ.BUS_MOTHER_MASK;
   128:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
   129:          MainMemory.mmrBuffer.putShort (a, (short) d);
   130:        } else {
   131:          MainMemory.mmrM8[a    ] = (byte) (d >> 8);
   132:          MainMemory.mmrM8[a + 1] = (byte)  d;
   133:        }
   134:      }
   135:     @Override protected void mmdWl (int a, int d) throws M68kException {
   136:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ramlong;
   137:        a &= XEiJ.BUS_MOTHER_MASK;
   138:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
   139:          MainMemory.mmrBuffer.putInt (a, d);
   140:        } else {
   141:          MainMemory.mmrM8[a    ] = (byte) (d >> 24);
   142:          MainMemory.mmrM8[a + 1] = (byte) (d >> 16);
   143:          MainMemory.mmrM8[a + 2] = (byte) (d >> 8);
   144:          MainMemory.mmrM8[a + 3] = (byte)  d;
   145:        }
   146:      }
   147:   },  //MMD_MMR
   148: 
   149:   //--------------------------------------------------------------------------------
   150:   //MMD_MM1 1MB搭載機の2MB目
   151:   //  $00100000~$001FFFFF
   152:   //  リードはShodaiは$6100、ACE/PRO/PROIIは$FFFFの繰り返し
   153:   //  ライトは無視
   154:   MMD_MM1 {
   155:     @Override public String toString () {
   156:       return Multilingual.mlnJapanese ? "1MB 搭載機の 2MB 目" : "2nd MB of machines with 1MB";
   157:     }
   158:     //リード
   159:     @Override protected byte mmdRbs (int a) throws M68kException {
   160:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   161:       return (byte) ((a & 1) == 0 ? mmdRwz (a) >> 8 : mmdRwz (a));
   162:     }
   163:     @Override protected int mmdRbz (int a) throws M68kException {
   164:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   165:       return (a & 1) == 0 ? mmdRwz (a) >> 8 : mmdRwz (a) & 0xff;
   166:     }
   167:     @Override protected int mmdRws (int a) throws M68kException {
   168:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   169:       return (short) mmdRwz (a);
   170:     }
   171:     @Override protected int mmdRwz (int a) throws M68kException {
   172:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   173:       return XEiJ.currentModel.isShodai () ? 0x6100 : 0xffff;
   174:     }
   175:     @Override protected int mmdRls (int a) throws M68kException {
   176:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ramlong;
   177:       return mmdRwz (a) << 16 | mmdRwz (a + 2);
   178:     }
   179:     //ライト
   180:     @Override protected void mmdWb (int a, int d) throws M68kException {
   181:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   182:      }
   183:     @Override protected void mmdWw (int a, int d) throws M68kException {
   184:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ram;
   185:      }
   186:     @Override protected void mmdWl (int a, int d) throws M68kException {
   187:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ramlong;
   188:      }
   189:   },
   190: 
   191:   //--------------------------------------------------------------------------------
   192:   //MMD_XMM 拡張メモリ
   193:   MMD_XMM {
   194:     @Override public String toString () {
   195:       return Multilingual.mlnJapanese ? "拡張メモリ" : "Expansion Memory";
   196:     }
   197:     //ピーク
   198:     @Override protected byte mmdPbs (int a) {
   199:       a -= XEiJ.busExMemoryStart;
   200:       return XEiJ.busExMemoryArray[a];
   201:     }
   202:     @Override protected int mmdPbz (int a) {
   203:       a -= XEiJ.busExMemoryStart;
   204:       return XEiJ.busExMemoryArray[a] & 0xff;
   205:     }
   206:     @Override protected int mmdPws (int a) {
   207:       a -= XEiJ.busExMemoryStart;
   208:       return XEiJ.busExMemoryArray[a] << 8 | (XEiJ.busExMemoryArray[a + 1] & 0xff);
   209:     }
   210:     @Override protected int mmdPwz (int a) {
   211:       a -= XEiJ.busExMemoryStart;
   212:       return (char) (XEiJ.busExMemoryArray[a] << 8 | (XEiJ.busExMemoryArray[a + 1] & 0xff));
   213:     }
   214:     @Override protected int mmdPls (int a) {
   215:       a -= XEiJ.busExMemoryStart;
   216:       return XEiJ.busExMemoryArray[a] << 24 | (XEiJ.busExMemoryArray[a + 1] & 0xff) << 16 | (char) (XEiJ.busExMemoryArray[a + 2] << 8 | (XEiJ.busExMemoryArray[a + 3] & 0xff));
   217:     }
   218:     //リード
   219:     @Override protected byte mmdRbs (int a) throws M68kException {
   220:        a -= XEiJ.busExMemoryStart;
   221:        return XEiJ.busExMemoryArray[a];
   222:      }
   223:     @Override protected int mmdRbz (int a) throws M68kException {
   224:        a -= XEiJ.busExMemoryStart;
   225:        return XEiJ.busExMemoryArray[a] & 0xff;
   226:      }
   227:     @Override protected int mmdRws (int a) throws M68kException {
   228:        a -= XEiJ.busExMemoryStart;
   229:        return XEiJ.busExMemoryArray[a] << 8 | (XEiJ.busExMemoryArray[a + 1] & 0xff);
   230:      }
   231:     @Override protected int mmdRwz (int a) throws M68kException {
   232:        a -= XEiJ.busExMemoryStart;
   233:        return (char) (XEiJ.busExMemoryArray[a] << 8 | (XEiJ.busExMemoryArray[a + 1] & 0xff));
   234:      }
   235:     @Override protected int mmdRls (int a) throws M68kException {
   236:        a -= XEiJ.busExMemoryStart;
   237:        return XEiJ.busExMemoryArray[a] << 24 | (XEiJ.busExMemoryArray[a + 1] & 0xff) << 16 | (char) (XEiJ.busExMemoryArray[a + 2] << 8 | (XEiJ.busExMemoryArray[a + 3] & 0xff));
   238:      }
   239:     //ライト
   240:     @Override protected void mmdWb (int a, int d) throws M68kException {
   241:        a -= XEiJ.busExMemoryStart;
   242:        XEiJ.busExMemoryArray[a    ] = (byte)  d;
   243:      }
   244:     @Override protected void mmdWw (int a, int d) throws M68kException {
   245:        a -= XEiJ.busExMemoryStart;
   246:        XEiJ.busExMemoryArray[a    ] = (byte) (d >> 8);
   247:        XEiJ.busExMemoryArray[a + 1] = (byte)  d;
   248:      }
   249:     @Override protected void mmdWl (int a, int d) throws M68kException {
   250:        a -= XEiJ.busExMemoryStart;
   251:        XEiJ.busExMemoryArray[a    ] = (byte) (d >> 24);
   252:        XEiJ.busExMemoryArray[a + 1] = (byte) (d >> 16);
   253:        XEiJ.busExMemoryArray[a + 2] = (byte) (d >> 8);
   254:        XEiJ.busExMemoryArray[a + 3] = (byte)  d;
   255:      }
   256:   },  //MMD_XMM
   257: 
   258:   //--------------------------------------------------------------------------------
   259:   //MMD_GE0 グラフィックス画面(512ドット16色ページ0)
   260:   //
   261:   //  512ドット16色
   262:   //                アドレス             アクセス                  格納
   263:   //    GE0  0x00c00000~0x00c7ffff  ............3210  ──  ............3210
   264:   //    GE1  0x00c80000~0x00cfffff  ............7654  ──  ............7654
   265:   //    GE2  0x00d00000~0x00d7ffff  ............ba98  ──  ............ba98
   266:   //    GE3  0x00d80000~0x00dfffff  ............fedc  ──  ............fedc
   267:   //
   268:   MMD_GE0 {
   269:     @Override public String toString () {
   270:       return Multilingual.mlnJapanese ? "グラフィックス画面 (512 ドット 16 色 ページ 0)" : "Graphics Screen (512 dots 16 colors page 0)";
   271:     }
   272:     //ピーク
   273:     @Override protected byte mmdPbs (int a) {
   274:       a &= XEiJ.BUS_MOTHER_MASK;
   275:       return MainMemory.mmrM8[a];
   276:     }
   277:     @Override protected int mmdPbz (int a) {
   278:       a &= XEiJ.BUS_MOTHER_MASK;
   279:       return MainMemory.mmrM8[a];
   280:     }
   281:     @Override protected int mmdPws (int a) {
   282:       a &= XEiJ.BUS_MOTHER_MASK;
   283:       return MainMemory.mmrM8[a + 1];
   284:     }
   285:     @Override protected int mmdPwz (int a) {
   286:       a &= XEiJ.BUS_MOTHER_MASK;
   287:       return MainMemory.mmrM8[a + 1];
   288:     }
   289:     @Override protected int mmdPls (int a) {
   290:       a &= XEiJ.BUS_MOTHER_MASK;
   291:       return MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 3];
   292:     }
   293:     //リード
   294:     @Override protected byte mmdRbs (int a) throws M68kException {
   295:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   296:        a &= XEiJ.BUS_MOTHER_MASK;
   297:        return MainMemory.mmrM8[a];
   298:      }
   299:     @Override protected int mmdRbz (int a) throws M68kException {
   300:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   301:        a &= XEiJ.BUS_MOTHER_MASK;
   302:        return MainMemory.mmrM8[a];
   303:      }
   304:     @Override protected int mmdRws (int a) throws M68kException {
   305:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   306:        a &= XEiJ.BUS_MOTHER_MASK;
   307:        return MainMemory.mmrM8[a + 1];
   308:      }
   309:     @Override protected int mmdRwz (int a) throws M68kException {
   310:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   311:        a &= XEiJ.BUS_MOTHER_MASK;
   312:        return MainMemory.mmrM8[a + 1];
   313:      }
   314:     @Override protected int mmdRls (int a) throws M68kException {
   315:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   316:        a &= XEiJ.BUS_MOTHER_MASK;
   317:        return MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 3];
   318:      }
   319:     //ライト
   320:     @Override protected void mmdWb (int a, int d) throws M68kException {
   321:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   322:        a &= XEiJ.BUS_MOTHER_MASK;
   323:        if (XEiJ.TEST_BIT_0_SHIFT ? a << 31 - 0 < 0 : (a & 1) != 0) {
   324:          MainMemory.mmrM8[a] = (byte) (d          & 15);
   325:          int y = (a >> 10) - CRTC.crtR13GrYCurr[0] & 511;
   326:          CRTC.crtRasterStamp[y      ] = 0;
   327:          CRTC.crtRasterStamp[y + 512] = 0;
   328:        }
   329:      }
   330:     @Override protected void mmdWw (int a, int d) throws M68kException {
   331:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   332:        a &= XEiJ.BUS_MOTHER_MASK;
   333:        MainMemory.mmrM8[a + 1] = (byte) (d          & 15);
   334:        int y = (a >> 10) - CRTC.crtR13GrYCurr[0] & 511;
   335:        CRTC.crtRasterStamp[y      ] = 0;
   336:        CRTC.crtRasterStamp[y + 512] = 0;
   337:      }
   338:     @Override protected void mmdWl (int a, int d) throws M68kException {
   339:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   340:        a &= XEiJ.BUS_MOTHER_MASK;
   341:        MainMemory.mmrM8[a + 1] = (byte) (d << 12  >>> 28);
   342:        MainMemory.mmrM8[a + 3] = (byte) (d          & 15);
   343:        int y = (a >> 10) - CRTC.crtR13GrYCurr[0] & 511;
   344:        CRTC.crtRasterStamp[y      ] = 0;
   345:        CRTC.crtRasterStamp[y + 512] = 0;
   346:      }
   347:   },  //MMD_GE0
   348: 
   349:   //--------------------------------------------------------------------------------
   350:   //MMD_GE1 グラフィックス画面(512ドット16色ページ1)
   351:   //
   352:   //  512ドット16色
   353:   //                アドレス             アクセス                  格納
   354:   //    GE0  0x00c00000~0x00c7ffff  ............3210  ──  ............3210
   355:   //    GE1  0x00c80000~0x00cfffff  ............7654  ──  ............7654
   356:   //    GE2  0x00d00000~0x00d7ffff  ............ba98  ──  ............ba98
   357:   //    GE3  0x00d80000~0x00dfffff  ............fedc  ──  ............fedc
   358:   //
   359:   MMD_GE1 {
   360:     @Override public String toString () {
   361:       return Multilingual.mlnJapanese ? "グラフィックス画面 (512 ドット 16 色 ページ 1)" : "Graphics Screen (512 dots 16 colors page 1)";
   362:     }
   363:     //ピーク
   364:     @Override protected byte mmdPbs (int a) {
   365:       a &= XEiJ.BUS_MOTHER_MASK;
   366:       return MainMemory.mmrM8[a];
   367:     }
   368:     @Override protected int mmdPbz (int a) {
   369:       a &= XEiJ.BUS_MOTHER_MASK;
   370:       return MainMemory.mmrM8[a];
   371:     }
   372:     @Override protected int mmdPws (int a) {
   373:       a &= XEiJ.BUS_MOTHER_MASK;
   374:       return MainMemory.mmrM8[a + 1];
   375:     }
   376:     @Override protected int mmdPwz (int a) {
   377:       a &= XEiJ.BUS_MOTHER_MASK;
   378:       return MainMemory.mmrM8[a + 1];
   379:     }
   380:     @Override protected int mmdPls (int a) {
   381:       a &= XEiJ.BUS_MOTHER_MASK;
   382:       return MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 3];
   383:     }
   384:     //リード
   385:     @Override protected byte mmdRbs (int a) throws M68kException {
   386:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   387:        a &= XEiJ.BUS_MOTHER_MASK;
   388:        return MainMemory.mmrM8[a];
   389:      }
   390:     @Override protected int mmdRbz (int a) throws M68kException {
   391:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   392:        a &= XEiJ.BUS_MOTHER_MASK;
   393:        return MainMemory.mmrM8[a];
   394:      }
   395:     @Override protected int mmdRws (int a) throws M68kException {
   396:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   397:        a &= XEiJ.BUS_MOTHER_MASK;
   398:        return MainMemory.mmrM8[a + 1];
   399:      }
   400:     @Override protected int mmdRwz (int a) throws M68kException {
   401:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   402:        a &= XEiJ.BUS_MOTHER_MASK;
   403:        return MainMemory.mmrM8[a + 1];
   404:      }
   405:     @Override protected int mmdRls (int a) throws M68kException {
   406:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   407:        a &= XEiJ.BUS_MOTHER_MASK;
   408:        return MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 3];
   409:      }
   410:     //ライト
   411:     @Override protected void mmdWb (int a, int d) throws M68kException {
   412:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   413:        a &= XEiJ.BUS_MOTHER_MASK;
   414:        if (XEiJ.TEST_BIT_0_SHIFT ? a << 31 - 0 < 0 : (a & 1) != 0) {
   415:          MainMemory.mmrM8[a] = (byte) (d          & 15);
   416:          int y = (a >> 10) - CRTC.crtR13GrYCurr[1] & 511;
   417:          CRTC.crtRasterStamp[y      ] = 0;
   418:          CRTC.crtRasterStamp[y + 512] = 0;
   419:        }
   420:      }
   421:     @Override protected void mmdWw (int a, int d) throws M68kException {
   422:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   423:        a &= XEiJ.BUS_MOTHER_MASK;
   424:        MainMemory.mmrM8[a + 1] = (byte) (d          & 15);
   425:        int y = (a >> 10) - CRTC.crtR13GrYCurr[1] & 511;
   426:        CRTC.crtRasterStamp[y      ] = 0;
   427:        CRTC.crtRasterStamp[y + 512] = 0;
   428:      }
   429:     @Override protected void mmdWl (int a, int d) throws M68kException {
   430:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   431:        a &= XEiJ.BUS_MOTHER_MASK;
   432:        MainMemory.mmrM8[a + 1] = (byte) (d << 12  >>> 28);
   433:        MainMemory.mmrM8[a + 3] = (byte) (d          & 15);
   434:        int y = (a >> 10) - CRTC.crtR13GrYCurr[1] & 511;
   435:        CRTC.crtRasterStamp[y      ] = 0;
   436:        CRTC.crtRasterStamp[y + 512] = 0;
   437:      }
   438:   },  //MMD_GE1
   439: 
   440:   //--------------------------------------------------------------------------------
   441:   //MMD_GE2 グラフィックス画面(512ドット16色ページ2)
   442:   //
   443:   //  512ドット16色
   444:   //                アドレス             アクセス                  格納
   445:   //    GE0  0x00c00000~0x00c7ffff  ............3210  ──  ............3210
   446:   //    GE1  0x00c80000~0x00cfffff  ............7654  ──  ............7654
   447:   //    GE2  0x00d00000~0x00d7ffff  ............ba98  ──  ............ba98
   448:   //    GE3  0x00d80000~0x00dfffff  ............fedc  ──  ............fedc
   449:   //
   450:   MMD_GE2 {
   451:     @Override public String toString () {
   452:       return Multilingual.mlnJapanese ? "グラフィックス画面 (512 ドット 16 色 ページ 2)" : "Graphics Screen (512 dots 16 colors page 2)";
   453:     }
   454:     //ピーク
   455:     @Override protected byte mmdPbs (int a) {
   456:       a &= XEiJ.BUS_MOTHER_MASK;
   457:       return MainMemory.mmrM8[a];
   458:     }
   459:     @Override protected int mmdPbz (int a) {
   460:       a &= XEiJ.BUS_MOTHER_MASK;
   461:       return MainMemory.mmrM8[a];
   462:     }
   463:     @Override protected int mmdPws (int a) {
   464:       a &= XEiJ.BUS_MOTHER_MASK;
   465:       return MainMemory.mmrM8[a + 1];
   466:     }
   467:     @Override protected int mmdPwz (int a) {
   468:       a &= XEiJ.BUS_MOTHER_MASK;
   469:       return MainMemory.mmrM8[a + 1];
   470:     }
   471:     @Override protected int mmdPls (int a) {
   472:       a &= XEiJ.BUS_MOTHER_MASK;
   473:       return MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 3];
   474:     }
   475:     //リード
   476:     @Override protected byte mmdRbs (int a) throws M68kException {
   477:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   478:        a &= XEiJ.BUS_MOTHER_MASK;
   479:        return MainMemory.mmrM8[a];
   480:      }
   481:     @Override protected int mmdRbz (int a) throws M68kException {
   482:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   483:        a &= XEiJ.BUS_MOTHER_MASK;
   484:        return MainMemory.mmrM8[a];
   485:      }
   486:     @Override protected int mmdRws (int a) throws M68kException {
   487:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   488:        a &= XEiJ.BUS_MOTHER_MASK;
   489:        return MainMemory.mmrM8[a + 1];
   490:      }
   491:     @Override protected int mmdRwz (int a) throws M68kException {
   492:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   493:        a &= XEiJ.BUS_MOTHER_MASK;
   494:        return MainMemory.mmrM8[a + 1];
   495:      }
   496:     @Override protected int mmdRls (int a) throws M68kException {
   497:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   498:        a &= XEiJ.BUS_MOTHER_MASK;
   499:        return MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 3];
   500:      }
   501:     //ライト
   502:     @Override protected void mmdWb (int a, int d) throws M68kException {
   503:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   504:        a &= XEiJ.BUS_MOTHER_MASK;
   505:        if (XEiJ.TEST_BIT_0_SHIFT ? a << 31 - 0 < 0 : (a & 1) != 0) {
   506:          MainMemory.mmrM8[a] = (byte) (d          & 15);
   507:          int y = (a >> 10) - CRTC.crtR13GrYCurr[2] & 511;
   508:          CRTC.crtRasterStamp[y      ] = 0;
   509:          CRTC.crtRasterStamp[y + 512] = 0;
   510:        }
   511:      }
   512:     @Override protected void mmdWw (int a, int d) throws M68kException {
   513:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   514:        a &= XEiJ.BUS_MOTHER_MASK;
   515:        MainMemory.mmrM8[a + 1] = (byte) (d          & 15);
   516:        int y = (a >> 10) - CRTC.crtR13GrYCurr[2] & 511;
   517:        CRTC.crtRasterStamp[y      ] = 0;
   518:        CRTC.crtRasterStamp[y + 512] = 0;
   519:      }
   520:     @Override protected void mmdWl (int a, int d) throws M68kException {
   521:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   522:        a &= XEiJ.BUS_MOTHER_MASK;
   523:        MainMemory.mmrM8[a + 1] = (byte) (d << 12  >>> 28);
   524:        MainMemory.mmrM8[a + 3] = (byte) (d          & 15);
   525:        int y = (a >> 10) - CRTC.crtR13GrYCurr[2] & 511;
   526:        CRTC.crtRasterStamp[y      ] = 0;
   527:        CRTC.crtRasterStamp[y + 512] = 0;
   528:      }
   529:   },  //MMD_GE2
   530: 
   531:   //--------------------------------------------------------------------------------
   532:   //MMD_GE3 グラフィックス画面(512ドット16色ページ3)
   533:   //
   534:   //  512ドット16色
   535:   //                アドレス             アクセス                  格納
   536:   //    GE0  0x00c00000~0x00c7ffff  ............3210  ──  ............3210
   537:   //    GE1  0x00c80000~0x00cfffff  ............7654  ──  ............7654
   538:   //    GE2  0x00d00000~0x00d7ffff  ............ba98  ──  ............ba98
   539:   //    GE3  0x00d80000~0x00dfffff  ............fedc  ──  ............fedc
   540:   //
   541:   MMD_GE3 {
   542:     @Override public String toString () {
   543:       return Multilingual.mlnJapanese ? "グラフィックス画面 (512 ドット 16 色 ページ 3)" : "Graphics Screen (512 dots 16 colors page 3)";
   544:     }
   545:     //ピーク
   546:     @Override protected byte mmdPbs (int a) {
   547:       a &= XEiJ.BUS_MOTHER_MASK;
   548:       return MainMemory.mmrM8[a];
   549:     }
   550:     @Override protected int mmdPbz (int a) {
   551:       a &= XEiJ.BUS_MOTHER_MASK;
   552:       return MainMemory.mmrM8[a];
   553:     }
   554:     @Override protected int mmdPws (int a) {
   555:       a &= XEiJ.BUS_MOTHER_MASK;
   556:       return MainMemory.mmrM8[a + 1];
   557:     }
   558:     @Override protected int mmdPwz (int a) {
   559:       a &= XEiJ.BUS_MOTHER_MASK;
   560:       return MainMemory.mmrM8[a + 1];
   561:     }
   562:     @Override protected int mmdPls (int a) {
   563:       a &= XEiJ.BUS_MOTHER_MASK;
   564:       return MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 3];
   565:     }
   566:     //リード
   567:     @Override protected byte mmdRbs (int a) throws M68kException {
   568:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   569:        a &= XEiJ.BUS_MOTHER_MASK;
   570:        return MainMemory.mmrM8[a];
   571:      }
   572:     @Override protected int mmdRbz (int a) throws M68kException {
   573:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   574:        a &= XEiJ.BUS_MOTHER_MASK;
   575:        return MainMemory.mmrM8[a];
   576:      }
   577:     @Override protected int mmdRws (int a) throws M68kException {
   578:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   579:        a &= XEiJ.BUS_MOTHER_MASK;
   580:        return MainMemory.mmrM8[a + 1];
   581:      }
   582:     @Override protected int mmdRwz (int a) throws M68kException {
   583:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   584:        a &= XEiJ.BUS_MOTHER_MASK;
   585:        return MainMemory.mmrM8[a + 1];
   586:      }
   587:     @Override protected int mmdRls (int a) throws M68kException {
   588:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   589:        a &= XEiJ.BUS_MOTHER_MASK;
   590:        return MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 3];
   591:      }
   592:     //ライト
   593:     @Override protected void mmdWb (int a, int d) throws M68kException {
   594:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   595:        a &= XEiJ.BUS_MOTHER_MASK;
   596:        if (XEiJ.TEST_BIT_0_SHIFT ? a << 31 - 0 < 0 : (a & 1) != 0) {
   597:          MainMemory.mmrM8[a] = (byte) (d          & 15);
   598:          int y = (a >> 10) - CRTC.crtR13GrYCurr[3] & 511;
   599:          CRTC.crtRasterStamp[y      ] = 0;
   600:          CRTC.crtRasterStamp[y + 512] = 0;
   601:        }
   602:      }
   603:     @Override protected void mmdWw (int a, int d) throws M68kException {
   604:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   605:        a &= XEiJ.BUS_MOTHER_MASK;
   606:        MainMemory.mmrM8[a + 1] = (byte) (d          & 15);
   607:        int y = (a >> 10) - CRTC.crtR13GrYCurr[3] & 511;
   608:        CRTC.crtRasterStamp[y      ] = 0;
   609:        CRTC.crtRasterStamp[y + 512] = 0;
   610:      }
   611:     @Override protected void mmdWl (int a, int d) throws M68kException {
   612:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   613:        a &= XEiJ.BUS_MOTHER_MASK;
   614:        MainMemory.mmrM8[a + 1] = (byte) (d << 12  >>> 28);
   615:        MainMemory.mmrM8[a + 3] = (byte) (d          & 15);
   616:        int y = (a >> 10) - CRTC.crtR13GrYCurr[3] & 511;
   617:        CRTC.crtRasterStamp[y      ] = 0;
   618:        CRTC.crtRasterStamp[y + 512] = 0;
   619:      }
   620:   },  //MMD_GE3
   621: 
   622:   //--------------------------------------------------------------------------------
   623:   //MMD_GF0 グラフィックス画面(512ドット256色ページ0)
   624:   //
   625:   //  512ドット256色
   626:   //                アドレス             アクセス                  格納
   627:   //    GF0  0x00c00000~0x00c7ffff  ........76543210  ─┬  ............3210
   628:   //    GF1  0x00c80000~0x00cfffff  ........fedcba98  ┐└  ............7654
   629:   //         0x00d00000~0x00d7ffff                    ├─  ............ba98
   630:   //         0x00d80000~0x00dfffff                    └─  ............fedc
   631:   //
   632:   MMD_GF0 {
   633:     @Override public String toString () {
   634:       return Multilingual.mlnJapanese ? "グラフィックス画面 (512 ドット 256 色 ページ 0)" : "Graphics Screen (512 dots 256 colors page 0)";
   635:     }
   636:     //ピーク
   637:     @Override protected byte mmdPbs (int a) {
   638:       a &= XEiJ.BUS_MOTHER_MASK;
   639:       return (byte) (MainMemory.mmrM8[a + 0x00080000] << 4 | MainMemory.mmrM8[a]);
   640:     }
   641:     @Override protected int mmdPbz (int a) {
   642:       a &= XEiJ.BUS_MOTHER_MASK;
   643:       return MainMemory.mmrM8[a + 0x00080000] << 4 | MainMemory.mmrM8[a];
   644:     }
   645:     @Override protected int mmdPws (int a) {
   646:       a &= XEiJ.BUS_MOTHER_MASK;
   647:       return MainMemory.mmrM8[a + 0x00080001] << 4 | MainMemory.mmrM8[a + 1];
   648:     }
   649:     @Override protected int mmdPwz (int a) {
   650:       a &= XEiJ.BUS_MOTHER_MASK;
   651:       return MainMemory.mmrM8[a + 0x00080001] << 4 | MainMemory.mmrM8[a + 1];
   652:     }
   653:     @Override protected int mmdPls (int a) {
   654:       a &= XEiJ.BUS_MOTHER_MASK;
   655:       return MainMemory.mmrM8[a + 0x00080001] << 20 | MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 0x00080003] << 4 | MainMemory.mmrM8[a + 3];
   656:     }
   657:     //リード
   658:     @Override protected byte mmdRbs (int a) throws M68kException {
   659:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   660:        a &= XEiJ.BUS_MOTHER_MASK;
   661:        return (byte) (MainMemory.mmrM8[a + 0x00080000] << 4 | MainMemory.mmrM8[a]);
   662:      }
   663:     @Override protected int mmdRbz (int a) throws M68kException {
   664:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   665:        a &= XEiJ.BUS_MOTHER_MASK;
   666:        return MainMemory.mmrM8[a + 0x00080000] << 4 | MainMemory.mmrM8[a];
   667:      }
   668:     @Override protected int mmdRws (int a) throws M68kException {
   669:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   670:        a &= XEiJ.BUS_MOTHER_MASK;
   671:        return MainMemory.mmrM8[a + 0x00080001] << 4 | MainMemory.mmrM8[a + 1];
   672:      }
   673:     @Override protected int mmdRwz (int a) throws M68kException {
   674:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   675:        a &= XEiJ.BUS_MOTHER_MASK;
   676:        return MainMemory.mmrM8[a + 0x00080001] << 4 | MainMemory.mmrM8[a + 1];
   677:      }
   678:     @Override protected int mmdRls (int a) throws M68kException {
   679:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   680:        a &= XEiJ.BUS_MOTHER_MASK;
   681:        return MainMemory.mmrM8[a + 0x00080001] << 20 | MainMemory.mmrM8[a + 1] << 16 | MainMemory.mmrM8[a + 0x00080003] << 4 | MainMemory.mmrM8[a + 3];
   682:      }
   683:     //ライト
   684:     @Override protected void mmdWb (int a, int d) throws M68kException {
   685:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   686:        a &= XEiJ.BUS_MOTHER_MASK;
   687:        if (XEiJ.TEST_BIT_0_SHIFT ? a << 31 - 0 < 0 : (a & 1) != 0) {
   688:          MainMemory.mmrM8[a + 0x00080000] = (byte) (d << 24  >>> 28);
   689:          MainMemory.mmrM8[a             ] = (byte) (d          & 15);
   690:          a >>= 10;
   691:          int y = a - CRTC.crtR13GrYCurr[0] & 511;
   692:          CRTC.crtRasterStamp[y      ] = 0;
   693:          CRTC.crtRasterStamp[y + 512] = 0;
   694:          y = a - CRTC.crtR13GrYCurr[1] & 511;
   695:          CRTC.crtRasterStamp[y      ] = 0;
   696:          CRTC.crtRasterStamp[y + 512] = 0;
   697:        }
   698:      }
   699:     @Override protected void mmdWw (int a, int d) throws M68kException {
   700:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   701:        a &= XEiJ.BUS_MOTHER_MASK;
   702:        MainMemory.mmrM8[a + 0x00080001] = (byte) (d << 24  >>> 28);
   703:        MainMemory.mmrM8[a + 0x00000001] = (byte) (d          & 15);
   704:        a >>= 10;
   705:        int y = a - CRTC.crtR13GrYCurr[0] & 511;
   706:        CRTC.crtRasterStamp[y      ] = 0;
   707:        CRTC.crtRasterStamp[y + 512] = 0;
   708:        y = a - CRTC.crtR13GrYCurr[1] & 511;
   709:        CRTC.crtRasterStamp[y      ] = 0;
   710:        CRTC.crtRasterStamp[y + 512] = 0;
   711:      }
   712:     @Override protected void mmdWl (int a, int d) throws M68kException {
   713:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   714:        a &= XEiJ.BUS_MOTHER_MASK;
   715:        MainMemory.mmrM8[a + 0x00080001] = (byte) (d <<  8  >>> 28);
   716:        MainMemory.mmrM8[a + 0x00000001] = (byte) (d << 12  >>> 28);
   717:        MainMemory.mmrM8[a + 0x00080003] = (byte) (d << 24  >>> 28);
   718:        MainMemory.mmrM8[a + 0x00000003] = (byte) (d          & 15);
   719:        a >>= 10;
   720:        int y = a - CRTC.crtR13GrYCurr[0] & 511;
   721:        CRTC.crtRasterStamp[y      ] = 0;
   722:        CRTC.crtRasterStamp[y + 512] = 0;
   723:        y = a - CRTC.crtR13GrYCurr[1] & 511;
   724:        CRTC.crtRasterStamp[y      ] = 0;
   725:        CRTC.crtRasterStamp[y + 512] = 0;
   726:      }
   727:   },  //MMD_GF0
   728: 
   729:   //--------------------------------------------------------------------------------
   730:   //MMD_GF1 グラフィックス画面(512ドット256色ページ1)
   731:   //
   732:   //  512ドット256色
   733:   //                アドレス             アクセス                  格納
   734:   //    GF0  0x00c00000~0x00c7ffff  ........76543210  ─┬  ............3210
   735:   //    GF1  0x00c80000~0x00cfffff  ........fedcba98  ┐└  ............7654
   736:   //         0x00d00000~0x00d7ffff                    ├─  ............ba98
   737:   //         0x00d80000~0x00dfffff                    └─  ............fedc
   738:   //
   739:   MMD_GF1 {
   740:     @Override public String toString () {
   741:       return Multilingual.mlnJapanese ? "グラフィックス画面 (512 ドット 256 色 ページ 1)" : "Graphics Screen (512 dots 256 colors page 1)";
   742:     }
   743:     //ピーク
   744:     @Override protected byte mmdPbs (int a) {
   745:       a &= XEiJ.BUS_MOTHER_MASK;
   746:       return (byte) (MainMemory.mmrM8[a + 0x00100000] << 4 | MainMemory.mmrM8[a + 0x00080000]);
   747:     }
   748:     @Override protected int mmdPbz (int a) {
   749:       a &= XEiJ.BUS_MOTHER_MASK;
   750:       return MainMemory.mmrM8[a + 0x00100000] << 4 | MainMemory.mmrM8[a + 0x00080000];
   751:     }
   752:     @Override protected int mmdPws (int a) {
   753:       a &= XEiJ.BUS_MOTHER_MASK;
   754:       return MainMemory.mmrM8[a + 0x00100001] << 4 | MainMemory.mmrM8[a + 0x00080001];
   755:     }
   756:     @Override protected int mmdPwz (int a) {
   757:       a &= XEiJ.BUS_MOTHER_MASK;
   758:       return MainMemory.mmrM8[a + 0x00100001] << 4 | MainMemory.mmrM8[a + 0x00080001];
   759:     }
   760:     @Override protected int mmdPls (int a) {
   761:       a &= XEiJ.BUS_MOTHER_MASK;
   762:       return MainMemory.mmrM8[a + 0x00100001] << 20 | MainMemory.mmrM8[a + 0x00080001] << 16 | MainMemory.mmrM8[a + 0x00100003] << 4 | MainMemory.mmrM8[a + 0x00080003];
   763:     }
   764:     //リード
   765:     @Override protected byte mmdRbs (int a) throws M68kException {
   766:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   767:        a &= XEiJ.BUS_MOTHER_MASK;
   768:        return (byte) (MainMemory.mmrM8[a + 0x00100000] << 4 | MainMemory.mmrM8[a + 0x00080000]);
   769:      }
   770:     @Override protected int mmdRbz (int a) throws M68kException {
   771:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   772:        a &= XEiJ.BUS_MOTHER_MASK;
   773:        return MainMemory.mmrM8[a + 0x00100000] << 4 | MainMemory.mmrM8[a + 0x00080000];
   774:      }
   775:     @Override protected int mmdRws (int a) throws M68kException {
   776:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   777:        a &= XEiJ.BUS_MOTHER_MASK;
   778:        return MainMemory.mmrM8[a + 0x00100001] << 4 | MainMemory.mmrM8[a + 0x00080001];
   779:      }
   780:     @Override protected int mmdRwz (int a) throws M68kException {
   781:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   782:        a &= XEiJ.BUS_MOTHER_MASK;
   783:        return MainMemory.mmrM8[a + 0x00100001] << 4 | MainMemory.mmrM8[a + 0x00080001];
   784:      }
   785:     @Override protected int mmdRls (int a) throws M68kException {
   786:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   787:        a &= XEiJ.BUS_MOTHER_MASK;
   788:        return MainMemory.mmrM8[a + 0x00100001] << 20 | MainMemory.mmrM8[a + 0x00080001] << 16 | MainMemory.mmrM8[a + 0x00100003] << 4 | MainMemory.mmrM8[a + 0x00080003];
   789:      }
   790:     //ライト
   791:     @Override protected void mmdWb (int a, int d) throws M68kException {
   792:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   793:        a &= XEiJ.BUS_MOTHER_MASK;
   794:        if (XEiJ.TEST_BIT_0_SHIFT ? a << 31 - 0 < 0 : (a & 1) != 0) {
   795:          MainMemory.mmrM8[a + 0x00100000] = (byte) (d << 24  >>> 28);
   796:          MainMemory.mmrM8[a + 0x00080000] = (byte) (d          & 15);
   797:          a >>= 10;
   798:          int y = a - CRTC.crtR13GrYCurr[2] & 511;
   799:          CRTC.crtRasterStamp[y      ] = 0;
   800:          CRTC.crtRasterStamp[y + 512] = 0;
   801:          y = a - CRTC.crtR13GrYCurr[3] & 511;
   802:          CRTC.crtRasterStamp[y      ] = 0;
   803:          CRTC.crtRasterStamp[y + 512] = 0;
   804:        }
   805:      }
   806:     @Override protected void mmdWw (int a, int d) throws M68kException {
   807:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   808:        a &= XEiJ.BUS_MOTHER_MASK;
   809:        MainMemory.mmrM8[a + 0x00100001] = (byte) (d << 24  >>> 28);
   810:        MainMemory.mmrM8[a + 0x00080001] = (byte) (d          & 15);
   811:        a >>= 10;
   812:        int y = a - CRTC.crtR13GrYCurr[2] & 511;
   813:        CRTC.crtRasterStamp[y      ] = 0;
   814:        CRTC.crtRasterStamp[y + 512] = 0;
   815:        y = a - CRTC.crtR13GrYCurr[3] & 511;
   816:        CRTC.crtRasterStamp[y      ] = 0;
   817:        CRTC.crtRasterStamp[y + 512] = 0;
   818:      }
   819:     @Override protected void mmdWl (int a, int d) throws M68kException {
   820:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   821:        a &= XEiJ.BUS_MOTHER_MASK;
   822:        MainMemory.mmrM8[a + 0x00100001] = (byte) (d <<  8  >>> 28);
   823:        MainMemory.mmrM8[a + 0x00080001] = (byte) (d << 12  >>> 28);
   824:        MainMemory.mmrM8[a + 0x00100003] = (byte) (d << 24  >>> 28);
   825:        MainMemory.mmrM8[a + 0x00080003] = (byte) (d          & 15);
   826:        a >>= 10;
   827:        int y = a - CRTC.crtR13GrYCurr[2] & 511;
   828:        CRTC.crtRasterStamp[y      ] = 0;
   829:        CRTC.crtRasterStamp[y + 512] = 0;
   830:        y = a - CRTC.crtR13GrYCurr[3] & 511;
   831:        CRTC.crtRasterStamp[y      ] = 0;
   832:        CRTC.crtRasterStamp[y + 512] = 0;
   833:      }
   834:   },  //MMD_GF1
   835: 
   836:   //--------------------------------------------------------------------------------
   837:   //MMD_GM2 グラフィックス画面(メモリモード2)
   838:   //
   839:   //  バイトリード
   840:   //    0x00c00000  0x00が読み出される
   841:   //    0x00c00001  4bitページ1-0が読み出される
   842:   //    0x00c80000  0x00が読み出される
   843:   //    0x00c80001  0x00が読み出される
   844:   //    0x00d00000  0x00が読み出される
   845:   //    0x00d00001  4bitページ1-0が読み出される
   846:   //    0x00d80000  0x00が読み出される
   847:   //    0x00d80001  0x00が読み出される
   848:   //
   849:   //  ワードリード
   850:   //    0x00c00000  上位バイトは0x00で下位バイトに4bitページ1-0が読み出される
   851:   //    0x00c80000  上位バイトは0x00で下位バイトに4bitページ3-2が読み出される
   852:   //    0x00d00000  上位バイトは0x00で下位バイトに4bitページ1-0が読み出される
   853:   //    0x00d80000  上位バイトは0x00で下位バイトに4bitページ3-2が読み出される
   854:   //
   855:   //  バイトライト
   856:   //    0x00c00000  060turboの060モードのときデータは無視され0x00が4bitページ3-2に書き込まれる。それ以外はデータが4bitページ3-2に書き込まれる
   857:   //    0x00c00001  データが4bitページ1-0に書き込まれる
   858:   //    0x00c80000  060turboの060モードのときデータは無視され0x00が4bitページ3-2に書き込まれる。それ以外はデータが4bitページ3-2に書き込まれる
   859:   //    0x00c80001  データが4bitページ1-0に書き込まれる
   860:   //    0x00d00000  060turboの060モードのときデータは無視され0x00が4bitページ3-2に書き込まれる。それ以外はデータが4bitページ3-2に書き込まれる
   861:   //    0x00d00001  データが4bitページ1-0に書き込まれる
   862:   //    0x00d80000  060turboの060モードのときデータは無視され0x00が4bitページ3-2に書き込まれる。それ以外はデータが4bitページ3-2に書き込まれる
   863:   //    0x00d80001  データが4bitページ1-0に書き込まれる
   864:   //
   865:   //  ワードライト
   866:   //    0x00c00000  上位バイトは無視され下位バイトが4bitページ3-2と4bitページ1-0の両方に書き込まれる
   867:   //    0x00c80000  上位バイトは無視され下位バイトが4bitページ3-2と4bitページ1-0の両方に書き込まれる
   868:   //    0x00d00000  上位バイトは無視され下位バイトが4bitページ3-2と4bitページ1-0の両方に書き込まれる
   869:   //    0x00d80000  上位バイトは無視され下位バイトが4bitページ3-2と4bitページ1-0の両方に書き込まれる
   870:   //
   871:   MMD_GM2 {
   872:     @Override public String toString () {
   873:       return Multilingual.mlnJapanese ? "グラフィックス画面 (メモリモード 2)" : "Graphics Screen (memory mode 2)";
   874:     }
   875:     //ピーク
   876:     @Override protected byte mmdPbs (int a) {
   877:       if ((a & 0x00080001) == 0x00000001) {  //0x00c00000..0x00c7ffff,0x00d00000..0x00d7ffffかつ下位バイト
   878:         a &= 0x00c7fffe;
   879:         return (byte) (MainMemory.mmrM8[0x00080001 + a] << 4 |  //4bitページ1
   880:                        MainMemory.mmrM8[0x00000001 + a]);  //4bitページ0
   881:       } else {  //0x00c80000..0x00cfffff,0x00d80000..0x00dfffffまたは上位バイト
   882:         return 0x00;
   883:       }
   884:     }
   885:     @Override protected int mmdPbz (int a) {
   886:       if ((a & 0x00080001) == 0x00000001) {  //0x00c00000..0x00c7ffff,0x00d00000..0x00d7ffffかつ下位バイト
   887:         a &= 0x00c7fffe;
   888:         return (byte) (MainMemory.mmrM8[0x00080001 + a] << 4 |  //4bitページ1
   889:                        MainMemory.mmrM8[0x00000001 + a]);  //4bitページ0
   890:       } else {  //0x00c80000..0x00cfffff,0x00d80000..0x00dfffffまたは上位バイト
   891:         return 0x00;
   892:       }
   893:     }
   894:     @Override protected int mmdPws (int a) {
   895:       if ((a & 0x00080000) == 0x00000000) {  //0x00c00000..0x00c7ffff,0x00d00000..0x00d7ffff
   896:         a &= 0x00c7fffe;
   897:         return (MainMemory.mmrM8[0x00080001 + a] << 4 |  //4bitページ1
   898:                 MainMemory.mmrM8[0x00000001 + a]);  //4bitページ0
   899:       } else {  //0x00c80000..0x00cfffff,0x00d80000..0x00dfffff
   900:         a &= 0x00c7fffe;
   901:         return (MainMemory.mmrM8[0x00180001 + a] << 4 |  //4bitページ3
   902:                 MainMemory.mmrM8[0x00100001 + a]);  //4bitページ2
   903:       }
   904:     }
   905:     @Override protected int mmdPwz (int a) {
   906:       if ((a & 0x00080000) == 0x00000000) {  //0x00c00000..0x00c7ffff,0x00d00000..0x00d7ffff
   907:         a &= 0x00c7fffe;
   908:         return (MainMemory.mmrM8[0x00080001 + a] << 4 |  //4bitページ1
   909:                 MainMemory.mmrM8[0x00000001 + a]);  //4bitページ0
   910:       } else {  //0x00c80000..0x00cfffff,0x00d80000..0x00dfffff
   911:         a &= 0x00c7fffe;
   912:         return (MainMemory.mmrM8[0x00180001 + a] << 4 |  //4bitページ3
   913:                 MainMemory.mmrM8[0x00100001 + a]);  //4bitページ2
   914:       }
   915:     }
   916:     @Override protected int mmdPls (int a) {
   917:       a &= 0x00d7fffe;
   918:       return (MainMemory.mmrM8[0x00080001 + a] << 20 |  //4bitページ1,3
   919:               MainMemory.mmrM8[0x00000001 + a] << 16 |  //4bitページ0,2
   920:               MainMemory.mmrM8[0x00080003 + a] <<  4 |  //4bitページ1,3
   921:               MainMemory.mmrM8[0x00000003 + a]);  //4bitページ0,2
   922:     }
   923:     //リード
   924:     @Override protected byte mmdRbs (int a) throws M68kException {
   925:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   926:        if ((a & 0x00080001) == 0x00000001) {  //0x00c00000..0x00c7ffff,0x00d00000..0x00d7ffffかつ下位バイト
   927:          a &= 0x00c7fffe;
   928:          return (byte) (MainMemory.mmrM8[0x00080001 + a] << 4 |  //4bitページ1
   929:                         MainMemory.mmrM8[0x00000001 + a]);  //4bitページ0
   930:        } else {  //0x00c80000..0x00cfffff,0x00d80000..0x00dfffffまたは上位バイト
   931:          return 0x00;
   932:        }
   933:      }
   934:     @Override protected int mmdRbz (int a) throws M68kException {
   935:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   936:        if ((a & 0x00080001) == 0x00000001) {  //0x00c00000..0x00c7ffff,0x00d00000..0x00d7ffffかつ下位バイト
   937:          a &= 0x00c7fffe;
   938:          return (byte) (MainMemory.mmrM8[0x00080001 + a] << 4 |  //4bitページ1
   939:                         MainMemory.mmrM8[0x00000001 + a]);  //4bitページ0
   940:        } else {  //0x00c80000..0x00cfffff,0x00d80000..0x00dfffffまたは上位バイト
   941:          return 0x00;
   942:        }
   943:      }
   944:     @Override protected int mmdRws (int a) throws M68kException {
   945:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   946:        if ((a & 0x00080000) == 0x00000000) {  //0x00c00000..0x00c7ffff,0x00d00000..0x00d7ffff
   947:          a &= 0x00c7fffe;
   948:          return (MainMemory.mmrM8[0x00080001 + a] << 4 |  //4bitページ1
   949:                  MainMemory.mmrM8[0x00000001 + a]);  //4bitページ0
   950:        } else {  //0x00c80000..0x00cfffff,0x00d80000..0x00dfffff
   951:          a &= 0x00c7fffe;
   952:          return (MainMemory.mmrM8[0x00180001 + a] << 4 |  //4bitページ3
   953:                  MainMemory.mmrM8[0x00100001 + a]);  //4bitページ2
   954:        }
   955:      }
   956:     @Override protected int mmdRwz (int a) throws M68kException {
   957:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   958:        if ((a & 0x00080000) == 0x00000000) {  //0x00c00000..0x00c7ffff,0x00d00000..0x00d7ffff
   959:          a &= 0x00c7fffe;
   960:          return (MainMemory.mmrM8[0x00080001 + a] << 4 |  //4bitページ1
   961:                  MainMemory.mmrM8[0x00000001 + a]);  //4bitページ0
   962:        } else {  //0x00c80000..0x00cfffff,0x00d80000..0x00dfffff
   963:          a &= 0x00c7fffe;
   964:          return (MainMemory.mmrM8[0x00180001 + a] << 4 |  //4bitページ3
   965:                  MainMemory.mmrM8[0x00100001 + a]);  //4bitページ2
   966:        }
   967:      }
   968:     @Override protected int mmdRls (int a) throws M68kException {
   969:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
   970:        a &= 0x00d7fffe;
   971:        return (MainMemory.mmrM8[0x00080001 + a] << 20 |  //4bitページ1,3
   972:                MainMemory.mmrM8[0x00000001 + a] << 16 |  //4bitページ0,2
   973:                MainMemory.mmrM8[0x00080003 + a] <<  4 |  //4bitページ1,3
   974:                MainMemory.mmrM8[0x00000003 + a]);  //4bitページ0,2
   975:      }
   976:     //ライト
   977:     @Override protected void mmdWb (int a, int d) throws M68kException {
   978:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
   979:        if ((a & 0x00000001) == 0x00000000) {  //上位バイト
   980:          a &= 0x00c7fffe;
   981:          if (XEiJ.currentMPU < Model.MPU_MC68LC040) {
   982:            MainMemory.mmrM8[0x00180001 + a] = (byte) (d >>> 4 & 15);  //4bitページ3
   983:            MainMemory.mmrM8[0x00100001 + a] = (byte) (d       & 15);  //4bitページ2
   984:          } else {
   985:            MainMemory.mmrM8[0x00180001 + a] = 0;  //4bitページ3
   986:            MainMemory.mmrM8[0x00100001 + a] = 0;  //4bitページ2
   987:          }
   988:          a >>>= 10;
   989:          int y = a - CRTC.crtR13GrYCurr[3] & 511;
   990:          CRTC.crtRasterStamp[y      ] = 0;
   991:          CRTC.crtRasterStamp[y + 512] = 0;
   992:          y = a - CRTC.crtR13GrYCurr[2] & 511;
   993:          CRTC.crtRasterStamp[y      ] = 0;
   994:          CRTC.crtRasterStamp[y + 512] = 0;
   995:        } else {  //下位バイト
   996:          a &= 0x00c7fffe;
   997:          MainMemory.mmrM8[0x00080001 + a] = (byte) (d >>> 4 & 15);  //4bitページ1
   998:          MainMemory.mmrM8[0x00000001 + a] = (byte) (d       & 15);  //4bitページ0
   999:          a >>>= 10;
  1000:          int y = a - CRTC.crtR13GrYCurr[1] & 511;
  1001:          CRTC.crtRasterStamp[y      ] = 0;
  1002:          CRTC.crtRasterStamp[y + 512] = 0;
  1003:          y = a - CRTC.crtR13GrYCurr[0] & 511;
  1004:          CRTC.crtRasterStamp[y      ] = 0;
  1005:          CRTC.crtRasterStamp[y + 512] = 0;
  1006:        }
  1007:      }
  1008:     @Override protected void mmdWw (int a, int d) throws M68kException {
  1009:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1010:        a &= 0x00c7fffe;
  1011:        MainMemory.mmrM8[0x00180001 + a] = MainMemory.mmrM8[0x00080001 + a] = (byte) (d >>> 4 & 15);  //4bitページ1,3
  1012:        MainMemory.mmrM8[0x00100001 + a] = MainMemory.mmrM8[0x00000001 + a] = (byte) (d       & 15);  //4bitページ0,2
  1013:        a >>>= 10;
  1014:        int y = a - CRTC.crtR13GrYCurr[3] & 511;
  1015:        CRTC.crtRasterStamp[y      ] = 0;
  1016:        CRTC.crtRasterStamp[y + 512] = 0;
  1017:        y = a - CRTC.crtR13GrYCurr[2] & 511;
  1018:        CRTC.crtRasterStamp[y      ] = 0;
  1019:        CRTC.crtRasterStamp[y + 512] = 0;
  1020:        y = a - CRTC.crtR13GrYCurr[1] & 511;
  1021:        CRTC.crtRasterStamp[y      ] = 0;
  1022:        CRTC.crtRasterStamp[y + 512] = 0;
  1023:        y = a - CRTC.crtR13GrYCurr[0] & 511;
  1024:        CRTC.crtRasterStamp[y      ] = 0;
  1025:        CRTC.crtRasterStamp[y + 512] = 0;
  1026:      }
  1027:     @Override protected void mmdWl (int a, int d) throws M68kException {
  1028:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1029:        a &= 0x00c7fffe;
  1030:        MainMemory.mmrM8[0x00180001 + a] = MainMemory.mmrM8[0x00080001 + a] = (byte) (d >>> 20 & 15);  //ページ1,3
  1031:        MainMemory.mmrM8[0x00100001 + a] = MainMemory.mmrM8[0x00000001 + a] = (byte) (d >>> 16 & 15);  //ページ0,2
  1032:        MainMemory.mmrM8[0x00180003 + a] = MainMemory.mmrM8[0x00080003 + a] = (byte) (d >>>  4 & 15);  //ページ1,3
  1033:        MainMemory.mmrM8[0x00100003 + a] = MainMemory.mmrM8[0x00000003 + a] = (byte) (d        & 15);  //ページ0,2
  1034:        a >>>= 10;
  1035:        int y = a - CRTC.crtR13GrYCurr[3] & 511;
  1036:        CRTC.crtRasterStamp[y      ] = 0;
  1037:        CRTC.crtRasterStamp[y + 512] = 0;
  1038:        y = a - CRTC.crtR13GrYCurr[2] & 511;
  1039:        CRTC.crtRasterStamp[y      ] = 0;
  1040:        CRTC.crtRasterStamp[y + 512] = 0;
  1041:        y = a - CRTC.crtR13GrYCurr[1] & 511;
  1042:        CRTC.crtRasterStamp[y      ] = 0;
  1043:        CRTC.crtRasterStamp[y + 512] = 0;
  1044:        y = a - CRTC.crtR13GrYCurr[0] & 511;
  1045:        CRTC.crtRasterStamp[y      ] = 0;
  1046:        CRTC.crtRasterStamp[y + 512] = 0;
  1047:      }
  1048:   },  //MMD_GM2
  1049: 
  1050:   //--------------------------------------------------------------------------------
  1051:   //MMD_GG0 グラフィックス画面(512ドット65536色)
  1052:   //
  1053:   //  512ドット65536色
  1054:   //                アドレス             アクセス                  格納
  1055:   //    GG0  0x00c00000~0x00c7ffff  fedcba9876543210  ─┬  ............3210
  1056:   //         0x00c80000~0x00cfffff                      ├  ............7654
  1057:   //         0x00d00000~0x00d7ffff                      ├  ............ba98
  1058:   //         0x00d80000~0x00dfffff                      └  ............fedc
  1059:   //
  1060:   MMD_GG0 {
  1061:     @Override public String toString () {
  1062:       return Multilingual.mlnJapanese ? "グラフィックス画面 (512 ドット 65536 色)" : "Graphics Screen (512 dots 65536 colors)";
  1063:     }
  1064:     //ピーク
  1065:     @Override protected byte mmdPbs (int a) {
  1066:       a &= XEiJ.BUS_MOTHER_MASK;
  1067:       a += -(~a & 1) & 0x00100001;
  1068:       return (byte) (MainMemory.mmrM8[a + 0x00080000] << 4 | MainMemory.mmrM8[a]);
  1069:     }
  1070:     @Override protected int mmdPbz (int a) {
  1071:       a &= XEiJ.BUS_MOTHER_MASK;
  1072:       a += -(~a & 1) & 0x00100001;
  1073:       return MainMemory.mmrM8[a + 0x00080000] << 4 | MainMemory.mmrM8[a];
  1074:     }
  1075:     @Override protected int mmdPws (int a) {
  1076:       a &= XEiJ.BUS_MOTHER_MASK;
  1077:       return (short) (MainMemory.mmrM8[a + 0x00180001] << 12 | MainMemory.mmrM8[a + 0x00100001] << 8 | MainMemory.mmrM8[a + 0x00080001] << 4 | MainMemory.mmrM8[a + 1]);
  1078:     }
  1079:     @Override protected int mmdPwz (int a) {
  1080:       a &= XEiJ.BUS_MOTHER_MASK;
  1081:       return MainMemory.mmrM8[a + 0x00180001] << 12 | MainMemory.mmrM8[a + 0x00100001] << 8 | MainMemory.mmrM8[a + 0x00080001] << 4 | MainMemory.mmrM8[a + 1];
  1082:     }
  1083:     @Override protected int mmdPls (int a) {
  1084:       a &= XEiJ.BUS_MOTHER_MASK;
  1085:       return (MainMemory.mmrM8[a + 0x00180001] << 28 | MainMemory.mmrM8[a + 0x00100001] << 24 | MainMemory.mmrM8[a + 0x00080001] << 20 | MainMemory.mmrM8[a + 1] << 16 |
  1086:               MainMemory.mmrM8[a + 0x00180003] << 12 | MainMemory.mmrM8[a + 0x00100003] << 8 | MainMemory.mmrM8[a + 0x00080003] << 4 | MainMemory.mmrM8[a + 3]);
  1087:     }
  1088:     //リード
  1089:     @Override protected byte mmdRbs (int a) throws M68kException {
  1090:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1091:        a &= XEiJ.BUS_MOTHER_MASK;
  1092:        a += -(~a & 1) & 0x00100001;
  1093:        return (byte) (MainMemory.mmrM8[a + 0x00080000] << 4 | MainMemory.mmrM8[a]);
  1094:      }
  1095:     @Override protected int mmdRbz (int a) throws M68kException {
  1096:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1097:        a &= XEiJ.BUS_MOTHER_MASK;
  1098:        a += -(~a & 1) & 0x00100001;
  1099:        return MainMemory.mmrM8[a + 0x00080000] << 4 | MainMemory.mmrM8[a];
  1100:      }
  1101:     @Override protected int mmdRws (int a) throws M68kException {
  1102:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1103:        a &= XEiJ.BUS_MOTHER_MASK;
  1104:        return (short) (MainMemory.mmrM8[a + 0x00180001] << 12 | MainMemory.mmrM8[a + 0x00100001] << 8 | MainMemory.mmrM8[a + 0x00080001] << 4 | MainMemory.mmrM8[a + 1]);
  1105:      }
  1106:     @Override protected int mmdRwz (int a) throws M68kException {
  1107:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1108:        a &= XEiJ.BUS_MOTHER_MASK;
  1109:        return MainMemory.mmrM8[a + 0x00180001] << 12 | MainMemory.mmrM8[a + 0x00100001] << 8 | MainMemory.mmrM8[a + 0x00080001] << 4 | MainMemory.mmrM8[a + 1];
  1110:      }
  1111:     @Override protected int mmdRls (int a) throws M68kException {
  1112:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1113:        a &= XEiJ.BUS_MOTHER_MASK;
  1114:        return (MainMemory.mmrM8[a + 0x00180001] << 28 | MainMemory.mmrM8[a + 0x00100001] << 24 | MainMemory.mmrM8[a + 0x00080001] << 20 | MainMemory.mmrM8[a + 1] << 16 |
  1115:                MainMemory.mmrM8[a + 0x00180003] << 12 | MainMemory.mmrM8[a + 0x00100003] << 8 | MainMemory.mmrM8[a + 0x00080003] << 4 | MainMemory.mmrM8[a + 3]);
  1116:      }
  1117:     //ライト
  1118:     @Override protected void mmdWb (int a, int d) throws M68kException {
  1119:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1120:        a &= XEiJ.BUS_MOTHER_MASK;
  1121:        if (XEiJ.TEST_BIT_0_SHIFT ? a << 31 - 0 >= 0 : (a & 1) == 0) {
  1122:          MainMemory.mmrM8[a + 0x00180001] = (byte) (d << 24  >>> 28);
  1123:          MainMemory.mmrM8[a + 0x00100001] = (byte) (d          & 15);
  1124:          a >>= 10;
  1125:          int y = a - CRTC.crtR13GrYCurr[2] & 511;
  1126:          CRTC.crtRasterStamp[y      ] = 0;
  1127:          CRTC.crtRasterStamp[y + 512] = 0;
  1128:          y = a - CRTC.crtR13GrYCurr[3] & 511;
  1129:          CRTC.crtRasterStamp[y      ] = 0;
  1130:          CRTC.crtRasterStamp[y + 512] = 0;
  1131:        } else {
  1132:          MainMemory.mmrM8[a + 0x00080000] = (byte) (d << 24  >>> 28);
  1133:          MainMemory.mmrM8[a             ] = (byte) (d          & 15);
  1134:          a >>= 10;
  1135:          int y = a - CRTC.crtR13GrYCurr[0] & 511;
  1136:          CRTC.crtRasterStamp[y      ] = 0;
  1137:          CRTC.crtRasterStamp[y + 512] = 0;
  1138:          y = a - CRTC.crtR13GrYCurr[1] & 511;
  1139:          CRTC.crtRasterStamp[y      ] = 0;
  1140:          CRTC.crtRasterStamp[y + 512] = 0;
  1141:        }
  1142:      }
  1143:     @Override protected void mmdWw (int a, int d) throws M68kException {
  1144:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1145:        a &= XEiJ.BUS_MOTHER_MASK;
  1146:        MainMemory.mmrM8[a + 0x00180001] = (byte) ((char) d >>> 12);
  1147:        MainMemory.mmrM8[a + 0x00100001] = (byte) (d << 20  >>> 28);
  1148:        MainMemory.mmrM8[a + 0x00080001] = (byte) (d << 24  >>> 28);
  1149:        MainMemory.mmrM8[a + 0x00000001] = (byte) (d          & 15);
  1150:        a >>= 10;
  1151:        int y = a - CRTC.crtR13GrYCurr[0] & 511;
  1152:        CRTC.crtRasterStamp[y      ] = 0;
  1153:        CRTC.crtRasterStamp[y + 512] = 0;
  1154:        y = a - CRTC.crtR13GrYCurr[1] & 511;
  1155:        CRTC.crtRasterStamp[y      ] = 0;
  1156:        CRTC.crtRasterStamp[y + 512] = 0;
  1157:        y = a - CRTC.crtR13GrYCurr[2] & 511;
  1158:        CRTC.crtRasterStamp[y      ] = 0;
  1159:        CRTC.crtRasterStamp[y + 512] = 0;
  1160:        y = a - CRTC.crtR13GrYCurr[3] & 511;
  1161:        CRTC.crtRasterStamp[y      ] = 0;
  1162:        CRTC.crtRasterStamp[y + 512] = 0;
  1163:      }
  1164:     @Override protected void mmdWl (int a, int d) throws M68kException {
  1165:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1166:        a &= XEiJ.BUS_MOTHER_MASK;
  1167:        MainMemory.mmrM8[a + 0x00180001] = (byte) (d        >>> 28);
  1168:        MainMemory.mmrM8[a + 0x00100001] = (byte) (d <<  4  >>> 28);
  1169:        MainMemory.mmrM8[a + 0x00080001] = (byte) (d <<  8  >>> 28);
  1170:        MainMemory.mmrM8[a + 0x00000001] = (byte) (d << 12  >>> 28);
  1171:        MainMemory.mmrM8[a + 0x00180003] = (byte) ((char) d >>> 12);
  1172:        MainMemory.mmrM8[a + 0x00100003] = (byte) (d << 20  >>> 28);
  1173:        MainMemory.mmrM8[a + 0x00080003] = (byte) (d << 24  >>> 28);
  1174:        MainMemory.mmrM8[a + 0x00000003] = (byte) (d          & 15);
  1175:        a >>= 10;
  1176:        int y = a - CRTC.crtR13GrYCurr[0] & 511;
  1177:        CRTC.crtRasterStamp[y      ] = 0;
  1178:        CRTC.crtRasterStamp[y + 512] = 0;
  1179:        y = a - CRTC.crtR13GrYCurr[1] & 511;
  1180:        CRTC.crtRasterStamp[y      ] = 0;
  1181:        CRTC.crtRasterStamp[y + 512] = 0;
  1182:        y = a - CRTC.crtR13GrYCurr[2] & 511;
  1183:        CRTC.crtRasterStamp[y      ] = 0;
  1184:        CRTC.crtRasterStamp[y + 512] = 0;
  1185:        y = a - CRTC.crtR13GrYCurr[3] & 511;
  1186:        CRTC.crtRasterStamp[y      ] = 0;
  1187:        CRTC.crtRasterStamp[y + 512] = 0;
  1188:      }
  1189:   },  //MMD_GG0
  1190: 
  1191:   //--------------------------------------------------------------------------------
  1192:   //MMD_GH0 グラフィックス画面(1024ドット16色)
  1193:   //
  1194:   //  参照アドレス
  1195:   //    0b00000000_110Yyyyy_yyyyyXxx_xxxxxxx?
  1196:   //    +--------------------------+--------------------------+
  1197:   //    | 0x00c00000 .. 0x00c003ff | 0x00c00400 .. 0x00c007ff |
  1198:   //    | 0x00c00800    0x00c00bff | 0x00c00c00    0x00c00fff |
  1199:   //    |      :             :     |      :             :     |
  1200:   //    | 0x00cff000    0x00cff3ff | 0x00cff400    0x00cff7ff |
  1201:   //    | 0x00cff800 .. 0x00cffbff | 0x00cffc00 .. 0x00cfffff |
  1202:   //    +--------------------------+--------------------------+
  1203:   //    | 0x00d00000 .. 0x00d003ff | 0x00d00400 .. 0x00d007ff |
  1204:   //    | 0x00d00800    0x00d00bff | 0x00d00c00    0x00d00fff |
  1205:   //    |      :             :     |      :             :     |
  1206:   //    | 0x00dff000    0x00dff3ff | 0x00dff400    0x00dff7ff |
  1207:   //    | 0x00dff800 .. 0x00dffbff | 0x00dffc00 .. 0x00dfffff |
  1208:   //    +--------------------------+--------------------------+
  1209:   //
  1210:   //  格納アドレス
  1211:   //    0b00000000_110YXyyy_yyyyyyxx_xxxxxxx?
  1212:   //    +--------------------------+--------------------------+
  1213:   //    | 0x00c00000 .. 0x00c003ff | 0x00c80000 .. 0x00c803ff |
  1214:   //    | 0x00c00400    0x00c007ff | 0x00c80400    0x00c807ff |
  1215:   //    |      :     G0      :     |      :     G1      :     |
  1216:   //    | 0x00c7f800    0x00c7fbff | 0x00cff800    0x00cffbff |
  1217:   //    | 0x00c7fc00 .. 0x00c7ffff | 0x00cffc00 .. 0x00cfffff |
  1218:   //    +--------------------------+--------------------------+
  1219:   //    | 0x00d00000 .. 0x00d003ff | 0x00d80000 .. 0x00d803ff |
  1220:   //    | 0x00d00400    0x00d007ff | 0x00d80400    0x00d807ff |
  1221:   //    |      :     G2      :     |      :     G3      :     |
  1222:   //    | 0x00d7f800    0x00d7fbff | 0x00dff800    0x00dffbff |
  1223:   //    | 0x00d7fc00 .. 0x00d7ffff | 0x00dffc00 .. 0x00dfffff |
  1224:   //    +--------------------------+--------------------------+
  1225:   //
  1226:   //    perl -e "@m=(0,1,2,3);sub f{my($a)=@_;my$x=$a>>1&1023;my$y=$a>>11&1023;($a&0x00c00001)+($m[($y>>8&2)+($x>>9&1)]<<19)+(($y&511)<<10)+(($x&511)<<1);}my@a=(0xc00000,0xc003ff,0xc00400,0xc007ff,0xc00800,0xc00bff,0xc00c00,0xc00fff,0xcff000,0xcff3ff,0xcff400,0xcff7ff,0xcff800,0xcffbff,0xcffc00,0xcfffff,0xd00000,0xd003ff,0xd00400,0xd007ff,0xd00800,0xd00bff,0xd00c00,0xd00fff,0xdff000,0xdff3ff,0xdff400,0xdff7ff,0xdff800,0xdffbff,0xdffc00,0xdfffff);for$v(0..7){print'  //    ';for$u(0..3){$a=$a[4*$v+$u];$b=f($a);printf'  0x%08x',$b;}print qq@\n@;}"
  1227:   //    perl -e "sub f{my($a)=@_;($a&0x00c00000+(1<<20)+1023)+($a<<9&1<<19)+($a>>1&511<<10);}my@a=(0xc00000,0xc003ff,0xc00400,0xc007ff,0xc00800,0xc00bff,0xc00c00,0xc00fff,0xcff000,0xcff3ff,0xcff400,0xcff7ff,0xcff800,0xcffbff,0xcffc00,0xcfffff,0xd00000,0xd003ff,0xd00400,0xd007ff,0xd00800,0xd00bff,0xd00c00,0xd00fff,0xdff000,0xdff3ff,0xdff400,0xdff7ff,0xdff800,0xdffbff,0xdffc00,0xdfffff);for$v(0..7){print'  //    ';for$u(0..3){$a=$a[4*$v+$u];$b=f($a);printf'  0x%08x',$b;}print qq@\n@;}"
  1228:   //      0x00c00000  0x00c003ff  0x00c80000  0x00c803ff
  1229:   //      0x00c00400  0x00c007ff  0x00c80400  0x00c807ff
  1230:   //      0x00c7f800  0x00c7fbff  0x00cff800  0x00cffbff
  1231:   //      0x00c7fc00  0x00c7ffff  0x00cffc00  0x00cfffff
  1232:   //      0x00d00000  0x00d003ff  0x00d80000  0x00d803ff
  1233:   //      0x00d00400  0x00d007ff  0x00d80400  0x00d807ff
  1234:   //      0x00d7f800  0x00d7fbff  0x00dff800  0x00dffbff
  1235:   //      0x00d7fc00  0x00d7ffff  0x00dffc00  0x00dfffff
  1236:   //
  1237:   MMD_GH0 {
  1238:     @Override public String toString () {
  1239:       return Multilingual.mlnJapanese ? "グラフィックス画面 (1024 ドット 16 色)" : "Graphics Screen (1024 dots 16 colors)";
  1240:     }
  1241:     //ピーク
  1242:     @Override protected byte mmdPbs (int a) {
  1243:       int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1244:       return MainMemory.mmrM8[b0];
  1245:     }
  1246:     @Override protected int mmdPbz (int a) {
  1247:       int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1248:       return MainMemory.mmrM8[b0];
  1249:     }
  1250:     @Override protected int mmdPws (int a) {
  1251:       int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1252:       return MainMemory.mmrM8[b0 + 1];
  1253:     }
  1254:     @Override protected int mmdPwz (int a) {
  1255:       int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1256:       return MainMemory.mmrM8[b0 + 1];
  1257:     }
  1258:     @Override protected int mmdPls (int a) {
  1259:       //4bitページを跨ぐ場合があることに注意
  1260:       int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1261:       a += 2;
  1262:       int b2 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1263:       return MainMemory.mmrM8[b0 + 1] << 16 | MainMemory.mmrM8[b2 + 1];
  1264:     }
  1265:     //リード
  1266:     @Override protected byte mmdRbs (int a) throws M68kException {
  1267:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1268:        int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1269:        return MainMemory.mmrM8[b0];
  1270:      }
  1271:     @Override protected int mmdRbz (int a) throws M68kException {
  1272:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1273:        int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1274:        return MainMemory.mmrM8[b0];
  1275:      }
  1276:     @Override protected int mmdRws (int a) throws M68kException {
  1277:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1278:        int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1279:        return MainMemory.mmrM8[b0 + 1];
  1280:      }
  1281:     @Override protected int mmdRwz (int a) throws M68kException {
  1282:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1283:        int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1284:        return MainMemory.mmrM8[b0 + 1];
  1285:      }
  1286:     @Override protected int mmdRls (int a) throws M68kException {
  1287:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1288:        //4bitページを跨ぐ場合があることに注意
  1289:        int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1290:        a += 2;
  1291:        int b2 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1292:        return MainMemory.mmrM8[b0 + 1] << 16 | MainMemory.mmrM8[b2 + 1];
  1293:      }
  1294:     //ライト
  1295:     @Override protected void mmdWb (int a, int d) throws M68kException {
  1296:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1297:        if ((a & 1) != 0) {
  1298:          CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1299:          int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1300:          MainMemory.mmrM8[b0] = (byte) (d & 15);
  1301:        }
  1302:      }
  1303:     @Override protected void mmdWw (int a, int d) throws M68kException {
  1304:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1305:        CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1306:        int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1307:        MainMemory.mmrM8[b0 + 1] = (byte) (d & 15);
  1308:      }
  1309:     @Override protected void mmdWl (int a, int d) throws M68kException {
  1310:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1311:        CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1312:        //4bitページを跨ぐ場合があることに注意
  1313:        int b0 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1314:        a += 2;
  1315:        int b2 = (a & 0x00c00000 + (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1316:        MainMemory.mmrM8[b0 + 1] = (byte) (d >>> 16 & 15);
  1317:        MainMemory.mmrM8[b2 + 1] = (byte) (d & 15);
  1318:      }
  1319:   },  //MMD_GH0
  1320: 
  1321:   //--------------------------------------------------------------------------------
  1322:   //MMD_GI0 グラフィックス画面(1024ドット256色)
  1323:   //
  1324:   //  参照アドレスと格納アドレスはGH0と同じ
  1325:   //
  1326:   MMD_GI0 {
  1327:     @Override public String toString () {
  1328:       return Multilingual.mlnJapanese ? "グラフィックス画面 (1024 ドット 256 色)" : "Graphics Screen (1024 dots 256 colors)";
  1329:     }
  1330:     //ピーク
  1331:     @Override protected byte mmdPbs (int a) {
  1332:       int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1333:       return MainMemory.mmrM8[b0];
  1334:     }
  1335:     @Override protected int mmdPbz (int a) {
  1336:       int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1337:       return MainMemory.mmrM8[b0] & 0xff;
  1338:     }
  1339:     @Override protected int mmdPws (int a) {
  1340:       int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1341:       return MainMemory.mmrM8[b0 + 1] & 0xff;
  1342:     }
  1343:     @Override protected int mmdPwz (int a) {
  1344:       int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1345:       return MainMemory.mmrM8[b0 + 1] & 0xff;
  1346:     }
  1347:     @Override protected int mmdPls (int a) {
  1348:       //4bitページを跨ぐ場合があることに注意
  1349:       int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1350:       a += 2;
  1351:       int b2 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1352:       return (MainMemory.mmrM8[b0 + 1] & 0xff) << 16 | MainMemory.mmrM8[b2 + 1] & 0xff;
  1353:     }
  1354:     //リード
  1355:     @Override protected byte mmdRbs (int a) throws M68kException {
  1356:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1357:        int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1358:        return MainMemory.mmrM8[b0];
  1359:      }
  1360:     @Override protected int mmdRbz (int a) throws M68kException {
  1361:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1362:        int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1363:        return MainMemory.mmrM8[b0] & 0xff;
  1364:      }
  1365:     @Override protected int mmdRws (int a) throws M68kException {
  1366:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1367:        int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1368:        return MainMemory.mmrM8[b0 + 1] & 0xff;
  1369:      }
  1370:     @Override protected int mmdRwz (int a) throws M68kException {
  1371:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1372:        int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1373:        return MainMemory.mmrM8[b0 + 1] & 0xff;
  1374:      }
  1375:     @Override protected int mmdRls (int a) throws M68kException {
  1376:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1377:        //4bitページを跨ぐ場合があることに注意
  1378:        int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1379:        a += 2;
  1380:        int b2 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1381:        return (MainMemory.mmrM8[b0 + 1] & 0xff) << 16 | MainMemory.mmrM8[b2 + 1] & 0xff;
  1382:      }
  1383:     //ライト
  1384:     @Override protected void mmdWb (int a, int d) throws M68kException {
  1385:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1386:        if ((a & 1) != 0) {
  1387:          CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1388:          int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1389:          MainMemory.mmrM8[b0] = (byte) d;
  1390:        }
  1391:      }
  1392:     @Override protected void mmdWw (int a, int d) throws M68kException {
  1393:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1394:        CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1395:        int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1396:        MainMemory.mmrM8[b0 + 1] = (byte) d;
  1397:      }
  1398:     @Override protected void mmdWl (int a, int d) throws M68kException {
  1399:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1400:        CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1401:        //4bitページを跨ぐ場合があることに注意
  1402:        int b0 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1403:        a += 2;
  1404:        int b2 = XEiJ.BUS_MODIFIED_256_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1405:        MainMemory.mmrM8[b0 + 1] = (byte) (d >>> 16);
  1406:        MainMemory.mmrM8[b2 + 1] = (byte) d;
  1407:      }
  1408:   },  //MMD_GI0
  1409: 
  1410:   //--------------------------------------------------------------------------------
  1411:   //MMD_GJ0 グラフィックス画面(1024ドット65536色)
  1412:   //
  1413:   //  参照アドレスと格納アドレスはGH0と同じ
  1414:   //
  1415:   MMD_GJ0 {
  1416:     @Override public String toString () {
  1417:       return Multilingual.mlnJapanese ? "グラフィックス画面 (1024 ドット 65536 色)" : "Graphics Screen (1024 dots 65536 colors)";
  1418:     }
  1419:     //ピーク
  1420:     @Override protected byte mmdPbs (int a) {
  1421:       int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1422:       return MainMemory.mmrM8[b0];
  1423:     }
  1424:     @Override protected int mmdPbz (int a) {
  1425:       int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1426:       return MainMemory.mmrM8[b0] & 0xff;
  1427:     }
  1428:     @Override protected int mmdPws (int a) {
  1429:       int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1430:       return MainMemory.mmrM8[b0] << 8 | (MainMemory.mmrM8[b0 + 1] & 0xff);
  1431:     }
  1432:     @Override protected int mmdPwz (int a) {
  1433:       int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1434:       return (char) (MainMemory.mmrM8[b0] << 8 | (MainMemory.mmrM8[b0 + 1] & 0xff));
  1435:     }
  1436:     @Override protected int mmdPls (int a) {
  1437:        //4bitページを跨ぐ場合があることに注意
  1438:       int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1439:       a += 2;
  1440:       int b2 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1441:       return (MainMemory.mmrM8[b0] << 24 | (MainMemory.mmrM8[b0 + 1] & 0xff) << 16 |
  1442:               (char) (MainMemory.mmrM8[b2] << 8 | (MainMemory.mmrM8[b2 + 1] & 0xff)));
  1443:     }
  1444:     //リード
  1445:     @Override protected byte mmdRbs (int a) throws M68kException {
  1446:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1447:        return MainMemory.mmrM8[XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10)];
  1448:      }
  1449:     @Override protected int mmdRbz (int a) throws M68kException {
  1450:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1451:        return MainMemory.mmrM8[XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10)] & 0xff;
  1452:      }
  1453:     @Override protected int mmdRws (int a) throws M68kException {
  1454:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1455:        int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1456:        return MainMemory.mmrM8[b0] << 8 | (MainMemory.mmrM8[b0 + 1] & 0xff);
  1457:      }
  1458:     @Override protected int mmdRwz (int a) throws M68kException {
  1459:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1460:        int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1461:        return (char) (MainMemory.mmrM8[b0] << 8 | (MainMemory.mmrM8[b0 + 1] & 0xff));
  1462:      }
  1463:     @Override protected int mmdRls (int a) throws M68kException {
  1464:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1465:        //4bitページを跨ぐ場合があることに注意
  1466:        int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1467:        a += 2;
  1468:        int b2 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1469:        return (MainMemory.mmrM8[b0] << 24 | (MainMemory.mmrM8[b0 + 1] & 0xff) << 16 |
  1470:                (char) (MainMemory.mmrM8[b2] << 8 | (MainMemory.mmrM8[b2 + 1] & 0xff)));
  1471:      }
  1472:     //ライト
  1473:     @Override protected void mmdWb (int a, int d) throws M68kException {
  1474:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1475:        if ((a & 1) != 0) {
  1476:          CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1477:          MainMemory.mmrM8[XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10)] = (byte) d;
  1478:        }
  1479:      }
  1480:     @Override protected void mmdWw (int a, int d) throws M68kException {
  1481:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram;
  1482:        CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1483:        int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1484:        MainMemory.mmrM8[b0] = (byte) (d >> 8);
  1485:        MainMemory.mmrM8[b0 + 1] = (byte) d;
  1486:      }
  1487:     @Override protected void mmdWl (int a, int d) throws M68kException {
  1488:        XEiJ.mpuClockTime += XEiJ.busWaitTime.gvram * 2;
  1489:        CRTC.crtRasterStamp[(a >> 11) - CRTC.crtR13GrYCurr[0] & 1023] = 0;
  1490:        //4bitページを跨ぐ場合があることに注意
  1491:        int b0 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1492:        a += 2;
  1493:        int b2 = XEiJ.BUS_MODIFIED_65536_PAGE + (a & (1 << 20) + 1023) + (a << 9 & 1 << 19) + (a >>> 1 & 511 << 10);
  1494:        MainMemory.mmrM8[b0] = (byte) (d >>> 24);
  1495:        MainMemory.mmrM8[b0 + 1] = (byte) (d >>> 16);
  1496:        MainMemory.mmrM8[b2] = (byte) (d >>> 8);
  1497:        MainMemory.mmrM8[b2 + 1] = (byte) d;
  1498:      }
  1499:   },  //MMD_GJ0
  1500: 
  1501:   //--------------------------------------------------------------------------------
  1502:   //MMD_TXT テキスト画面
  1503:   MMD_TXT {
  1504:     @Override public String toString () {
  1505:       return Multilingual.mlnJapanese ? "テキスト画面" : "Text Screen";
  1506:     }
  1507:     //ピーク
  1508:     @Override protected byte mmdPbs (int a) {
  1509:       a &= XEiJ.BUS_MOTHER_MASK;
  1510:       return MainMemory.mmrM8[a];
  1511:     }
  1512:     @Override protected int mmdPbz (int a) {
  1513:       a &= XEiJ.BUS_MOTHER_MASK;
  1514:       return MainMemory.mmrM8[a] & 0xff;
  1515:     }
  1516:     @Override protected int mmdPws (int a) {
  1517:       a &= XEiJ.BUS_MOTHER_MASK;
  1518:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  1519:         return MainMemory.mmrBuffer.getShort (a);
  1520:       } else {
  1521:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  1522:       }
  1523:     }
  1524:     @Override protected int mmdPwz (int a) {
  1525:       a &= XEiJ.BUS_MOTHER_MASK;
  1526:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  1527:         return MainMemory.mmrBuffer.getChar (a);
  1528:       } else {
  1529:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  1530:       }
  1531:     }
  1532:     @Override protected int mmdPls (int a) {
  1533:       a &= XEiJ.BUS_MOTHER_MASK;
  1534:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  1535:         return MainMemory.mmrBuffer.getInt (a);
  1536:       } else {
  1537:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  1538:       }
  1539:     }
  1540:     //リード
  1541:     @Override protected byte mmdRbs (int a) throws M68kException {
  1542:        XEiJ.mpuClockTime += XEiJ.busWaitTime.tvram;
  1543:        a &= XEiJ.BUS_MOTHER_MASK;
  1544:        return MainMemory.mmrM8[a];
  1545:      }
  1546:     @Override protected int mmdRbz (int a) throws M68kException {
  1547:        XEiJ.mpuClockTime += XEiJ.busWaitTime.tvram;
  1548:        a &= XEiJ.BUS_MOTHER_MASK;
  1549:        return MainMemory.mmrM8[a] & 0xff;
  1550:      }
  1551:     @Override protected int mmdRws (int a) throws M68kException {
  1552:        XEiJ.mpuClockTime += XEiJ.busWaitTime.tvram;
  1553:        a &= XEiJ.BUS_MOTHER_MASK;
  1554:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  1555:          return MainMemory.mmrBuffer.getShort (a);
  1556:        } else {
  1557:          return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  1558:        }
  1559:      }
  1560:     @Override protected int mmdRwz (int a) throws M68kException {
  1561:        XEiJ.mpuClockTime += XEiJ.busWaitTime.tvram;
  1562:        a &= XEiJ.BUS_MOTHER_MASK;
  1563:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  1564:          return MainMemory.mmrBuffer.getChar (a);
  1565:        } else {
  1566:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  1567:        }
  1568:      }
  1569:     @Override protected int mmdRls (int a) throws M68kException {
  1570:        XEiJ.mpuClockTime += XEiJ.busWaitTime.tvram * 2;
  1571:        a &= XEiJ.BUS_MOTHER_MASK;
  1572:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  1573:          return MainMemory.mmrBuffer.getInt (a);
  1574:        } else {
  1575:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  1576:        }
  1577:      }
  1578:     //ライト
  1579:     @Override protected void mmdWb (int a, int d) throws M68kException {
  1580:        XEiJ.mpuClockTime += XEiJ.busWaitTime.tvram;
  1581:        a &= XEiJ.BUS_MOTHER_MASK;
  1582:        int x;  //マスク
  1583:        if (CRTC.crtSimAccess) {  //同時アクセスあり
  1584:          a &= 0x00e1ffff;
  1585:          if (CRTC.crtBitMask) {  //同時アクセスあり,ビットマスクあり
  1586:            d &= ~(x = CRTC.crtR23Mask >> ((~a & 1) << 3));
  1587:            if (CRTC.crtSimPlane0) {
  1588:              MainMemory.mmrM8[a             ] = (byte) (MainMemory.mmrM8[a             ] & x | d);
  1589:            }
  1590:            if (CRTC.crtSimPlane1) {
  1591:              MainMemory.mmrM8[a + 0x00020000] = (byte) (MainMemory.mmrM8[a + 0x00020000] & x | d);
  1592:            }
  1593:            if (CRTC.crtSimPlane2) {
  1594:              MainMemory.mmrM8[a + 0x00040000] = (byte) (MainMemory.mmrM8[a + 0x00040000] & x | d);
  1595:            }
  1596:            if (CRTC.crtSimPlane3) {
  1597:              MainMemory.mmrM8[a + 0x00060000] = (byte) (MainMemory.mmrM8[a + 0x00060000] & x | d);
  1598:            }
  1599:          } else {  //同時アクセスあり,ビットマスクなし
  1600:            if (CRTC.crtSimPlane0) {
  1601:              MainMemory.mmrM8[a             ] = (byte) d;
  1602:            }
  1603:            if (CRTC.crtSimPlane1) {
  1604:              MainMemory.mmrM8[a + 0x00020000] = (byte) d;
  1605:            }
  1606:            if (CRTC.crtSimPlane2) {
  1607:              MainMemory.mmrM8[a + 0x00040000] = (byte) d;
  1608:            }
  1609:            if (CRTC.crtSimPlane3) {
  1610:              MainMemory.mmrM8[a + 0x00060000] = (byte) d;
  1611:            }
  1612:          }
  1613:        } else if (CRTC.crtBitMask) {  //同時アクセスなし,ビットマスクあり
  1614:          x = CRTC.crtR23Mask >> ((~a & 1) << 3);
  1615:          MainMemory.mmrM8[a] = (byte) (MainMemory.mmrM8[a] & x | d & ~x);
  1616:        } else {  //同時アクセスなし,ビットマスクなし
  1617:          MainMemory.mmrM8[a] = (byte) d;
  1618:        }
  1619:        //同時アクセスやビットマスクで1ピクセルも書き換えなくても更新することになる
  1620:        a = ((a & 0x0001ffff) >> 7) - CRTC.crtR11TxYCurr & 1020;
  1621:        CRTC.crtRasterStamp[a    ] = 0;
  1622:        CRTC.crtRasterStamp[a + 1] = 0;
  1623:        CRTC.crtRasterStamp[a + 2] = 0;
  1624:        CRTC.crtRasterStamp[a + 3] = 0;
  1625:      }  //mmdWb
  1626:     @Override protected void mmdWw (int a, int d) throws M68kException {
  1627:        XEiJ.mpuClockTime += XEiJ.busWaitTime.tvram;
  1628:        a &= XEiJ.BUS_MOTHER_MASK;
  1629:        int e;  //上位バイトのデータ
  1630:        int x;  //下位バイトのマスク
  1631:        int y;  //上位バイトのマスク
  1632:        if (CRTC.crtSimAccess) {  //同時アクセスあり
  1633:          a &= 0x00e1ffff;
  1634:          if (CRTC.crtBitMask) {  //同時アクセスあり,ビットマスクあり
  1635:            e = d >> 8 & ~(y = (x = CRTC.crtR23Mask) >> 8);
  1636:            d &= ~x;
  1637:            if (CRTC.crtSimPlane0) {
  1638:              MainMemory.mmrM8[a             ] = (byte) (MainMemory.mmrM8[a             ] & y | e);
  1639:              MainMemory.mmrM8[a + 0x00000001] = (byte) (MainMemory.mmrM8[a + 0x00000001] & x | d);
  1640:            }
  1641:            if (CRTC.crtSimPlane1) {
  1642:              MainMemory.mmrM8[a + 0x00020000] = (byte) (MainMemory.mmrM8[a + 0x00020000] & y | e);
  1643:              MainMemory.mmrM8[a + 0x00020001] = (byte) (MainMemory.mmrM8[a + 0x00020001] & x | d);
  1644:            }
  1645:            if (CRTC.crtSimPlane2) {
  1646:              MainMemory.mmrM8[a + 0x00040000] = (byte) (MainMemory.mmrM8[a + 0x00040000] & y | e);
  1647:              MainMemory.mmrM8[a + 0x00040001] = (byte) (MainMemory.mmrM8[a + 0x00040001] & x | d);
  1648:            }
  1649:            if (CRTC.crtSimPlane3) {
  1650:              MainMemory.mmrM8[a + 0x00060000] = (byte) (MainMemory.mmrM8[a + 0x00060000] & y | e);
  1651:              MainMemory.mmrM8[a + 0x00060001] = (byte) (MainMemory.mmrM8[a + 0x00060001] & x | d);
  1652:            }
  1653:          } else {  //同時アクセスあり,ビットマスクなし
  1654:            e = d >> 8;
  1655:            if (CRTC.crtSimPlane0) {
  1656:              MainMemory.mmrM8[a             ] = (byte) e;
  1657:              MainMemory.mmrM8[a + 0x00000001] = (byte) d;
  1658:            }
  1659:            if (CRTC.crtSimPlane1) {
  1660:              MainMemory.mmrM8[a + 0x00020000] = (byte) e;
  1661:              MainMemory.mmrM8[a + 0x00020001] = (byte) d;
  1662:            }
  1663:            if (CRTC.crtSimPlane2) {
  1664:              MainMemory.mmrM8[a + 0x00040000] = (byte) e;
  1665:              MainMemory.mmrM8[a + 0x00040001] = (byte) d;
  1666:            }
  1667:            if (CRTC.crtSimPlane3) {
  1668:              MainMemory.mmrM8[a + 0x00060000] = (byte) e;
  1669:              MainMemory.mmrM8[a + 0x00060001] = (byte) d;
  1670:            }
  1671:          }
  1672:        } else if (CRTC.crtBitMask) {  //同時アクセスなし,ビットマスクあり
  1673:          y = (x = CRTC.crtR23Mask) >> 8;
  1674:          MainMemory.mmrM8[a    ] = (byte) (MainMemory.mmrM8[a    ] & y | (d >> 8) & ~y);
  1675:          MainMemory.mmrM8[a + 1] = (byte) (MainMemory.mmrM8[a + 1] & x |  d       & ~x);
  1676:        } else {  //同時アクセスなし,ビットマスクなし
  1677:          if (MainMemory.MMR_USE_BYTE_BUFFER) {
  1678:            MainMemory.mmrBuffer.putShort (a, (short) d);
  1679:          } else {
  1680:            MainMemory.mmrM8[a    ] = (byte) (d >> 8);
  1681:            MainMemory.mmrM8[a + 1] = (byte)  d;
  1682:          }
  1683:        }
  1684:        //同時アクセスやビットマスクで1ピクセルも書き換えなくても更新することになる
  1685:        a = ((a & 0x0001ffff) >> 7) - CRTC.crtR11TxYCurr & 1020;
  1686:        CRTC.crtRasterStamp[a    ] = 0;
  1687:        CRTC.crtRasterStamp[a + 1] = 0;
  1688:        CRTC.crtRasterStamp[a + 2] = 0;
  1689:        CRTC.crtRasterStamp[a + 3] = 0;
  1690:      }  //mmdWw
  1691:     @Override protected void mmdWl (int a, int d) throws M68kException {
  1692:        XEiJ.mpuClockTime += XEiJ.busWaitTime.tvram * 2;
  1693:        a &= XEiJ.BUS_MOTHER_MASK;
  1694:        int e;  //下位ワードの上位バイトのデータ
  1695:        int f;  //上位ワードの下位バイトのデータ
  1696:        int g;  //上位ワードの上位バイトのデータ
  1697:        int x;  //下位バイトのマスク
  1698:        int y;  //上位バイトのマスク
  1699:        if (CRTC.crtSimAccess) {  //同時アクセスあり
  1700:          a &= 0x00e1ffff;
  1701:          if (CRTC.crtBitMask) {  //同時アクセスあり,ビットマスクあり
  1702:            g = d >> 24 & ~(y = (x = CRTC.crtR23Mask) >> 8);
  1703:            f = d >> 16 & ~x;
  1704:            e = d >>  8 & ~y;
  1705:            d &= ~x;
  1706:            if (CRTC.crtSimPlane0) {
  1707:              MainMemory.mmrM8[a             ] = (byte) (MainMemory.mmrM8[a             ] & y | g);
  1708:              MainMemory.mmrM8[a + 0x00000001] = (byte) (MainMemory.mmrM8[a + 0x00000001] & x | f);
  1709:              MainMemory.mmrM8[a + 0x00000002] = (byte) (MainMemory.mmrM8[a + 0x00000002] & y | e);
  1710:              MainMemory.mmrM8[a + 0x00000003] = (byte) (MainMemory.mmrM8[a + 0x00000003] & x | d);
  1711:            }
  1712:            if (CRTC.crtSimPlane1) {
  1713:              MainMemory.mmrM8[a + 0x00020000] = (byte) (MainMemory.mmrM8[a + 0x00020000] & y | g);
  1714:              MainMemory.mmrM8[a + 0x00020001] = (byte) (MainMemory.mmrM8[a + 0x00020001] & x | f);
  1715:              MainMemory.mmrM8[a + 0x00020002] = (byte) (MainMemory.mmrM8[a + 0x00020002] & y | e);
  1716:              MainMemory.mmrM8[a + 0x00020003] = (byte) (MainMemory.mmrM8[a + 0x00020003] & x | d);
  1717:            }
  1718:            if (CRTC.crtSimPlane2) {
  1719:              MainMemory.mmrM8[a + 0x00040000] = (byte) (MainMemory.mmrM8[a + 0x00040000] & y | g);
  1720:              MainMemory.mmrM8[a + 0x00040001] = (byte) (MainMemory.mmrM8[a + 0x00040001] & x | f);
  1721:              MainMemory.mmrM8[a + 0x00040002] = (byte) (MainMemory.mmrM8[a + 0x00040002] & y | e);
  1722:              MainMemory.mmrM8[a + 0x00040003] = (byte) (MainMemory.mmrM8[a + 0x00040003] & x | d);
  1723:            }
  1724:            if (CRTC.crtSimPlane3) {
  1725:              MainMemory.mmrM8[a + 0x00060000] = (byte) (MainMemory.mmrM8[a + 0x00060000] & y | g);
  1726:              MainMemory.mmrM8[a + 0x00060001] = (byte) (MainMemory.mmrM8[a + 0x00060001] & x | f);
  1727:              MainMemory.mmrM8[a + 0x00060002] = (byte) (MainMemory.mmrM8[a + 0x00060002] & y | e);
  1728:              MainMemory.mmrM8[a + 0x00060003] = (byte) (MainMemory.mmrM8[a + 0x00060003] & x | d);
  1729:            }
  1730:          } else {  //同時アクセスあり,ビットマスクなし
  1731:            g = d >> 24;
  1732:            f = d >> 16;
  1733:            e = d >>  8;
  1734:            if (CRTC.crtSimPlane0) {
  1735:              MainMemory.mmrM8[a             ] = (byte) g;
  1736:              MainMemory.mmrM8[a + 0x00000001] = (byte) f;
  1737:              MainMemory.mmrM8[a + 0x00000002] = (byte) e;
  1738:              MainMemory.mmrM8[a + 0x00000003] = (byte) d;
  1739:            }
  1740:            if (CRTC.crtSimPlane1) {
  1741:              MainMemory.mmrM8[a + 0x00020000] = (byte) g;
  1742:              MainMemory.mmrM8[a + 0x00020001] = (byte) f;
  1743:              MainMemory.mmrM8[a + 0x00020002] = (byte) e;
  1744:              MainMemory.mmrM8[a + 0x00020003] = (byte) d;
  1745:            }
  1746:            if (CRTC.crtSimPlane2) {
  1747:              MainMemory.mmrM8[a + 0x00040000] = (byte) g;
  1748:              MainMemory.mmrM8[a + 0x00040001] = (byte) f;
  1749:              MainMemory.mmrM8[a + 0x00040002] = (byte) e;
  1750:              MainMemory.mmrM8[a + 0x00040003] = (byte) d;
  1751:            }
  1752:            if (CRTC.crtSimPlane3) {
  1753:              MainMemory.mmrM8[a + 0x00060000] = (byte) g;
  1754:              MainMemory.mmrM8[a + 0x00060001] = (byte) f;
  1755:              MainMemory.mmrM8[a + 0x00060002] = (byte) e;
  1756:              MainMemory.mmrM8[a + 0x00060003] = (byte) d;
  1757:            }
  1758:          }
  1759:        } else if (CRTC.crtBitMask) {  //同時アクセスなし,ビットマスクあり
  1760:          y = (x = CRTC.crtR23Mask) >> 8;
  1761:          MainMemory.mmrM8[a    ] = (byte) (MainMemory.mmrM8[a    ] & y | (d >> 24) & ~y);
  1762:          MainMemory.mmrM8[a + 1] = (byte) (MainMemory.mmrM8[a + 1] & x | (d >> 16) & ~x);
  1763:          MainMemory.mmrM8[a + 2] = (byte) (MainMemory.mmrM8[a + 1] & y | (d >>  8) & ~y);
  1764:          MainMemory.mmrM8[a + 3] = (byte) (MainMemory.mmrM8[a + 1] & x |  d        & ~x);
  1765:        } else {  //同時アクセスなし,ビットマスクなし
  1766:          if (MainMemory.MMR_USE_BYTE_BUFFER) {
  1767:            MainMemory.mmrBuffer.putInt (a, d);
  1768:          } else {
  1769:            MainMemory.mmrM8[a    ] = (byte) (d >> 24);
  1770:            MainMemory.mmrM8[a + 1] = (byte) (d >> 16);
  1771:            MainMemory.mmrM8[a + 2] = (byte) (d >>  8);
  1772:            MainMemory.mmrM8[a + 3] = (byte)  d;
  1773:          }
  1774:        }
  1775:        //同時アクセスやビットマスクで1ピクセルも書き換えなくても更新することになる
  1776:        int b = ((a     & 0x0001ffff) >> 7) - CRTC.crtR11TxYCurr & 1020;
  1777:        CRTC.crtRasterStamp[b    ] = 0;
  1778:        CRTC.crtRasterStamp[b + 1] = 0;
  1779:        CRTC.crtRasterStamp[b + 2] = 0;
  1780:        CRTC.crtRasterStamp[b + 3] = 0;
  1781:        a = ((a + 2 & 0x0001ffff) >> 7) - CRTC.crtR11TxYCurr & 1020;
  1782:        if (a != b) {
  1783:          CRTC.crtRasterStamp[a    ] = 0;
  1784:          CRTC.crtRasterStamp[a + 1] = 0;
  1785:          CRTC.crtRasterStamp[a + 2] = 0;
  1786:          CRTC.crtRasterStamp[a + 3] = 0;
  1787:        }
  1788:      }  //mmdWl
  1789:   },  //MMD_TXT
  1790: 
  1791:   //--------------------------------------------------------------------------------
  1792:   //MMD_CRT CRTコントローラ
  1793:   //
  1794:   //  $00E80000~$00E8002F  ワードレジスタ
  1795:   //  $00E80030~$00E8003F  $0000
  1796:   //  $00E80040~$00E803FF  $00E80000~$00E8003Fの繰り返し
  1797:   //  $00E80400~$00E8047F  バスエラー
  1798:   //  $00E80480~$00E80481  ワードレジスタ
  1799:   //  $00E80482~$00E804FF  $00E80480~$00E80481の繰り返し
  1800:   //  $00E80500~$00E807FF  $00E80400~$00E804FFの繰り返し
  1801:   //  $00E80800~$00E81FFF  $00E80000~$00E807FFの繰り返し
  1802:   //
  1803:   MMD_CRT {
  1804:     @Override public String toString () {
  1805:       return Multilingual.mlnJapanese ? "CRT コントローラ" : "CRT Controller";
  1806:     }
  1807:     //リード
  1808:     @Override protected int mmdRbz (int a) throws M68kException {
  1809:        XEiJ.mpuClockTime += XEiJ.busWaitTime.crtc;
  1810:        int aa = a & 0x07ff;  //$00E80800~$00E81FFF→$00E80000~$00E807FF
  1811:        if (aa < 0x0400) {  //$00E80000~$00E803FF
  1812:          aa &= 0x003f;
  1813:          switch (aa) {
  1814:            //case 0x0001:  //R00の下位
  1815:            //  return CRTC.crtR00HFrontEndPort;
  1816:            //case 0x0003:  //R01の下位
  1817:            //  return CRTC.crtR01HSyncEndPort;
  1818:            //case 0x0005:  //R02の下位
  1819:            //  return CRTC.crtR02HBackEndPort;
  1820:            //case 0x0007:  //R03の下位
  1821:            //  return CRTC.crtR03HDispEndPort;
  1822:            //case 0x0008:  //R04の上位
  1823:            //  return CRTC.crtR04VFrontEndPort >> 8;
  1824:            //case 0x0009:  //R04の下位
  1825:            //  return CRTC.crtR04VFrontEndPort & 0xff;
  1826:            //case 0x000a:  //R05の上位
  1827:            //  return CRTC.crtR05VSyncEndPort >> 8;
  1828:            //case 0x000b:  //R05の下位
  1829:            //  return CRTC.crtR05VSyncEndPort & 0xff;
  1830:            //case 0x000c:  //R06の上位
  1831:            //  return CRTC.crtR06VBackEndPort >> 8;
  1832:            //case 0x000d:  //R06の下位
  1833:            //  return CRTC.crtR06VBackEndPort & 0xff;
  1834:            //case 0x000e:  //R07の上位
  1835:            //  return CRTC.crtR07VDispEndPort >> 8;
  1836:            //case 0x000f:  //R07の下位
  1837:            //  return CRTC.crtR07VDispEndPort & 0xff;
  1838:            //case 0x0011:  //R08の下位
  1839:            //  return CRTC.crtR08Adjust;
  1840:            //case 0x0012:  //R09の上位
  1841:            //  return CRTC.crtR09IRQRasterPort >> 8;
  1842:            //case 0x0013:  //R09の下位
  1843:            //  return CRTC.crtR09IRQRasterPort & 0xff;
  1844:            //case 0x0014:  //R10の上位
  1845:            //  return CRTC.crtR10TxXPort >> 8;
  1846:            //case 0x0015:  //R10の下位
  1847:            //  return CRTC.crtR10TxXPort & 0xff;
  1848:            //case 0x0016:  //R11の上位
  1849:            //  return CRTC.crtR11TxYCurr >> 8;
  1850:            //case 0x0017:  //R11の下位
  1851:            //  return CRTC.crtR11TxYCurr & 0xff;
  1852:            //case 0x0018:  //R12の上位
  1853:            //case 0x001c:  //R14の上位
  1854:            //case 0x0020:  //R16の上位
  1855:            //case 0x0024:  //R18の上位
  1856:            //  return CRTC.crtR12GrXPort[(aa - 0x0018) >> 2] >> 8;
  1857:            //case 0x0019:  //R12の下位
  1858:            //case 0x001d:  //R14の下位
  1859:            //case 0x0021:  //R16の下位
  1860:            //case 0x0025:  //R18の下位
  1861:            //  return CRTC.crtR12GrXPort[(aa - 0x0018) >> 2] & 0xff;
  1862:            //case 0x001a:  //R13の上位
  1863:            //case 0x001e:  //R15の上位
  1864:            //case 0x0022:  //R17の上位
  1865:            //case 0x0026:  //R19の上位
  1866:            //  return CRTC.crtR13GrYPort[(aa - 0x0018) >> 2] >> 8;
  1867:            //case 0x001b:  //R13の下位
  1868:            //case 0x001f:  //R15の下位
  1869:            //case 0x0023:  //R17の下位
  1870:            //case 0x0027:  //R19の下位
  1871:            //  return CRTC.crtR13GrYPort[(aa - 0x0018) >> 2] & 0xff;
  1872:          case 0x0028:  //R20の上位
  1873:            return (CRTC.crtTextStorage    << 4 |
  1874:                    CRTC.crtGraphicStorage << 3 |
  1875:                    CRTC.crtMemoryModePort);
  1876:          case 0x0029:  //R20の下位
  1877:            return (CRTC.crtHighResoPort << 4 |
  1878:                    CRTC.crtVResoPort    << 2 |
  1879:                    CRTC.crtHResoPort);
  1880:          case 0x002a:  //R21の上位
  1881:            return ((CRTC.crtBitMask   ? 0b00000010 : 0) |
  1882:                    (CRTC.crtSimAccess ? 0b00000001 : 0));
  1883:          case 0x002b:  //R21の下位
  1884:            return ((CRTC.crtSimPlane3 ? 0b10000000 : 0) |
  1885:                    (CRTC.crtSimPlane2 ? 0b01000000 : 0) |
  1886:                    (CRTC.crtSimPlane1 ? 0b00100000 : 0) |
  1887:                    (CRTC.crtSimPlane0 ? 0b00010000 : 0) |
  1888:                    (CRTC.crtCCPlane3  ? 0b00001000 : 0) |
  1889:                    (CRTC.crtCCPlane2  ? 0b00000100 : 0) |
  1890:                    (CRTC.crtCCPlane1  ? 0b00000010 : 0) |
  1891:                    (CRTC.crtCCPlane0  ? 0b00000001 : 0));
  1892:            //case 0x002c:  //R22の上位
  1893:            //  return CRTC.crtR22SrcBlock;
  1894:            //case 0x002d:  //R22の下位
  1895:            //  return CRTC.crtR22DstBlock;
  1896:            //case 0x002e:  //R23の上位
  1897:            //  return CRTC.crtR23Mask >> 8;
  1898:            //case 0x002f:  //R23の下位
  1899:            //  return CRTC.crtR23Mask & 0xff;
  1900:            //case 0x0000:  //R00の上位
  1901:            //case 0x0002:  //R01の上位
  1902:            //case 0x0004:  //R02の上位
  1903:            //case 0x0006:  //R03の上位
  1904:            //case 0x0010:  //R08の上位
  1905:            //case 0x0030:  //R24の上位
  1906:            //case 0x0031:  //R24の下位
  1907:            //case 0x0032:  //R25の上位
  1908:            //case 0x0033:  //R25の下位
  1909:            //case 0x0034:  //R26の上位
  1910:            //case 0x0035:  //R26の下位
  1911:            //case 0x0036:  //R27の上位
  1912:            //case 0x0037:  //R27の下位
  1913:            //case 0x0038:  //R28の上位
  1914:            //case 0x0039:  //R28の下位
  1915:            //case 0x003a:  //R29の上位
  1916:            //case 0x003b:  //R29の下位
  1917:            //case 0x003c:  //R30の上位
  1918:            //case 0x003d:  //R30の下位
  1919:            //case 0x003e:  //R31の上位
  1920:            //case 0x003f:  //R31の下位
  1921:          default:
  1922:            return 0x00;
  1923:            //return VideoController.vcnMode.ordinal () >> 8;
  1924:            //return VideoController.vcnMode.ordinal () & 0xff;
  1925:          }
  1926:        } else {  //$00E80400~$00E807FF
  1927:          aa &= 0xff;  //$00E80500~$00E807FF→$00E80400~$00E804FF
  1928:          if (aa < 0x80) {  //$00E80400~$00E8047F
  1929:            return super.mmdRbz (a);  //バスエラー
  1930:          } else {  //$00E80480~$00E804FF
  1931:            aa &= 0x01;  //$00E80482~$00E804FF→$00E80480~$00E80481
  1932:            if (aa == 0) {  //動作ポートの上位
  1933:              return 0;
  1934:            } else {  //動作ポートの下位
  1935:              return ((CRTC.crtRasterCopyOn ? 8 : 0) |  //ラスタコピー
  1936:                      (CRTC.crtClearStandby || CRTC.crtClearFrames != 0 ? 2 : 0));  //高速クリア
  1937:            }
  1938:          }
  1939:        }
  1940:      }  //mmdRbz
  1941:     @Override protected int mmdRwz (int a) throws M68kException {
  1942:        XEiJ.mpuClockTime += XEiJ.busWaitTime.crtc;
  1943:        int aa = a & 0x07ff;  //$00E80800~$00E81FFF→$00E80000~$00E807FF
  1944:        if (aa < 0x0400) {  //$00E80000~$00E803FF
  1945:          aa &= 0x003f;
  1946:          switch (aa) {
  1947:            //case 0x0000:  //R00
  1948:            //  return CRTC.crtR00HFrontEndPort;
  1949:            //case 0x0002:  //R01
  1950:            //  return CRTC.crtR01HSyncEndPort;
  1951:            //case 0x0004:  //R02
  1952:            //  return CRTC.crtR02HBackEndPort;
  1953:            //case 0x0006:  //R03
  1954:            //  return CRTC.crtR03HDispEndPort;
  1955:            //case 0x0008:  //R04
  1956:            //  return CRTC.crtR04VFrontEndPort;
  1957:            //case 0x000a:  //R05
  1958:            //  return CRTC.crtR05VSyncEndPort;
  1959:            //case 0x000c:  //R06
  1960:            //  return CRTC.crtR06VBackEndPort;
  1961:            //case 0x000e:  //R07
  1962:            //  return CRTC.crtR07VDispEndPort;
  1963:            //case 0x0010:  //R08
  1964:            //  return CRTC.crtR08Adjust;
  1965:            //case 0x0012:  //R09
  1966:            //  return CRTC.crtR09IRQRasterPort;
  1967:            //case 0x0014:  //R10
  1968:            //  return CRTC.crtR10TxXPort;
  1969:            //case 0x0016:  //R11
  1970:            //  return CRTC.crtR11TxYPort;
  1971:            //case 0x0018:  //R12
  1972:            //case 0x001c:  //R14
  1973:            //case 0x0020:  //R16
  1974:            //case 0x0024:  //R18
  1975:            //  return CRTC.crtR12GrXPort[(aa - 0x0018) >> 2];
  1976:            //case 0x001a:  //R13
  1977:            //case 0x001e:  //R15
  1978:            //case 0x0022:  //R17
  1979:            //case 0x0026:  //R19
  1980:            //  return CRTC.crtR13GrYPort[(aa - 0x0018) >> 2];
  1981:          case 0x0028:  //R20
  1982:            return (CRTC.crtTextStorage    << 12 |
  1983:                    CRTC.crtGraphicStorage << 11 |
  1984:                    CRTC.crtMemoryModePort <<  8 |
  1985:                    CRTC.crtHighResoPort   <<  4 |
  1986:                    CRTC.crtVResoPort      <<  2 |
  1987:                    CRTC.crtHResoPort);
  1988:          case 0x002a:  //R21
  1989:            return ((CRTC.crtBitMask   ? 0b00000010_00000000 : 0) |
  1990:                    (CRTC.crtSimAccess ? 0b00000001_00000000 : 0) |
  1991:                    (CRTC.crtSimPlane3 ? 0b00000000_10000000 : 0) |
  1992:                    (CRTC.crtSimPlane2 ? 0b00000000_01000000 : 0) |
  1993:                    (CRTC.crtSimPlane1 ? 0b00000000_00100000 : 0) |
  1994:                    (CRTC.crtSimPlane0 ? 0b00000000_00010000 : 0) |
  1995:                    (CRTC.crtCCPlane3  ? 0b00000000_00001000 : 0) |
  1996:                    (CRTC.crtCCPlane2  ? 0b00000000_00000100 : 0) |
  1997:                    (CRTC.crtCCPlane1  ? 0b00000000_00000010 : 0) |
  1998:                    (CRTC.crtCCPlane0  ? 0b00000000_00000001 : 0));
  1999:            //case 0x002c:  //R22
  2000:            //  return CRTC.crtR22SrcBlock << 8 | CRTC.crtR22DstBlock;
  2001:            //case 0x002e:  //R23
  2002:            //  return CRTC.crtR23Mask;
  2003:            //case 0x0030:  //R24
  2004:            //case 0x0032:  //R25
  2005:            //case 0x0034:  //R26
  2006:            //case 0x0036:  //R27
  2007:            //case 0x0038:  //R28
  2008:            //case 0x003a:  //R29
  2009:            //case 0x003c:  //R30
  2010:            //case 0x003e:  //R31
  2011:          default:
  2012:            return 0x0000;
  2013:          }
  2014:        } else {  //$00E80400~$00E807FF
  2015:          aa &= 0xff;  //$00E80500~$00E807FF→$00E80400~$00E804FF
  2016:          if (aa < 0x80) {  //$00E80400~$00E8047F
  2017:            return super.mmdRbz (a);  //バスエラー
  2018:          } else {  //$00E80480~$00E804FF  動作ポート
  2019:            return ((CRTC.crtRasterCopyOn ? 8 : 0) |  //ラスタコピー
  2020:                    (CRTC.crtClearStandby || CRTC.crtClearFrames != 0 ? 2 : 0));  //高速クリア
  2021:          }
  2022:        }
  2023:      }  //mmdRwz
  2024:     @Override protected int mmdRls (int a) throws M68kException {
  2025:        return mmdRwz (a) << 16 | mmdRwz (a + 2);
  2026:      }
  2027:     //ライト
  2028:     @Override protected void mmdWb (int a, int d) throws M68kException {
  2029:        XEiJ.mpuClockTime += XEiJ.busWaitTime.crtc;
  2030:        int aa = a & 0x07ff;  //$00E80800~$00E81FFF→$00E80000~$00E807FF
  2031:        if (aa < 0x0400) {  //$00E80000~$00E803FF
  2032:          aa &= 0x003f;
  2033:          switch (aa) {
  2034:          case 0x0001:  //R00の下位
  2035:            CRTC.crtR00HFrontEndPort = (d & 0xff) | (CRTC.crtR00Bit0Zero ? 0x00 : 0x01);
  2036:            {
  2037:              int curr = CRTC.crtR00HFrontEndMask == 0 ? CRTC.crtR00HFrontEndPort : CRTC.crtR00HFrontEndTest;
  2038:              if (CRTC.crtR00HFrontEndCurr != curr) {
  2039:                CRTC.crtR00HFrontEndCurr = curr;
  2040:                CRTC.crtRestart ();
  2041:              }
  2042:            }
  2043:          return;
  2044:          case 0x0003:  //R01の下位
  2045:            CRTC.crtR01HSyncEndPort = d & 0xff;
  2046:            {
  2047:              int curr = CRTC.crtR01HSyncEndMask == 0 ? CRTC.crtR01HSyncEndPort : CRTC.crtR01HSyncEndTest;
  2048:              if (CRTC.crtR01HSyncEndCurr != curr) {
  2049:                CRTC.crtR01HSyncEndCurr = curr;
  2050:                CRTC.crtRestart ();
  2051:              }
  2052:            }
  2053:            return;
  2054:          case 0x0005:  //R02の下位
  2055:            CRTC.crtR02HBackEndPort = d & 0xff;
  2056:            {
  2057:              int curr = CRTC.crtR02HBackEndMask == 0 ? CRTC.crtR02HBackEndPort : CRTC.crtR02HBackEndTest;
  2058:              if (CRTC.crtR02HBackEndCurr != curr) {
  2059:                CRTC.crtR02HBackEndCurr = curr;
  2060:                CRTC.crtRestart ();
  2061:              }
  2062:            }
  2063:            return;
  2064:          case 0x0007:  //R03の下位
  2065:            CRTC.crtR03HDispEndPort = d & 0xff;
  2066:            {
  2067:              int curr = CRTC.crtR03HDispEndMask == 0 ? CRTC.crtR03HDispEndPort : CRTC.crtR03HDispEndTest;
  2068:              if (CRTC.crtR03HDispEndCurr != curr) {
  2069:                CRTC.crtR03HDispEndCurr = curr;
  2070:                CRTC.crtRestart ();
  2071:              }
  2072:            }
  2073:            return;
  2074:          case 0x0008:  //R04の上位
  2075:            CRTC.crtR04VFrontEndPort = (d & (CRTC.crtVerticalMask >> 8)) << 8 | (CRTC.crtR04VFrontEndPort & 0xff);
  2076:            {
  2077:              int curr = CRTC.crtR04VFrontEndMask == 0 ? CRTC.crtR04VFrontEndPort : CRTC.crtR04VFrontEndTest;
  2078:              if (CRTC.crtR04VFrontEndCurr != curr) {
  2079:                CRTC.crtR04VFrontEndCurr = curr;
  2080:                if (CRTC.CRT_RASTER_HASH_ON) {
  2081:                  CRTC.crtUpdateRasterHash ();
  2082:                }
  2083:                CRTC.crtRestart ();
  2084:              }
  2085:            }
  2086:            return;
  2087:          case 0x0009:  //R04の下位
  2088:            CRTC.crtR04VFrontEndPort = (CRTC.crtR04VFrontEndPort & ~0xff) | (d & 0xff);
  2089:            {
  2090:              int curr = CRTC.crtR04VFrontEndMask == 0 ? CRTC.crtR04VFrontEndPort : CRTC.crtR04VFrontEndTest;
  2091:              if (CRTC.crtR04VFrontEndCurr != curr) {
  2092:                CRTC.crtR04VFrontEndCurr = curr;
  2093:                if (CRTC.CRT_RASTER_HASH_ON) {
  2094:                  CRTC.crtUpdateRasterHash ();
  2095:                }
  2096:                CRTC.crtRestart ();
  2097:              }
  2098:            }
  2099:            return;
  2100:          case 0x000a:  //R05の上位
  2101:            CRTC.crtR05VSyncEndPort = (d & (CRTC.crtVerticalMask >> 8)) << 8 | (CRTC.crtR05VSyncEndPort & 0xff);
  2102:            {
  2103:              int curr = CRTC.crtR05VSyncEndMask == 0 ? CRTC.crtR05VSyncEndPort : CRTC.crtR05VSyncEndTest;
  2104:              if (CRTC.crtR05VSyncEndCurr != curr) {
  2105:                CRTC.crtR05VSyncEndCurr = curr;
  2106:                CRTC.crtRestart ();
  2107:              }
  2108:            }
  2109:            return;
  2110:          case 0x000b:  //R05の下位
  2111:            CRTC.crtR05VSyncEndPort = (CRTC.crtR05VSyncEndPort & ~0xff) | (d & 0xff);
  2112:            {
  2113:              int curr = CRTC.crtR05VSyncEndMask == 0 ? CRTC.crtR05VSyncEndPort : CRTC.crtR05VSyncEndTest;
  2114:              if (CRTC.crtR05VSyncEndCurr != curr) {
  2115:                CRTC.crtR05VSyncEndCurr = curr;
  2116:                CRTC.crtRestart ();
  2117:              }
  2118:            }
  2119:            return;
  2120:          case 0x000c:  //R06の上位
  2121:            CRTC.crtR06VBackEndPort = (d & (CRTC.crtVerticalMask >> 8)) << 8 | (CRTC.crtR06VBackEndPort & 0xff);
  2122:            {
  2123:              int curr = CRTC.crtR06VBackEndMask == 0 ? CRTC.crtR06VBackEndPort : CRTC.crtR06VBackEndTest;
  2124:              if (CRTC.crtR06VBackEndCurr != curr) {
  2125:                CRTC.crtR06VBackEndCurr = curr;
  2126:                CRTC.crtVDispStart = curr + 1;
  2127:                if (CRTC.CRT_RASTER_HASH_ON) {
  2128:                  CRTC.crtUpdateRasterHash ();
  2129:                }
  2130:                CRTC.crtRestart ();
  2131:              }
  2132:            }
  2133:            return;
  2134:          case 0x000d:  //R06の下位
  2135:            CRTC.crtR06VBackEndPort = (CRTC.crtR06VBackEndPort & ~0xff) | (d & 0xff);
  2136:            {
  2137:              int curr = CRTC.crtR06VBackEndMask == 0 ? CRTC.crtR06VBackEndPort : CRTC.crtR06VBackEndTest;
  2138:              if (CRTC.crtR06VBackEndCurr != curr) {
  2139:                CRTC.crtR06VBackEndCurr = curr;
  2140:                CRTC.crtVDispStart = curr + 1;
  2141:                if (CRTC.CRT_RASTER_HASH_ON) {
  2142:                  CRTC.crtUpdateRasterHash ();
  2143:                }
  2144:                CRTC.crtRestart ();
  2145:              }
  2146:            }
  2147:            return;
  2148:          case 0x000e:  //R07の上位
  2149:            CRTC.crtR07VDispEndPort = (d & (CRTC.crtVerticalMask >> 8)) << 8 | (CRTC.crtR07VDispEndPort & 0xff);
  2150:            {
  2151:              int curr = CRTC.crtR07VDispEndMask == 0 ? CRTC.crtR07VDispEndPort : CRTC.crtR07VDispEndTest;
  2152:              if (CRTC.crtR07VDispEndCurr != curr) {
  2153:                CRTC.crtR07VDispEndCurr = curr;
  2154:                CRTC.crtVIdleStart = curr + 1;
  2155:                if (CRTC.CRT_RASTER_HASH_ON) {
  2156:                  CRTC.crtUpdateRasterHash ();
  2157:                }
  2158:                CRTC.crtRestart ();
  2159:              }
  2160:            }
  2161:            return;
  2162:          case 0x000f:  //R07の下位
  2163:            CRTC.crtR07VDispEndPort = (CRTC.crtR07VDispEndPort & ~0xff) | (d & 0xff);
  2164:            {
  2165:              int curr = CRTC.crtR07VDispEndMask == 0 ? CRTC.crtR07VDispEndPort : CRTC.crtR07VDispEndTest;
  2166:              if (CRTC.crtR07VDispEndCurr != curr) {
  2167:                CRTC.crtR07VDispEndCurr = curr;
  2168:                CRTC.crtVIdleStart = curr + 1;
  2169:                if (CRTC.CRT_RASTER_HASH_ON) {
  2170:                  CRTC.crtUpdateRasterHash ();
  2171:                }
  2172:                CRTC.crtRestart ();
  2173:              }
  2174:            }
  2175:            return;
  2176:          case 0x0011:  //R08の下位
  2177:            d &= 0xff;
  2178:            if (CRTC.crtR08Adjust != d) {
  2179:              CRTC.crtR08Adjust = d;
  2180:              CRTC.crtRestart ();
  2181:            }
  2182:            return;
  2183:          case 0x0012:  //R09の上位
  2184:            CRTC.crtR09IRQRasterPort = (d & (CRTC.crtVerticalMask >> 8)) << 8 | (CRTC.crtR09IRQRasterPort & 0xff);
  2185:            {
  2186:              int curr = CRTC.crtR09IRQRasterMask == 0 ? CRTC.crtR09IRQRasterPort : CRTC.crtR09IRQRasterTest;
  2187:              if (CRTC.crtR09IRQRasterCurr != curr) {
  2188:                CRTC.crtR09IRQRasterCurr = curr;
  2189:                if (CRTC.CRT_RASTER_HASH_ON) {
  2190:                  CRTC.crtUpdateRasterHash ();
  2191:                }
  2192:                if (RasterBreakPoint.RBP_ON) {
  2193:                  RasterBreakPoint.rbpCheckIRQ ();
  2194:                }
  2195:              }
  2196:            }
  2197:            return;
  2198:          case 0x0013:  //R09の下位
  2199:            CRTC.crtR09IRQRasterPort = (CRTC.crtR09IRQRasterPort & ~0xff) | (d & 0xff);
  2200:            {
  2201:              int curr = CRTC.crtR09IRQRasterMask == 0 ? CRTC.crtR09IRQRasterPort : CRTC.crtR09IRQRasterTest;
  2202:              if (CRTC.crtR09IRQRasterCurr != curr) {
  2203:                CRTC.crtR09IRQRasterCurr = curr;
  2204:                if (CRTC.CRT_RASTER_HASH_ON) {
  2205:                  CRTC.crtUpdateRasterHash ();
  2206:                }
  2207:                if (RasterBreakPoint.RBP_ON) {
  2208:                  RasterBreakPoint.rbpCheckIRQ ();
  2209:                }
  2210:              }
  2211:            }
  2212:            return;
  2213:          case 0x0014:  //R10の上位
  2214:            CRTC.crtR10TxXPort = (d & 0x03) << 8 | (CRTC.crtR10TxXPort & 0xff);
  2215:            {
  2216:              int curr = CRTC.crtR10TxXMask == 0 ? CRTC.crtR10TxXPort : CRTC.crtR10TxXTest;
  2217:              if (CRTC.crtR10TxXCurr != curr) {
  2218:                CRTC.crtR10TxXCurr = curr;
  2219:                CRTC.crtAllStamp += 2;
  2220:              }
  2221:            }
  2222:            return;
  2223:          case 0x0015:  //R10の下位
  2224:            CRTC.crtR10TxXPort = (CRTC.crtR10TxXPort & ~0xff) | (d & 0xff);
  2225:            {
  2226:              int curr = CRTC.crtR10TxXMask == 0 ? CRTC.crtR10TxXPort : CRTC.crtR10TxXTest;
  2227:              if (CRTC.crtR10TxXCurr != curr) {
  2228:                CRTC.crtR10TxXCurr = curr;
  2229:                CRTC.crtAllStamp += 2;
  2230:              }
  2231:            }
  2232:            return;
  2233:          case 0x0016:  //R11の上位
  2234:            CRTC.crtR11TxYPort = (d & 0x03) << 8 | (CRTC.crtR11TxYPort & 0xff);
  2235:            {
  2236:              int curr = CRTC.crtR11TxYMask == 0 ? CRTC.crtR11TxYPort : CRTC.crtR11TxYTest;
  2237:              if (CRTC.crtR11TxYCurr != curr) {
  2238:                CRTC.crtR11TxYCurr = curr;
  2239:                //CRTC.crtAllStamp += 2;  //ラッチするとき更新する
  2240:              }
  2241:            }
  2242:            return;
  2243:          case 0x0017:  //R11の下位
  2244:            CRTC.crtR11TxYPort = (CRTC.crtR11TxYPort & ~0xff) | (d & 0xff);
  2245:            {
  2246:              int curr = CRTC.crtR11TxYMask == 0 ? CRTC.crtR11TxYPort : CRTC.crtR11TxYTest;
  2247:              if (CRTC.crtR11TxYCurr != curr) {
  2248:                CRTC.crtR11TxYCurr = curr;
  2249:                //CRTC.crtAllStamp += 2;  //ラッチするとき更新する
  2250:              }
  2251:            }
  2252:            return;
  2253:          case 0x0018:  //R12の上位
  2254:          case 0x001c:  //R14の上位
  2255:          case 0x0020:  //R16の上位
  2256:          case 0x0024:  //R18の上位
  2257:            {
  2258:              int p = (aa - 0x0018) >> 2;  //0,1,2,3
  2259:              CRTC.crtR12GrXPort[p] = (d & (p == 0 ? 0x03 : 0x01)) << 8 | (CRTC.crtR12GrXPort[p] & 0xff);
  2260:              int curr = CRTC.crtR12GrXMask[p] == 0 ? CRTC.crtR12GrXPort[p] : CRTC.crtR12GrXTest[p];
  2261:              if (CRTC.crtR12GrXCurr[p] != curr) {
  2262:                CRTC.crtR12GrXCurr[p] = curr;
  2263:                CRTC.crtAllStamp += 2;
  2264:              }
  2265:            }
  2266:            return;
  2267:          case 0x0019:  //R12の下位
  2268:          case 0x001d:  //R14の下位
  2269:          case 0x0021:  //R16の下位
  2270:          case 0x0025:  //R18の下位
  2271:            {
  2272:              int p = (aa - 0x0018) >> 2;  //0,1,2,3
  2273:              CRTC.crtR12GrXPort[p] = (CRTC.crtR12GrXPort[p] & ~0xff) | (d & 0xff);
  2274:              int curr = CRTC.crtR12GrXMask[p] == 0 ? CRTC.crtR12GrXPort[p] : CRTC.crtR12GrXTest[p];
  2275:              if (CRTC.crtR12GrXCurr[p] != curr) {
  2276:                CRTC.crtR12GrXCurr[p] = curr;
  2277:                CRTC.crtAllStamp += 2;
  2278:              }
  2279:            }
  2280:            return;
  2281:          case 0x001a:  //R13の上位
  2282:          case 0x001e:  //R15の上位
  2283:          case 0x0022:  //R17の上位
  2284:          case 0x0026:  //R19の上位
  2285:            {
  2286:              int p = (aa - 0x0018) >> 2;  //0,1,2,3
  2287:              CRTC.crtR13GrYPort[p] = (d & (p == 0 ? 0x03 : 0x01)) << 8 | (CRTC.crtR13GrYPort[p] & 0xff);
  2288:              int curr = CRTC.crtR13GrYMask[p] == 0 ? CRTC.crtR13GrYPort[p] : CRTC.crtR13GrYTest[p];
  2289:              if (CRTC.crtR13GrYCurr[p] != curr) {
  2290:                CRTC.crtR13GrYCurr[p] = curr;
  2291:                //CRTC.crtAllStamp += 2;  //ラッチするとき更新する
  2292:              }
  2293:            }
  2294:            return;
  2295:          case 0x001b:  //R13の下位
  2296:          case 0x001f:  //R15の下位
  2297:          case 0x0023:  //R17の下位
  2298:          case 0x0027:  //R19の下位
  2299:            {
  2300:              int p = (aa - 0x0018) >> 2;  //0,1,2,3
  2301:              CRTC.crtR13GrYPort[p] = (CRTC.crtR13GrYPort[p] & ~0xff) | (d & 0xff);
  2302:              int curr = CRTC.crtR13GrYMask[p] == 0 ? CRTC.crtR13GrYPort[p] : CRTC.crtR13GrYTest[p];
  2303:              if (CRTC.crtR13GrYCurr[p] != curr) {
  2304:                CRTC.crtR13GrYCurr[p] = curr;
  2305:                //CRTC.crtAllStamp += 2;  //ラッチするとき更新する
  2306:              }
  2307:            }
  2308:            return;
  2309:          case 0x0028:  //R20の上位
  2310:            CRTC.crtSetMemoryMode (d >> 4, d >> 3, d);
  2311:            return;
  2312:          case 0x0029:  //R20の下位
  2313:            CRTC.crtHighResoPort = d >>> 4 & 1;
  2314:            CRTC.crtVResoPort    = d >>> 2 & 3;
  2315:            CRTC.crtHResoPort    = d       & 3;
  2316:            SpriteScreen.sprAccessible = (d & 0b10010) != 0b10010;
  2317:            int highResoCurr = CRTC.crtHighResoMask == 0 ? CRTC.crtHighResoPort : CRTC.crtHighResoTest;
  2318:            int vResoCurr = CRTC.crtVResoMask == 0 ? CRTC.crtVResoPort : CRTC.crtVResoTest;
  2319:            int hResoCurr = CRTC.crtHResoMask == 0 ? CRTC.crtHResoPort : CRTC.crtHResoTest;
  2320:            if (CRTC.crtHighResoCurr != highResoCurr ||
  2321:                CRTC.crtVResoCurr != vResoCurr ||
  2322:                CRTC.crtHResoCurr != hResoCurr) {
  2323:              CRTC.crtHighResoCurr = highResoCurr;
  2324:              CRTC.crtVResoCurr = vResoCurr;
  2325:              CRTC.crtHResoCurr = hResoCurr;
  2326:              CRTC.crtRestart ();
  2327:            }
  2328:            return;
  2329:          case 0x002a:  //R21の上位
  2330:            CRTC.crtBitMask   = XEiJ.TEST_BIT_1_SHIFT ? d << 31 - 1 < 0 : (d & 2) != 0;
  2331:            CRTC.crtSimAccess = XEiJ.TEST_BIT_0_SHIFT ? d << 31 - 0 < 0 : (d & 1) != 0;
  2332:            return;
  2333:          case 0x002b:  //R21の下位
  2334:            CRTC.crtSimPlane3 = (byte) d < 0;  //(d & 128) != 0。d << 24 < 0
  2335:            CRTC.crtSimPlane2 = d << 25 < 0;  //(d & 64) != 0
  2336:            CRTC.crtSimPlane1 = d << 26 < 0;  //(d & 32) != 0
  2337:            CRTC.crtSimPlane0 = d << 27 < 0;  //(d & 16) != 0
  2338:            CRTC.crtCCPlane3  = XEiJ.TEST_BIT_3_SHIFT ? d << 31 - 3 < 0 : (d & 8) != 0;
  2339:            CRTC.crtCCPlane2  = XEiJ.TEST_BIT_2_SHIFT ? d << 31 - 2 < 0 : (d & 4) != 0;
  2340:            CRTC.crtCCPlane1  = XEiJ.TEST_BIT_1_SHIFT ? d << 31 - 1 < 0 : (d & 2) != 0;
  2341:            CRTC.crtCCPlane0  = XEiJ.TEST_BIT_0_SHIFT ? d << 31 - 0 < 0 : (d & 1) != 0;
  2342:            return;
  2343:          case 0x002c:  //R22の上位
  2344:            CRTC.crtR22SrcBlock = d & 0xff;
  2345:            return;
  2346:          case 0x002d:  //R22の下位
  2347:            CRTC.crtR22DstBlock = d & 0xff;
  2348:            return;
  2349:          case 0x002e:  //R23の上位
  2350:            CRTC.crtR23Mask = (d & 0xff) << 8 | (CRTC.crtR23Mask & 0xff);
  2351:            return;
  2352:          case 0x002f:  //R23の下位
  2353:            CRTC.crtR23Mask = (CRTC.crtR23Mask & ~0xff) | (d & 0xff);
  2354:            return;
  2355:            //case 0x0000:  //R00の上位
  2356:            //case 0x0002:  //R01の上位
  2357:            //case 0x0004:  //R02の上位
  2358:            //case 0x0006:  //R03の上位
  2359:            //case 0x0010:  //R08の上位
  2360:            //case 0x0030:  //R24の上位
  2361:            //case 0x0031:  //R24の下位
  2362:            //case 0x0032:  //R25の上位
  2363:            //case 0x0033:  //R25の下位
  2364:            //case 0x0034:  //R26の上位
  2365:            //case 0x0035:  //R26の下位
  2366:            //case 0x0036:  //R27の上位
  2367:            //case 0x0037:  //R27の下位
  2368:            //case 0x0038:  //R28の上位
  2369:            //case 0x0039:  //R28の下位
  2370:            //case 0x003a:  //R29の上位
  2371:            //case 0x003b:  //R29の下位
  2372:            //case 0x003c:  //R30の上位
  2373:            //case 0x003d:  //R30の下位
  2374:            //case 0x003e:  //R31の上位
  2375:            //case 0x003f:  //R31の下位
  2376:          default:
  2377:            return;
  2378:          }
  2379:        } else {  //$00E80400~$00E807FF
  2380:          aa &= 0xff;  //$00E80500~$00E807FF→$00E80400~$00E804FF
  2381:          if (aa < 0x80) {  //$00E80400~$00E8047F
  2382:            super.mmdWb (a, d);  //バスエラー
  2383:          } else {  //$00E80480~$00E804FF
  2384:            aa &= 0x01;  //$00E80482~$00E804FF→$00E80480~$00E80481
  2385:            if (aa == 0) {  //動作ポートの上位
  2386:              return;
  2387:            } else {  //動作ポートの下位
  2388:              boolean rasterCopyOn = (d & 8) != 0;
  2389:              if (CRTC.crtRasterCopyOn != rasterCopyOn) {
  2390:                CRTC.crtRasterCopyOn = rasterCopyOn;  //ラスタコピー
  2391:                if (CRTC.CRT_RASTER_HASH_ON) {
  2392:                  CRTC.crtUpdateRasterHash ();
  2393:                }
  2394:              }
  2395:              CRTC.crtClearStandby = (d & 2) != 0;  //高速クリア
  2396:              return;
  2397:            }
  2398:          }
  2399:        }
  2400:      }
  2401:     @Override protected void mmdWw (int a, int d) throws M68kException {
  2402:        XEiJ.mpuClockTime += XEiJ.busWaitTime.crtc;
  2403:        int aa = a & 0x07ff;  //$00E80800~$00E81FFF→$00E80000~$00E807FF
  2404:        if (aa < 0x0400) {  //$00E80000~$00E803FF
  2405:          aa &= 0x003f;
  2406:          switch (aa) {
  2407:          case 0x0000:  //R00
  2408:            CRTC.crtR00HFrontEndPort = (d & 0xff) | (CRTC.crtR00Bit0Zero ? 0x00 : 0x01);
  2409:            {
  2410:              int curr = CRTC.crtR00HFrontEndMask == 0 ? CRTC.crtR00HFrontEndPort : CRTC.crtR00HFrontEndTest;
  2411:              if (CRTC.crtR00HFrontEndCurr != curr) {
  2412:                CRTC.crtR00HFrontEndCurr = curr;
  2413:                CRTC.crtRestart ();
  2414:              }
  2415:            }
  2416:            return;
  2417:          case 0x0002:  //R01
  2418:            CRTC.crtR01HSyncEndPort = d & 0xff;
  2419:            {
  2420:              int curr = CRTC.crtR01HSyncEndMask == 0 ? CRTC.crtR01HSyncEndPort : CRTC.crtR01HSyncEndTest;
  2421:              if (CRTC.crtR01HSyncEndCurr != curr) {
  2422:                CRTC.crtR01HSyncEndCurr = curr;
  2423:                CRTC.crtRestart ();
  2424:              }
  2425:            }
  2426:            return;
  2427:          case 0x0004:  //R02
  2428:            CRTC.crtR02HBackEndPort = d & 0xff;
  2429:            {
  2430:              int curr = CRTC.crtR02HBackEndMask == 0 ? CRTC.crtR02HBackEndPort : CRTC.crtR02HBackEndTest;
  2431:              if (CRTC.crtR02HBackEndCurr != curr) {
  2432:                CRTC.crtR02HBackEndCurr = curr;
  2433:                CRTC.crtRestart ();
  2434:              }
  2435:            }
  2436:            return;
  2437:          case 0x0006:  //R03
  2438:            CRTC.crtR03HDispEndPort = d & 0xff;
  2439:            {
  2440:              int curr = CRTC.crtR03HDispEndMask == 0 ? CRTC.crtR03HDispEndPort : CRTC.crtR03HDispEndTest;
  2441:              if (CRTC.crtR03HDispEndCurr != curr) {
  2442:                CRTC.crtR03HDispEndCurr = curr;
  2443:                CRTC.crtRestart ();
  2444:              }
  2445:            }
  2446:            return;
  2447:          case 0x0008:  //R04
  2448:            CRTC.crtR04VFrontEndPort = d & CRTC.crtVerticalMask;
  2449:            {
  2450:              int curr = CRTC.crtR04VFrontEndMask == 0 ? CRTC.crtR04VFrontEndPort : CRTC.crtR04VFrontEndTest;
  2451:              if (CRTC.crtR04VFrontEndCurr != curr) {
  2452:                CRTC.crtR04VFrontEndCurr = curr;
  2453:                if (CRTC.CRT_RASTER_HASH_ON) {
  2454:                  CRTC.crtUpdateRasterHash ();
  2455:                }
  2456:                CRTC.crtRestart ();
  2457:              }
  2458:            }
  2459:            return;
  2460:          case 0x000a:  //R05
  2461:            CRTC.crtR05VSyncEndPort = d & CRTC.crtVerticalMask;
  2462:            {
  2463:              int curr = CRTC.crtR05VSyncEndMask == 0 ? CRTC.crtR05VSyncEndPort : CRTC.crtR05VSyncEndTest;
  2464:              if (CRTC.crtR05VSyncEndCurr != curr) {
  2465:                CRTC.crtR05VSyncEndCurr = curr;
  2466:                CRTC.crtRestart ();
  2467:              }
  2468:            }
  2469:            return;
  2470:          case 0x000c:  //R06
  2471:            CRTC.crtR06VBackEndPort = d & CRTC.crtVerticalMask;
  2472:            {
  2473:              int curr = CRTC.crtR06VBackEndMask == 0 ? CRTC.crtR06VBackEndPort : CRTC.crtR06VBackEndTest;
  2474:              if (CRTC.crtR06VBackEndCurr != curr) {
  2475:                CRTC.crtR06VBackEndCurr = curr;
  2476:                CRTC.crtVDispStart = curr + 1;
  2477:                if (CRTC.CRT_RASTER_HASH_ON) {
  2478:                  CRTC.crtUpdateRasterHash ();
  2479:                }
  2480:                CRTC.crtRestart ();
  2481:              }
  2482:            }
  2483:            return;
  2484:          case 0x000e:  //R07
  2485:            CRTC.crtR07VDispEndPort = d & CRTC.crtVerticalMask;
  2486:            {
  2487:              int curr = CRTC.crtR07VDispEndMask == 0 ? CRTC.crtR07VDispEndPort : CRTC.crtR07VDispEndTest;
  2488:              if (CRTC.crtR07VDispEndCurr != curr) {
  2489:                CRTC.crtR07VDispEndCurr = curr;
  2490:                CRTC.crtVIdleStart = curr + 1;
  2491:                if (CRTC.CRT_RASTER_HASH_ON) {
  2492:                  CRTC.crtUpdateRasterHash ();
  2493:                }
  2494:                CRTC.crtRestart ();
  2495:              }
  2496:            }
  2497:            return;
  2498:          case 0x0010:  //R08
  2499:            d &= 0xff;
  2500:            if (CRTC.crtR08Adjust != d) {
  2501:              CRTC.crtR08Adjust = d;
  2502:              CRTC.crtRestart ();
  2503:            }
  2504:            return;
  2505:          case 0x0012:  //R09
  2506:            CRTC.crtR09IRQRasterPort = d & CRTC.crtVerticalMask;
  2507:            {
  2508:              int curr = CRTC.crtR09IRQRasterMask == 0 ? CRTC.crtR09IRQRasterPort : CRTC.crtR09IRQRasterTest;
  2509:              if (CRTC.crtR09IRQRasterCurr != curr) {
  2510:                CRTC.crtR09IRQRasterCurr = curr;
  2511:                if (CRTC.CRT_RASTER_HASH_ON) {
  2512:                  CRTC.crtUpdateRasterHash ();
  2513:                }
  2514:                if (RasterBreakPoint.RBP_ON) {
  2515:                  RasterBreakPoint.rbpCheckIRQ ();
  2516:                }
  2517:              }
  2518:            }
  2519:            return;
  2520:          case 0x0014:  //R10
  2521:            CRTC.crtR10TxXPort = d & 0x03ff;
  2522:            {
  2523:              int curr = CRTC.crtR10TxXMask == 0 ? CRTC.crtR10TxXPort : CRTC.crtR10TxXTest;
  2524:              if (CRTC.crtR10TxXCurr != curr) {
  2525:                CRTC.crtR10TxXCurr = curr;
  2526:                CRTC.crtAllStamp += 2;
  2527:              }
  2528:            }
  2529:            return;
  2530:          case 0x0016:  //R11
  2531:            CRTC.crtR11TxYPort = d & 0x03ff;
  2532:            {
  2533:              int curr = CRTC.crtR11TxYMask == 0 ? CRTC.crtR11TxYPort : CRTC.crtR11TxYTest;
  2534:              if (CRTC.crtR11TxYCurr != curr) {
  2535:                CRTC.crtR11TxYCurr = curr;
  2536:                //CRTC.crtAllStamp += 2;  //ラッチするとき更新する
  2537:              }
  2538:            }
  2539:            return;
  2540:          case 0x0018:  //R12
  2541:          case 0x001c:  //R14
  2542:          case 0x0020:  //R16
  2543:          case 0x0024:  //R18
  2544:            {
  2545:              int p = (aa - 0x0018) >> 2;  //0,1,2,3
  2546:              CRTC.crtR12GrXPort[p] = d & (p == 0 ? 0x03ff : 0x01ff);
  2547:              int curr = CRTC.crtR12GrXMask[p] == 0 ? CRTC.crtR12GrXPort[p] : CRTC.crtR12GrXTest[p];
  2548:              if (CRTC.crtR12GrXCurr[p] != curr) {
  2549:                CRTC.crtR12GrXCurr[p] = curr;
  2550:                CRTC.crtAllStamp += 2;
  2551:              }
  2552:            }
  2553:            return;
  2554:          case 0x001a:  //R13
  2555:          case 0x001e:  //R15
  2556:          case 0x0022:  //R17
  2557:          case 0x0026:  //R19
  2558:            {
  2559:              int p = (aa - 0x0018) >> 2;  //0,1,2,3
  2560:              CRTC.crtR13GrYPort[p] = d & (p == 0 ? 0x03ff : 0x01ff);
  2561:              int curr = CRTC.crtR13GrYMask[p] == 0 ? CRTC.crtR13GrYPort[p] : CRTC.crtR13GrYTest[p];
  2562:              if (CRTC.crtR13GrYCurr[p] != curr) {
  2563:                CRTC.crtR13GrYCurr[p] = curr;
  2564:                //CRTC.crtAllStamp += 2;  //ラッチするとき更新する
  2565:              }
  2566:            }
  2567:            return;
  2568:          case 0x0028:  //R20
  2569:            CRTC.crtSetMemoryMode (d >> 12, d >> 11, d >> 8);
  2570:            CRTC.crtHighResoPort = d >>> 4 & 1;
  2571:            CRTC.crtVResoPort    = d >>> 2 & 3;
  2572:            CRTC.crtHResoPort    = d       & 3;
  2573:            SpriteScreen.sprAccessible = (d & 0b10010) != 0b10010;
  2574:            int highResoCurr = CRTC.crtHighResoMask == 0 ? CRTC.crtHighResoPort : CRTC.crtHighResoTest;
  2575:            int vResoCurr = CRTC.crtVResoMask == 0 ? CRTC.crtVResoPort : CRTC.crtVResoTest;
  2576:            int hResoCurr = CRTC.crtHResoMask == 0 ? CRTC.crtHResoPort : CRTC.crtHResoTest;
  2577:            if (CRTC.crtHighResoCurr != highResoCurr ||
  2578:                CRTC.crtVResoCurr != vResoCurr ||
  2579:                CRTC.crtHResoCurr != hResoCurr) {
  2580:              CRTC.crtHighResoCurr = highResoCurr;
  2581:              CRTC.crtVResoCurr = vResoCurr;
  2582:              CRTC.crtHResoCurr = hResoCurr;
  2583:              CRTC.crtRestart ();
  2584:            }
  2585:            return;
  2586:          case 0x002a:  //R21
  2587:            CRTC.crtBitMask   = d << 22 < 0;  //(d & 512) != 0
  2588:            CRTC.crtSimAccess = d << 23 < 0;  //(d & 256) != 0
  2589:            CRTC.crtSimPlane3 = (byte) d < 0;  //(d & 128) != 0。d << 24 < 0
  2590:            CRTC.crtSimPlane2 = d << 25 < 0;  //(d & 64) != 0
  2591:            CRTC.crtSimPlane1 = d << 26 < 0;  //(d & 32) != 0
  2592:            CRTC.crtSimPlane0 = d << 27 < 0;  //(d & 16) != 0
  2593:            CRTC.crtCCPlane3  = XEiJ.TEST_BIT_3_SHIFT ? d << 31 - 3 < 0 : (d & 8) != 0;
  2594:            CRTC.crtCCPlane2  = XEiJ.TEST_BIT_2_SHIFT ? d << 31 - 2 < 0 : (d & 4) != 0;
  2595:            CRTC.crtCCPlane1  = XEiJ.TEST_BIT_1_SHIFT ? d << 31 - 1 < 0 : (d & 2) != 0;
  2596:            CRTC.crtCCPlane0  = XEiJ.TEST_BIT_0_SHIFT ? d << 31 - 0 < 0 : (d & 1) != 0;
  2597:            return;
  2598:          case 0x002c:  //R22
  2599:            CRTC.crtR22SrcBlock = d >> 8 & 0xff;
  2600:            CRTC.crtR22DstBlock = d      & 0xff;
  2601:            return;
  2602:          case 0x002e:  //R23
  2603:            CRTC.crtR23Mask = (char) d;
  2604:            return;
  2605:            //case 0x0030:  //R24
  2606:            //case 0x0032:  //R25
  2607:            //case 0x0034:  //R26
  2608:            //case 0x0036:  //R27
  2609:            //case 0x0038:  //R28
  2610:            //case 0x003a:  //R29
  2611:            //case 0x003c:  //R30
  2612:            //case 0x003e:  //R31
  2613:          default:
  2614:            return;
  2615:          }
  2616:        } else {  //$00E80400~$00E807FF
  2617:          aa &= 0xff;  //$00E80500~$00E807FF→$00E80400~$00E804FF
  2618:          if (aa < 0x80) {  //$00E80400~$00E8047F
  2619:            super.mmdWw (a, d);  //バスエラー
  2620:          } else {  //$00E80480~$00E804FF  動作ポート
  2621:            boolean rasterCopyOn = (d & 8) != 0;
  2622:            if (CRTC.crtRasterCopyOn != rasterCopyOn) {
  2623:              CRTC.crtRasterCopyOn = rasterCopyOn;  //ラスタコピー
  2624:              if (CRTC.CRT_RASTER_HASH_ON) {
  2625:                CRTC.crtUpdateRasterHash ();
  2626:              }
  2627:            }
  2628:            CRTC.crtClearStandby = (d & 2) != 0;  //高速クリア
  2629:            return;
  2630:          }
  2631:        }
  2632:      }
  2633:     @Override protected void mmdWl (int a, int d) throws M68kException {
  2634:        mmdWw (a    , d >> 16);
  2635:        mmdWw (a + 2, d      );
  2636:      }
  2637:   },  //MMD_CRT
  2638: 
  2639:   //--------------------------------------------------------------------------------
  2640:   //MMD_VCN ビデオコントローラ
  2641:   //
  2642:   //  $00E82000~$00E821FF  ワードレジスタ
  2643:   //  $00E82200~$00E823FF  ワードレジスタ
  2644:   //  $00E82400~$00E82401  ワードレジスタ
  2645:   //  $00E82402~$00E824FF  $00E82400~$00E82401の繰り返し
  2646:   //  $00E82500~$00E82501  ワードレジスタ
  2647:   //  $00E82502~$00E825FF  $00E82500~$00E82501の繰り返し
  2648:   //  $00E82600~$00E82601  ワードレジスタ
  2649:   //  $00E82602~$00E826FF  $00E82600~$00E82601の繰り返し
  2650:   //  $00E82700~$00E82FFF  $0000
  2651:   //  $00E83000~$00E83FFF  $00E82000~$00E82FFFの繰り返し
  2652:   //
  2653:   MMD_VCN {
  2654:     @Override public String toString () {
  2655:       return Multilingual.mlnJapanese ? "ビデオコントローラ" : "Video Controller";
  2656:     }
  2657:     //リード
  2658:     @Override protected int mmdRbz (int a) throws M68kException {
  2659:        int aa = a & 0x1fff;  //$00E83000~$00E83FFF→$00E82000~$00E82FFF
  2660:        if (aa < 0x0400) {  //パレット
  2661:          XEiJ.mpuClockTime += XEiJ.busWaitTime.palet;
  2662:          int d = (aa < 0x0200 ? VideoController.vcnPal16G8[aa >> 1] :  //$00E82000~$00E821FF  グラフィック
  2663:                   VideoController.vcnPal16TS[(aa - 0x0200) >> 1]);  //$00E82200~$00E823FF  テキストスプライト
  2664:          return (aa & 1) == 0 ? d >> 8 : d & 0xff;
  2665:        } else {  //レジスタ
  2666:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2667:          int d = (aa < 0x0500 ? VideoController.vcnReg1Port :  //$00E82400~$00E824FF
  2668:                   aa < 0x0600 ? VideoController.vcnReg2Port :  //$00E82500~$00E825FF
  2669:                   aa < 0x0700 ? VideoController.vcnReg3Port :  //$00E82600~$00E826FF
  2670:                   0);  //$00E82700~$00E82FFF
  2671:          return (aa & 1) == 0 ? d >> 8 : d & 0xff;
  2672:        }
  2673:      }
  2674:     @Override protected int mmdRwz (int a) throws M68kException {
  2675:        int aa = a & 0x1fff;  //$00E83000~$00E83FFF→$00E82000~$00E82FFF
  2676:        if (aa < 0x0400) {  //パレット
  2677:          XEiJ.mpuClockTime += XEiJ.busWaitTime.palet;
  2678:          return (aa < 0x0200 ? VideoController.vcnPal16G8[aa >> 1] :  //$00E82000~$00E821FF  グラフィックスパレット
  2679:                  VideoController.vcnPal16TS[(aa - 0x0200) >> 1]);  //$00E82200~$00E823FF  テキストスプライトパレット
  2680:        } else {  //レジスタ
  2681:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2682:          return (aa < 0x0500 ? VideoController.vcnReg1Port :  //$00E82400~$00E824FF
  2683:                  aa < 0x0600 ? VideoController.vcnReg2Port :  //$00E82500~$00E825FF
  2684:                  aa < 0x0700 ? VideoController.vcnReg3Port :  //$00E82600~$00E826FF
  2685:                  0);  //$00E82700~$00E82FFF
  2686:        }
  2687:      }
  2688:     @Override protected int mmdRls (int a) throws M68kException {
  2689:        return mmdRwz (a) << 16 | mmdRwz (a + 2);
  2690:      }
  2691:     //ライト
  2692:     @Override protected void mmdWb (int a, int d) throws M68kException {
  2693:        int aa = a & 0x1fff;  //$00E83000~$00E83FFF→$00E82000~$00E82FFF
  2694:        if (aa < 0x0200) {  //$00E82000~$00E821FF  グラフィックスパレット
  2695:          XEiJ.mpuClockTime += XEiJ.busWaitTime.palet;
  2696:          d &= 0xff;
  2697:          int n = aa >> 1;
  2698:          if ((aa & 1) == 0) {  //a=0,2,4,6,8,10,12,14
  2699:            VideoController.vcnPal32G8[n] = VideoController.vcnPalTbl[
  2700:              VideoController.vcnPal16G8[n] = d << 8 | (VideoController.vcnPal16G8[n] & 0xff)
  2701:              ];
  2702:            if ((n & 1) == 0) {  //a=0,4,8,12 n=0,2,4,6
  2703:              VideoController.vcnPal8G16L[n] = d;
  2704:            } else {  //a=2,6,10,14 n-1=0,2,4,6
  2705:              VideoController.vcnPal8G16H[n - 1] = d << 8;
  2706:            }
  2707:          } else {  //a=1,3,5,7,9,11,13,15
  2708:            VideoController.vcnPal32G8[n] = VideoController.vcnPalTbl[
  2709:              VideoController.vcnPal16G8[n] = (VideoController.vcnPal16G8[n] & ~0xff) | d
  2710:              ];
  2711:            if ((n & 1) == 0) {  //a=1,5,9,13 n+1=1,3,5,7
  2712:              VideoController.vcnPal8G16L[n + 1] = d;
  2713:            } else {  //a=3,7,11,15 n=1,3,5,7
  2714:              VideoController.vcnPal8G16H[n] = d << 8;
  2715:            }
  2716:          }
  2717:          if ((VideoController.vcnReg3Curr & 0x001f) != 0) {  //グラフィックス画面が表示されている
  2718:            CRTC.crtAllStamp += 2;
  2719:          }
  2720:        } else if (aa < 0x0400) {  //$00E82200~$00E823FF  テキストスプライトパレット
  2721:          XEiJ.mpuClockTime += XEiJ.busWaitTime.palet;
  2722:          d &= 0xff;
  2723:          int n = (aa - 0x0200) >> 1;
  2724:          VideoController.vcnPal32TS[n] = VideoController.vcnPalTbl[
  2725:            VideoController.vcnPal16TS[n] = ((aa & 1) == 0 ?
  2726:                                             d << 8 | (VideoController.vcnPal16TS[n] & 0xff) :
  2727:                                             (VideoController.vcnPal16TS[n] & ~0xff) | d)
  2728:            ];
  2729:          if ((VideoController.vcnReg3Curr << 31 - 6 < 0 && SpriteScreen.sprReg4BgCtrlCurr << 31 - 9 < 0) ||  //スプライト画面が表示されている
  2730:              (VideoController.vcnReg3Curr << 31 - 5 < 0 && n < 16)) {  //テキスト画面が表示されていてテキストパレットが操作された
  2731:            CRTC.crtAllStamp += 2;
  2732:          }
  2733:        } else if (aa < 0x0500) {  //$00E82400~$00E824FF
  2734:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2735:          d = (aa & 1) == 0 ? 0x00 : d & 0x07;
  2736:          if (VideoController.vcnReg1Port != d) {
  2737:            VideoController.vcnReg1Port = d;
  2738:            VideoController.vcnReg1Curr = ((VideoController.vcnReg1Port & ~VideoController.vcnReg1Mask) |
  2739:                                           (VideoController.vcnReg1Test & VideoController.vcnReg1Mask));
  2740:            VideoController.vcnUpdateMode ();
  2741:          }
  2742:        } else if (aa < 0x0600) {  //$00E82500~$00E825FF
  2743:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2744:          d = ((aa & 1) == 0 ?
  2745:               (d & 0x3f) << 8 | (VideoController.vcnReg2Port & 0xff) :
  2746:               (VideoController.vcnReg2Port & ~0xff) | (d & 0xff));
  2747:          if (VideoController.vcnReg2Port != d) {
  2748:            VideoController.vcnReg2Port = d;
  2749:            VideoController.vcnReg2Curr = ((VideoController.vcnReg2Port & ~VideoController.vcnReg2Mask) |
  2750:                                           (VideoController.vcnReg2Test & VideoController.vcnReg2Mask));
  2751:            VideoController.vcnUpdateMode ();
  2752:          }
  2753:        } else if (aa < 0x0700) {  //$00E82600~$00E826FF
  2754:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2755:          d = ((aa & 1) == 0 ?
  2756:               (d & 0xff) << 8 | (VideoController.vcnReg3Port & 0xff) :
  2757:               (VideoController.vcnReg3Port & ~0xff) | (d & 0xff));
  2758:          if (VideoController.vcnReg3Port != d) {
  2759:            VideoController.vcnReg3Port = d;
  2760:            VideoController.vcnReg3Curr = ((VideoController.vcnReg3Port & ~VideoController.vcnReg3Mask) |
  2761:                                           (VideoController.vcnReg3Test & VideoController.vcnReg3Mask));
  2762:            VideoController.vcnUpdateMode ();
  2763:          }
  2764:        } else {  //$00E82700~$00E82FFF
  2765:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2766:        }
  2767:      }
  2768:     @Override protected void mmdWw (int a, int d) throws M68kException {
  2769:        int aa = a & 0x1fff;  //$00E83000~$00E83FFF→$00E82000~$00E82FFF
  2770:        if (aa < 0x0200) {  //$00E82000~$00E821FF  グラフィックスパレット
  2771:          XEiJ.mpuClockTime += XEiJ.busWaitTime.palet;
  2772:          int n = aa >> 1;  //a=0,2,4,6,8,10,12,14 n=0,1,2,3,4,5,6,7
  2773:          VideoController.vcnPal32G8[n] = VideoController.vcnPalTbl[
  2774:            VideoController.vcnPal16G8[n] = (char) d
  2775:            ];
  2776:          if ((n & 1) == 0) {  //a=0,4,8,12 n=0,2,4,6 n+1=1,3,5,7
  2777:            VideoController.vcnPal8G16L[n] = d >> 8 & 0xff;
  2778:            VideoController.vcnPal8G16L[n + 1] = d & 0xff;
  2779:          } else {  //a=2,4,6,8 n-1=0,2,4,6 n=1,3,5,7
  2780:            VideoController.vcnPal8G16H[n - 1] = d & 0xff00;
  2781:            VideoController.vcnPal8G16H[n] = (d & 0xff) << 8;
  2782:          }
  2783:          if ((VideoController.vcnReg3Curr & 0x001f) != 0) {  //グラフィックス画面が表示されている
  2784:            CRTC.crtAllStamp += 2;
  2785:          }
  2786:        } else if (aa < 0x0400) {  //$00E82200~$00E823FF  テキストスプライトパレット
  2787:          XEiJ.mpuClockTime += XEiJ.busWaitTime.palet;
  2788:          int n = (aa - 0x0200) >> 1;
  2789:          VideoController.vcnPal32TS[n] = VideoController.vcnPalTbl[
  2790:            VideoController.vcnPal16TS[n] = (char) d
  2791:            ];
  2792:          if ((VideoController.vcnReg3Curr << 31 - 6 < 0 && SpriteScreen.sprReg4BgCtrlCurr << 31 - 9 < 0) ||  //スプライト画面が表示されている
  2793:              (VideoController.vcnReg3Curr << 31 - 5 < 0 && n < 16)) {  //テキスト画面が表示されていてテキストパレットが操作された
  2794:            CRTC.crtAllStamp += 2;
  2795:          }
  2796:        } else if (aa < 0x0500) {  //$00E82400~$00E824FF
  2797:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2798:          d &= 0x0007;
  2799:          if (VideoController.vcnReg1Port != d) {
  2800:            VideoController.vcnReg1Port = d;
  2801:            VideoController.vcnReg1Curr = ((VideoController.vcnReg1Port & ~VideoController.vcnReg1Mask) |
  2802:                                           (VideoController.vcnReg1Test & VideoController.vcnReg1Mask));
  2803:            VideoController.vcnUpdateMode ();
  2804:          }
  2805:        } else if (aa < 0x0600) {  //$00E82500~$00E825FF
  2806:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2807:          d &= 0x3fff;
  2808:          if (VideoController.vcnReg2Port != d) {
  2809:            VideoController.vcnReg2Port = d;
  2810:            VideoController.vcnReg2Curr = ((VideoController.vcnReg2Port & ~VideoController.vcnReg2Mask) |
  2811:                                           (VideoController.vcnReg2Test & VideoController.vcnReg2Mask));
  2812:            VideoController.vcnUpdateMode ();
  2813:          }
  2814:        } else if (aa < 0x0700) {  //$00E82600~$00E826FF
  2815:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2816:          d &= 0xffff;
  2817:          if (VideoController.vcnReg3Port != d) {
  2818:            VideoController.vcnReg3Port = d;
  2819:            VideoController.vcnReg3Curr = ((VideoController.vcnReg3Port & ~VideoController.vcnReg3Mask) |
  2820:                                           (VideoController.vcnReg3Test & VideoController.vcnReg3Mask));
  2821:            VideoController.vcnUpdateMode ();
  2822:          }
  2823:        } else {  //$00E82700~$00E82FFF
  2824:          XEiJ.mpuClockTime += XEiJ.busWaitTime.vicon;
  2825:        }
  2826:      }
  2827:     @Override protected void mmdWl (int a, int d) throws M68kException {
  2828:        mmdWw (a    , d >> 16);
  2829:        mmdWw (a + 2, d      );
  2830:      }
  2831:   },  //MMD_VCN
  2832: 
  2833:   //--------------------------------------------------------------------------------
  2834:   //MMD_DMA DMAコントローラ
  2835:   //
  2836:   //  $00E84000~$00E8403F  ワードまたはロングワードレジスタ(CH0)
  2837:   //  $00E84040~$00E8407F  ワードまたはロングワードレジスタ(CH1)
  2838:   //  $00E84080~$00E840BF  ワードまたはロングワードレジスタ(CH2)
  2839:   //  $00E840C0~$00E840FF  ワードまたはロングワードレジスタ(CH4)
  2840:   //  $00E84100~$00E85FFF  $00E84000~$00E840FFの繰り返し
  2841:   //
  2842:   MMD_DMA {
  2843:     @Override public String toString () {
  2844:       return Multilingual.mlnJapanese ? "DMA コントローラ" : "DMA Controller";
  2845:     }
  2846:     //リード
  2847:     @Override protected int mmdRbz (int a) throws M68kException {
  2848:        XEiJ.mpuClockTime += XEiJ.busWaitTime.dmac;
  2849:        return HD63450.dmaReadByte (a);
  2850:      }
  2851:     @Override protected int mmdRwz (int a) throws M68kException {
  2852:        XEiJ.mpuClockTime += XEiJ.busWaitTime.dmac;
  2853:        return HD63450.dmaReadWord (a);
  2854:      }
  2855:     @Override protected int mmdRls (int a) throws M68kException {
  2856:        XEiJ.mpuClockTime += XEiJ.busWaitTime.dmac * 2;
  2857:        return HD63450.dmaReadLong (a);
  2858:      }
  2859:     //ライト
  2860:     @Override protected void mmdWb (int a, int d) throws M68kException {
  2861:        XEiJ.mpuClockTime += XEiJ.busWaitTime.dmac;
  2862:        HD63450.dmaWriteByte (a, d);
  2863:        return;
  2864:      }
  2865:     @Override protected void mmdWw (int a, int d) throws M68kException {
  2866:        XEiJ.mpuClockTime += XEiJ.busWaitTime.dmac;
  2867:        HD63450.dmaWriteWord (a, d);
  2868:        return;
  2869:      }
  2870:     @Override protected void mmdWl (int a, int d) throws M68kException {
  2871:        XEiJ.mpuClockTime += XEiJ.busWaitTime.dmac * 2;
  2872:        HD63450.dmaWriteLong (a, d);
  2873:        return;
  2874:      }
  2875:   },  //MMD_DMA
  2876: 
  2877:   //--------------------------------------------------------------------------------
  2878:   //MMD_SVS スーパーバイザ領域設定
  2879:   //
  2880:   //  $00E86000  バイトアクセスはバスエラー。ワードリードはバスエラー。ワードライトは$??xx
  2881:   //  $00E86001  バイトリードはバスエラー。バイトライトは$xx
  2882:   //  $00E86002~$00E87FFF  $00E86000~$00E86001の繰り返し
  2883:   //
  2884:   MMD_SVS {
  2885:     @Override public String toString () {
  2886:       return Multilingual.mlnJapanese ? "スーパーバイザ領域設定" : "Supervisor Area Setting";
  2887:     }
  2888:     //ライト
  2889:     @Override protected void mmdWb (int a, int d) throws M68kException {
  2890:        if ((a & 1) == 0) {  //偶数アドレスへのバイトライト
  2891:          super.mmdWb (a, d);  //バスエラー
  2892:        } else {  //奇数アドレスへのバイトライト
  2893:          XEiJ.mpuClockTime += XEiJ.busWaitTime.sysport;  //!!!
  2894:          MainMemory.mmrSetSupervisorArea (d);
  2895:        }
  2896:      }
  2897:     @Override protected void mmdWw (int a, int d) throws M68kException {
  2898:        mmdWb (a + 1, d);
  2899:      }
  2900:     @Override protected void mmdWl (int a, int d) throws M68kException {
  2901:        mmdWw (a, d >> 16);
  2902:        mmdWw (a + 2, d);
  2903:      }
  2904:   },  //MMD_SVS
  2905: 
  2906:   //--------------------------------------------------------------------------------
  2907:   //MMD_MFP MFP
  2908:   //
  2909:   //  $00E88000~$00E8803F(偶数)  バイトアクセスはバスエラー。ワードリードは$FFxx。ワードライトは$??xx
  2910:   //  $00E88000~$00E8803F(奇数)  バイトレジスタ
  2911:   //  $00E88040~$00E89FFF  $00E88000~$00E8803Fの繰り返し
  2912:   //
  2913:   MMD_MFP {
  2914:     @Override public String toString () {
  2915:       return Multilingual.mlnJapanese ? "MFP" : "MFP";  //Multi Function Peripheral
  2916:     }
  2917:     //ピーク
  2918:     @Override protected int mmdPbz (int a) {
  2919:       return MC68901.mfpPeekByte (a);
  2920:     }
  2921:     //リード
  2922:     @Override protected int mmdRbz (int a) throws M68kException {
  2923:        return MC68901.mfpReadByte (a);
  2924:      }
  2925:     @Override protected int mmdRwz (int a) throws M68kException {
  2926:        return 0xff00 | mmdRbz (a + 1);
  2927:      }
  2928:     @Override protected int mmdRls (int a) throws M68kException {
  2929:        return mmdRwz (a) << 16 | mmdRwz (a + 2);
  2930:      }
  2931:     //ライト
  2932:     @Override protected void mmdWb (int a, int d) throws M68kException {
  2933:        MC68901.mfpWriteByte (a, d);
  2934:      }
  2935:     @Override protected void mmdWw (int a, int d) throws M68kException {
  2936:        mmdWb (a + 1, d);
  2937:      }
  2938:     @Override protected void mmdWl (int a, int d) throws M68kException {
  2939:        mmdWw (a, d >> 16);
  2940:        mmdWw (a + 2, d);
  2941:      }
  2942:   },  //MMD_MFP
  2943: 
  2944:   //--------------------------------------------------------------------------------
  2945:   //MMD_RTC_FIRST RTC
  2946:   //
  2947:   //  $00E8A000~$00E8A01F(偶数)  バイトアクセスはバスエラー。ワードリードは$FFxx。ワードライトは$??xx
  2948:   //  $00E8A000~$00E8A01F(奇数)  バイトレジスタ
  2949:   //  $00E8A020~$00E8AFFF  $00E8A000~$00E8A01Fの繰り返し
  2950:   //
  2951:   MMD_RTC_FIRST {
  2952:     @Override public String toString () {
  2953:       return Multilingual.mlnJapanese ? "RTC" : "RTC";  //Real-Time Clock
  2954:     }
  2955:     //ピーク
  2956:     @Override protected byte mmdPbs (int a) {
  2957:       return (byte) RP5C15.rtcPeekByte (a);
  2958:     }
  2959:     @Override protected int mmdPbz (int a) {
  2960:       return RP5C15.rtcPeekByte (a);
  2961:     }
  2962:     @Override protected int mmdPws (int a) {
  2963:       return RP5C15.rtcPeekByte (a + 1);
  2964:     }
  2965:     @Override protected int mmdPwz (int a) {
  2966:       return RP5C15.rtcPeekByte (a + 1);
  2967:     }
  2968:     @Override protected int mmdPls (int a) {
  2969:       return (RP5C15.rtcPeekByte (a + 1) << 16 |
  2970:               RP5C15.rtcPeekByte (a + 3));
  2971:     }
  2972:     //リード
  2973:     @Override protected byte mmdRbs (int a) throws M68kException {
  2974:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  2975:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  2976:          return super.mmdRbs (a);  //バスエラー
  2977:        }
  2978:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  2979:        XEiJ.busSuper (MemoryMappedDevice.MMD_RTC_NEXT, 0x00e8a000, 0x00e8c000);  //RTC RTC
  2980:        RP5C15.rtcUpdate ();
  2981:        return (byte) RP5C15.rtcReadByte (a);
  2982:      }
  2983:     @Override protected int mmdRbz (int a) throws M68kException {
  2984:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  2985:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  2986:          return super.mmdRbz (a);  //バスエラー
  2987:        }
  2988:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  2989:        XEiJ.busSuper (MemoryMappedDevice.MMD_RTC_NEXT, 0x00e8a000, 0x00e8c000);  //RTC RTC
  2990:        RP5C15.rtcUpdate ();
  2991:        return RP5C15.rtcReadByte (a);
  2992:      }
  2993:     @Override protected int mmdRws (int a) throws M68kException {
  2994:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  2995:        XEiJ.busSuper (MemoryMappedDevice.MMD_RTC_NEXT, 0x00e8a000, 0x00e8c000);  //RTC RTC
  2996:        RP5C15.rtcUpdate ();
  2997:        return RP5C15.rtcReadByte (a + 1);
  2998:      }
  2999:     @Override protected int mmdRwz (int a) throws M68kException {
  3000:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3001:        XEiJ.busSuper (MemoryMappedDevice.MMD_RTC_NEXT, 0x00e8a000, 0x00e8c000);  //RTC RTC
  3002:        RP5C15.rtcUpdate ();
  3003:        return RP5C15.rtcReadByte (a + 1);
  3004:      }
  3005:     @Override protected int mmdRls (int a) throws M68kException {
  3006:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc * 2;
  3007:        XEiJ.busSuper (MemoryMappedDevice.MMD_RTC_NEXT, 0x00e8a000, 0x00e8c000);  //RTC RTC
  3008:        RP5C15.rtcUpdate ();
  3009:        return (RP5C15.rtcReadByte (a + 1) << 16 |
  3010:                RP5C15.rtcReadByte (a + 3));
  3011:      }
  3012:     //ライト
  3013:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3014:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3015:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3016:          super.mmdWb (a, d);  //バスエラー
  3017:        }
  3018:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3019:        XEiJ.busSuper (MemoryMappedDevice.MMD_RTC_NEXT, 0x00e8a000, 0x00e8c000);  //RTC RTC
  3020:        RP5C15.rtcUpdate ();
  3021:        RP5C15.rtcWriteByte (a, d);
  3022:      }
  3023:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3024:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3025:        XEiJ.busSuper (MemoryMappedDevice.MMD_RTC_NEXT, 0x00e8a000, 0x00e8c000);  //RTC RTC
  3026:        RP5C15.rtcUpdate ();
  3027:        RP5C15.rtcWriteByte (a + 1, d);
  3028:      }
  3029:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3030:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc * 2;
  3031:        XEiJ.busSuper (MemoryMappedDevice.MMD_RTC_NEXT, 0x00e8a000, 0x00e8c000);  //RTC RTC
  3032:        RP5C15.rtcUpdate ();
  3033:        RP5C15.rtcWriteByte (a + 1, d >> 16);
  3034:        RP5C15.rtcWriteByte (a + 3, d);
  3035:      }
  3036:   },  //MMD_RTC_FIRST
  3037: 
  3038:   //--------------------------------------------------------------------------------
  3039:   //MMD_RTC_NEXT RTC
  3040:   MMD_RTC_NEXT {
  3041:     @Override public String toString () {
  3042:       return Multilingual.mlnJapanese ? "RTC" : "RTC";  //Real-Time Clock
  3043:     }
  3044:     //ピーク
  3045:     @Override protected byte mmdPbs (int a) {
  3046:       return (byte) RP5C15.rtcPeekByte (a);
  3047:     }
  3048:     @Override protected int mmdPbz (int a) {
  3049:       return RP5C15.rtcPeekByte (a);
  3050:     }
  3051:     @Override protected int mmdPws (int a) {
  3052:       return RP5C15.rtcPeekByte (a + 1);
  3053:     }
  3054:     @Override protected int mmdPwz (int a) {
  3055:       return RP5C15.rtcPeekByte (a + 1);
  3056:     }
  3057:     @Override protected int mmdPls (int a) {
  3058:       return (RP5C15.rtcPeekByte (a + 1) << 16 |
  3059:               RP5C15.rtcPeekByte (a + 3));
  3060:     }
  3061:     //リード
  3062:     @Override protected byte mmdRbs (int a) throws M68kException {
  3063:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3064:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3065:          return super.mmdRbs (a);  //バスエラー
  3066:        }
  3067:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3068:        return (byte) RP5C15.rtcReadByte (a);
  3069:      }
  3070:     @Override protected int mmdRbz (int a) throws M68kException {
  3071:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3072:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3073:          return super.mmdRbz (a);  //バスエラー
  3074:        }
  3075:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3076:        return RP5C15.rtcReadByte (a);
  3077:      }
  3078:     @Override protected int mmdRws (int a) throws M68kException {
  3079:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3080:        return RP5C15.rtcReadByte (a + 1);
  3081:      }
  3082:     @Override protected int mmdRwz (int a) throws M68kException {
  3083:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3084:        return RP5C15.rtcReadByte (a + 1);
  3085:      }
  3086:     @Override protected int mmdRls (int a) throws M68kException {
  3087:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc * 2;
  3088:        return (RP5C15.rtcReadByte (a + 1) << 16 |
  3089:                RP5C15.rtcReadByte (a + 3));
  3090:      }
  3091:     //ライト
  3092:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3093:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3094:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3095:          super.mmdWb (a, d);  //バスエラー
  3096:        }
  3097:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3098:        RP5C15.rtcWriteByte (a, d);
  3099:      }
  3100:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3101:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3102:        RP5C15.rtcWriteByte (a + 1, d);
  3103:      }
  3104:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3105:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc * 2;
  3106:        RP5C15.rtcWriteByte (a + 1, d >> 16);
  3107:        RP5C15.rtcWriteByte (a + 3, d);
  3108:      }
  3109:   },  //MMD_RTC_NEXT
  3110: 
  3111:   //--------------------------------------------------------------------------------
  3112:   //MMD_RTC_TEST RTC
  3113:   MMD_RTC_TEST {
  3114:     @Override public String toString () {
  3115:       return Multilingual.mlnJapanese ? "RTC テスト" : "RTC test";  //Real-Time Clock
  3116:     }
  3117:     //ピーク
  3118:     @Override protected byte mmdPbs (int a) {
  3119:       return (byte) RP5C15.rtcPeekByte (a);
  3120:     }
  3121:     @Override protected int mmdPbz (int a) {
  3122:       return RP5C15.rtcPeekByte (a);
  3123:     }
  3124:     @Override protected int mmdPws (int a) {
  3125:       return RP5C15.rtcPeekByte (a + 1);
  3126:     }
  3127:     @Override protected int mmdPwz (int a) {
  3128:       return RP5C15.rtcPeekByte (a + 1);
  3129:     }
  3130:     @Override protected int mmdPls (int a) {
  3131:       return (RP5C15.rtcPeekByte (a + 1) << 16 |
  3132:               RP5C15.rtcPeekByte (a + 3));
  3133:     }
  3134:     //リード
  3135:     @Override protected byte mmdRbs (int a) throws M68kException {
  3136:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3137:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3138:          return super.mmdRbs (a);  //バスエラー
  3139:        }
  3140:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3141:        RP5C15.rtcTestUpdate ();
  3142:        return (byte) RP5C15.rtcReadByte (a);
  3143:      }
  3144:     @Override protected int mmdRbz (int a) throws M68kException {
  3145:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3146:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3147:          return super.mmdRbz (a);  //バスエラー
  3148:        }
  3149:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3150:        RP5C15.rtcTestUpdate ();
  3151:        return RP5C15.rtcReadByte (a);
  3152:      }
  3153:     @Override protected int mmdRws (int a) throws M68kException {
  3154:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3155:        RP5C15.rtcTestUpdate ();
  3156:        return RP5C15.rtcReadByte (a + 1);
  3157:      }
  3158:     @Override protected int mmdRwz (int a) throws M68kException {
  3159:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3160:        RP5C15.rtcTestUpdate ();
  3161:        return RP5C15.rtcReadByte (a + 1);
  3162:      }
  3163:     @Override protected int mmdRls (int a) throws M68kException {
  3164:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc * 2;
  3165:        RP5C15.rtcTestUpdate ();
  3166:        return (RP5C15.rtcReadByte (a + 1) << 16 |
  3167:                RP5C15.rtcReadByte (a + 3));
  3168:      }
  3169:     //ライト
  3170:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3171:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3172:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3173:          super.mmdWb (a, d);  //バスエラー
  3174:        }
  3175:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3176:        RP5C15.rtcTestUpdate ();
  3177:        RP5C15.rtcWriteByte (a, d);
  3178:      }
  3179:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3180:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc;
  3181:        RP5C15.rtcTestUpdate ();
  3182:        RP5C15.rtcWriteByte (a + 1, d);
  3183:      }
  3184:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3185:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rtc * 2;
  3186:        RP5C15.rtcTestUpdate ();
  3187:        RP5C15.rtcWriteByte (a + 1, d >> 16);
  3188:        RP5C15.rtcWriteByte (a + 3, d);
  3189:      }
  3190:   },  //MMD_RTC_TEST
  3191: 
  3192:   //--------------------------------------------------------------------------------
  3193:   //MMD_PRN プリンタポート
  3194:   //
  3195:   //  $00E8C000~$00E8C003(偶数)  バイトリードは$FF。バイトライトは$??。ワードリードは$FFxx。ワードライトは$??xx
  3196:   //  $00E8C000~$00E8C003(奇数)  バイトリードは$FF。バイトライトは$??
  3197:   //  $00E8C004~$00E8DFFF  $00E8C000~$00E8C003の繰り返し(?)
  3198:   //
  3199:   MMD_PRN {
  3200:     @Override public String toString () {
  3201:       return Multilingual.mlnJapanese ? "プリンタポート" : "Printer Port";
  3202:     }
  3203:     //リード
  3204:     @Override protected int mmdRbz (int a) throws M68kException {
  3205:        XEiJ.mpuClockTime += XEiJ.busWaitTime.prnport;
  3206:        a &= 3;
  3207:        return (a == (PrinterPort.PRN_DATA & 3) ? PrinterPort.prnReadData () :
  3208:                a == (PrinterPort.PRN_STROBE & 3) ? PrinterPort.prnReadStrobe () :
  3209:                0xff);
  3210:      }
  3211:     @Override protected int mmdRwz (int a) throws M68kException {
  3212:        return 0xff00 | mmdRbz (a + 1);
  3213:      }
  3214:     @Override protected int mmdRls (int a) throws M68kException {
  3215:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3216:      }
  3217:     //ライト
  3218:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3219:        XEiJ.mpuClockTime += XEiJ.busWaitTime.prnport;
  3220:        a &= 3;
  3221:        if (a == (PrinterPort.PRN_DATA & 3)) {
  3222:          PrinterPort.prnWriteData (d);
  3223:        } else if (a == (PrinterPort.PRN_STROBE & 3)) {
  3224:          PrinterPort.prnWriteStrobe (d);
  3225:        }
  3226:      }
  3227:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3228:        mmdWb (a + 1, d);
  3229:      }
  3230:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3231:        mmdWb (a + 1, d >> 16);
  3232:        mmdWb (a + 3, d);
  3233:      }
  3234:   },  //MMD_PRN
  3235: 
  3236:   //--------------------------------------------------------------------------------
  3237:   //MMD_SYS システムポート
  3238:   //
  3239:   //  $00E8E000~$00E8E00F(偶数)  バイトリードは$FF、バイトライトは$??、ワードリードは$FFxx、ワードライトは$??xx
  3240:   //  $00E8E000~$00E8E00F(奇数)  バイトリードは$xx、バイトライトは$xx
  3241:   //  $00E8E010~$00E8FFFF  $00E8E000~$00E8E00Fの繰り返し
  3242:   //
  3243:   MMD_SYS {
  3244:     @Override public String toString () {
  3245:       return Multilingual.mlnJapanese ? "システムポート" : "System Port";
  3246:     }
  3247:     //リード
  3248:     @Override protected int mmdRbz (int a) throws M68kException {
  3249:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sysport;
  3250:        switch (a & 15) {
  3251:        case 0x01:
  3252:          return 0b11110000 | VideoController.vcnTargetContrastPort;
  3253:        case 0x03:
  3254:          return 0b11111000 | XEiJ.pnlStereoscopicShutter;
  3255:        case 0x07:
  3256:          return 0b11110100 | (Keyboard.kbdOn ? 8 : 0) | CRTC.crtHRLPort << 1;
  3257:        case 0x0b:
  3258:          return (XEiJ.currentModel.isX68030 () ? 0xdc :
  3259:                  XEiJ.currentMPU < Model.MPU_MC68020 ?
  3260:                  XEiJ.mpuClockMHz <= 10.0 ? 0xff : 0xfe :
  3261:                  XEiJ.mpuClockMHz <= 20.0 ? 0xff : 0xfe);
  3262:        }
  3263:        return 0xff;
  3264:      }
  3265:     @Override protected int mmdRwz (int a) throws M68kException {
  3266:        return 0xff00 | mmdRbz (a + 1);
  3267:      }
  3268:     @Override protected int mmdRls (int a) throws M68kException {
  3269:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3270:      }
  3271:     //ライト
  3272:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3273:        d &= 0xff;
  3274:        switch (a & 15) {
  3275:        case 0x01:
  3276:          VideoController.vcnTargetContrastPort = d & 15;
  3277:          {
  3278:            int curr = VideoController.vcnTargetContrastMask == 0 ? VideoController.vcnTargetContrastPort : VideoController.vcnTargetContrastTest;
  3279:            if (VideoController.vcnTargetContrastCurr != curr) {
  3280:              VideoController.vcnTargetContrastCurr = curr;
  3281:              VideoController.vcnTargetScaledContrast = VideoController.VCN_CONTRAST_SCALE * VideoController.vcnTargetContrastCurr;
  3282:              CRTC.crtContrastClock = XEiJ.mpuClockTime;
  3283:              CRTC.crtFrameTaskClock = Math.min (CRTC.crtContrastClock, CRTC.crtCaptureClock);
  3284:            }
  3285:          }
  3286:          return;
  3287:        case 0x03:
  3288:          XEiJ.pnlStereoscopicShutter = d & 3;
  3289:          break;
  3290:        case 0x07:
  3291:          {
  3292:            CRTC.crtHRLPort = d >> 1 & 1;
  3293:            int curr = CRTC.crtHRLMask == 0 ? CRTC.crtHRLPort : CRTC.crtHRLTest;
  3294:            if (CRTC.crtHRLCurr != curr) {
  3295:              CRTC.crtHRLCurr = curr;
  3296:              CRTC.crtRestart ();
  3297:            }
  3298:            if ((d & 1 << 2) != 0) {
  3299:              XEiJ.sysResetNMI ();  //NMIリセット
  3300:            }
  3301:          }
  3302:          return;
  3303:        case 0x09:
  3304:          if (XEiJ.currentModel.isX68030 ()) {
  3305:            //X68030のとき
  3306:            //  d=ROMウェイト設定値<<4|RAMウェイト設定値
  3307:            //  ROMウェイト
  3308:            //    ROMウェイト設定値+2
  3309:            //  RAMウェイト
  3310:            //    RAMウェイト設定値が0のとき
  3311:            //      スタティックカラムが有効なとき0
  3312:            //      スタティックカラムが無効なとき4
  3313:            //    RAMウェイト設定値が0でないとき
  3314:            //      RAMウェイト設定値+2
  3315:            //  ROMとRAMにはキャッシュが効く
  3316:            if (XEiJ.currentModel.isX68030 ()) {  //X68030
  3317:              XEiJ.mpuROMWaitCycles = (d >> 4 & 15) + 2;
  3318:              XEiJ.mpuRAMWaitCycles = (d & 15) == 0 ? 0 : (d & 15) + 2;
  3319:              XEiJ.mpuSetWait ();
  3320:            }
  3321:          }
  3322:          return;
  3323:        case 0x0d:
  3324:          SRAM.smrWriteEnableOn = d == 0x31;
  3325:          return;
  3326:        }
  3327:      }
  3328:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3329:        mmdWb (a + 1, d);
  3330:      }
  3331:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3332:        mmdWb (a + 1, d >> 16);
  3333:        mmdWb (a + 3, d);
  3334:      }
  3335:   },  //MMD_SYS
  3336: 
  3337:   //--------------------------------------------------------------------------------
  3338:   //MMD_OPM FM音源
  3339:   //
  3340:   //  $00E90000  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFFF、ワードライトは$??xx
  3341:   //  $00E90001  バイトリードは$FF、バイトライトは$xx
  3342:   //  $00E90002  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3343:   //  $00E90003  バイトリードは$xx、バイトライトは$xx
  3344:   //  $00E90004~$00E91FFF  $00E90000~$00E90003の繰り返し
  3345:   //
  3346:   MMD_OPM {
  3347:     @Override public String toString () {
  3348:       return Multilingual.mlnJapanese ? "FM 音源" : "FM Sound Generator";
  3349:     }
  3350:     //リード
  3351:     @Override protected int mmdRbz (int a) throws M68kException {
  3352:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3353:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3354:          return super.mmdRbz (a);  //バスエラー
  3355:        }
  3356:        XEiJ.mpuClockTime += XEiJ.busWaitTime.opm;
  3357:        return (a & 3) == 3 ? OPM.opmYM2151.readStatus () : 0xff;
  3358:      }
  3359:     @Override protected int mmdRwz (int a) throws M68kException {
  3360:        return 0xff00 | mmdRbz (a + 1);
  3361:      }
  3362:     @Override protected int mmdRls (int a) throws M68kException {
  3363:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3364:      }
  3365:     //ライト
  3366:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3367:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3368:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3369:          super.mmdWb (a, d);  //バスエラー
  3370:        }
  3371:        XEiJ.mpuClockTime += XEiJ.busWaitTime.opm;
  3372:        a &= XEiJ.BUS_MOTHER_MASK;
  3373:        a &= 3;
  3374:        d &= 0xff;
  3375:        if (a == 3) {  //データレジスタ
  3376:          OPM.opmYM2151.generate (SoundSource.SND_CHANNELS *
  3377:                                  (OPM.OPM_BLOCK_SAMPLES - Math.max (0, (int) ((double) (SoundSource.sndBlockClock - XEiJ.mpuClockTime) /
  3378:                                                                               (double) OPM.OPM_SAMPLE_TIME))));
  3379:          OPM.opmYM2151.writeData (d);
  3380:        } else if (a == 1) {  //アドレスレジスタ
  3381:          OPM.opmYM2151.writeAddress (d);
  3382:        }
  3383:      }
  3384:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3385:        mmdWb (a + 1, d);
  3386:      }
  3387:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3388:        mmdWb (a + 1, d >> 16);
  3389:        mmdWb (a + 3, d);
  3390:      }
  3391:   },  //MMD_OPM
  3392: 
  3393:   //--------------------------------------------------------------------------------
  3394:   //MMD_PCM ADPCM音源
  3395:   //
  3396:   //  $00E92000~$00E92003(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3397:   //  $00E92000~$00E92003(奇数)  バイトリードは$xx、バイトライトは$xx
  3398:   //  $00E92004~$00E93FFF  $00E92000~$00E92003の繰り返し
  3399:   //
  3400:   MMD_PCM {
  3401:     @Override public String toString () {
  3402:       return Multilingual.mlnJapanese ? "ADPCM 音源" : "ADPCM Sound Generator";
  3403:     }
  3404:     //リード
  3405:     @Override protected int mmdRbz (int a) throws M68kException {
  3406:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3407:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3408:          return super.mmdRbz (a);  //バスエラー
  3409:        }
  3410:        XEiJ.mpuClockTime += XEiJ.busWaitTime.adpcm;
  3411:        return (a & 3) == 1 ? (ADPCM.pcmActive ? 0b10000000 : 0) | 0x40 : 0xff;
  3412:      }
  3413:     @Override protected int mmdRwz (int a) throws M68kException {
  3414:        return 0xff00 | mmdRbz (a + 1);
  3415:      }
  3416:     @Override protected int mmdRls (int a) throws M68kException {
  3417:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3418:      }
  3419:     //ライト
  3420:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3421:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3422:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3423:          super.mmdWb (a, d);  //バスエラー
  3424:        }
  3425:        XEiJ.mpuClockTime += XEiJ.busWaitTime.adpcm;
  3426:        a &= XEiJ.BUS_MOTHER_MASK;
  3427:        a &= 3;
  3428:        if (a == 1) {  //コマンド
  3429:          if ((d & 0b00000001) != 0) {  //動作終了
  3430:            if (ADPCM.pcmActive) {  //動作中
  3431:              ADPCM.pcmClock = XEiJ.FAR_FUTURE;
  3432:              TickerQueue.tkqRemove (SoundSource.sndPcmTicker);
  3433:              ADPCM.pcmActive = false;
  3434:              ADPCM.pcmEncodedData = -1;
  3435:              ADPCM.pcmDecoderPointer = 0;
  3436:              HD63450.dmaRisePCL (3);
  3437:            }
  3438:          } else if ((d & 0b00000010) != 0) {  //動作開始
  3439:            if (!ADPCM.pcmActive) {  //停止中
  3440:              //現在のブロックの残り時間が1サンプルの時間の倍数になるように切り上げる
  3441:              int remainingSamples = Math.max (0, (int) ((double) (SoundSource.sndBlockClock - XEiJ.mpuClockTime) / (double) ADPCM.PCM_SAMPLE_TIME));  //現在のブロックの残りサンプル数
  3442:              ADPCM.pcmClock = SoundSource.sndBlockClock - ADPCM.PCM_SAMPLE_TIME * (long) remainingSamples;  //書き込み開始時刻
  3443:              TickerQueue.tkqAdd (SoundSource.sndPcmTicker, ADPCM.pcmClock);
  3444:              ADPCM.pcmActive = true;
  3445:              int newPointer = SoundSource.SND_CHANNELS * (ADPCM.PCM_BLOCK_SAMPLES - remainingSamples);  //書き込み開始位置
  3446:              if (ADPCM.pcmPointer < newPointer) {
  3447:                ADPCM.pcmFillBuffer (newPointer);
  3448:              } else {
  3449:                ADPCM.pcmPointer = newPointer;  //少し戻る場合がある
  3450:              }
  3451:              //DMAに最初のデータを要求する
  3452:              HD63450.dmaFallPCL (3);
  3453:            }
  3454:            //} else if ((d & 0b00000100) != 0) {  //録音開始
  3455:            //! 非対応
  3456:          }
  3457:        } else if (a == 3) {  //データ
  3458:          if (ADPCM.pcmActive) {
  3459:            ADPCM.pcmEncodedData = d & 0xff;
  3460:            HD63450.dmaRisePCL (3);
  3461:          }
  3462:        }
  3463:      }
  3464:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3465:        mmdWb (a + 1, d);
  3466:      }
  3467:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3468:        mmdWb (a + 1, d >> 16);
  3469:        mmdWb (a + 3, d);
  3470:      }
  3471:   },  //MMD_PCM
  3472: 
  3473:   //--------------------------------------------------------------------------------
  3474:   //MMD_FDC FDコントローラ
  3475:   //
  3476:   //  $00E94000~$00E94007(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3477:   //  $00E94000~$00E94007(奇数)  バイトリードは$xx、バイトライトは$xx
  3478:   //  $00E94008~$00E95FFF  $00E94000~$00E94007の繰り返し
  3479:   //
  3480:   MMD_FDC {
  3481:     @Override public String toString () {
  3482:       return Multilingual.mlnJapanese ? "FD コントローラ" : "FD Controller";
  3483:     }
  3484:     //ピーク
  3485:     @Override protected byte mmdPbs (int a) {
  3486:       return (byte) mmdPbz (a);
  3487:     }
  3488:     @Override protected int mmdPbz (int a) {
  3489:       a &= XEiJ.BUS_MOTHER_MASK;
  3490:       switch (a) {
  3491:       case FDC.FDC_STATUS_PORT:  //0x00e94001
  3492:         return FDC.fdcPeekStatus ();
  3493:       case FDC.FDC_DATA_PORT:  //0x00e94003
  3494:         return FDC.fdcPeekData ();
  3495:       case FDC.FDC_DRIVE_STATUS:  //0x00e94005
  3496:         return FDC.fdcPeekDriveStatus ();
  3497:       }
  3498:       return 0xff;
  3499:     }
  3500:     @Override protected int mmdPws (int a) {
  3501:       return (short) (mmdPbz (a) << 8 | mmdPbz (a + 1));
  3502:     }
  3503:     @Override protected int mmdPwz (int a) {
  3504:       return mmdPbz (a) << 8 | mmdPbz (a + 1);
  3505:     }
  3506:     @Override protected int mmdPls (int a) {
  3507:       return mmdPwz (a) << 16 | mmdPwz (a + 2);
  3508:     }
  3509:     //リード
  3510:     @Override protected int mmdRbz (int a) throws M68kException {
  3511:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3512:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3513:          return super.mmdRbz (a);  //バスエラー
  3514:        }
  3515:        XEiJ.mpuClockTime += XEiJ.busWaitTime.fdc;
  3516:        a &= XEiJ.BUS_MOTHER_MASK;
  3517:        switch (a) {
  3518:        case FDC.FDC_STATUS_PORT:  //0x00e94001
  3519:          return FDC.fdcReadStatus ();
  3520:        case FDC.FDC_DATA_PORT:  //0x00e94003
  3521:          return FDC.fdcReadData ();
  3522:        case FDC.FDC_DRIVE_STATUS:  //0x00e94005
  3523:          return FDC.fdcReadDriveStatus ();
  3524:        }
  3525:        return 0xff;
  3526:      }
  3527:     @Override protected int mmdRwz (int a) throws M68kException {
  3528:        return 0xff00 | mmdRbz (a + 1);
  3529:      }
  3530:     @Override protected int mmdRls (int a) throws M68kException {
  3531:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3532:      }
  3533:     //ライト
  3534:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3535:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3536:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3537:          super.mmdWb (a, d);  //バスエラー
  3538:        }
  3539:        XEiJ.mpuClockTime += XEiJ.busWaitTime.fdc;
  3540:        a &= XEiJ.BUS_MOTHER_MASK;
  3541:        switch (a) {
  3542:        case FDC.FDC_STATUS_PORT:  //0x00e94001
  3543:          FDC.fdcWriteCommand (d);
  3544:          break;
  3545:        case FDC.FDC_DATA_PORT:  //0x00e94003
  3546:          FDC.fdcWriteData (d);
  3547:          break;
  3548:        case FDC.FDC_DRIVE_STATUS:  //0x00e94005
  3549:          FDC.fdcWriteDriveControl (d);
  3550:          break;
  3551:        case FDC.FDC_DRIVE_SELECT:  //0x00e94007
  3552:          FDC.fdcWriteDriveSelect (d);
  3553:          break;
  3554:        }
  3555:      }
  3556:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3557:        mmdWb (a + 1, d);
  3558:      }
  3559:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3560:        mmdWb (a + 1, d >> 16);
  3561:        mmdWb (a + 3, d);
  3562:      }
  3563:   },  //MMD_FDC
  3564: 
  3565:   //--------------------------------------------------------------------------------
  3566:   //MMD_HDC SASI HDコントローラ
  3567:   //
  3568:   //  $00E96000~$00E9603F(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3569:   //  $00E96000~$00E9603F(奇数)  バイトリードは$xx、バイトライトは$xx
  3570:   //                              X68030の$00E96000~$00E9601Fは$00,$00,$FF,$FFの繰り返し。$00E9603Fは$FF
  3571:   //  $00E96040~$00E97FFF  $00E96000~$00E9603Fの繰り返し
  3572:   //
  3573:   MMD_HDC {
  3574:     @Override public String toString () {
  3575:       return Multilingual.mlnJapanese ? "内蔵 SASI/SCSI ポート" : "Internal SASI/SCSI Port";
  3576:     }
  3577:     //ピーク
  3578:     @Override protected int mmdPbz (int a) {
  3579:       if ((a & 0x01) == 0) {  //偶数番地
  3580:         return 0xff;
  3581:       } else {  //奇数番地
  3582:         if (SPC.spcSCSIINOn) {  //SCSI内蔵機
  3583:           if ((a & 0x20) == 0) {  //SASIポート
  3584:             return ((a & 0x02) == 0 ? 0x00 : 0xff);
  3585:           } else {  //SCSIポート
  3586:             if (SUK.SUK_ON && SUK.sukOn && !SUK.sukExpansion) {
  3587:               return SUK.sukPeek (a);
  3588:             }
  3589:             return SPC.spcSCSIINChip.spiPeek (a);
  3590:           }
  3591:         } else {  //SASI内蔵機
  3592:           switch (a & 0x3f) {
  3593:           case HDC.HDC_DATA_PORT & 0x3f:  //0x00e96001
  3594:             return HDC.hdcPeekData ();
  3595:           case HDC.HDC_STATUS_PORT & 0x3f:  //0x00e96003
  3596:             return HDC.hdcPeekStatus ();
  3597:           case HDC.HDC_RESET_PORT & 0x3f:  //0x00e96005
  3598:             return 0xff;
  3599:           case HDC.HDC_SELECTION_PORT & 0x3f:  //0x00e96007
  3600:             return 0xff;
  3601:           default:
  3602:             return 0xff;
  3603:           }
  3604:         }
  3605:       }
  3606:     }
  3607:     @Override protected int mmdPwz (int a) {
  3608:       return 0xff00 | mmdPbz (a + 1);
  3609:     }
  3610:     @Override protected int mmdPls (int a) {
  3611:       return 0xff00ff00 | mmdPbz (a + 1) << 16 | mmdPbz (a + 3);
  3612:     }
  3613:     //リード
  3614:     @Override protected int mmdRbz (int a) throws M68kException {
  3615:        XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;
  3616:        if ((a & 0x01) == 0) {  //偶数番地
  3617:          if (XEiJ.currentIsSecond) {  //Xellent30の030モード
  3618:            return 0xff;
  3619:          }
  3620:          return super.mmdRbz (a);  //バスエラー
  3621:        } else {  //奇数番地
  3622:          if (SPC.spcSCSIINOn) {  //SCSI内蔵機
  3623:            if ((a & 0x20) == 0) {  //SASIポート
  3624:              return ((a & 0x02) == 0 ? 0x00 : 0xff);
  3625:            } else {  //SCSIポート
  3626:              if (SUK.SUK_ON && SUK.sukOn && !SUK.sukExpansion) {
  3627:                return SUK.sukRead (a);
  3628:              }
  3629:              return SPC.spcSCSIINChip.spiRead (a);
  3630:            }
  3631:          } else {  //SASI内蔵機
  3632:            switch (a & 0x3f) {
  3633:            case HDC.HDC_DATA_PORT & 0x3f:  //0x00e96001
  3634:              return HDC.hdcReadData ();
  3635:            case HDC.HDC_STATUS_PORT & 0x3f:  //0x00e96003
  3636:              return HDC.hdcReadStatus ();
  3637:            case HDC.HDC_RESET_PORT & 0x3f:  //0x00e96005
  3638:              return 0xff;
  3639:            case HDC.HDC_SELECTION_PORT & 0x3f:  //0x00e96007
  3640:              return 0xff;
  3641:            default:
  3642:              return 0xff;
  3643:            }
  3644:          }
  3645:        }
  3646:      }
  3647:     @Override protected int mmdRwz (int a) throws M68kException {
  3648:        return 0xff00 | mmdRbz (a + 1);
  3649:      }
  3650:     @Override protected int mmdRls (int a) throws M68kException {
  3651:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3652:      }
  3653:     //ライト
  3654:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3655:        XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;
  3656:        if ((a & 0x01) == 0) {  //偶数番地
  3657:          if (XEiJ.currentIsSecond) {  //Xellent30の030モード
  3658:            return;
  3659:          }
  3660:          super.mmdWb (a, d);  //バスエラー
  3661:        } else {  //奇数番地
  3662:          if (SPC.spcSCSIINOn) {  //SCSI内蔵機
  3663:            if ((a & 0x20) == 0) {  //SASIポート
  3664:              return;
  3665:            } else {  //SCSIポート
  3666:              if (SUK.SUK_ON && SUK.sukOn && !SUK.sukExpansion) {
  3667:                SUK.sukWrite (a, d);
  3668:                return;
  3669:              }
  3670:              SPC.spcSCSIINChip.spiWrite (a, d);
  3671:              return;
  3672:            }
  3673:          } else {  //SASI内蔵機
  3674:            switch (a & 0x3f) {
  3675:            case HDC.HDC_DATA_PORT & 0x3f:  //0x00e96001
  3676:              HDC.hdcWriteData (d);
  3677:              return;
  3678:            case HDC.HDC_STATUS_PORT & 0x3f:  //0x00e96003
  3679:              HDC.hdcWriteCommand (d);
  3680:              return;
  3681:            case HDC.HDC_RESET_PORT & 0x3f:  //0x00e96005
  3682:              HDC.hdcWriteReset (d);
  3683:              return;
  3684:            case HDC.HDC_SELECTION_PORT & 0x3f:  //0x00e96007
  3685:              HDC.hdcWriteSelect (d);
  3686:              return;
  3687:            default:
  3688:              return;
  3689:            }
  3690:          }
  3691:        }
  3692:      }
  3693:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3694:        mmdWb (a + 1, d);
  3695:      }
  3696:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3697:        mmdWb (a + 1, d >> 16);
  3698:        mmdWb (a + 3, d);
  3699:      }
  3700:   },  //MMD_HDC
  3701: 
  3702:   //--------------------------------------------------------------------------------
  3703:   //MMD_SCC SCC
  3704:   //
  3705:   //  $00E98000~$00E98007(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3706:   //  $00E98000~$00E98007(奇数)  バイトリードは$xx、バイトライトは$xx
  3707:   //  $00E98008~$00E99FFF  $00E98000~$00E98007の繰り返し
  3708:   //
  3709:   MMD_SCC {
  3710:     @Override public String toString () {
  3711:       return Multilingual.mlnJapanese ? "SCC" : "SCC";  //Serial Communication Controller
  3712:     }
  3713:     //ピーク
  3714:     @Override protected int mmdPbz (int a) {
  3715:       return Z8530.sccReadByte (a, true);
  3716:     }
  3717:     @Override protected int mmdPwz (int a) {
  3718:       return 0xff00 | mmdPbz (a + 1);
  3719:     }
  3720:     @Override protected int mmdPls (int a) {
  3721:       return 0xff00ff00 | mmdPbz (a + 1) << 16 | mmdPbz (a + 3);
  3722:     }
  3723:     //リード
  3724:     @Override protected int mmdRbz (int a) throws M68kException {
  3725:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3726:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3727:          return super.mmdRbz (a);  //バスエラー
  3728:        }
  3729:        return Z8530.sccReadByte (a, false);
  3730:      }
  3731:     @Override protected int mmdRwz (int a) throws M68kException {
  3732:        return 0xff00 | mmdRbz (a + 1);
  3733:      }
  3734:     @Override protected int mmdRls (int a) throws M68kException {
  3735:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3736:      }
  3737:     //ライト
  3738:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3739:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3740:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3741:          super.mmdWb (a, d);  //バスエラー
  3742:        }
  3743:        Z8530.sccWriteByte (a, d);
  3744:      }
  3745:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3746:        mmdWb (a + 1, d);
  3747:      }
  3748:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3749:        mmdWb (a + 1, d >> 16);
  3750:        mmdWb (a + 3, d);
  3751:      }
  3752:   },  //MMD_SCC
  3753: 
  3754:   //--------------------------------------------------------------------------------
  3755:   //MMD_PPI PPI
  3756:   //
  3757:   //  $00E9A000~$00E9A007(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3758:   //  $00E9A000~$00E9A007(奇数)  バイトリードは$xx、バイトライトは$xx
  3759:   //  $00E9A008~$00E9BFFF  $00E9A000~$00E9A007の繰り返し
  3760:   //
  3761:   MMD_PPI {
  3762:     @Override public String toString () {
  3763:       return Multilingual.mlnJapanese ? "PPI" : "PPI";  //Programmable Peripheral Interface
  3764:     }
  3765:     //リード
  3766:     @Override protected int mmdRbz (int a) throws M68kException {
  3767:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3768:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3769:          return super.mmdRbz (a);  //バスエラー
  3770:        }
  3771:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ppi;
  3772:        return PPI.ppiReadByte (a);
  3773:      }
  3774:     @Override protected int mmdRwz (int a) throws M68kException {
  3775:        return 0xff00 | mmdRbz (a + 1);
  3776:      }
  3777:     @Override protected int mmdRls (int a) throws M68kException {
  3778:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3779:      }
  3780:     //ライト
  3781:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3782:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3783:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3784:          super.mmdWb (a, d);  //バスエラー
  3785:        }
  3786:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ppi;
  3787:        PPI.ppiWriteByte (a, d);
  3788:      }
  3789:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3790:        mmdWb (a + 1, d);
  3791:      }
  3792:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3793:        mmdWb (a + 1, d >> 16);
  3794:        mmdWb (a + 3, d);
  3795:      }
  3796:   },  //MMD_PPI
  3797: 
  3798:   //--------------------------------------------------------------------------------
  3799:   //MMD_IOI I/O割り込み
  3800:   //
  3801:   //  $00E9C000~$00E9C00F(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3802:   //  $00E9C000~$00E9C00F(奇数)  バイトリードは$xx、バイトライトは$xx
  3803:   //  $00E9C010~$00E9BFFF  $00E9C000~$00E9C00Fの繰り返し
  3804:   //
  3805:   MMD_IOI {
  3806:     @Override public String toString () {
  3807:       return Multilingual.mlnJapanese ? "I/O 割り込み" : "I/O Interrupt";
  3808:     }
  3809:     //リード
  3810:     @Override protected int mmdRbz (int a) throws M68kException {
  3811:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3812:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3813:          return super.mmdRbz (a);  //バスエラー
  3814:        }
  3815:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ioi;
  3816:        a &= XEiJ.BUS_MOTHER_MASK;
  3817:        if (a == IOInterrupt.IOI_STATUS) {
  3818:          return IOInterrupt.ioiReadStatus ();
  3819:        } else if (a == IOInterrupt.IOI_VECTOR) {  //ライトオンリー。リードすると$FFが返る
  3820:          //return IOInterrupt.ioiReadVector ();
  3821:          return 0xff;
  3822:        } else {
  3823:          return super.mmdRbz (a);  //バスエラー
  3824:        }
  3825:      }
  3826:     @Override protected int mmdRwz (int a) throws M68kException {
  3827:        return 0xff00 | mmdRbz (a + 1);
  3828:      }
  3829:     @Override protected int mmdRls (int a) throws M68kException {
  3830:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3831:      }
  3832:     //ライト
  3833:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3834:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3835:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3836:          super.mmdWb (a, d);  //バスエラー
  3837:        }
  3838:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ioi;
  3839:        a &= XEiJ.BUS_MOTHER_MASK;
  3840:        if (a == IOInterrupt.IOI_STATUS) {
  3841:          IOInterrupt.ioiWriteEnable (d);
  3842:        } else if (a == IOInterrupt.IOI_VECTOR) {
  3843:          IOInterrupt.ioiWriteVector (d);
  3844:        } else {
  3845:          super.mmdWb (a, d);  //バスエラー
  3846:        }
  3847:      }
  3848:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3849:        mmdWb (a + 1, d);
  3850:      }
  3851:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3852:        mmdWb (a + 1, d >> 16);
  3853:        mmdWb (a + 3, d);
  3854:      }
  3855:   },  //MMD_IOI
  3856: 
  3857:   //--------------------------------------------------------------------------------
  3858:   //MMD_XB1 拡張ボード領域1
  3859:   MMD_XB1 {
  3860:     @Override public String toString () {
  3861:       return Multilingual.mlnJapanese ? "拡張ボード領域 1" : "Expansion Board Area 1";
  3862:     }
  3863:     //ピーク
  3864:     @Override protected int mmdPbz (int a) {
  3865:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3866:         return XEiJ.fpuCoproboard1.cirPeekByteZero (a);
  3867:       }
  3868:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3869:         return XEiJ.fpuCoproboard2.cirPeekByteZero (a);
  3870:       }
  3871:       if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3872:         a &= XEiJ.BUS_MOTHER_MASK;
  3873:         return MainMemory.mmrM8[a] & 0xff;
  3874:       }
  3875:       if (Keyboard.KBD_ZKEY_ON &&
  3876:           (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3877:         return Keyboard.kbdZKeyIOReadByte (a);
  3878:       }
  3879:       return 0xff;
  3880:     }
  3881:     @Override protected int mmdPwz (int a) {
  3882:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3883:         return XEiJ.fpuCoproboard1.cirPeekWordZero (a);
  3884:       }
  3885:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3886:         return XEiJ.fpuCoproboard2.cirPeekWordZero (a);
  3887:       }
  3888:       if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3889:         a &= XEiJ.BUS_MOTHER_MASK;
  3890:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  3891:       }
  3892:       if (Keyboard.KBD_ZKEY_ON &&
  3893:           (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3894:         return Keyboard.kbdZKeyIOReadWord (a);
  3895:       }
  3896:       return 0xffff;
  3897:     }
  3898:     @Override protected int mmdPls (int a) {
  3899:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3900:         return XEiJ.fpuCoproboard1.cirPeekLong (a);
  3901:       }
  3902:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3903:         return XEiJ.fpuCoproboard2.cirPeekLong (a);
  3904:       }
  3905:       if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3906:         a &= XEiJ.BUS_MOTHER_MASK;
  3907:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  3908:       }
  3909:       if (Keyboard.KBD_ZKEY_ON &&
  3910:           (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3911:         return Keyboard.kbdZKeyIOReadLong (a);
  3912:       }
  3913:       return -1;
  3914:     }
  3915:     //リード
  3916:     @Override protected int mmdRbz (int a) throws M68kException {
  3917:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3918:          return XEiJ.fpuCoproboard1.cirReadByteZero (a);
  3919:        }
  3920:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3921:          return XEiJ.fpuCoproboard2.cirReadByteZero (a);
  3922:        }
  3923:        if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3924:          a &= XEiJ.BUS_MOTHER_MASK;
  3925:          return MainMemory.mmrM8[a] & 0xff;
  3926:        }
  3927:        if (Keyboard.KBD_ZKEY_ON &&
  3928:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3929:          return Keyboard.kbdZKeyIOReadByte (a);
  3930:        }
  3931:        return super.mmdRbz (a);  //バスエラー
  3932:      }
  3933:     @Override protected int mmdRwz (int a) throws M68kException {
  3934:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3935:          return XEiJ.fpuCoproboard1.cirReadWordZero (a);
  3936:        }
  3937:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3938:          return XEiJ.fpuCoproboard2.cirReadWordZero (a);
  3939:        }
  3940:        if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3941:          a &= XEiJ.BUS_MOTHER_MASK;
  3942:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  3943:        }
  3944:        if (Keyboard.KBD_ZKEY_ON &&
  3945:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3946:          return Keyboard.kbdZKeyIOReadWord (a);
  3947:        }
  3948:        return super.mmdRwz (a);  //バスエラー
  3949:      }
  3950:     @Override protected int mmdRls (int a) throws M68kException {
  3951:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3952:          return XEiJ.fpuCoproboard1.cirReadLong (a);
  3953:        }
  3954:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3955:          return XEiJ.fpuCoproboard2.cirReadLong (a);
  3956:        }
  3957:        if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3958:          a &= XEiJ.BUS_MOTHER_MASK;
  3959:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  3960:        }
  3961:        if (Keyboard.KBD_ZKEY_ON &&
  3962:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3963:          return Keyboard.kbdZKeyIOReadLong (a);
  3964:        }
  3965:        return super.mmdRls (a);  //バスエラー
  3966:      }
  3967:     //ライト
  3968:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3969:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3970:          XEiJ.fpuCoproboard1.cirWriteByte (a, d);
  3971:          return;
  3972:        }
  3973:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3974:          XEiJ.fpuCoproboard2.cirWriteByte (a, d);
  3975:          return;
  3976:        }
  3977:        if (Keyboard.KBD_ZKEY_ON &&
  3978:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3979:          Keyboard.kbdZKeyIOWriteByte (a, d);
  3980:          return;
  3981:        }
  3982:        super.mmdWb (a, d);  //バスエラー
  3983:      }
  3984:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3985:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3986:          XEiJ.fpuCoproboard1.cirWriteWord (a, d);
  3987:          return;
  3988:        }
  3989:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3990:          XEiJ.fpuCoproboard2.cirWriteWord (a, d);
  3991:          return;
  3992:        }
  3993:        if (Keyboard.KBD_ZKEY_ON &&
  3994:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3995:          Keyboard.kbdZKeyIOWriteWord (a, d);
  3996:          return;
  3997:        }
  3998:        super.mmdWw (a, d);  //バスエラー
  3999:      }
  4000:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4001:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  4002:          XEiJ.fpuCoproboard1.cirWriteLong (a, d);
  4003:          return;
  4004:        }
  4005:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  4006:          XEiJ.fpuCoproboard2.cirWriteLong (a, d);
  4007:          return;
  4008:        }
  4009:        if (Keyboard.KBD_ZKEY_ON &&
  4010:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  4011:          Keyboard.kbdZKeyIOWriteLong (a, d);
  4012:          return;
  4013:        }
  4014:        super.mmdWl (a, d);  //バスエラー
  4015:      }
  4016:   },  //MMD_XB1
  4017: 
  4018:   //--------------------------------------------------------------------------------
  4019:   //MMD_EXS 拡張SCSI
  4020:   //  必要なときだけ接続される
  4021:   //  拡張SCSIのROMのサイズは8KBなのでリードのときのバスエラーのチェックは不要
  4022:   //  ライトのときはROMには書き込めないのでSPCのレジスタでなければバスエラー
  4023:   MMD_EXS {
  4024:     @Override public String toString () {
  4025:       return Multilingual.mlnJapanese ? "拡張 SCSI ポート" : "Expansion SCSI Port";
  4026:     }
  4027:     //ピーク
  4028:     @Override protected int mmdPbz (int a) {
  4029:       if ((a & (-32 & XEiJ.BUS_MOTHER_MASK)) == SPC.SPC_BASE_EX) {  //レジスタ
  4030:         if ((a & 0x01) == 0) {  //偶数番地
  4031:           return 0xff;
  4032:         } else {  //奇数番地
  4033:           if (SUK.SUK_ON && SUK.sukOn && SUK.sukExpansion) {
  4034:             return SUK.sukPeek (a);
  4035:           }
  4036:           return SPC.spcSCSIEXChip.spiPeek (a);
  4037:         }
  4038:       } else {  //ROM
  4039:         return 0xff & MainMemory.mmrM8[a];
  4040:       }
  4041:     }
  4042:     @Override protected int mmdPwz (int a) {
  4043:       XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;  //!!!
  4044:       if ((a & (-32 & XEiJ.BUS_MOTHER_MASK)) == SPC.SPC_BASE_EX) {  //レジスタ
  4045:         if (SUK.SUK_ON && SUK.sukOn && SUK.sukExpansion) {
  4046:           return 0xff00 | SUK.sukPeek (a + 1);
  4047:         }
  4048:         return 0xff00 | SPC.spcSCSIEXChip.spiPeek (a + 1);
  4049:       } else {  //ROM
  4050:         return (0xff & MainMemory.mmrM8[a]) << 8 | (0xff & MainMemory.mmrM8[a + 1]);
  4051:       }
  4052:     }
  4053:     @Override protected int mmdPls (int a) {
  4054:       return mmdPwz (a) << 16 | mmdPwz (a + 2);
  4055:     }
  4056:     //リード
  4057:     @Override protected int mmdRbz (int a) throws M68kException {
  4058:        XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;  //!!!
  4059:        if ((a & (-32 & XEiJ.BUS_MOTHER_MASK)) == SPC.SPC_BASE_EX) {  //レジスタ
  4060:          if ((a & 0x01) == 0) {  //偶数番地
  4061:            if (XEiJ.currentIsSecond) {  //Xellent30の030モード
  4062:              return 0xff;
  4063:            }
  4064:            return super.mmdRbz (a);  //バスエラー
  4065:          } else {  //奇数番地
  4066:            if (SUK.SUK_ON && SUK.sukOn && SUK.sukExpansion) {
  4067:              return SUK.sukRead (a);
  4068:            }
  4069:            return SPC.spcSCSIEXChip.spiRead (a);
  4070:          }
  4071:        } else {  //ROM
  4072:          return 0xff & MainMemory.mmrM8[a];
  4073:        }
  4074:      }
  4075:     @Override protected int mmdRwz (int a) throws M68kException {
  4076:        XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;  //!!!
  4077:        if ((a & (-32 & XEiJ.BUS_MOTHER_MASK)) == SPC.SPC_BASE_EX) {  //レジスタ
  4078:          if (SUK.SUK_ON && SUK.sukOn && SUK.sukExpansion) {
  4079:            return 0xff00 | SUK.sukRead (a + 1);
  4080:          }
  4081:          return 0xff00 | SPC.spcSCSIEXChip.spiRead (a + 1);
  4082:        } else {  //ROM
  4083:          return (0xff & MainMemory.mmrM8[a]) << 8 | (0xff & MainMemory.mmrM8[a + 1]);
  4084:        }
  4085:      }
  4086:     @Override protected int mmdRls (int a) throws M68kException {
  4087:        return mmdRwz (a) << 16 | mmdRwz (a + 2);
  4088:      }
  4089:     //ライト
  4090:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4091:        XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;  //!!!
  4092:        if ((a & (-32 & XEiJ.BUS_MOTHER_MASK)) == SPC.SPC_BASE_EX) {  //レジスタ
  4093:          if ((a & 1) == 0) {  //偶数番地
  4094:            if (XEiJ.currentIsSecond) {  //Xellent30の030モード
  4095:              return;
  4096:            }
  4097:            super.mmdWb (a, d);  //バスエラー
  4098:          } else {  //奇数番地
  4099:            if (SUK.SUK_ON && SUK.sukOn && SUK.sukExpansion) {
  4100:              SUK.sukWrite (a, d);
  4101:              return;
  4102:            }
  4103:            SPC.spcSCSIEXChip.spiWrite (a, d);
  4104:            return;
  4105:          }
  4106:        } else {  //ROM
  4107:          super.mmdWb (a, d);  //バスエラー
  4108:        }
  4109:      }
  4110:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4111:        XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;  //!!!
  4112:        if ((a & (-32 & XEiJ.BUS_MOTHER_MASK)) == SPC.SPC_BASE_EX) {  //レジスタ
  4113:          if (SUK.SUK_ON && SUK.sukOn && SUK.sukExpansion) {
  4114:            SUK.sukWrite (a + 1, d);
  4115:            return;
  4116:          }
  4117:          SPC.spcSCSIEXChip.spiWrite (a + 1, d);
  4118:          return;
  4119:        } else {  //ROM
  4120:          super.mmdWw (a, d);  //バスエラー
  4121:        }
  4122:      }
  4123:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4124:        mmdWw (a, d >> 16);
  4125:        mmdWw (a + 2, d);
  4126:      }
  4127:   },  //MMD_EXS
  4128: 
  4129:   //--------------------------------------------------------------------------------
  4130:   //MMD_XB2 拡張ボード領域2
  4131:   //
  4132:   //  $00EAFF80  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00200000~$003FFFFFがあるとき$??xx、ないときバスエラー
  4133:   //  $00EAFF81  リードはバスエラー、ライトは$00200000~$003FFFFFがあるとき$xx、ないときバスエラー
  4134:   //  $00EAFF82  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00400000~$005FFFFFがあるとき$??xx、ないときバスエラー
  4135:   //  $00EAFF83  リードはバスエラー、ライトは$00400000~$005FFFFFがあるとき$xx、ないときバスエラー
  4136:   //  $00EAFF84  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00600000~$007FFFFFがあるとき$??xx、ないときバスエラー
  4137:   //  $00EAFF85  リードはバスエラー、ライトは$00600000~$007FFFFFがあるとき$xx、ないときバスエラー
  4138:   //  $00EAFF86  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00800000~$009FFFFFがあるとき$??xx、ないときバスエラー
  4139:   //  $00EAFF87  リードはバスエラー、ライトは$00800000~$009FFFFFがあるとき$xx、ないときバスエラー
  4140:   //  $00EAFF88  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00A00000~$00BFFFFFがあるとき$??xx、ないときバスエラー
  4141:   //  $00EAFF89  リードはバスエラー、ライトは$00A00000~$00BFFFFFがあるとき$xx、ないときバスエラー
  4142:   //  $00EAFF8A~$00EAFF8F  バスエラー
  4143:   //  $00EAFF90~$00EAFFFF  $00EAFF80~$00EAFF8Fの繰り返し
  4144:   //
  4145:   //  拡張
  4146:   //  $00EAFF7F  バンクメモリのページ番号
  4147:   //
  4148:   MMD_XB2 {
  4149:     @Override public String toString () {
  4150:       return Multilingual.mlnJapanese ? "拡張ボード領域 2" : "Expansion Board Area 2";
  4151:     }
  4152:     //リード
  4153:     @Override protected int mmdRbz (int a) throws M68kException {
  4154:        a &= XEiJ.BUS_MOTHER_MASK;
  4155:        if (0x00eaff81 <= a && a <= 0x00eaff89 && (a & 1) != 0) {  //スーパーバイザエリア設定ポート
  4156:          return MainMemory.mmrM8[a] & 0xff;  //読み出せるようにしておく(本来はライトオンリー)
  4157:        }
  4158:        if (XEiJ.bnkOn && a == 0x00eaff7f) {  //バンクメモリのページ番号
  4159:          return XEiJ.bnkPageStart >> 17;
  4160:        }
  4161:        return super.mmdRbz (a);  //バスエラー
  4162:      }
  4163:     //ライト
  4164:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4165:        a &= XEiJ.BUS_MOTHER_MASK;
  4166:        if (0x00eaff81 <= a && a <= 0x00eaff89 && (a & 1) != 0) {  //スーパーバイザエリア設定ポート
  4167:          MainMemory.mmrM8[a] = (byte) d;  //読み出せるようにしておく(本来はライトオンリー)
  4168:          a = (a & 14) + 2 << 20;  //1,3,5,7,9→2,4,6,8,a
  4169:          for (int m = 1; m <= 128; m <<= 1) {
  4170:            if ((d & m) == 0) {  //ユーザエリア
  4171:              XEiJ.busUser ( MemoryMappedDevice.MMD_MMR, a, a + 0x00040000);
  4172:            } else {  //スーパーバイザエリア
  4173:              XEiJ.busSuper (MemoryMappedDevice.MMD_MMR, a, a + 0x00040000);
  4174:            }
  4175:            a += 0x00040000;
  4176:          }
  4177:          return;
  4178:        }
  4179:        if (XEiJ.bnkOn && a == 0x00eaff7f) {  //バンクメモリのページ番号
  4180:          XEiJ.bnkPageStart = (d & 0xff) << 17;
  4181:          return;
  4182:        }
  4183:        super.mmdWb (a, d);  //バスエラー
  4184:      }
  4185:   },  //MMD_XB2
  4186: 
  4187:   //--------------------------------------------------------------------------------
  4188:   //MMD_SPR スプライト画面
  4189:   //
  4190:   //  CRTCのR20の下位5ビットが%1??1?でないとき
  4191:   //    $00EB0000-$00EB03FF  スプライトスクロールレジスタ(0~127)
  4192:   //    $00EB0400-$00EB07FF  $FF。256枚表示のときスプライトスクロールレジスタ(128~255)
  4193:   //    $00EB0800-$00EB0811  設定
  4194:   //    $00EB0812-$00EB7FFF  $FF
  4195:   //    $00EB8000-$00EBFFFF  スプライトPCG・テキストエリア
  4196:   //
  4197:   //  CRTCのR20の下位5ビットが%1??1?のとき
  4198:   //    $00EB0000-$00EB03FF  バスエラー
  4199:   //    $00EB0400-$00EB07FF  バスエラー
  4200:   //    $00EB0800-$00EB0811  設定
  4201:   //    $00EB0812-$00EB7FFF  $FF
  4202:   //    $00EB8000-$00EBFFFF  バスエラー
  4203:   //
  4204:   //  メモ
  4205:   //    スプライトPCG・テキストエリアにバイトサイズで書き込むとデータが破壊される
  4206:   //
  4207:   MMD_SPR {
  4208:     @Override public String toString () {
  4209:       return Multilingual.mlnJapanese ? "スプライト画面" : "Sprite Screen";
  4210:     }
  4211:     //リード
  4212:     @Override protected byte mmdRbs (int a) throws M68kException {
  4213:        a &= XEiJ.BUS_MOTHER_MASK;
  4214:        return (a & 1) == 0 ? (byte) (mmdRwz (a) >> 8) : (byte) mmdRwz (a - 1);
  4215:      }
  4216:     @Override protected int mmdRbz (int a) throws M68kException {
  4217:        a &= XEiJ.BUS_MOTHER_MASK;
  4218:        return (a & 1) == 0 ? mmdRwz (a) >> 8 : mmdRwz (a - 1) & 0xff;
  4219:      }
  4220:     @Override protected int mmdRws (int a) throws M68kException {
  4221:        a &= XEiJ.BUS_MOTHER_MASK;
  4222:        return (short) mmdRwz (a);
  4223:      }
  4224:     @Override protected int mmdRwz (int a) throws M68kException {
  4225:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sprc;
  4226:        a &= XEiJ.BUS_MOTHER_MASK;
  4227:        if (a < 0x00eb0800) {  //スプライトスクロールレジスタ
  4228:          if (!SpriteScreen.sprAccessible) {
  4229:            return super.mmdRwz (a);  //バスエラー
  4230:          }
  4231:          int n = (a >> 3) & 0xff;  //スプライト番号
  4232:          if (SpriteScreen.sprNumberOfSprites <= n) {
  4233:            return 0xffff;
  4234:          }
  4235:          switch (a & 0x06) {
  4236:          case 0:  //x座標
  4237:            return SpriteScreen.sprX[n];
  4238:          case 2:  //y座標
  4239:            return SpriteScreen.sprY[n];
  4240:          case 4:  //パターン番号、パレットブロック、水平反転、垂直反転
  4241:            return (SpriteScreen.sprV[n] ? 0x8000 : 0) | (SpriteScreen.sprH[n] ? 0x4000 : 0) | SpriteScreen.sprColPort[n] << 4 | SpriteScreen.sprNum[n];
  4242:          case 6:  //プライオリティ
  4243:            return SpriteScreen.sprPrw[n];
  4244:          }
  4245:        } else if (a < 0x00eb8000) {  //各種レジスタ
  4246:          switch (a) {
  4247:          case SpriteScreen.SPR_REG0_BG0_X:
  4248:            return SpriteScreen.sprReg0Bg0XPort;
  4249:          case SpriteScreen.SPR_REG1_BG0_Y:
  4250:            return SpriteScreen.sprReg1Bg0YPort;
  4251:          case SpriteScreen.SPR_REG2_BG1_X:
  4252:            return SpriteScreen.sprReg2Bg1XPort;
  4253:          case SpriteScreen.SPR_REG3_BG1_Y:
  4254:            return SpriteScreen.sprReg3Bg1YPort;
  4255:          case SpriteScreen.SPR_REG4_BG_CTRL:
  4256:            return SpriteScreen.sprReg4BgCtrlPort;
  4257:          case SpriteScreen.SPR_REG5_H_FRONT_END:
  4258:            return SpriteScreen.sprReg5HFrontEndPort;
  4259:          case SpriteScreen.SPR_REG6_H_BACK_END:
  4260:            return SpriteScreen.sprReg6HBackEndPort;
  4261:          case SpriteScreen.SPR_REG7_V_BACK_END:
  4262:            return SpriteScreen.sprReg7VBackEndPort;
  4263:          case SpriteScreen.SPR_REG8_RESO:
  4264:            return SpriteScreen.sprReg8ResoPort;
  4265:          }
  4266:          return 0xffff;
  4267:        } else {  //PCGエリアとテキストエリア
  4268:          if (!SpriteScreen.sprAccessible) {
  4269:            return super.mmdRwz (a);  //バスエラー
  4270:          }
  4271:          int t = a >> 2 & 0x1fff;
  4272:          return (a & 0x02) == 0 ? SpriteScreen.sprPatPort[t] >>> 16 : (char) SpriteScreen.sprPatPort[t];
  4273:        }
  4274:        return 0;
  4275:      }
  4276:     @Override protected int mmdRls (int a) throws M68kException {
  4277:        a &= XEiJ.BUS_MOTHER_MASK;
  4278:        return mmdRwz (a) << 16 | mmdRwz (a + 2);
  4279:      }
  4280:     //ライト
  4281:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4282:        a &= XEiJ.BUS_MOTHER_MASK;
  4283:        if (a < 0x00eb0800 || 0x00eb8000 <= a) {
  4284:          mmdWw (a & ~1, d << 8 | (d & 0xff));  //上位バイトと下位バイトに同じ値を書き込む
  4285:        } else {
  4286:          if ((a & 1) == 0) {
  4287:            mmdWw (a, d << 8 | (mmdRwz (a) & 0xff));
  4288:          } else {
  4289:            mmdWw (a - 1, (mmdRwz (a - 1) & ~0xff) | (d & 0xff));
  4290:          }
  4291:        }
  4292:      }
  4293:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4294:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sprc;
  4295:        a &= XEiJ.BUS_MOTHER_MASK;
  4296:        if (a < 0x00eb0800) {  //スプライトスクロールレジスタ
  4297:          if (!SpriteScreen.sprAccessible) {
  4298:            super.mmdWw (a, d);  //バスエラー
  4299:          }
  4300:          int n = (a >> 3) & 0xff;  //スプライト番号
  4301:          if (SpriteScreen.sprNumberOfSprites <= n) {
  4302:            return;
  4303:          }
  4304:          switch (a & 0x06) {
  4305:          case 0:  //x座標
  4306:            SpriteScreen.sprX[n] = (short) (d & 1023);
  4307:            break;
  4308:          case 2:  //y座標
  4309:            d &= 1023;
  4310:            if (SpriteScreen.sprY[n] != d) {
  4311:              int y = SpriteScreen.sprY[n];
  4312:              SpriteScreen.sprY[n] = (short) d;
  4313:              if (SpriteScreen.sprPrw[n] != 0) {
  4314:                int mask = ~(0x80000000 >>> n);  //intのシフトカウントは5bitでマスクされる
  4315:                int i = y << 3 | n >> 5;  //移動元
  4316:                SpriteScreen.sprRRmap[i            ] &= mask;
  4317:                SpriteScreen.sprRRmap[i + ( 1 << 3)] &= mask;
  4318:                SpriteScreen.sprRRmap[i + ( 2 << 3)] &= mask;
  4319:                SpriteScreen.sprRRmap[i + ( 3 << 3)] &= mask;
  4320:                SpriteScreen.sprRRmap[i + ( 4 << 3)] &= mask;
  4321:                SpriteScreen.sprRRmap[i + ( 5 << 3)] &= mask;
  4322:                SpriteScreen.sprRRmap[i + ( 6 << 3)] &= mask;
  4323:                SpriteScreen.sprRRmap[i + ( 7 << 3)] &= mask;
  4324:                SpriteScreen.sprRRmap[i + ( 8 << 3)] &= mask;
  4325:                SpriteScreen.sprRRmap[i + ( 9 << 3)] &= mask;
  4326:                SpriteScreen.sprRRmap[i + (10 << 3)] &= mask;
  4327:                SpriteScreen.sprRRmap[i + (11 << 3)] &= mask;
  4328:                SpriteScreen.sprRRmap[i + (12 << 3)] &= mask;
  4329:                SpriteScreen.sprRRmap[i + (13 << 3)] &= mask;
  4330:                SpriteScreen.sprRRmap[i + (14 << 3)] &= mask;
  4331:                SpriteScreen.sprRRmap[i + (15 << 3)] &= mask;
  4332:                mask = ~mask;
  4333:                i = d << 3 | n >> 5;  //移動先
  4334:                SpriteScreen.sprRRmap[i            ] |= mask;
  4335:                SpriteScreen.sprRRmap[i + ( 1 << 3)] |= mask;
  4336:                SpriteScreen.sprRRmap[i + ( 2 << 3)] |= mask;
  4337:                SpriteScreen.sprRRmap[i + ( 3 << 3)] |= mask;
  4338:                SpriteScreen.sprRRmap[i + ( 4 << 3)] |= mask;
  4339:                SpriteScreen.sprRRmap[i + ( 5 << 3)] |= mask;
  4340:                SpriteScreen.sprRRmap[i + ( 6 << 3)] |= mask;
  4341:                SpriteScreen.sprRRmap[i + ( 7 << 3)] |= mask;
  4342:                SpriteScreen.sprRRmap[i + ( 8 << 3)] |= mask;
  4343:                SpriteScreen.sprRRmap[i + ( 9 << 3)] |= mask;
  4344:                SpriteScreen.sprRRmap[i + (10 << 3)] |= mask;
  4345:                SpriteScreen.sprRRmap[i + (11 << 3)] |= mask;
  4346:                SpriteScreen.sprRRmap[i + (12 << 3)] |= mask;
  4347:                SpriteScreen.sprRRmap[i + (13 << 3)] |= mask;
  4348:                SpriteScreen.sprRRmap[i + (14 << 3)] |= mask;
  4349:                SpriteScreen.sprRRmap[i + (15 << 3)] |= mask;
  4350:              }
  4351:            }
  4352:            break;
  4353:          case 4:  //パターン番号、パレットブロック、水平反転、垂直反転
  4354:            {
  4355:              int num = SpriteScreen.sprNum[n];  //元のパターン番号
  4356:              SpriteScreen.sprNum[n] = (short) (d & 0xff);
  4357:              SpriteScreen.sprColPort[n] = (short) (d >> 4 & 0x0f << 4);
  4358:              SpriteScreen.sprH[n] = (short) (d << 1) < 0;
  4359:              SpriteScreen.sprV[n] = (short) d < 0;
  4360:              if (SpriteScreen.sprPrw[n] != 0) {
  4361:                int mask = 0x80000000 >>> n;  //intのシフトカウントは5bitでマスクされる
  4362:                SpriteScreen.sprPPmap[num << 3 | n >> 5] &= ~mask;  //消滅
  4363:                SpriteScreen.sprPPmap[(d & 0xff) << 3 | n >> 5] |= mask;  //出現
  4364:              }
  4365:            }
  4366:            break;
  4367:          case 6:  //プライオリティ
  4368:            d &= 0x0003;
  4369:            int prw = SpriteScreen.sprPrw[n];
  4370:            SpriteScreen.sprPrw[n] = (byte) d;
  4371:            if (prw != d) {
  4372:              if (prw == 0) {  //出現
  4373:                int y = SpriteScreen.sprY[n];
  4374:                int mask = 0x80000000 >>> n;  //intのシフトカウントは5bitでマスクされる
  4375:                int i = y << 3 | n >> 5;
  4376:                SpriteScreen.sprRRmap[i            ] |= mask;
  4377:                SpriteScreen.sprRRmap[i + ( 1 << 3)] |= mask;
  4378:                SpriteScreen.sprRRmap[i + ( 2 << 3)] |= mask;
  4379:                SpriteScreen.sprRRmap[i + ( 3 << 3)] |= mask;
  4380:                SpriteScreen.sprRRmap[i + ( 4 << 3)] |= mask;
  4381:                SpriteScreen.sprRRmap[i + ( 5 << 3)] |= mask;
  4382:                SpriteScreen.sprRRmap[i + ( 6 << 3)] |= mask;
  4383:                SpriteScreen.sprRRmap[i + ( 7 << 3)] |= mask;
  4384:                SpriteScreen.sprRRmap[i + ( 8 << 3)] |= mask;
  4385:                SpriteScreen.sprRRmap[i + ( 9 << 3)] |= mask;
  4386:                SpriteScreen.sprRRmap[i + (10 << 3)] |= mask;
  4387:                SpriteScreen.sprRRmap[i + (11 << 3)] |= mask;
  4388:                SpriteScreen.sprRRmap[i + (12 << 3)] |= mask;
  4389:                SpriteScreen.sprRRmap[i + (13 << 3)] |= mask;
  4390:                SpriteScreen.sprRRmap[i + (14 << 3)] |= mask;
  4391:                SpriteScreen.sprRRmap[i + (15 << 3)] |= mask;
  4392:                SpriteScreen.sprPPmap[SpriteScreen.sprNum[n] << 3 | n >> 5] |= mask;
  4393:              } else if (d == 0) {  //消滅
  4394:                int y = SpriteScreen.sprY[n];
  4395:                int mask = ~(0x80000000 >>> n);  //intのシフトカウントは5bitでマスクされる
  4396:                int i = y << 3 | n >> 5;
  4397:                SpriteScreen.sprRRmap[i            ] &= mask;
  4398:                SpriteScreen.sprRRmap[i + ( 1 << 3)] &= mask;
  4399:                SpriteScreen.sprRRmap[i + ( 2 << 3)] &= mask;
  4400:                SpriteScreen.sprRRmap[i + ( 3 << 3)] &= mask;
  4401:                SpriteScreen.sprRRmap[i + ( 4 << 3)] &= mask;
  4402:                SpriteScreen.sprRRmap[i + ( 5 << 3)] &= mask;
  4403:                SpriteScreen.sprRRmap[i + ( 6 << 3)] &= mask;
  4404:                SpriteScreen.sprRRmap[i + ( 7 << 3)] &= mask;
  4405:                SpriteScreen.sprRRmap[i + ( 8 << 3)] &= mask;
  4406:                SpriteScreen.sprRRmap[i + ( 9 << 3)] &= mask;
  4407:                SpriteScreen.sprRRmap[i + (10 << 3)] &= mask;
  4408:                SpriteScreen.sprRRmap[i + (11 << 3)] &= mask;
  4409:                SpriteScreen.sprRRmap[i + (12 << 3)] &= mask;
  4410:                SpriteScreen.sprRRmap[i + (13 << 3)] &= mask;
  4411:                SpriteScreen.sprRRmap[i + (14 << 3)] &= mask;
  4412:                SpriteScreen.sprRRmap[i + (15 << 3)] &= mask;
  4413:                SpriteScreen.sprPPmap[SpriteScreen.sprNum[n] << 3 | n >> 5] &= mask;
  4414:              }
  4415:            }
  4416:            break;
  4417:          }  //スプライトスクロールレジスタのswitch
  4418:          return;
  4419:        } else if (a < 0x00eb8000) {  //各種レジスタ
  4420:          switch (a) {
  4421:          case SpriteScreen.SPR_REG0_BG0_X:
  4422:            SpriteScreen.sprReg0Bg0XPort = d & 1023;
  4423:            {
  4424:              int curr = SpriteScreen.sprReg0Bg0XMask == 0 ? SpriteScreen.sprReg0Bg0XPort : SpriteScreen.sprReg0Bg0XTest;
  4425:              if (SpriteScreen.sprReg0Bg0XCurr != curr) {
  4426:                SpriteScreen.sprReg0Bg0XCurr = curr;
  4427:              }
  4428:            }
  4429:            return;
  4430:          case SpriteScreen.SPR_REG1_BG0_Y:
  4431:            SpriteScreen.sprReg1Bg0YPort = d & 1023;
  4432:            {
  4433:              int curr = SpriteScreen.sprReg1Bg0YMask == 0 ? SpriteScreen.sprReg1Bg0YPort : SpriteScreen.sprReg1Bg0YTest;
  4434:              if (SpriteScreen.sprReg1Bg0YCurr != curr) {
  4435:                SpriteScreen.sprReg1Bg0YCurr = curr;
  4436:              }
  4437:            }
  4438:            return;
  4439:          case SpriteScreen.SPR_REG2_BG1_X:
  4440:            SpriteScreen.sprReg2Bg1XPort = d & 1023;
  4441:            {
  4442:              int curr = SpriteScreen.sprReg2Bg1XMask == 0 ? SpriteScreen.sprReg2Bg1XPort : SpriteScreen.sprReg2Bg1XTest;
  4443:              if (SpriteScreen.sprReg2Bg1XCurr != curr) {
  4444:                SpriteScreen.sprReg2Bg1XCurr = curr;
  4445:              }
  4446:            }
  4447:            return;
  4448:          case SpriteScreen.SPR_REG3_BG1_Y:
  4449:            SpriteScreen.sprReg3Bg1YPort = d & 1023;
  4450:            {
  4451:              int curr = SpriteScreen.sprReg3Bg1YMask == 0 ? SpriteScreen.sprReg3Bg1YPort : SpriteScreen.sprReg3Bg1YTest;
  4452:              if (SpriteScreen.sprReg3Bg1YCurr != curr) {
  4453:                SpriteScreen.sprReg3Bg1YCurr = curr;
  4454:              }
  4455:            }
  4456:            return;
  4457:          case SpriteScreen.SPR_REG4_BG_CTRL:
  4458:            SpriteScreen.sprReg4BgCtrlPort = d & 2047;
  4459:            {
  4460:              int curr = SpriteScreen.sprReg4BgCtrlPort & ~SpriteScreen.sprReg4BgCtrlMask | SpriteScreen.sprReg4BgCtrlTest & SpriteScreen.sprReg4BgCtrlMask;
  4461:              if (SpriteScreen.sprReg4BgCtrlCurr != curr) {
  4462:                SpriteScreen.sprReg4BgCtrlCurr = curr;
  4463:              }
  4464:            }
  4465:            return;
  4466:          case SpriteScreen.SPR_REG5_H_FRONT_END:
  4467:            SpriteScreen.sprReg5HFrontEndPort = d & 0xff;
  4468:            {
  4469:              int curr = SpriteScreen.sprReg5HFrontEndMask == 0 ? SpriteScreen.sprReg5HFrontEndPort : SpriteScreen.sprReg5HFrontEndTest;
  4470:              if (SpriteScreen.sprReg5HFrontEndCurr != curr) {
  4471:                SpriteScreen.sprReg5HFrontEndCurr = curr;
  4472:              }
  4473:            }
  4474:            return;
  4475:          case SpriteScreen.SPR_REG6_H_BACK_END:
  4476:            SpriteScreen.sprReg6HBackEndPort = d & 63;
  4477:            {
  4478:              int curr = SpriteScreen.sprReg6HBackEndMask == 0 ? SpriteScreen.sprReg6HBackEndPort : SpriteScreen.sprReg6HBackEndTest;
  4479:              if (SpriteScreen.sprReg6HBackEndCurr != curr) {
  4480:                SpriteScreen.sprReg6HBackEndCurr = curr;
  4481:              }
  4482:            }
  4483:            return;
  4484:          case SpriteScreen.SPR_REG7_V_BACK_END:
  4485:            SpriteScreen.sprReg7VBackEndPort = d & 0xff;
  4486:            {
  4487:              int curr = SpriteScreen.sprReg7VBackEndMask == 0 ? SpriteScreen.sprReg7VBackEndPort : SpriteScreen.sprReg7VBackEndTest;
  4488:              if (SpriteScreen.sprReg7VBackEndCurr != curr) {
  4489:                SpriteScreen.sprReg7VBackEndCurr = curr;
  4490:              }
  4491:            }
  4492:            return;
  4493:          case SpriteScreen.SPR_REG8_RESO:
  4494:            SpriteScreen.sprReg8ResoPort = d & 31;
  4495:            {
  4496:              int curr = SpriteScreen.sprReg8ResoPort & ~SpriteScreen.sprReg8ResoMask | SpriteScreen.sprReg8ResoTest & SpriteScreen.sprReg8ResoMask;
  4497:              if (SpriteScreen.sprReg8ResoCurr != curr) {
  4498:                SpriteScreen.sprReg8ResoCurr = curr;
  4499:                CRTC.crtRestart ();
  4500:              }
  4501:            }
  4502:            return;
  4503:          }
  4504:          return;
  4505:        } else {  //PCGエリアとテキストエリア
  4506:          if (!SpriteScreen.sprAccessible) {
  4507:            super.mmdWw (a, d);  //バスエラー
  4508:          }
  4509:          if (0x00ebe000 <= a) {  //テキストエリア1
  4510:            int n = a >> 1 & 0x0fff;
  4511:            SpriteScreen.sprT1Num[n] = (short) ((d & 0xff) << 3);
  4512:            SpriteScreen.sprT1ColPort[n] = (short) ((d & 0x0f00) >> 4);
  4513:            SpriteScreen.sprT1H[n] = (short) (d << 1) < 0;
  4514:            SpriteScreen.sprT1V[n] = (short) d < 0;
  4515:          } else if (0x00ebc000 <= a) {  //テキストエリア0
  4516:            int n = a >> 1 & 0x0fff;
  4517:            SpriteScreen.sprT0Num[n] = (short) ((d & 0xff) << 3);
  4518:            SpriteScreen.sprT0ColPort[n] = (short) ((d & 0x0f00) >> 4);
  4519:            SpriteScreen.sprT0H[n] = (short) (d << 1) < 0;
  4520:            SpriteScreen.sprT0V[n] = (short) d < 0;
  4521:          }
  4522:          int t = a >> 2 & 0x1fff;
  4523:          SpriteScreen.sprPatPort[t] = (a & 0x02) == 0 ? d << 16 | (char) SpriteScreen.sprPatPort[t] : (SpriteScreen.sprPatPort[t] & ~0xffff) | (char) d;
  4524:        }  //PCGエリアとテキストエリア
  4525:      }  //mmdWw
  4526:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4527:        a &= XEiJ.BUS_MOTHER_MASK;
  4528:        mmdWw (a    , d >> 16);
  4529:        mmdWw (a + 2, d      );
  4530:      }
  4531:   },  //MMD_SPR
  4532: 
  4533:   //--------------------------------------------------------------------------------
  4534:   //MMD_XB3 拡張ボード領域3
  4535:   //  $00EC0000~$00ECFFFF  64KB
  4536:   //  0x00ec0000  ユーザI/Oエリア
  4537:   //  0x00ec0000  Awesome
  4538:   //  0x00ec0000  Xellent30
  4539:   //  0x00ecc000  Mercury
  4540:   //  0x00ece000  Neptune
  4541:   //  0x00ecf000  Venus-X/030
  4542:   MMD_XB3 {
  4543:     @Override public String toString () {
  4544:       return Multilingual.mlnJapanese ? "拡張ボード領域 3" : "Expansion Board Area 3";
  4545:     }
  4546:     //リード
  4547:     @Override protected int mmdRbz (int a) throws M68kException {
  4548:        a &= XEiJ.BUS_MOTHER_MASK;
  4549:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4550:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4551:          return (a & 1) == 0 ? 0 : XEiJ.xt3PortRead ();
  4552:        }
  4553:        return super.mmdRbz (a);  //バスエラー
  4554:      }
  4555:     @Override protected int mmdRwz (int a) throws M68kException {
  4556:        a &= XEiJ.BUS_MOTHER_MASK;
  4557:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4558:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4559:          return XEiJ.xt3PortRead ();
  4560:        }
  4561:        return super.mmdRwz (a);  //バスエラー
  4562:      }
  4563:     @Override protected int mmdRls (int a) throws M68kException {
  4564:        a &= XEiJ.BUS_MOTHER_MASK;
  4565:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4566:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4567:          return XEiJ.xt3PortRead () << 16 | XEiJ.xt3PortRead ();
  4568:        }
  4569:        return super.mmdRls (a);  //バスエラー
  4570:      }
  4571:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4572:        a &= XEiJ.BUS_MOTHER_MASK;
  4573:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4574:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4575:          if ((a & 1) == 0) {
  4576:          } else {
  4577:            XEiJ.xt3PortWrite (d);
  4578:          }
  4579:          return;
  4580:        }
  4581:        super.mmdWb (a, d);  //バスエラー
  4582:      }
  4583:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4584:        a &= XEiJ.BUS_MOTHER_MASK;
  4585:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4586:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4587:          XEiJ.xt3PortWrite (d);
  4588:          return;
  4589:        }
  4590:        super.mmdWw (a, d);  //バスエラー
  4591:      }
  4592:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4593:        a &= XEiJ.BUS_MOTHER_MASK;
  4594:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4595:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4596:          XEiJ.xt3PortWrite (d >> 16);
  4597:          XEiJ.xt3PortWrite (d);
  4598:          return;
  4599:        }
  4600:        super.mmdWl (a, d);  //バスエラー
  4601:      }
  4602:   },  //MMD_XB3
  4603: 
  4604:   //--------------------------------------------------------------------------------
  4605:   //MMD_XTM Xellent30のSRAM
  4606:   MMD_XTM {
  4607:     @Override public String toString () {
  4608:       return Multilingual.mlnJapanese ? "Xellent30 の SRAM" : "SRAM on Xellent30";
  4609:     }
  4610:     //ピーク
  4611:     @Override protected byte mmdPbs (int a) {
  4612:       a -= XEiJ.xt3MemoryPosition;
  4613:       return XEiJ.xt3MemoryArray[a];
  4614:     }
  4615:     @Override protected int mmdPbz (int a) {
  4616:       a -= XEiJ.xt3MemoryPosition;
  4617:       return XEiJ.xt3MemoryArray[a] & 0xff;
  4618:     }
  4619:     @Override protected int mmdPws (int a) {
  4620:       a -= XEiJ.xt3MemoryPosition;
  4621:       return XEiJ.xt3MemoryArray[a] << 8 | (XEiJ.xt3MemoryArray[a + 1] & 0xff);
  4622:     }
  4623:     @Override protected int mmdPwz (int a) {
  4624:       a -= XEiJ.xt3MemoryPosition;
  4625:       return (char) (XEiJ.xt3MemoryArray[a] << 8 | (XEiJ.xt3MemoryArray[a + 1] & 0xff));
  4626:     }
  4627:     @Override protected int mmdPls (int a) {
  4628:       a -= XEiJ.xt3MemoryPosition;
  4629:       return XEiJ.xt3MemoryArray[a] << 24 | (XEiJ.xt3MemoryArray[a + 1] & 0xff) << 16 | (char) (XEiJ.xt3MemoryArray[a + 2] << 8 | (XEiJ.xt3MemoryArray[a + 3] & 0xff));
  4630:     }
  4631:     //リード
  4632:     @Override protected byte mmdRbs (int a) throws M68kException {
  4633:        a -= XEiJ.xt3MemoryPosition;
  4634:        return XEiJ.xt3MemoryArray[a];
  4635:      }
  4636:     @Override protected int mmdRbz (int a) throws M68kException {
  4637:        a -= XEiJ.xt3MemoryPosition;
  4638:        return XEiJ.xt3MemoryArray[a] & 0xff;
  4639:      }
  4640:     @Override protected int mmdRws (int a) throws M68kException {
  4641:        a -= XEiJ.xt3MemoryPosition;
  4642:        return XEiJ.xt3MemoryArray[a] << 8 | (XEiJ.xt3MemoryArray[a + 1] & 0xff);
  4643:      }
  4644:     @Override protected int mmdRwz (int a) throws M68kException {
  4645:        a -= XEiJ.xt3MemoryPosition;
  4646:        return (char) (XEiJ.xt3MemoryArray[a] << 8 | (XEiJ.xt3MemoryArray[a + 1] & 0xff));
  4647:      }
  4648:     @Override protected int mmdRls (int a) throws M68kException {
  4649:        a -= XEiJ.xt3MemoryPosition;
  4650:        return XEiJ.xt3MemoryArray[a] << 24 | (XEiJ.xt3MemoryArray[a + 1] & 0xff) << 16 | (char) (XEiJ.xt3MemoryArray[a + 2] << 8 | (XEiJ.xt3MemoryArray[a + 3] & 0xff));
  4651:      }
  4652:     //ライト
  4653:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4654:        a -= XEiJ.xt3MemoryPosition;
  4655:        XEiJ.xt3MemoryArray[a    ] = (byte)  d;
  4656:      }
  4657:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4658:        a -= XEiJ.xt3MemoryPosition;
  4659:        XEiJ.xt3MemoryArray[a    ] = (byte) (d >> 8);
  4660:        XEiJ.xt3MemoryArray[a + 1] = (byte)  d;
  4661:      }
  4662:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4663:        a -= XEiJ.xt3MemoryPosition;
  4664:        XEiJ.xt3MemoryArray[a    ] = (byte) (d >> 24);
  4665:        XEiJ.xt3MemoryArray[a + 1] = (byte) (d >> 16);
  4666:        XEiJ.xt3MemoryArray[a + 2] = (byte) (d >> 8);
  4667:        XEiJ.xt3MemoryArray[a + 3] = (byte)  d;
  4668:      }
  4669:   },  //MMD_XTM
  4670: 
  4671:   //--------------------------------------------------------------------------------
  4672:   //MMD_SMR SRAM
  4673:   MMD_SMR {
  4674:     @Override public String toString () {
  4675:       return Multilingual.mlnJapanese ? "SRAM" : "SRAM";
  4676:     }
  4677:     //ピーク
  4678:     @Override protected byte mmdPbs (int a) {
  4679:       a &= XEiJ.BUS_MOTHER_MASK;
  4680:       return MainMemory.mmrM8[a];
  4681:     }
  4682:     @Override protected int mmdPbz (int a) {
  4683:       a &= XEiJ.BUS_MOTHER_MASK;
  4684:       return MainMemory.mmrM8[a] & 0xff;
  4685:     }
  4686:     @Override protected int mmdPws (int a) {
  4687:       a &= XEiJ.BUS_MOTHER_MASK;
  4688:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4689:         return MainMemory.mmrBuffer.getShort (a);
  4690:       } else {
  4691:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4692:       }
  4693:     }
  4694:     @Override protected int mmdPwz (int a) {
  4695:       a &= XEiJ.BUS_MOTHER_MASK;
  4696:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4697:         return MainMemory.mmrBuffer.getChar (a);
  4698:       } else {
  4699:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4700:       }
  4701:     }
  4702:     @Override protected int mmdPls (int a) {
  4703:       a &= XEiJ.BUS_MOTHER_MASK;
  4704:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4705:         return MainMemory.mmrBuffer.getInt (a);
  4706:       } else {
  4707:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4708:       }
  4709:     }
  4710:     //リード
  4711:     @Override protected byte mmdRbs (int a) throws M68kException {
  4712:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4713:        a &= XEiJ.BUS_MOTHER_MASK;
  4714:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4715:        return MainMemory.mmrM8[a];
  4716:      }
  4717:     @Override protected int mmdRbz (int a) throws M68kException {
  4718:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4719:        a &= XEiJ.BUS_MOTHER_MASK;
  4720:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4721:        return MainMemory.mmrM8[a] & 0xff;
  4722:      }
  4723:     @Override protected int mmdRws (int a) throws M68kException {
  4724:        return (short) mmdRwz (a);
  4725:      }
  4726:     @Override protected int mmdRwz (int a) throws M68kException {
  4727:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4728:        a &= XEiJ.BUS_MOTHER_MASK;
  4729:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4730:        int d;
  4731:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4732:          d = MainMemory.mmrBuffer.getChar (a);
  4733:        } else {
  4734:          d = (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4735:        }
  4736:        return d;
  4737:      }
  4738:     @Override protected int mmdRls (int a) throws M68kException {
  4739:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram * 2;
  4740:        a &= XEiJ.BUS_MOTHER_MASK;
  4741:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram * 2;
  4742:        int d;
  4743:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4744:          d = MainMemory.mmrBuffer.getInt (a);
  4745:        } else {
  4746:          d = MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4747:        }
  4748:        return d;
  4749:      }
  4750:     //ライト
  4751:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4752:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4753:        if (SRAM.smrWriteEnableOn) {
  4754:          a &= XEiJ.BUS_MOTHER_MASK;
  4755:          XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4756:          MainMemory.mmrM8[a] = (byte) d;
  4757:          if (a == 0x00ed002b || a == 0x00ed0059) {  //キーボードの配列または字体が変化した
  4758:            Keyboard.kbdRepaint ();  //キーボードが表示されているときkbdImageを作り直して再描画する
  4759:          } else if (a == 0x00ed005a) {  //HDMAX
  4760:            if (0x00fe0000 <= XEiJ.regPC0 && XEiJ.regPC0 <= 0x00ffffff) {  //IPLROMがSRAMのHDMAXを書き換えようとしている 
  4761:              SRAM.smrOverride ();  //SRAMの設定を上書きする
  4762:            }
  4763:          }
  4764:        } else {
  4765:          System.out.printf ("%08X writing $%02X to $%08X in a write-protected state\n", XEiJ.regPC0, d & 0xff, a);
  4766:          if (SRAM.smrSRAMBusErrorOn) {
  4767:            super.mmdWb (a, d);  //バスエラー
  4768:          }
  4769:        }
  4770:      }
  4771:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4772:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4773:        if (SRAM.smrWriteEnableOn) {
  4774:          a &= XEiJ.BUS_MOTHER_MASK;
  4775:          XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4776:          MainMemory.mmrM8[a    ] = (byte) (d >> 8);
  4777:          MainMemory.mmrM8[a + 1] = (byte)  d;
  4778:          if (a == (0x00ed002b & -2) || a == (0x00ed0059 & -2)) {  //キーボードの配列または字体が変化した
  4779:            Keyboard.kbdRepaint ();  //キーボードが表示されているときkbdImageを作り直して再描画する
  4780:          }
  4781:        } else {
  4782:          System.out.printf ("%08X writing $%04X to $%08X in a write-protected state\n", XEiJ.regPC0, d & 0xffff, a);
  4783:          if (SRAM.smrSRAMBusErrorOn) {
  4784:            super.mmdWw (a, d);  //バスエラー
  4785:          }
  4786:        }
  4787:      }
  4788:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4789:        if (SRAM.smrWriteEnableOn) {
  4790:          mmdWw (a    , d >> 16);
  4791:          mmdWw (a + 2, d      );
  4792:        } else {
  4793:          System.out.printf ("%08X writing $%08X to $%08X in a write-protected state\n", XEiJ.regPC0, d, a);
  4794:          if (SRAM.smrSRAMBusErrorOn) {
  4795:            super.mmdWl (a, d);  //バスエラー
  4796:          }
  4797:        }
  4798:      }
  4799:   },  //MMD_SMR
  4800: 
  4801:   //--------------------------------------------------------------------------------
  4802:   //MMD_XB4 拡張ボード領域4
  4803:   //  $00EE0000~$00EFFFFF  バンクメモリ
  4804:   MMD_XB4 {
  4805:     @Override public String toString () {
  4806:       return Multilingual.mlnJapanese ? "拡張ボード領域 4" : "Expansion Board Area 4";
  4807:     }
  4808:     //リード
  4809:     @Override protected byte mmdRbs (int a) throws M68kException {
  4810:        if (XEiJ.bnkOn) {
  4811:          a &= XEiJ.BUS_MOTHER_MASK;
  4812:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4813:          return XEiJ.bnkMemory[a];
  4814:        }
  4815:        return super.mmdRbs (a);  //バスエラー
  4816:      }
  4817:     @Override protected int mmdRbz (int a) throws M68kException {
  4818:        if (XEiJ.bnkOn) {
  4819:          a &= XEiJ.BUS_MOTHER_MASK;
  4820:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4821:          return XEiJ.bnkMemory[a] & 0xff;
  4822:        }
  4823:        return super.mmdRbz (a);  //バスエラー
  4824:      }
  4825:     @Override protected int mmdRws (int a) throws M68kException {
  4826:        if (XEiJ.bnkOn) {
  4827:          a &= XEiJ.BUS_MOTHER_MASK;
  4828:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4829:          return ((XEiJ.bnkMemory[a    ]       ) << 8 |
  4830:                  (XEiJ.bnkMemory[a + 1] & 0xff));
  4831:        }
  4832:        return super.mmdRws (a);  //バスエラー
  4833:      }
  4834:     @Override protected int mmdRwz (int a) throws M68kException {
  4835:        if (XEiJ.bnkOn) {
  4836:          a &= XEiJ.BUS_MOTHER_MASK;
  4837:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4838:          return ((XEiJ.bnkMemory[a    ] & 0xff) << 8 |
  4839:                  (XEiJ.bnkMemory[a + 1] & 0xff));
  4840:        }
  4841:        return super.mmdRwz (a);  //バスエラー
  4842:      }
  4843:     @Override protected int mmdRls (int a) throws M68kException {
  4844:        if (XEiJ.bnkOn) {
  4845:          a &= XEiJ.BUS_MOTHER_MASK;
  4846:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4847:          return ((XEiJ.bnkMemory[a    ]       ) << 24 |
  4848:                  (XEiJ.bnkMemory[a + 1] & 0xff) << 16 |
  4849:                  (XEiJ.bnkMemory[a + 2] & 0xff) <<  8 |
  4850:                  (XEiJ.bnkMemory[a + 3] & 0xff));
  4851:        }
  4852:        return super.mmdRls (a);  //バスエラー
  4853:      }
  4854:     //ライト
  4855:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4856:        if (XEiJ.bnkOn) {
  4857:          a &= XEiJ.BUS_MOTHER_MASK;
  4858:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4859:          XEiJ.bnkMemory[a] = (byte) d;
  4860:          return;
  4861:        }
  4862:        super.mmdWb (a, d);  //バスエラー
  4863:      }
  4864:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4865:        if (XEiJ.bnkOn) {
  4866:          a &= XEiJ.BUS_MOTHER_MASK;
  4867:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4868:          XEiJ.bnkMemory[a    ] = (byte) (d >> 8);
  4869:          XEiJ.bnkMemory[a + 1] = (byte)  d;
  4870:          return;
  4871:        }
  4872:        super.mmdWw (a, d);  //バスエラー
  4873:      }
  4874:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4875:        if (XEiJ.bnkOn) {
  4876:          a &= XEiJ.BUS_MOTHER_MASK;
  4877:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4878:          XEiJ.bnkMemory[a    ] = (byte) (d >> 24);
  4879:          XEiJ.bnkMemory[a + 1] = (byte) (d >> 16);
  4880:          XEiJ.bnkMemory[a + 2] = (byte) (d >>  8);
  4881:          XEiJ.bnkMemory[a + 3] = (byte)  d;
  4882:          return;
  4883:        }
  4884:        super.mmdWl (a, d);  //バスエラー
  4885:      }
  4886:   },  //MMD_XB4
  4887: 
  4888:   //--------------------------------------------------------------------------------
  4889:   //MMD_CG1 CGROM1
  4890:   MMD_CG1 {
  4891:     @Override public String toString () {
  4892:       return Multilingual.mlnJapanese ? "CGROM" : "CGROM";
  4893:     }
  4894:     //ピーク
  4895:     @Override protected byte mmdPbs (int a) {
  4896:       a &= XEiJ.BUS_MOTHER_MASK;
  4897:       return MainMemory.mmrM8[a];
  4898:     }
  4899:     @Override protected int mmdPbz (int a) {
  4900:       a &= XEiJ.BUS_MOTHER_MASK;
  4901:       return MainMemory.mmrM8[a] & 0xff;
  4902:     }
  4903:     @Override protected int mmdPws (int a) {
  4904:       a &= XEiJ.BUS_MOTHER_MASK;
  4905:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4906:         return MainMemory.mmrBuffer.getShort (a);
  4907:       } else {
  4908:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4909:       }
  4910:     }
  4911:     @Override protected int mmdPwz (int a) {
  4912:       a &= XEiJ.BUS_MOTHER_MASK;
  4913:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4914:         return MainMemory.mmrBuffer.getChar (a);
  4915:       } else {
  4916:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4917:       }
  4918:     }
  4919:     @Override protected int mmdPls (int a) {
  4920:       a &= XEiJ.BUS_MOTHER_MASK;
  4921:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4922:         return MainMemory.mmrBuffer.getInt (a);
  4923:       } else {
  4924:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4925:       }
  4926:     }
  4927:     //リード
  4928:     @Override protected byte mmdRbs (int a) throws M68kException {
  4929:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4930:        a &= XEiJ.BUS_MOTHER_MASK;
  4931:        return MainMemory.mmrM8[a];
  4932:      }
  4933:     @Override protected int mmdRbz (int a) throws M68kException {
  4934:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4935:        a &= XEiJ.BUS_MOTHER_MASK;
  4936:        return MainMemory.mmrM8[a] & 0xff;
  4937:      }
  4938:     @Override protected int mmdRws (int a) throws M68kException {
  4939:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4940:        a &= XEiJ.BUS_MOTHER_MASK;
  4941:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4942:          return MainMemory.mmrBuffer.getShort (a);
  4943:        } else {
  4944:          return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4945:        }
  4946:      }
  4947:     @Override protected int mmdRwz (int a) throws M68kException {
  4948:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4949:        a &= XEiJ.BUS_MOTHER_MASK;
  4950:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4951:          return MainMemory.mmrBuffer.getChar (a);
  4952:        } else {
  4953:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4954:        }
  4955:      }
  4956:     @Override protected int mmdRls (int a) throws M68kException {
  4957:        XEiJ.mpuClockTime += XEiJ.busWaitTime.romlong;
  4958:        a &= XEiJ.BUS_MOTHER_MASK;
  4959:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4960:          return MainMemory.mmrBuffer.getInt (a);
  4961:        } else {
  4962:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4963:        }
  4964:      }
  4965:   },  //MMD_CG1
  4966: 
  4967:   //--------------------------------------------------------------------------------
  4968:   //MMD_CG2 CGROM2
  4969:   MMD_CG2 {
  4970:     @Override public String toString () {
  4971:       return Multilingual.mlnJapanese ? "CGROM" : "CGROM";
  4972:     }
  4973:     //ピーク
  4974:     @Override protected byte mmdPbs (int a) {
  4975:       a &= XEiJ.BUS_MOTHER_MASK;
  4976:       return MainMemory.mmrM8[a];
  4977:     }
  4978:     @Override protected int mmdPbz (int a) {
  4979:       a &= XEiJ.BUS_MOTHER_MASK;
  4980:       return MainMemory.mmrM8[a] & 0xff;
  4981:     }
  4982:     @Override protected int mmdPws (int a) {
  4983:       a &= XEiJ.BUS_MOTHER_MASK;
  4984:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4985:         return MainMemory.mmrBuffer.getShort (a);
  4986:       } else {
  4987:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4988:       }
  4989:     }
  4990:     @Override protected int mmdPwz (int a) {
  4991:       a &= XEiJ.BUS_MOTHER_MASK;
  4992:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4993:         return MainMemory.mmrBuffer.getChar (a);
  4994:       } else {
  4995:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4996:       }
  4997:     }
  4998:     @Override protected int mmdPls (int a) {
  4999:       a &= XEiJ.BUS_MOTHER_MASK;
  5000:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5001:         return MainMemory.mmrBuffer.getInt (a);
  5002:       } else {
  5003:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  5004:       }
  5005:     }
  5006:     //リード
  5007:     @Override protected byte mmdRbs (int a) throws M68kException {
  5008:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5009:        a &= XEiJ.BUS_MOTHER_MASK;
  5010:        return MainMemory.mmrM8[a];
  5011:      }
  5012:     @Override protected int mmdRbz (int a) throws M68kException {
  5013:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5014:        a &= XEiJ.BUS_MOTHER_MASK;
  5015:        return MainMemory.mmrM8[a] & 0xff;
  5016:      }
  5017:     @Override protected int mmdRws (int a) throws M68kException {
  5018:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5019:        a &= XEiJ.BUS_MOTHER_MASK;
  5020:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5021:          return MainMemory.mmrBuffer.getShort (a);
  5022:        } else {
  5023:          return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  5024:        }
  5025:      }
  5026:     @Override protected int mmdRwz (int a) throws M68kException {
  5027:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5028:        a &= XEiJ.BUS_MOTHER_MASK;
  5029:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5030:          return MainMemory.mmrBuffer.getChar (a);
  5031:        } else {
  5032:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  5033:        }
  5034:      }
  5035:     @Override protected int mmdRls (int a) throws M68kException {
  5036:        XEiJ.mpuClockTime += XEiJ.busWaitTime.romlong;
  5037:        a &= XEiJ.BUS_MOTHER_MASK;
  5038:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5039:          return MainMemory.mmrBuffer.getInt (a);
  5040:        } else {
  5041:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  5042:        }
  5043:      }
  5044:   },  //MMD_CG2
  5045: 
  5046:   //--------------------------------------------------------------------------------
  5047:   //MMD_ROM ROM
  5048:   MMD_ROM {
  5049:     @Override public String toString () {
  5050:       return Multilingual.mlnJapanese ? "ROM" : "ROM";
  5051:     }
  5052:     //ピーク
  5053:     @Override protected byte mmdPbs (int a) {
  5054:       a &= XEiJ.BUS_MOTHER_MASK;
  5055:       return MainMemory.mmrM8[a];
  5056:     }
  5057:     @Override protected int mmdPbz (int a) {
  5058:       a &= XEiJ.BUS_MOTHER_MASK;
  5059:       return MainMemory.mmrM8[a] & 0xff;
  5060:     }
  5061:     @Override protected int mmdPws (int a) {
  5062:       a &= XEiJ.BUS_MOTHER_MASK;
  5063:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5064:         return MainMemory.mmrBuffer.getShort (a);
  5065:       } else {
  5066:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  5067:       }
  5068:     }
  5069:     @Override protected int mmdPwz (int a) {
  5070:       a &= XEiJ.BUS_MOTHER_MASK;
  5071:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5072:         return MainMemory.mmrBuffer.getChar (a);
  5073:       } else {
  5074:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  5075:       }
  5076:     }
  5077:     @Override protected int mmdPls (int a) {
  5078:       a &= XEiJ.BUS_MOTHER_MASK;
  5079:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5080:         return MainMemory.mmrBuffer.getInt (a);
  5081:       } else {
  5082:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  5083:       }
  5084:     }
  5085:     //リード
  5086:     @Override protected byte mmdRbs (int a) throws M68kException {
  5087:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5088:        a &= XEiJ.BUS_MOTHER_MASK;
  5089:        return MainMemory.mmrM8[a];
  5090:      }
  5091:     @Override protected int mmdRbz (int a) throws M68kException {
  5092:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5093:        a &= XEiJ.BUS_MOTHER_MASK;
  5094:        return MainMemory.mmrM8[a] & 0xff;
  5095:      }
  5096:     @Override protected int mmdRws (int a) throws M68kException {
  5097:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5098:        a &= XEiJ.BUS_MOTHER_MASK;
  5099:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5100:          return MainMemory.mmrBuffer.getShort (a);
  5101:        } else {
  5102:          return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  5103:        }
  5104:      }
  5105:     @Override protected int mmdRwz (int a) throws M68kException {
  5106:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5107:        a &= XEiJ.BUS_MOTHER_MASK;
  5108:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5109:          return MainMemory.mmrBuffer.getChar (a);
  5110:        } else {
  5111:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  5112:        }
  5113:      }
  5114:     @Override protected int mmdRls (int a) throws M68kException {
  5115:        XEiJ.mpuClockTime += XEiJ.busWaitTime.romlong;
  5116:        a &= XEiJ.BUS_MOTHER_MASK;
  5117:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5118:          return MainMemory.mmrBuffer.getInt (a);
  5119:        } else {
  5120:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  5121:        }
  5122:      }
  5123:   },  //MMD_ROM
  5124: 
  5125:   //--------------------------------------------------------------------------------
  5126:   //MMD_IBP 命令ブレークポイント
  5127:   MMD_IBP {
  5128:     @Override public String toString () {
  5129:       return Multilingual.mlnJapanese ? "命令ブレークポイント" : "Instruction Break Point";
  5130:     }
  5131:     @Override protected int mmdRwz (int a) throws M68kException {
  5132:        if (InstructionBreakPoint.IBP_ON) {
  5133:          InstructionBreakPoint.InstructionBreakRecord[] hashTable = InstructionBreakPoint.ibpHashTable;
  5134:          for (InstructionBreakPoint.InstructionBreakRecord r = hashTable[a >> 1 & InstructionBreakPoint.IBP_HASH_MASK];
  5135:               r != null;
  5136:               r = r.ibrNext) {  //同じ物理ハッシュコードを持つ命令ブレークポイントについて
  5137:            if (r.ibrPhysicalAddress == a) {  //命令ブレークポイントが設定されているとき
  5138:              if (r.ibrValue == r.ibrTarget) {  //現在値が目標値と一致しているとき
  5139:                if (r.ibrThreshold < 0) {  //インスタントのとき
  5140:                  InstructionBreakPoint.ibpRemove (r.ibrLogicalAddress, XEiJ.regSRS);  //取り除く
  5141:                  XEiJ.mpuContinue = true;  //ステップ実行を継続する
  5142:                } else if (r.ibrTarget < r.ibrThreshold) {  //インスタント化しているとき
  5143:                  r.ibrTarget = r.ibrThreshold;  //目標値を閾値に戻す
  5144:                  XEiJ.mpuContinue = true;  //ステップ実行を継続する
  5145:                } else {  //インスタントでなくインスタント化していないとき
  5146:                  if (r.ibrScriptElement != null &&  //スクリプトが指定されていて
  5147:                      r.ibrScriptElement.exlEval (ExpressionEvaluator.EVM_EXPRESSION).exlFloatValue.iszero ()) {  //条件が成立していないとき
  5148:                    break;  //続行する
  5149:                  }
  5150:                  r.ibrTarget++;  //目標値を増やす
  5151:                  XEiJ.mpuContinue = false;  //ステップ実行を継続しない
  5152:                }
  5153:                M68kException.m6eNumber = M68kException.M6E_INSTRUCTION_BREAK_POINT;  //命令ブレークポイントによる停止。XEiJ.mpuContinueを設定すること
  5154:                throw M68kException.m6eSignal;  //停止する
  5155:              } else {  //現在値が目標値と一致していないとき
  5156:                if (r.ibrWaitInstruction != null) {  //待機ポイントがあるとき
  5157:                  WaitInstruction.instruction = r.ibrWaitInstruction;  //待機命令を設定して
  5158:                  return XEiJ.EMX_OPCODE_EMXWAIT;  //返す
  5159:                }
  5160:                r.ibrValue++;  //現在値を増やす
  5161:                break;  //続行する
  5162:              }
  5163:            }
  5164:          }
  5165:        }
  5166:        if (DataBreakPoint.DBP_ON) {
  5167:          return DataBreakPoint.dbpMemoryMap[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
  5168:        } else {
  5169:          return XEiJ.busMemoryMap[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
  5170:        }
  5171:      }
  5172:   },  //MMD_IBP
  5173: 
  5174:   //--------------------------------------------------------------------------------
  5175:   //MMD_DBP データブレークポイント
  5176:   MMD_DBP {
  5177:     @Override public String toString () {
  5178:       return Multilingual.mlnJapanese ? "データブレークポイント" : "Data Break Point";
  5179:     }
  5180:     //ピーク
  5181:     @Override protected byte mmdPbs (int a) {
  5182:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPbs (a);
  5183:     }
  5184:     @Override protected int mmdPbz (int a) {
  5185:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPbz (a);
  5186:     }
  5187:     @Override protected int mmdPws (int a) {
  5188:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPws (a);
  5189:     }
  5190:     @Override protected int mmdPwz (int a) {
  5191:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPwz (a);
  5192:     }
  5193:     @Override protected int mmdPls (int a) {
  5194:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPls (a);
  5195:     }
  5196:     //リード
  5197:     @Override protected byte mmdRbs (int a) throws M68kException {
  5198:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRbs (a);
  5199:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_BYTE, a, d);
  5200:        return (byte) d;
  5201:      }
  5202:     @Override protected int mmdRbz (int a) throws M68kException {
  5203:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a);
  5204:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_BYTE, a, d);
  5205:        return d;
  5206:      }
  5207:     @Override protected int mmdRws (int a) throws M68kException {
  5208:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRws (a);
  5209:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_WORD, a, d);
  5210:        return d;
  5211:      }
  5212:     @Override protected int mmdRwz (int a) throws M68kException {
  5213:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
  5214:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_WORD, a, d);
  5215:        return d;
  5216:      }
  5217:     @Override protected int mmdRls (int a) throws M68kException {
  5218:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRls (a);
  5219:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_LONG, a, d);
  5220:        return d;
  5221:      }
  5222:     //ライト
  5223:     @Override protected void mmdWb (int a, int d) throws M68kException {
  5224:        (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdWb (a, d);
  5225:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_BYTE, a, d);
  5226:      }
  5227:     @Override protected void mmdWw (int a, int d) throws M68kException {
  5228:        (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdWw (a, d);
  5229:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_WORD, a, d);
  5230:      }
  5231:     @Override protected void mmdWl (int a, int d) throws M68kException {
  5232:        (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdWl (a, d);
  5233:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_LONG, a, d);
  5234:      }
  5235:   },  //MMD_DBP
  5236: 
  5237:   //--------------------------------------------------------------------------------
  5238:   //MMD_NUL ヌルデバイス
  5239:   MMD_NUL {
  5240:     @Override public String toString () {
  5241:       return Multilingual.mlnJapanese ? "ヌルデバイス" : "Null Device";
  5242:     }
  5243:   };  //MMD_NUL
  5244: 
  5245:   //--------------------------------------------------------------------------------
  5246:   //ピークのデフォルト
  5247:   //  エラーや副作用なしでリードする
  5248:   //  バスエラーのときは-1をキャストした値を返す
  5249:   //  リードがデバイスの状態を変化させる可能性がある場合は個別に処理すること
  5250:   protected byte mmdPbs (int a) {
  5251:     return (byte) mmdPbz (a);
  5252:   }
  5253:   protected int mmdPbz (int a) {
  5254:     try {
  5255:       return mmdRbz (a);
  5256:     } catch (M68kException e) {
  5257:     }
  5258:     return 0xff;
  5259:   }
  5260:   protected int mmdPws (int a) {
  5261:     return (short) mmdPwz (a);
  5262:   }
  5263:   protected int mmdPwz (int a) {
  5264:     try {
  5265:       return mmdRwz (a);
  5266:     } catch (M68kException e) {
  5267:     }
  5268:     return 0xffff;
  5269:   }
  5270:   protected int mmdPls (int a) {
  5271:     try {
  5272:       return mmdRls (a);
  5273:     } catch (M68kException e) {
  5274:     }
  5275:     return -1;
  5276:   }
  5277:   //リードのデフォルト
  5278:   //  バイトとワードの符号拡張はゼロ拡張を呼び出す
  5279:   //  符号なしとロングはバスエラー
  5280:   protected byte mmdRbs (int a) throws M68kException {
  5281:     return (byte) mmdRbz (a);
  5282:   }
  5283:   protected int mmdRbz (int a) throws M68kException {
  5284:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_READ;  //サイズは設定済み。分割されている場合があることに注意
  5285:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5286:     M68kException.m6eAddress = a;
  5287:     M68kException.m6eDirection = XEiJ.MPU_WR_READ;
  5288:     M68kException.m6eSize = XEiJ.MPU_SS_BYTE;
  5289:     throw M68kException.m6eSignal;
  5290:   }
  5291:   protected int mmdRws (int a) throws M68kException {
  5292:     return (short) mmdRwz (a);
  5293:   }
  5294:   protected int mmdRwz (int a) throws M68kException {
  5295:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_READ;  //サイズは設定済み。分割されている場合があることに注意
  5296:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5297:     M68kException.m6eAddress = a;
  5298:     M68kException.m6eDirection = XEiJ.MPU_WR_READ;
  5299:     M68kException.m6eSize = XEiJ.MPU_SS_WORD;
  5300:     throw M68kException.m6eSignal;
  5301:   }
  5302:   protected int mmdRls (int a) throws M68kException {
  5303:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_READ;  //サイズは設定済み。分割されている場合があることに注意
  5304:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5305:     M68kException.m6eAddress = a;
  5306:     M68kException.m6eDirection = XEiJ.MPU_WR_READ;
  5307:     M68kException.m6eSize = XEiJ.MPU_SS_LONG;
  5308:     throw M68kException.m6eSignal;
  5309:   }
  5310:   //ポークのデフォルト
  5311:   //  エラーや副作用なしでライトする
  5312:   //  ライトがデバイスの状態を変化させる可能性がある場合は個別に処理すること
  5313:   protected void mmdVb (int a, int d) {
  5314:     try {
  5315:       mmdWb (a, d);
  5316:     } catch (M68kException e) {
  5317:     }
  5318:   }
  5319:   protected void mmdVw (int a, int d) {
  5320:     try {
  5321:       mmdWw (a, d);
  5322:     } catch (M68kException e) {
  5323:     }
  5324:   }
  5325:   protected void mmdVl (int a, int d) {
  5326:     try {
  5327:       mmdWl (a, d);
  5328:     } catch (M68kException e) {
  5329:     }
  5330:   }
  5331:   //ライトのデフォルト
  5332:   //  すべてバスエラー
  5333:   protected void mmdWb (int a, int d) throws M68kException {
  5334:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_WRITE;  //サイズは設定済み。分割されている場合があることに注意
  5335:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5336:     M68kException.m6eAddress = a;
  5337:     M68kException.m6eDirection = XEiJ.MPU_WR_WRITE;
  5338:     M68kException.m6eSize = XEiJ.MPU_SS_BYTE;
  5339:     throw M68kException.m6eSignal;
  5340:   }
  5341:   protected void mmdWw (int a, int d) throws M68kException {
  5342:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_WRITE;  //サイズは設定済み。分割されている場合があることに注意
  5343:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5344:     M68kException.m6eAddress = a;
  5345:     M68kException.m6eDirection = XEiJ.MPU_WR_WRITE;
  5346:     M68kException.m6eSize = XEiJ.MPU_SS_WORD;
  5347:     throw M68kException.m6eSignal;
  5348:   }
  5349:   protected void mmdWl (int a, int d) throws M68kException {
  5350:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_WRITE;  //サイズは設定済み。分割されている場合があることに注意
  5351:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5352:     M68kException.m6eAddress = a;
  5353:     M68kException.m6eDirection = XEiJ.MPU_WR_WRITE;
  5354:     M68kException.m6eSize = XEiJ.MPU_SS_LONG;
  5355:     throw M68kException.m6eSignal;
  5356:   }
  5357: }  //enum MemoryMappedDevice
  5358: 
  5359: 
  5360: