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";  //SCSIのIはInterfaceなのだからSCSIインタフェイスはおかしい
  3576:     }
  3577:     //ピーク
  3578:     @Override protected int mmdPbz (int a) {
  3579:       a &= XEiJ.BUS_MOTHER_MASK;
  3580:       if ((a & 0x01) == 0) {  //偶数番地
  3581:         return 0xff;
  3582:       } else {  //奇数番地
  3583:         if (SPC.spcSCSIINOn) {  //SCSI内蔵機
  3584:           if ((a & 0x20) == 0) {  //SASIポート
  3585:             return ((a & 0x02) == 0 ? 0x00 : 0xff);
  3586:           } else {  //SCSIポート
  3587:             if (SUK.SUK_ON) {
  3588:               if (SUK.sukOn) {
  3589:                 return SUK.sukPeek (a);
  3590:               }
  3591:             }
  3592:             return SPC.spcSCSIINChip.spiPeek (a);
  3593:           }
  3594:         } else {  //SASI内蔵機
  3595:           switch (a & 0x3f) {
  3596:           case HDC.HDC_DATA_PORT & 0x3f:  //0x00e96001
  3597:             return HDC.hdcPeekData ();
  3598:           case HDC.HDC_STATUS_PORT & 0x3f:  //0x00e96003
  3599:             return HDC.hdcPeekStatus ();
  3600:           case HDC.HDC_RESET_PORT & 0x3f:  //0x00e96005
  3601:             return 0xff;
  3602:           case HDC.HDC_SELECTION_PORT & 0x3f:  //0x00e96007
  3603:             return 0xff;
  3604:           default:
  3605:             return 0xff;
  3606:           }
  3607:         }
  3608:       }
  3609:     }
  3610:     @Override protected int mmdPwz (int a) {
  3611:       a &= XEiJ.BUS_MOTHER_MASK;
  3612:       return 0xff00 | mmdPbz (a + 1);
  3613:     }
  3614:     @Override protected int mmdPls (int a) {
  3615:       a &= XEiJ.BUS_MOTHER_MASK;
  3616:       return 0xff00ff00 | mmdPbz (a + 1) << 16 | mmdPbz (a + 3);
  3617:     }
  3618:     //リード
  3619:     @Override protected int mmdRbz (int a) throws M68kException {
  3620:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3621:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3622:          return super.mmdRbz (a);  //バスエラー
  3623:        }
  3624:        XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;
  3625:        a &= XEiJ.BUS_MOTHER_MASK;
  3626:        if ((a & 0x01) == 0) {  //偶数番地
  3627:          return super.mmdRbz (a);  //バスエラー
  3628:        } else {  //奇数番地
  3629:          if (SPC.spcSCSIINOn) {  //SCSI内蔵機
  3630:            if ((a & 0x20) == 0) {  //SASIポート
  3631:              return ((a & 0x02) == 0 ? 0x00 : 0xff);
  3632:            } else {  //SCSIポート
  3633:              if (SUK.SUK_ON) {
  3634:                if (SUK.sukOn) {
  3635:                  return SUK.sukRead (a);
  3636:                }
  3637:              }
  3638:              return SPC.spcSCSIINChip.spiRead (a);
  3639:            }
  3640:          } else {  //SASI内蔵機
  3641:            switch (a & 0x3f) {
  3642:            case HDC.HDC_DATA_PORT & 0x3f:  //0x00e96001
  3643:              return HDC.hdcReadData ();
  3644:            case HDC.HDC_STATUS_PORT & 0x3f:  //0x00e96003
  3645:              return HDC.hdcReadStatus ();
  3646:            case HDC.HDC_RESET_PORT & 0x3f:  //0x00e96005
  3647:              return 0xff;
  3648:            case HDC.HDC_SELECTION_PORT & 0x3f:  //0x00e96007
  3649:              return 0xff;
  3650:            default:
  3651:              return 0xff;
  3652:            }
  3653:          }
  3654:        }
  3655:      }
  3656:     @Override protected int mmdRwz (int a) throws M68kException {
  3657:        return 0xff00 | mmdRbz (a + 1);
  3658:      }
  3659:     @Override protected int mmdRls (int a) throws M68kException {
  3660:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3661:      }
  3662:     //ライト
  3663:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3664:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3665:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3666:          super.mmdWb (a, d);  //バスエラー
  3667:        }
  3668:        XEiJ.mpuClockTime += XEiJ.busWaitTime.hdc;
  3669:        a &= XEiJ.BUS_MOTHER_MASK;
  3670:        if ((a & 0x01) == 0) {  //偶数番地
  3671:          super.mmdWb (a, d);  //バスエラー
  3672:        } else {  //奇数番地
  3673:          if (SPC.spcSCSIINOn) {  //SCSI内蔵機
  3674:            if ((a & 0x20) == 0) {  //SASIポート
  3675:              return;
  3676:            } else {  //SCSIポート
  3677:              if (SUK.SUK_ON) {
  3678:                if (SUK.sukOn) {
  3679:                  SUK.sukWrite (a, d);
  3680:                  return;
  3681:                }
  3682:              }
  3683:              SPC.spcSCSIINChip.spiWrite (a, d);
  3684:              return;
  3685:            }
  3686:          } else {  //SASI内蔵機
  3687:            switch (a & 0x3f) {
  3688:            case HDC.HDC_DATA_PORT & 0x3f:  //0x00e96001
  3689:              HDC.hdcWriteData (d);
  3690:              return;
  3691:            case HDC.HDC_STATUS_PORT & 0x3f:  //0x00e96003
  3692:              HDC.hdcWriteCommand (d);
  3693:              return;
  3694:            case HDC.HDC_RESET_PORT & 0x3f:  //0x00e96005
  3695:              HDC.hdcWriteReset (d);
  3696:              return;
  3697:            case HDC.HDC_SELECTION_PORT & 0x3f:  //0x00e96007
  3698:              HDC.hdcWriteSelect (d);
  3699:              return;
  3700:            default:
  3701:              return;
  3702:            }
  3703:          }
  3704:        }
  3705:      }
  3706:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3707:        mmdWb (a + 1, d);
  3708:      }
  3709:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3710:        mmdWb (a + 1, d >> 16);
  3711:        mmdWb (a + 3, d);
  3712:      }
  3713:   },  //MMD_HDC
  3714: 
  3715:   //--------------------------------------------------------------------------------
  3716:   //MMD_SCC SCC
  3717:   //
  3718:   //  $00E98000~$00E98007(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3719:   //  $00E98000~$00E98007(奇数)  バイトリードは$xx、バイトライトは$xx
  3720:   //  $00E98008~$00E99FFF  $00E98000~$00E98007の繰り返し
  3721:   //
  3722:   MMD_SCC {
  3723:     @Override public String toString () {
  3724:       return Multilingual.mlnJapanese ? "SCC" : "SCC";  //Serial Communication Controller
  3725:     }
  3726:     //ピーク
  3727:     @Override protected int mmdPbz (int a) {
  3728:       return Z8530.sccReadByte (a, true);
  3729:     }
  3730:     @Override protected int mmdPwz (int a) {
  3731:       return 0xff00 | mmdPbz (a + 1);
  3732:     }
  3733:     @Override protected int mmdPls (int a) {
  3734:       return 0xff00ff00 | mmdPbz (a + 1) << 16 | mmdPbz (a + 3);
  3735:     }
  3736:     //リード
  3737:     @Override protected int mmdRbz (int a) throws M68kException {
  3738:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3739:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3740:          return super.mmdRbz (a);  //バスエラー
  3741:        }
  3742:        return Z8530.sccReadByte (a, false);
  3743:      }
  3744:     @Override protected int mmdRwz (int a) throws M68kException {
  3745:        return 0xff00 | mmdRbz (a + 1);
  3746:      }
  3747:     @Override protected int mmdRls (int a) throws M68kException {
  3748:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3749:      }
  3750:     //ライト
  3751:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3752:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3753:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3754:          super.mmdWb (a, d);  //バスエラー
  3755:        }
  3756:        Z8530.sccWriteByte (a, d);
  3757:      }
  3758:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3759:        mmdWb (a + 1, d);
  3760:      }
  3761:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3762:        mmdWb (a + 1, d >> 16);
  3763:        mmdWb (a + 3, d);
  3764:      }
  3765:   },  //MMD_SCC
  3766: 
  3767:   //--------------------------------------------------------------------------------
  3768:   //MMD_PPI PPI
  3769:   //
  3770:   //  $00E9A000~$00E9A007(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3771:   //  $00E9A000~$00E9A007(奇数)  バイトリードは$xx、バイトライトは$xx
  3772:   //  $00E9A008~$00E9BFFF  $00E9A000~$00E9A007の繰り返し
  3773:   //
  3774:   MMD_PPI {
  3775:     @Override public String toString () {
  3776:       return Multilingual.mlnJapanese ? "PPI" : "PPI";  //Programmable Peripheral Interface
  3777:     }
  3778:     //リード
  3779:     @Override protected int mmdRbz (int a) throws M68kException {
  3780:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3781:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3782:          return super.mmdRbz (a);  //バスエラー
  3783:        }
  3784:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ppi;
  3785:        return PPI.ppiReadByte (a);
  3786:      }
  3787:     @Override protected int mmdRwz (int a) throws M68kException {
  3788:        return 0xff00 | mmdRbz (a + 1);
  3789:      }
  3790:     @Override protected int mmdRls (int a) throws M68kException {
  3791:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3792:      }
  3793:     //ライト
  3794:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3795:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3796:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3797:          super.mmdWb (a, d);  //バスエラー
  3798:        }
  3799:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ppi;
  3800:        PPI.ppiWriteByte (a, d);
  3801:      }
  3802:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3803:        mmdWb (a + 1, d);
  3804:      }
  3805:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3806:        mmdWb (a + 1, d >> 16);
  3807:        mmdWb (a + 3, d);
  3808:      }
  3809:   },  //MMD_PPI
  3810: 
  3811:   //--------------------------------------------------------------------------------
  3812:   //MMD_IOI I/O割り込み
  3813:   //
  3814:   //  $00E9C000~$00E9C00F(偶数)  バイトリードはバスエラー、バイトライトはバスエラー、ワードリードは$FFxx、ワードライトは$??xx
  3815:   //  $00E9C000~$00E9C00F(奇数)  バイトリードは$xx、バイトライトは$xx
  3816:   //  $00E9C010~$00E9BFFF  $00E9C000~$00E9C00Fの繰り返し
  3817:   //
  3818:   MMD_IOI {
  3819:     @Override public String toString () {
  3820:       return Multilingual.mlnJapanese ? "I/O 割り込み" : "I/O Interrupt";
  3821:     }
  3822:     //リード
  3823:     @Override protected int mmdRbz (int a) throws M68kException {
  3824:        if ((a & 1) == 0 &&  //偶数アドレスのバイトリード
  3825:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3826:          return super.mmdRbz (a);  //バスエラー
  3827:        }
  3828:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ioi;
  3829:        a &= XEiJ.BUS_MOTHER_MASK;
  3830:        if (a == IOInterrupt.IOI_STATUS) {
  3831:          return IOInterrupt.ioiReadStatus ();
  3832:        } else if (a == IOInterrupt.IOI_VECTOR) {  //ライトオンリー。リードすると$FFが返る
  3833:          //return IOInterrupt.ioiReadVector ();
  3834:          return 0xff;
  3835:        } else {
  3836:          return super.mmdRbz (a);  //バスエラー
  3837:        }
  3838:      }
  3839:     @Override protected int mmdRwz (int a) throws M68kException {
  3840:        return 0xff00 | mmdRbz (a + 1);
  3841:      }
  3842:     @Override protected int mmdRls (int a) throws M68kException {
  3843:        return 0xff00ff00 | mmdRbz (a + 1) << 16 | mmdRbz (a + 3);
  3844:      }
  3845:     //ライト
  3846:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3847:        if ((a & 1) == 0 &&  //偶数アドレスのバイトライト
  3848:            !XEiJ.currentIsSecond) {  //Xellent30の030モードではない
  3849:          super.mmdWb (a, d);  //バスエラー
  3850:        }
  3851:        XEiJ.mpuClockTime += XEiJ.busWaitTime.ioi;
  3852:        a &= XEiJ.BUS_MOTHER_MASK;
  3853:        if (a == IOInterrupt.IOI_STATUS) {
  3854:          IOInterrupt.ioiWriteEnable (d);
  3855:        } else if (a == IOInterrupt.IOI_VECTOR) {
  3856:          IOInterrupt.ioiWriteVector (d);
  3857:        } else {
  3858:          super.mmdWb (a, d);  //バスエラー
  3859:        }
  3860:      }
  3861:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3862:        mmdWb (a + 1, d);
  3863:      }
  3864:     @Override protected void mmdWl (int a, int d) throws M68kException {
  3865:        mmdWb (a + 1, d >> 16);
  3866:        mmdWb (a + 3, d);
  3867:      }
  3868:   },  //MMD_IOI
  3869: 
  3870:   //--------------------------------------------------------------------------------
  3871:   //MMD_XB1 拡張ボード領域1
  3872:   MMD_XB1 {
  3873:     @Override public String toString () {
  3874:       return Multilingual.mlnJapanese ? "拡張ボード領域 1" : "Expansion Board Area 1";
  3875:     }
  3876:     //ピーク
  3877:     @Override protected int mmdPbz (int a) {
  3878:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3879:         return XEiJ.fpuCoproboard1.cirPeekByteZero (a);
  3880:       }
  3881:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3882:         return XEiJ.fpuCoproboard2.cirPeekByteZero (a);
  3883:       }
  3884:       if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3885:         a &= XEiJ.BUS_MOTHER_MASK;
  3886:         return MainMemory.mmrM8[a] & 0xff;
  3887:       }
  3888:       if (Keyboard.KBD_ZKEY_ON &&
  3889:           (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3890:         return Keyboard.kbdZKeyIOReadByte (a);
  3891:       }
  3892:       return 0xff;
  3893:     }
  3894:     @Override protected int mmdPwz (int a) {
  3895:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3896:         return XEiJ.fpuCoproboard1.cirPeekWordZero (a);
  3897:       }
  3898:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3899:         return XEiJ.fpuCoproboard2.cirPeekWordZero (a);
  3900:       }
  3901:       if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3902:         a &= XEiJ.BUS_MOTHER_MASK;
  3903:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  3904:       }
  3905:       if (Keyboard.KBD_ZKEY_ON &&
  3906:           (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3907:         return Keyboard.kbdZKeyIOReadWord (a);
  3908:       }
  3909:       return 0xffff;
  3910:     }
  3911:     @Override protected int mmdPls (int a) {
  3912:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3913:         return XEiJ.fpuCoproboard1.cirPeekLong (a);
  3914:       }
  3915:       if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3916:         return XEiJ.fpuCoproboard2.cirPeekLong (a);
  3917:       }
  3918:       if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3919:         a &= XEiJ.BUS_MOTHER_MASK;
  3920:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  3921:       }
  3922:       if (Keyboard.KBD_ZKEY_ON &&
  3923:           (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3924:         return Keyboard.kbdZKeyIOReadLong (a);
  3925:       }
  3926:       return -1;
  3927:     }
  3928:     //リード
  3929:     @Override protected int mmdRbz (int a) throws M68kException {
  3930:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3931:          return XEiJ.fpuCoproboard1.cirReadByteZero (a);
  3932:        }
  3933:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3934:          return XEiJ.fpuCoproboard2.cirReadByteZero (a);
  3935:        }
  3936:        if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3937:          a &= XEiJ.BUS_MOTHER_MASK;
  3938:          return MainMemory.mmrM8[a] & 0xff;
  3939:        }
  3940:        if (Keyboard.KBD_ZKEY_ON &&
  3941:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3942:          return Keyboard.kbdZKeyIOReadByte (a);
  3943:        }
  3944:        return super.mmdRbz (a);  //バスエラー
  3945:      }
  3946:     @Override protected int mmdRwz (int a) throws M68kException {
  3947:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3948:          return XEiJ.fpuCoproboard1.cirReadWordZero (a);
  3949:        }
  3950:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3951:          return XEiJ.fpuCoproboard2.cirReadWordZero (a);
  3952:        }
  3953:        if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3954:          a &= XEiJ.BUS_MOTHER_MASK;
  3955:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  3956:        }
  3957:        if (Keyboard.KBD_ZKEY_ON &&
  3958:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3959:          return Keyboard.kbdZKeyIOReadWord (a);
  3960:        }
  3961:        return super.mmdRwz (a);  //バスエラー
  3962:      }
  3963:     @Override protected int mmdRls (int a) throws M68kException {
  3964:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3965:          return XEiJ.fpuCoproboard1.cirReadLong (a);
  3966:        }
  3967:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3968:          return XEiJ.fpuCoproboard2.cirReadLong (a);
  3969:        }
  3970:        if ((a & (XEiJ.BUS_MOTHER_MASK & -HFS.HFS_ROM_SIZE)) == HFS.HFS_ADDRESS) {  //ホストファイルシステムインタフェイス
  3971:          a &= XEiJ.BUS_MOTHER_MASK;
  3972:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  3973:        }
  3974:        if (Keyboard.KBD_ZKEY_ON &&
  3975:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3976:          return Keyboard.kbdZKeyIOReadLong (a);
  3977:        }
  3978:        return super.mmdRls (a);  //バスエラー
  3979:      }
  3980:     //ライト
  3981:     @Override protected void mmdWb (int a, int d) throws M68kException {
  3982:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3983:          XEiJ.fpuCoproboard1.cirWriteByte (a, d);
  3984:          return;
  3985:        }
  3986:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  3987:          XEiJ.fpuCoproboard2.cirWriteByte (a, d);
  3988:          return;
  3989:        }
  3990:        if (Keyboard.KBD_ZKEY_ON &&
  3991:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  3992:          Keyboard.kbdZKeyIOWriteByte (a, d);
  3993:          return;
  3994:        }
  3995:        super.mmdWb (a, d);  //バスエラー
  3996:      }
  3997:     @Override protected void mmdWw (int a, int d) throws M68kException {
  3998:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  3999:          XEiJ.fpuCoproboard1.cirWriteWord (a, d);
  4000:          return;
  4001:        }
  4002:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  4003:          XEiJ.fpuCoproboard2.cirWriteWord (a, d);
  4004:          return;
  4005:        }
  4006:        if (Keyboard.KBD_ZKEY_ON &&
  4007:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  4008:          Keyboard.kbdZKeyIOWriteWord (a, d);
  4009:          return;
  4010:        }
  4011:        super.mmdWw (a, d);  //バスエラー
  4012:      }
  4013:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4014:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e000) {  //数値演算プロセッサボード1
  4015:          XEiJ.fpuCoproboard1.cirWriteLong (a, d);
  4016:          return;
  4017:        }
  4018:        if ((a & (XEiJ.BUS_MOTHER_MASK & -0x20)) == 0x00e9e080) {  //数値演算プロセッサボード2
  4019:          XEiJ.fpuCoproboard2.cirWriteLong (a, d);
  4020:          return;
  4021:        }
  4022:        if (Keyboard.KBD_ZKEY_ON &&
  4023:            (a & (XEiJ.BUS_MOTHER_MASK & -Keyboard.KBD_ZKEY_IO_SIZE)) == Keyboard.KBD_ZKEY_IO_ADDRESS) {  //Zキーボード
  4024:          Keyboard.kbdZKeyIOWriteLong (a, d);
  4025:          return;
  4026:        }
  4027:        super.mmdWl (a, d);  //バスエラー
  4028:      }
  4029:   },  //MMD_XB1
  4030: 
  4031:   //--------------------------------------------------------------------------------
  4032:   //MMD_EXS 拡張SCSI
  4033:   //  必要なときだけ接続される
  4034:   //  拡張SCSIのROMのサイズは8KBなのでリードのときのバスエラーのチェックは不要
  4035:   //  ライトのときはROMには書き込めないのでSPCのレジスタでなければバスエラー
  4036:   MMD_EXS {
  4037:     @Override public String toString () {
  4038:       return Multilingual.mlnJapanese ? "拡張 SCSI ポート" : "Expansion SCSI Port";
  4039:     }
  4040:     //ピーク
  4041:     @Override protected byte mmdPbs (int a) {
  4042:       a &= XEiJ.BUS_MOTHER_MASK;
  4043:        return (a & -32) == SPC.SPC_BASE_EX ? (byte) SPC.spcSCSIEXChip.spiPeek (a) : MainMemory.mmrM8[a];
  4044:      }
  4045:     @Override protected int mmdPbz (int a) {
  4046:       a &= XEiJ.BUS_MOTHER_MASK;
  4047:        return (a & -32) == SPC.SPC_BASE_EX ? SPC.spcSCSIEXChip.spiPeek (a) : MainMemory.mmrM8[a] & 0xff;
  4048:      }
  4049:     @Override protected int mmdPws (int a) {
  4050:       a &= XEiJ.BUS_MOTHER_MASK;
  4051:        return mmdPbs (a) << 8 | mmdPbz (a + 1);
  4052:      }
  4053:     @Override protected int mmdPwz (int a) {
  4054:       a &= XEiJ.BUS_MOTHER_MASK;
  4055:        return mmdPbz (a) << 8 | mmdPbz (a + 1);
  4056:      }
  4057:     @Override protected int mmdPls (int a) {
  4058:       a &= XEiJ.BUS_MOTHER_MASK;
  4059:        return mmdPbs (a) << 24 | mmdPbz (a + 1) << 16 | mmdPbz (a + 2) << 8 | mmdPbz (a + 3);
  4060:      }
  4061:     //リード
  4062:     @Override protected byte mmdRbs (int a) throws M68kException {
  4063:        a &= XEiJ.BUS_MOTHER_MASK;
  4064:        return (a & -32) == SPC.SPC_BASE_EX ? (byte) SPC.spcSCSIEXChip.spiRead (a) : MainMemory.mmrM8[a];
  4065:      }
  4066:     @Override protected int mmdRbz (int a) throws M68kException {
  4067:        a &= XEiJ.BUS_MOTHER_MASK;
  4068:        return (a & -32) == SPC.SPC_BASE_EX ? SPC.spcSCSIEXChip.spiRead (a) : MainMemory.mmrM8[a] & 0xff;
  4069:      }
  4070:     @Override protected int mmdRws (int a) throws M68kException {
  4071:        a &= XEiJ.BUS_MOTHER_MASK;
  4072:        return mmdRbs (a) << 8 | mmdRbz (a + 1);
  4073:      }
  4074:     @Override protected int mmdRwz (int a) throws M68kException {
  4075:        a &= XEiJ.BUS_MOTHER_MASK;
  4076:        return mmdRbz (a) << 8 | mmdRbz (a + 1);
  4077:      }
  4078:     @Override protected int mmdRls (int a) throws M68kException {
  4079:        a &= XEiJ.BUS_MOTHER_MASK;
  4080:        return mmdRbs (a) << 24 | mmdRbz (a + 1) << 16 | mmdRbz (a + 2) << 8 | mmdRbz (a + 3);
  4081:      }
  4082:     //ライト
  4083:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4084:        a &= XEiJ.BUS_MOTHER_MASK;
  4085:        if ((a & -32) == SPC.SPC_BASE_EX) {
  4086:          SPC.spcSCSIEXChip.spiWrite (a, d);
  4087:          return;
  4088:        }
  4089:        super.mmdWb (a, d);  //バスエラー
  4090:      }
  4091:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4092:        a &= XEiJ.BUS_MOTHER_MASK;
  4093:        mmdWb (a    , d >> 8);
  4094:        mmdWb (a + 1, d     );
  4095:      }
  4096:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4097:        a &= XEiJ.BUS_MOTHER_MASK;
  4098:        mmdWw (a    , d >> 16);
  4099:        mmdWw (a + 2, d      );
  4100:      }
  4101:   },  //MMD_EXS
  4102: 
  4103:   //--------------------------------------------------------------------------------
  4104:   //MMD_XB2 拡張ボード領域2
  4105:   //
  4106:   //  $00EAFF80  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00200000~$003FFFFFがあるとき$??xx、ないときバスエラー
  4107:   //  $00EAFF81  リードはバスエラー、ライトは$00200000~$003FFFFFがあるとき$xx、ないときバスエラー
  4108:   //  $00EAFF82  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00400000~$005FFFFFがあるとき$??xx、ないときバスエラー
  4109:   //  $00EAFF83  リードはバスエラー、ライトは$00400000~$005FFFFFがあるとき$xx、ないときバスエラー
  4110:   //  $00EAFF84  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00600000~$007FFFFFがあるとき$??xx、ないときバスエラー
  4111:   //  $00EAFF85  リードはバスエラー、ライトは$00600000~$007FFFFFがあるとき$xx、ないときバスエラー
  4112:   //  $00EAFF86  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00800000~$009FFFFFがあるとき$??xx、ないときバスエラー
  4113:   //  $00EAFF87  リードはバスエラー、ライトは$00800000~$009FFFFFがあるとき$xx、ないときバスエラー
  4114:   //  $00EAFF88  リードはバスエラー、バイトライトはバスエラー、ワードライトは$00A00000~$00BFFFFFがあるとき$??xx、ないときバスエラー
  4115:   //  $00EAFF89  リードはバスエラー、ライトは$00A00000~$00BFFFFFがあるとき$xx、ないときバスエラー
  4116:   //  $00EAFF8A~$00EAFF8F  バスエラー
  4117:   //  $00EAFF90~$00EAFFFF  $00EAFF80~$00EAFF8Fの繰り返し
  4118:   //
  4119:   //  拡張
  4120:   //  $00EAFF7F  バンクメモリのページ番号
  4121:   //
  4122:   MMD_XB2 {
  4123:     @Override public String toString () {
  4124:       return Multilingual.mlnJapanese ? "拡張ボード領域 2" : "Expansion Board Area 2";
  4125:     }
  4126:     //リード
  4127:     @Override protected int mmdRbz (int a) throws M68kException {
  4128:        a &= XEiJ.BUS_MOTHER_MASK;
  4129:        if (0x00eaff81 <= a && a <= 0x00eaff89 && (a & 1) != 0) {  //スーパーバイザエリア設定ポート
  4130:          return MainMemory.mmrM8[a] & 0xff;  //読み出せるようにしておく(本来はライトオンリー)
  4131:        }
  4132:        if (XEiJ.bnkOn && a == 0x00eaff7f) {  //バンクメモリのページ番号
  4133:          return XEiJ.bnkPageStart >> 17;
  4134:        }
  4135:        return super.mmdRbz (a);  //バスエラー
  4136:      }
  4137:     //ライト
  4138:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4139:        a &= XEiJ.BUS_MOTHER_MASK;
  4140:        if (0x00eaff81 <= a && a <= 0x00eaff89 && (a & 1) != 0) {  //スーパーバイザエリア設定ポート
  4141:          MainMemory.mmrM8[a] = (byte) d;  //読み出せるようにしておく(本来はライトオンリー)
  4142:          a = (a & 14) + 2 << 20;  //1,3,5,7,9→2,4,6,8,a
  4143:          for (int m = 1; m <= 128; m <<= 1) {
  4144:            if ((d & m) == 0) {  //ユーザエリア
  4145:              XEiJ.busUser ( MemoryMappedDevice.MMD_MMR, a, a + 0x00040000);
  4146:            } else {  //スーパーバイザエリア
  4147:              XEiJ.busSuper (MemoryMappedDevice.MMD_MMR, a, a + 0x00040000);
  4148:            }
  4149:            a += 0x00040000;
  4150:          }
  4151:          return;
  4152:        }
  4153:        if (XEiJ.bnkOn && a == 0x00eaff7f) {  //バンクメモリのページ番号
  4154:          XEiJ.bnkPageStart = (d & 0xff) << 17;
  4155:          return;
  4156:        }
  4157:        super.mmdWb (a, d);  //バスエラー
  4158:      }
  4159:   },  //MMD_XB2
  4160: 
  4161:   //--------------------------------------------------------------------------------
  4162:   //MMD_SPR スプライト画面
  4163:   //
  4164:   //  CRTCのR20の下位5ビットが%1??1?でないとき
  4165:   //    $00EB0000-$00EB03FF  スプライトスクロールレジスタ(0~127)
  4166:   //    $00EB0400-$00EB07FF  $FF。256枚表示のときスプライトスクロールレジスタ(128~255)
  4167:   //    $00EB0800-$00EB0811  設定
  4168:   //    $00EB0812-$00EB7FFF  $FF
  4169:   //    $00EB8000-$00EBFFFF  スプライトPCG・テキストエリア
  4170:   //
  4171:   //  CRTCのR20の下位5ビットが%1??1?のとき
  4172:   //    $00EB0000-$00EB03FF  バスエラー
  4173:   //    $00EB0400-$00EB07FF  バスエラー
  4174:   //    $00EB0800-$00EB0811  設定
  4175:   //    $00EB0812-$00EB7FFF  $FF
  4176:   //    $00EB8000-$00EBFFFF  バスエラー
  4177:   //
  4178:   //  メモ
  4179:   //    スプライトPCG・テキストエリアにバイトサイズで書き込むとデータが破壊される
  4180:   //
  4181:   MMD_SPR {
  4182:     @Override public String toString () {
  4183:       return Multilingual.mlnJapanese ? "スプライト画面" : "Sprite Screen";
  4184:     }
  4185:     //リード
  4186:     @Override protected byte mmdRbs (int a) throws M68kException {
  4187:        a &= XEiJ.BUS_MOTHER_MASK;
  4188:        return (a & 1) == 0 ? (byte) (mmdRwz (a) >> 8) : (byte) mmdRwz (a - 1);
  4189:      }
  4190:     @Override protected int mmdRbz (int a) throws M68kException {
  4191:        a &= XEiJ.BUS_MOTHER_MASK;
  4192:        return (a & 1) == 0 ? mmdRwz (a) >> 8 : mmdRwz (a - 1) & 0xff;
  4193:      }
  4194:     @Override protected int mmdRws (int a) throws M68kException {
  4195:        a &= XEiJ.BUS_MOTHER_MASK;
  4196:        return (short) mmdRwz (a);
  4197:      }
  4198:     @Override protected int mmdRwz (int a) throws M68kException {
  4199:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sprc;
  4200:        a &= XEiJ.BUS_MOTHER_MASK;
  4201:        if (a < 0x00eb0800) {  //スプライトスクロールレジスタ
  4202:          if (!SpriteScreen.sprAccessible) {
  4203:            return super.mmdRwz (a);  //バスエラー
  4204:          }
  4205:          int n = (a >> 3) & 0xff;  //スプライト番号
  4206:          if (SpriteScreen.sprNumberOfSprites <= n) {
  4207:            return 0xffff;
  4208:          }
  4209:          switch (a & 0x06) {
  4210:          case 0:  //x座標
  4211:            return SpriteScreen.sprX[n];
  4212:          case 2:  //y座標
  4213:            return SpriteScreen.sprY[n];
  4214:          case 4:  //パターン番号、パレットブロック、水平反転、垂直反転
  4215:            return (SpriteScreen.sprV[n] ? 0x8000 : 0) | (SpriteScreen.sprH[n] ? 0x4000 : 0) | SpriteScreen.sprColPort[n] << 4 | SpriteScreen.sprNum[n];
  4216:          case 6:  //プライオリティ
  4217:            return SpriteScreen.sprPrw[n];
  4218:          }
  4219:        } else if (a < 0x00eb8000) {  //各種レジスタ
  4220:          switch (a) {
  4221:          case SpriteScreen.SPR_REG0_BG0_X:
  4222:            return SpriteScreen.sprReg0Bg0XPort;
  4223:          case SpriteScreen.SPR_REG1_BG0_Y:
  4224:            return SpriteScreen.sprReg1Bg0YPort;
  4225:          case SpriteScreen.SPR_REG2_BG1_X:
  4226:            return SpriteScreen.sprReg2Bg1XPort;
  4227:          case SpriteScreen.SPR_REG3_BG1_Y:
  4228:            return SpriteScreen.sprReg3Bg1YPort;
  4229:          case SpriteScreen.SPR_REG4_BG_CTRL:
  4230:            return SpriteScreen.sprReg4BgCtrlPort;
  4231:          case SpriteScreen.SPR_REG5_H_FRONT_END:
  4232:            return SpriteScreen.sprReg5HFrontEndPort;
  4233:          case SpriteScreen.SPR_REG6_H_BACK_END:
  4234:            return SpriteScreen.sprReg6HBackEndPort;
  4235:          case SpriteScreen.SPR_REG7_V_BACK_END:
  4236:            return SpriteScreen.sprReg7VBackEndPort;
  4237:          case SpriteScreen.SPR_REG8_RESO:
  4238:            return SpriteScreen.sprReg8ResoPort;
  4239:          }
  4240:          return 0xffff;
  4241:        } else {  //PCGエリアとテキストエリア
  4242:          if (!SpriteScreen.sprAccessible) {
  4243:            return super.mmdRwz (a);  //バスエラー
  4244:          }
  4245:          int t = a >> 2 & 0x1fff;
  4246:          return (a & 0x02) == 0 ? SpriteScreen.sprPatPort[t] >>> 16 : (char) SpriteScreen.sprPatPort[t];
  4247:        }
  4248:        return 0;
  4249:      }
  4250:     @Override protected int mmdRls (int a) throws M68kException {
  4251:        a &= XEiJ.BUS_MOTHER_MASK;
  4252:        return mmdRwz (a) << 16 | mmdRwz (a + 2);
  4253:      }
  4254:     //ライト
  4255:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4256:        a &= XEiJ.BUS_MOTHER_MASK;
  4257:        if (a < 0x00eb0800 || 0x00eb8000 <= a) {
  4258:          mmdWw (a & ~1, d << 8 | (d & 0xff));  //上位バイトと下位バイトに同じ値を書き込む
  4259:        } else {
  4260:          if ((a & 1) == 0) {
  4261:            mmdWw (a, d << 8 | (mmdRwz (a) & 0xff));
  4262:          } else {
  4263:            mmdWw (a - 1, (mmdRwz (a - 1) & ~0xff) | (d & 0xff));
  4264:          }
  4265:        }
  4266:      }
  4267:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4268:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sprc;
  4269:        a &= XEiJ.BUS_MOTHER_MASK;
  4270:        if (a < 0x00eb0800) {  //スプライトスクロールレジスタ
  4271:          if (!SpriteScreen.sprAccessible) {
  4272:            super.mmdWw (a, d);  //バスエラー
  4273:          }
  4274:          int n = (a >> 3) & 0xff;  //スプライト番号
  4275:          if (SpriteScreen.sprNumberOfSprites <= n) {
  4276:            return;
  4277:          }
  4278:          switch (a & 0x06) {
  4279:          case 0:  //x座標
  4280:            SpriteScreen.sprX[n] = (short) (d & 1023);
  4281:            break;
  4282:          case 2:  //y座標
  4283:            d &= 1023;
  4284:            if (SpriteScreen.sprY[n] != d) {
  4285:              int y = SpriteScreen.sprY[n];
  4286:              SpriteScreen.sprY[n] = (short) d;
  4287:              if (SpriteScreen.sprPrw[n] != 0) {
  4288:                int mask = ~(0x80000000 >>> n);  //intのシフトカウントは5bitでマスクされる
  4289:                int i = y << 3 | n >> 5;  //移動元
  4290:                SpriteScreen.sprRRmap[i            ] &= mask;
  4291:                SpriteScreen.sprRRmap[i + ( 1 << 3)] &= mask;
  4292:                SpriteScreen.sprRRmap[i + ( 2 << 3)] &= mask;
  4293:                SpriteScreen.sprRRmap[i + ( 3 << 3)] &= mask;
  4294:                SpriteScreen.sprRRmap[i + ( 4 << 3)] &= mask;
  4295:                SpriteScreen.sprRRmap[i + ( 5 << 3)] &= mask;
  4296:                SpriteScreen.sprRRmap[i + ( 6 << 3)] &= mask;
  4297:                SpriteScreen.sprRRmap[i + ( 7 << 3)] &= mask;
  4298:                SpriteScreen.sprRRmap[i + ( 8 << 3)] &= mask;
  4299:                SpriteScreen.sprRRmap[i + ( 9 << 3)] &= mask;
  4300:                SpriteScreen.sprRRmap[i + (10 << 3)] &= mask;
  4301:                SpriteScreen.sprRRmap[i + (11 << 3)] &= mask;
  4302:                SpriteScreen.sprRRmap[i + (12 << 3)] &= mask;
  4303:                SpriteScreen.sprRRmap[i + (13 << 3)] &= mask;
  4304:                SpriteScreen.sprRRmap[i + (14 << 3)] &= mask;
  4305:                SpriteScreen.sprRRmap[i + (15 << 3)] &= mask;
  4306:                mask = ~mask;
  4307:                i = d << 3 | n >> 5;  //移動先
  4308:                SpriteScreen.sprRRmap[i            ] |= mask;
  4309:                SpriteScreen.sprRRmap[i + ( 1 << 3)] |= mask;
  4310:                SpriteScreen.sprRRmap[i + ( 2 << 3)] |= mask;
  4311:                SpriteScreen.sprRRmap[i + ( 3 << 3)] |= mask;
  4312:                SpriteScreen.sprRRmap[i + ( 4 << 3)] |= mask;
  4313:                SpriteScreen.sprRRmap[i + ( 5 << 3)] |= mask;
  4314:                SpriteScreen.sprRRmap[i + ( 6 << 3)] |= mask;
  4315:                SpriteScreen.sprRRmap[i + ( 7 << 3)] |= mask;
  4316:                SpriteScreen.sprRRmap[i + ( 8 << 3)] |= mask;
  4317:                SpriteScreen.sprRRmap[i + ( 9 << 3)] |= mask;
  4318:                SpriteScreen.sprRRmap[i + (10 << 3)] |= mask;
  4319:                SpriteScreen.sprRRmap[i + (11 << 3)] |= mask;
  4320:                SpriteScreen.sprRRmap[i + (12 << 3)] |= mask;
  4321:                SpriteScreen.sprRRmap[i + (13 << 3)] |= mask;
  4322:                SpriteScreen.sprRRmap[i + (14 << 3)] |= mask;
  4323:                SpriteScreen.sprRRmap[i + (15 << 3)] |= mask;
  4324:              }
  4325:            }
  4326:            break;
  4327:          case 4:  //パターン番号、パレットブロック、水平反転、垂直反転
  4328:            {
  4329:              int num = SpriteScreen.sprNum[n];  //元のパターン番号
  4330:              SpriteScreen.sprNum[n] = (short) (d & 0xff);
  4331:              SpriteScreen.sprColPort[n] = (short) (d >> 4 & 0x0f << 4);
  4332:              SpriteScreen.sprH[n] = (short) (d << 1) < 0;
  4333:              SpriteScreen.sprV[n] = (short) d < 0;
  4334:              if (SpriteScreen.sprPrw[n] != 0) {
  4335:                int mask = 0x80000000 >>> n;  //intのシフトカウントは5bitでマスクされる
  4336:                SpriteScreen.sprPPmap[num << 3 | n >> 5] &= ~mask;  //消滅
  4337:                SpriteScreen.sprPPmap[(d & 0xff) << 3 | n >> 5] |= mask;  //出現
  4338:              }
  4339:            }
  4340:            break;
  4341:          case 6:  //プライオリティ
  4342:            d &= 0x0003;
  4343:            int prw = SpriteScreen.sprPrw[n];
  4344:            SpriteScreen.sprPrw[n] = (byte) d;
  4345:            if (prw != d) {
  4346:              if (prw == 0) {  //出現
  4347:                int y = SpriteScreen.sprY[n];
  4348:                int mask = 0x80000000 >>> n;  //intのシフトカウントは5bitでマスクされる
  4349:                int i = y << 3 | n >> 5;
  4350:                SpriteScreen.sprRRmap[i            ] |= mask;
  4351:                SpriteScreen.sprRRmap[i + ( 1 << 3)] |= mask;
  4352:                SpriteScreen.sprRRmap[i + ( 2 << 3)] |= mask;
  4353:                SpriteScreen.sprRRmap[i + ( 3 << 3)] |= mask;
  4354:                SpriteScreen.sprRRmap[i + ( 4 << 3)] |= mask;
  4355:                SpriteScreen.sprRRmap[i + ( 5 << 3)] |= mask;
  4356:                SpriteScreen.sprRRmap[i + ( 6 << 3)] |= mask;
  4357:                SpriteScreen.sprRRmap[i + ( 7 << 3)] |= mask;
  4358:                SpriteScreen.sprRRmap[i + ( 8 << 3)] |= mask;
  4359:                SpriteScreen.sprRRmap[i + ( 9 << 3)] |= mask;
  4360:                SpriteScreen.sprRRmap[i + (10 << 3)] |= mask;
  4361:                SpriteScreen.sprRRmap[i + (11 << 3)] |= mask;
  4362:                SpriteScreen.sprRRmap[i + (12 << 3)] |= mask;
  4363:                SpriteScreen.sprRRmap[i + (13 << 3)] |= mask;
  4364:                SpriteScreen.sprRRmap[i + (14 << 3)] |= mask;
  4365:                SpriteScreen.sprRRmap[i + (15 << 3)] |= mask;
  4366:                SpriteScreen.sprPPmap[SpriteScreen.sprNum[n] << 3 | n >> 5] |= mask;
  4367:              } else if (d == 0) {  //消滅
  4368:                int y = SpriteScreen.sprY[n];
  4369:                int mask = ~(0x80000000 >>> n);  //intのシフトカウントは5bitでマスクされる
  4370:                int i = y << 3 | n >> 5;
  4371:                SpriteScreen.sprRRmap[i            ] &= mask;
  4372:                SpriteScreen.sprRRmap[i + ( 1 << 3)] &= mask;
  4373:                SpriteScreen.sprRRmap[i + ( 2 << 3)] &= mask;
  4374:                SpriteScreen.sprRRmap[i + ( 3 << 3)] &= mask;
  4375:                SpriteScreen.sprRRmap[i + ( 4 << 3)] &= mask;
  4376:                SpriteScreen.sprRRmap[i + ( 5 << 3)] &= mask;
  4377:                SpriteScreen.sprRRmap[i + ( 6 << 3)] &= mask;
  4378:                SpriteScreen.sprRRmap[i + ( 7 << 3)] &= mask;
  4379:                SpriteScreen.sprRRmap[i + ( 8 << 3)] &= mask;
  4380:                SpriteScreen.sprRRmap[i + ( 9 << 3)] &= mask;
  4381:                SpriteScreen.sprRRmap[i + (10 << 3)] &= mask;
  4382:                SpriteScreen.sprRRmap[i + (11 << 3)] &= mask;
  4383:                SpriteScreen.sprRRmap[i + (12 << 3)] &= mask;
  4384:                SpriteScreen.sprRRmap[i + (13 << 3)] &= mask;
  4385:                SpriteScreen.sprRRmap[i + (14 << 3)] &= mask;
  4386:                SpriteScreen.sprRRmap[i + (15 << 3)] &= mask;
  4387:                SpriteScreen.sprPPmap[SpriteScreen.sprNum[n] << 3 | n >> 5] &= mask;
  4388:              }
  4389:            }
  4390:            break;
  4391:          }  //スプライトスクロールレジスタのswitch
  4392:          return;
  4393:        } else if (a < 0x00eb8000) {  //各種レジスタ
  4394:          switch (a) {
  4395:          case SpriteScreen.SPR_REG0_BG0_X:
  4396:            SpriteScreen.sprReg0Bg0XPort = d & 1023;
  4397:            {
  4398:              int curr = SpriteScreen.sprReg0Bg0XMask == 0 ? SpriteScreen.sprReg0Bg0XPort : SpriteScreen.sprReg0Bg0XTest;
  4399:              if (SpriteScreen.sprReg0Bg0XCurr != curr) {
  4400:                SpriteScreen.sprReg0Bg0XCurr = curr;
  4401:              }
  4402:            }
  4403:            return;
  4404:          case SpriteScreen.SPR_REG1_BG0_Y:
  4405:            SpriteScreen.sprReg1Bg0YPort = d & 1023;
  4406:            {
  4407:              int curr = SpriteScreen.sprReg1Bg0YMask == 0 ? SpriteScreen.sprReg1Bg0YPort : SpriteScreen.sprReg1Bg0YTest;
  4408:              if (SpriteScreen.sprReg1Bg0YCurr != curr) {
  4409:                SpriteScreen.sprReg1Bg0YCurr = curr;
  4410:              }
  4411:            }
  4412:            return;
  4413:          case SpriteScreen.SPR_REG2_BG1_X:
  4414:            SpriteScreen.sprReg2Bg1XPort = d & 1023;
  4415:            {
  4416:              int curr = SpriteScreen.sprReg2Bg1XMask == 0 ? SpriteScreen.sprReg2Bg1XPort : SpriteScreen.sprReg2Bg1XTest;
  4417:              if (SpriteScreen.sprReg2Bg1XCurr != curr) {
  4418:                SpriteScreen.sprReg2Bg1XCurr = curr;
  4419:              }
  4420:            }
  4421:            return;
  4422:          case SpriteScreen.SPR_REG3_BG1_Y:
  4423:            SpriteScreen.sprReg3Bg1YPort = d & 1023;
  4424:            {
  4425:              int curr = SpriteScreen.sprReg3Bg1YMask == 0 ? SpriteScreen.sprReg3Bg1YPort : SpriteScreen.sprReg3Bg1YTest;
  4426:              if (SpriteScreen.sprReg3Bg1YCurr != curr) {
  4427:                SpriteScreen.sprReg3Bg1YCurr = curr;
  4428:              }
  4429:            }
  4430:            return;
  4431:          case SpriteScreen.SPR_REG4_BG_CTRL:
  4432:            SpriteScreen.sprReg4BgCtrlPort = d & 2047;
  4433:            {
  4434:              int curr = SpriteScreen.sprReg4BgCtrlPort & ~SpriteScreen.sprReg4BgCtrlMask | SpriteScreen.sprReg4BgCtrlTest & SpriteScreen.sprReg4BgCtrlMask;
  4435:              if (SpriteScreen.sprReg4BgCtrlCurr != curr) {
  4436:                SpriteScreen.sprReg4BgCtrlCurr = curr;
  4437:              }
  4438:            }
  4439:            return;
  4440:          case SpriteScreen.SPR_REG5_H_FRONT_END:
  4441:            SpriteScreen.sprReg5HFrontEndPort = d & 0xff;
  4442:            {
  4443:              int curr = SpriteScreen.sprReg5HFrontEndMask == 0 ? SpriteScreen.sprReg5HFrontEndPort : SpriteScreen.sprReg5HFrontEndTest;
  4444:              if (SpriteScreen.sprReg5HFrontEndCurr != curr) {
  4445:                SpriteScreen.sprReg5HFrontEndCurr = curr;
  4446:              }
  4447:            }
  4448:            return;
  4449:          case SpriteScreen.SPR_REG6_H_BACK_END:
  4450:            SpriteScreen.sprReg6HBackEndPort = d & 63;
  4451:            {
  4452:              int curr = SpriteScreen.sprReg6HBackEndMask == 0 ? SpriteScreen.sprReg6HBackEndPort : SpriteScreen.sprReg6HBackEndTest;
  4453:              if (SpriteScreen.sprReg6HBackEndCurr != curr) {
  4454:                SpriteScreen.sprReg6HBackEndCurr = curr;
  4455:              }
  4456:            }
  4457:            return;
  4458:          case SpriteScreen.SPR_REG7_V_BACK_END:
  4459:            SpriteScreen.sprReg7VBackEndPort = d & 0xff;
  4460:            {
  4461:              int curr = SpriteScreen.sprReg7VBackEndMask == 0 ? SpriteScreen.sprReg7VBackEndPort : SpriteScreen.sprReg7VBackEndTest;
  4462:              if (SpriteScreen.sprReg7VBackEndCurr != curr) {
  4463:                SpriteScreen.sprReg7VBackEndCurr = curr;
  4464:              }
  4465:            }
  4466:            return;
  4467:          case SpriteScreen.SPR_REG8_RESO:
  4468:            SpriteScreen.sprReg8ResoPort = d & 31;
  4469:            {
  4470:              int curr = SpriteScreen.sprReg8ResoPort & ~SpriteScreen.sprReg8ResoMask | SpriteScreen.sprReg8ResoTest & SpriteScreen.sprReg8ResoMask;
  4471:              if (SpriteScreen.sprReg8ResoCurr != curr) {
  4472:                SpriteScreen.sprReg8ResoCurr = curr;
  4473:                CRTC.crtRestart ();
  4474:              }
  4475:            }
  4476:            return;
  4477:          }
  4478:          return;
  4479:        } else {  //PCGエリアとテキストエリア
  4480:          if (!SpriteScreen.sprAccessible) {
  4481:            super.mmdWw (a, d);  //バスエラー
  4482:          }
  4483:          if (0x00ebe000 <= a) {  //テキストエリア1
  4484:            int n = a >> 1 & 0x0fff;
  4485:            SpriteScreen.sprT1Num[n] = (short) ((d & 0xff) << 3);
  4486:            SpriteScreen.sprT1ColPort[n] = (short) ((d & 0x0f00) >> 4);
  4487:            SpriteScreen.sprT1H[n] = (short) (d << 1) < 0;
  4488:            SpriteScreen.sprT1V[n] = (short) d < 0;
  4489:          } else if (0x00ebc000 <= a) {  //テキストエリア0
  4490:            int n = a >> 1 & 0x0fff;
  4491:            SpriteScreen.sprT0Num[n] = (short) ((d & 0xff) << 3);
  4492:            SpriteScreen.sprT0ColPort[n] = (short) ((d & 0x0f00) >> 4);
  4493:            SpriteScreen.sprT0H[n] = (short) (d << 1) < 0;
  4494:            SpriteScreen.sprT0V[n] = (short) d < 0;
  4495:          }
  4496:          int t = a >> 2 & 0x1fff;
  4497:          SpriteScreen.sprPatPort[t] = (a & 0x02) == 0 ? d << 16 | (char) SpriteScreen.sprPatPort[t] : (SpriteScreen.sprPatPort[t] & ~0xffff) | (char) d;
  4498:        }  //PCGエリアとテキストエリア
  4499:      }  //mmdWw
  4500:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4501:        a &= XEiJ.BUS_MOTHER_MASK;
  4502:        mmdWw (a    , d >> 16);
  4503:        mmdWw (a + 2, d      );
  4504:      }
  4505:   },  //MMD_SPR
  4506: 
  4507:   //--------------------------------------------------------------------------------
  4508:   //MMD_XB3 拡張ボード領域3
  4509:   //  $00EC0000~$00ECFFFF  64KB
  4510:   //  0x00ec0000  ユーザI/Oエリア
  4511:   //  0x00ec0000  Awesome
  4512:   //  0x00ec0000  Xellent30
  4513:   //  0x00ecc000  Mercury
  4514:   //  0x00ece000  Neptune
  4515:   //  0x00ecf000  Venus-X/030
  4516:   MMD_XB3 {
  4517:     @Override public String toString () {
  4518:       return Multilingual.mlnJapanese ? "拡張ボード領域 3" : "Expansion Board Area 3";
  4519:     }
  4520:     //リード
  4521:     @Override protected int mmdRbz (int a) throws M68kException {
  4522:        a &= XEiJ.BUS_MOTHER_MASK;
  4523:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4524:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4525:          return (a & 1) == 0 ? 0 : XEiJ.xt3PortRead ();
  4526:        }
  4527:        return super.mmdRbz (a);  //バスエラー
  4528:      }
  4529:     @Override protected int mmdRwz (int a) throws M68kException {
  4530:        a &= XEiJ.BUS_MOTHER_MASK;
  4531:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4532:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4533:          return XEiJ.xt3PortRead ();
  4534:        }
  4535:        return super.mmdRwz (a);  //バスエラー
  4536:      }
  4537:     @Override protected int mmdRls (int a) throws M68kException {
  4538:        a &= XEiJ.BUS_MOTHER_MASK;
  4539:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4540:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4541:          return XEiJ.xt3PortRead () << 16 | XEiJ.xt3PortRead ();
  4542:        }
  4543:        return super.mmdRls (a);  //バスエラー
  4544:      }
  4545:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4546:        a &= XEiJ.BUS_MOTHER_MASK;
  4547:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4548:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4549:          if ((a & 1) == 0) {
  4550:          } else {
  4551:            XEiJ.xt3PortWrite (d);
  4552:          }
  4553:          return;
  4554:        }
  4555:        super.mmdWb (a, d);  //バスエラー
  4556:      }
  4557:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4558:        a &= XEiJ.BUS_MOTHER_MASK;
  4559:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4560:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4561:          XEiJ.xt3PortWrite (d);
  4562:          return;
  4563:        }
  4564:        super.mmdWw (a, d);  //バスエラー
  4565:      }
  4566:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4567:        a &= XEiJ.BUS_MOTHER_MASK;
  4568:        if (XEiJ.currentAccelerator == XEiJ.ACCELERATOR_XELLENT30 &&
  4569:            XEiJ.xt3PortAddress <= a && a < XEiJ.xt3PortAddress + 0x4000) {  //Xellent30設定ポート
  4570:          XEiJ.xt3PortWrite (d >> 16);
  4571:          XEiJ.xt3PortWrite (d);
  4572:          return;
  4573:        }
  4574:        super.mmdWl (a, d);  //バスエラー
  4575:      }
  4576:   },  //MMD_XB3
  4577: 
  4578:   //--------------------------------------------------------------------------------
  4579:   //MMD_XTM Xellent30のSRAM
  4580:   MMD_XTM {
  4581:     @Override public String toString () {
  4582:       return Multilingual.mlnJapanese ? "Xellent30 の SRAM" : "SRAM on Xellent30";
  4583:     }
  4584:     //ピーク
  4585:     @Override protected byte mmdPbs (int a) {
  4586:       a -= XEiJ.xt3MemoryPosition;
  4587:       return XEiJ.xt3MemoryArray[a];
  4588:     }
  4589:     @Override protected int mmdPbz (int a) {
  4590:       a -= XEiJ.xt3MemoryPosition;
  4591:       return XEiJ.xt3MemoryArray[a] & 0xff;
  4592:     }
  4593:     @Override protected int mmdPws (int a) {
  4594:       a -= XEiJ.xt3MemoryPosition;
  4595:       return XEiJ.xt3MemoryArray[a] << 8 | (XEiJ.xt3MemoryArray[a + 1] & 0xff);
  4596:     }
  4597:     @Override protected int mmdPwz (int a) {
  4598:       a -= XEiJ.xt3MemoryPosition;
  4599:       return (char) (XEiJ.xt3MemoryArray[a] << 8 | (XEiJ.xt3MemoryArray[a + 1] & 0xff));
  4600:     }
  4601:     @Override protected int mmdPls (int a) {
  4602:       a -= XEiJ.xt3MemoryPosition;
  4603:       return XEiJ.xt3MemoryArray[a] << 24 | (XEiJ.xt3MemoryArray[a + 1] & 0xff) << 16 | (char) (XEiJ.xt3MemoryArray[a + 2] << 8 | (XEiJ.xt3MemoryArray[a + 3] & 0xff));
  4604:     }
  4605:     //リード
  4606:     @Override protected byte mmdRbs (int a) throws M68kException {
  4607:        a -= XEiJ.xt3MemoryPosition;
  4608:        return XEiJ.xt3MemoryArray[a];
  4609:      }
  4610:     @Override protected int mmdRbz (int a) throws M68kException {
  4611:        a -= XEiJ.xt3MemoryPosition;
  4612:        return XEiJ.xt3MemoryArray[a] & 0xff;
  4613:      }
  4614:     @Override protected int mmdRws (int a) throws M68kException {
  4615:        a -= XEiJ.xt3MemoryPosition;
  4616:        return XEiJ.xt3MemoryArray[a] << 8 | (XEiJ.xt3MemoryArray[a + 1] & 0xff);
  4617:      }
  4618:     @Override protected int mmdRwz (int a) throws M68kException {
  4619:        a -= XEiJ.xt3MemoryPosition;
  4620:        return (char) (XEiJ.xt3MemoryArray[a] << 8 | (XEiJ.xt3MemoryArray[a + 1] & 0xff));
  4621:      }
  4622:     @Override protected int mmdRls (int a) throws M68kException {
  4623:        a -= XEiJ.xt3MemoryPosition;
  4624:        return XEiJ.xt3MemoryArray[a] << 24 | (XEiJ.xt3MemoryArray[a + 1] & 0xff) << 16 | (char) (XEiJ.xt3MemoryArray[a + 2] << 8 | (XEiJ.xt3MemoryArray[a + 3] & 0xff));
  4625:      }
  4626:     //ライト
  4627:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4628:        a -= XEiJ.xt3MemoryPosition;
  4629:        XEiJ.xt3MemoryArray[a    ] = (byte)  d;
  4630:      }
  4631:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4632:        a -= XEiJ.xt3MemoryPosition;
  4633:        XEiJ.xt3MemoryArray[a    ] = (byte) (d >> 8);
  4634:        XEiJ.xt3MemoryArray[a + 1] = (byte)  d;
  4635:      }
  4636:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4637:        a -= XEiJ.xt3MemoryPosition;
  4638:        XEiJ.xt3MemoryArray[a    ] = (byte) (d >> 24);
  4639:        XEiJ.xt3MemoryArray[a + 1] = (byte) (d >> 16);
  4640:        XEiJ.xt3MemoryArray[a + 2] = (byte) (d >> 8);
  4641:        XEiJ.xt3MemoryArray[a + 3] = (byte)  d;
  4642:      }
  4643:   },  //MMD_XTM
  4644: 
  4645:   //--------------------------------------------------------------------------------
  4646:   //MMD_SMR SRAM
  4647:   MMD_SMR {
  4648:     @Override public String toString () {
  4649:       return Multilingual.mlnJapanese ? "SRAM" : "SRAM";
  4650:     }
  4651:     //ピーク
  4652:     @Override protected byte mmdPbs (int a) {
  4653:       a &= XEiJ.BUS_MOTHER_MASK;
  4654:       return MainMemory.mmrM8[a];
  4655:     }
  4656:     @Override protected int mmdPbz (int a) {
  4657:       a &= XEiJ.BUS_MOTHER_MASK;
  4658:       return MainMemory.mmrM8[a] & 0xff;
  4659:     }
  4660:     @Override protected int mmdPws (int a) {
  4661:       a &= XEiJ.BUS_MOTHER_MASK;
  4662:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4663:         return MainMemory.mmrBuffer.getShort (a);
  4664:       } else {
  4665:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4666:       }
  4667:     }
  4668:     @Override protected int mmdPwz (int a) {
  4669:       a &= XEiJ.BUS_MOTHER_MASK;
  4670:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4671:         return MainMemory.mmrBuffer.getChar (a);
  4672:       } else {
  4673:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4674:       }
  4675:     }
  4676:     @Override protected int mmdPls (int a) {
  4677:       a &= XEiJ.BUS_MOTHER_MASK;
  4678:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4679:         return MainMemory.mmrBuffer.getInt (a);
  4680:       } else {
  4681:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4682:       }
  4683:     }
  4684:     //リード
  4685:     @Override protected byte mmdRbs (int a) throws M68kException {
  4686:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4687:        a &= XEiJ.BUS_MOTHER_MASK;
  4688:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4689:        return MainMemory.mmrM8[a];
  4690:      }
  4691:     @Override protected int mmdRbz (int a) throws M68kException {
  4692:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4693:        a &= XEiJ.BUS_MOTHER_MASK;
  4694:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4695:        return MainMemory.mmrM8[a] & 0xff;
  4696:      }
  4697:     @Override protected int mmdRws (int a) throws M68kException {
  4698:        return (short) mmdRwz (a);
  4699:      }
  4700:     @Override protected int mmdRwz (int a) throws M68kException {
  4701:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4702:        a &= XEiJ.BUS_MOTHER_MASK;
  4703:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4704:        int d;
  4705:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4706:          d = MainMemory.mmrBuffer.getChar (a);
  4707:        } else {
  4708:          d = (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4709:        }
  4710:        return d;
  4711:      }
  4712:     @Override protected int mmdRls (int a) throws M68kException {
  4713:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram * 2;
  4714:        a &= XEiJ.BUS_MOTHER_MASK;
  4715:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram * 2;
  4716:        int d;
  4717:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4718:          d = MainMemory.mmrBuffer.getInt (a);
  4719:        } else {
  4720:          d = MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4721:        }
  4722:        return d;
  4723:      }
  4724:     //ライト
  4725:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4726:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4727:        if (SRAM.smrWriteEnableOn) {
  4728:          a &= XEiJ.BUS_MOTHER_MASK;
  4729:          XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4730:          MainMemory.mmrM8[a] = (byte) d;
  4731:          if (a == 0x00ed002b || a == 0x00ed0059) {  //キーボードの配列または字体が変化した
  4732:            Keyboard.kbdRepaint ();  //キーボードが表示されているときkbdImageを作り直して再描画する
  4733:          } else if (a == 0x00ed005a) {  //HDMAX
  4734:            if (0x00fe0000 <= XEiJ.regPC0 && XEiJ.regPC0 <= 0x00ffffff) {  //IPLROMがSRAMのHDMAXを書き換えようとしている 
  4735:              SRAM.smrOverride ();  //SRAMの設定を上書きする
  4736:            }
  4737:          }
  4738:        } else {
  4739:          System.out.printf ("%08X writing $%02X to $%08X in a write-protected state\n", XEiJ.regPC0, d & 0xff, a);
  4740:          if (SRAM.smrSRAMBusErrorOn) {
  4741:            super.mmdWb (a, d);  //バスエラー
  4742:          }
  4743:        }
  4744:      }
  4745:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4746:        XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4747:        if (SRAM.smrWriteEnableOn) {
  4748:          a &= XEiJ.BUS_MOTHER_MASK;
  4749:          XEiJ.mpuClockTime += XEiJ.busWaitTime.sram;
  4750:          MainMemory.mmrM8[a    ] = (byte) (d >> 8);
  4751:          MainMemory.mmrM8[a + 1] = (byte)  d;
  4752:          if (a == (0x00ed002b & -2) || a == (0x00ed0059 & -2)) {  //キーボードの配列または字体が変化した
  4753:            Keyboard.kbdRepaint ();  //キーボードが表示されているときkbdImageを作り直して再描画する
  4754:          }
  4755:        } else {
  4756:          System.out.printf ("%08X writing $%04X to $%08X in a write-protected state\n", XEiJ.regPC0, d & 0xffff, a);
  4757:          if (SRAM.smrSRAMBusErrorOn) {
  4758:            super.mmdWw (a, d);  //バスエラー
  4759:          }
  4760:        }
  4761:      }
  4762:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4763:        if (SRAM.smrWriteEnableOn) {
  4764:          mmdWw (a    , d >> 16);
  4765:          mmdWw (a + 2, d      );
  4766:        } else {
  4767:          System.out.printf ("%08X writing $%08X to $%08X in a write-protected state\n", XEiJ.regPC0, d, a);
  4768:          if (SRAM.smrSRAMBusErrorOn) {
  4769:            super.mmdWl (a, d);  //バスエラー
  4770:          }
  4771:        }
  4772:      }
  4773:   },  //MMD_SMR
  4774: 
  4775:   //--------------------------------------------------------------------------------
  4776:   //MMD_XB4 拡張ボード領域4
  4777:   //  $00EE0000~$00EFFFFF  バンクメモリ
  4778:   MMD_XB4 {
  4779:     @Override public String toString () {
  4780:       return Multilingual.mlnJapanese ? "拡張ボード領域 4" : "Expansion Board Area 4";
  4781:     }
  4782:     //リード
  4783:     @Override protected byte mmdRbs (int a) throws M68kException {
  4784:        if (XEiJ.bnkOn) {
  4785:          a &= XEiJ.BUS_MOTHER_MASK;
  4786:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4787:          return XEiJ.bnkMemory[a];
  4788:        }
  4789:        return super.mmdRbs (a);  //バスエラー
  4790:      }
  4791:     @Override protected int mmdRbz (int a) throws M68kException {
  4792:        if (XEiJ.bnkOn) {
  4793:          a &= XEiJ.BUS_MOTHER_MASK;
  4794:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4795:          return XEiJ.bnkMemory[a] & 0xff;
  4796:        }
  4797:        return super.mmdRbz (a);  //バスエラー
  4798:      }
  4799:     @Override protected int mmdRws (int a) throws M68kException {
  4800:        if (XEiJ.bnkOn) {
  4801:          a &= XEiJ.BUS_MOTHER_MASK;
  4802:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4803:          return ((XEiJ.bnkMemory[a    ]       ) << 8 |
  4804:                  (XEiJ.bnkMemory[a + 1] & 0xff));
  4805:        }
  4806:        return super.mmdRws (a);  //バスエラー
  4807:      }
  4808:     @Override protected int mmdRwz (int a) throws M68kException {
  4809:        if (XEiJ.bnkOn) {
  4810:          a &= XEiJ.BUS_MOTHER_MASK;
  4811:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4812:          return ((XEiJ.bnkMemory[a    ] & 0xff) << 8 |
  4813:                  (XEiJ.bnkMemory[a + 1] & 0xff));
  4814:        }
  4815:        return super.mmdRwz (a);  //バスエラー
  4816:      }
  4817:     @Override protected int mmdRls (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    ]       ) << 24 |
  4822:                  (XEiJ.bnkMemory[a + 1] & 0xff) << 16 |
  4823:                  (XEiJ.bnkMemory[a + 2] & 0xff) <<  8 |
  4824:                  (XEiJ.bnkMemory[a + 3] & 0xff));
  4825:        }
  4826:        return super.mmdRls (a);  //バスエラー
  4827:      }
  4828:     //ライト
  4829:     @Override protected void mmdWb (int a, int d) throws M68kException {
  4830:        if (XEiJ.bnkOn) {
  4831:          a &= XEiJ.BUS_MOTHER_MASK;
  4832:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4833:          XEiJ.bnkMemory[a] = (byte) d;
  4834:          return;
  4835:        }
  4836:        super.mmdWb (a, d);  //バスエラー
  4837:      }
  4838:     @Override protected void mmdWw (int a, int d) throws M68kException {
  4839:        if (XEiJ.bnkOn) {
  4840:          a &= XEiJ.BUS_MOTHER_MASK;
  4841:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4842:          XEiJ.bnkMemory[a    ] = (byte) (d >> 8);
  4843:          XEiJ.bnkMemory[a + 1] = (byte)  d;
  4844:          return;
  4845:        }
  4846:        super.mmdWw (a, d);  //バスエラー
  4847:      }
  4848:     @Override protected void mmdWl (int a, int d) throws M68kException {
  4849:        if (XEiJ.bnkOn) {
  4850:          a &= XEiJ.BUS_MOTHER_MASK;
  4851:          a = XEiJ.bnkPageStart + (a - 0x00ee0000);
  4852:          XEiJ.bnkMemory[a    ] = (byte) (d >> 24);
  4853:          XEiJ.bnkMemory[a + 1] = (byte) (d >> 16);
  4854:          XEiJ.bnkMemory[a + 2] = (byte) (d >>  8);
  4855:          XEiJ.bnkMemory[a + 3] = (byte)  d;
  4856:          return;
  4857:        }
  4858:        super.mmdWl (a, d);  //バスエラー
  4859:      }
  4860:   },  //MMD_XB4
  4861: 
  4862:   //--------------------------------------------------------------------------------
  4863:   //MMD_CG1 CGROM1
  4864:   MMD_CG1 {
  4865:     @Override public String toString () {
  4866:       return Multilingual.mlnJapanese ? "CGROM" : "CGROM";
  4867:     }
  4868:     //ピーク
  4869:     @Override protected byte mmdPbs (int a) {
  4870:       a &= XEiJ.BUS_MOTHER_MASK;
  4871:       return MainMemory.mmrM8[a];
  4872:     }
  4873:     @Override protected int mmdPbz (int a) {
  4874:       a &= XEiJ.BUS_MOTHER_MASK;
  4875:       return MainMemory.mmrM8[a] & 0xff;
  4876:     }
  4877:     @Override protected int mmdPws (int a) {
  4878:       a &= XEiJ.BUS_MOTHER_MASK;
  4879:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4880:         return MainMemory.mmrBuffer.getShort (a);
  4881:       } else {
  4882:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4883:       }
  4884:     }
  4885:     @Override protected int mmdPwz (int a) {
  4886:       a &= XEiJ.BUS_MOTHER_MASK;
  4887:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4888:         return MainMemory.mmrBuffer.getChar (a);
  4889:       } else {
  4890:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4891:       }
  4892:     }
  4893:     @Override protected int mmdPls (int a) {
  4894:       a &= XEiJ.BUS_MOTHER_MASK;
  4895:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4896:         return MainMemory.mmrBuffer.getInt (a);
  4897:       } else {
  4898:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4899:       }
  4900:     }
  4901:     //リード
  4902:     @Override protected byte mmdRbs (int a) throws M68kException {
  4903:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4904:        a &= XEiJ.BUS_MOTHER_MASK;
  4905:        return MainMemory.mmrM8[a];
  4906:      }
  4907:     @Override protected int mmdRbz (int a) throws M68kException {
  4908:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4909:        a &= XEiJ.BUS_MOTHER_MASK;
  4910:        return MainMemory.mmrM8[a] & 0xff;
  4911:      }
  4912:     @Override protected int mmdRws (int a) throws M68kException {
  4913:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4914:        a &= XEiJ.BUS_MOTHER_MASK;
  4915:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4916:          return MainMemory.mmrBuffer.getShort (a);
  4917:        } else {
  4918:          return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4919:        }
  4920:      }
  4921:     @Override protected int mmdRwz (int a) throws M68kException {
  4922:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4923:        a &= XEiJ.BUS_MOTHER_MASK;
  4924:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4925:          return MainMemory.mmrBuffer.getChar (a);
  4926:        } else {
  4927:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4928:        }
  4929:      }
  4930:     @Override protected int mmdRls (int a) throws M68kException {
  4931:        XEiJ.mpuClockTime += XEiJ.busWaitTime.romlong;
  4932:        a &= XEiJ.BUS_MOTHER_MASK;
  4933:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4934:          return MainMemory.mmrBuffer.getInt (a);
  4935:        } else {
  4936:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4937:        }
  4938:      }
  4939:   },  //MMD_CG1
  4940: 
  4941:   //--------------------------------------------------------------------------------
  4942:   //MMD_CG2 CGROM2
  4943:   MMD_CG2 {
  4944:     @Override public String toString () {
  4945:       return Multilingual.mlnJapanese ? "CGROM" : "CGROM";
  4946:     }
  4947:     //ピーク
  4948:     @Override protected byte mmdPbs (int a) {
  4949:       a &= XEiJ.BUS_MOTHER_MASK;
  4950:       return MainMemory.mmrM8[a];
  4951:     }
  4952:     @Override protected int mmdPbz (int a) {
  4953:       a &= XEiJ.BUS_MOTHER_MASK;
  4954:       return MainMemory.mmrM8[a] & 0xff;
  4955:     }
  4956:     @Override protected int mmdPws (int a) {
  4957:       a &= XEiJ.BUS_MOTHER_MASK;
  4958:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4959:         return MainMemory.mmrBuffer.getShort (a);
  4960:       } else {
  4961:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4962:       }
  4963:     }
  4964:     @Override protected int mmdPwz (int a) {
  4965:       a &= XEiJ.BUS_MOTHER_MASK;
  4966:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4967:         return MainMemory.mmrBuffer.getChar (a);
  4968:       } else {
  4969:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  4970:       }
  4971:     }
  4972:     @Override protected int mmdPls (int a) {
  4973:       a &= XEiJ.BUS_MOTHER_MASK;
  4974:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4975:         return MainMemory.mmrBuffer.getInt (a);
  4976:       } else {
  4977:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  4978:       }
  4979:     }
  4980:     //リード
  4981:     @Override protected byte mmdRbs (int a) throws M68kException {
  4982:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4983:        a &= XEiJ.BUS_MOTHER_MASK;
  4984:        return MainMemory.mmrM8[a];
  4985:      }
  4986:     @Override protected int mmdRbz (int a) throws M68kException {
  4987:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4988:        a &= XEiJ.BUS_MOTHER_MASK;
  4989:        return MainMemory.mmrM8[a] & 0xff;
  4990:      }
  4991:     @Override protected int mmdRws (int a) throws M68kException {
  4992:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  4993:        a &= XEiJ.BUS_MOTHER_MASK;
  4994:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  4995:          return MainMemory.mmrBuffer.getShort (a);
  4996:        } else {
  4997:          return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  4998:        }
  4999:      }
  5000:     @Override protected int mmdRwz (int a) throws M68kException {
  5001:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5002:        a &= XEiJ.BUS_MOTHER_MASK;
  5003:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5004:          return MainMemory.mmrBuffer.getChar (a);
  5005:        } else {
  5006:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  5007:        }
  5008:      }
  5009:     @Override protected int mmdRls (int a) throws M68kException {
  5010:        XEiJ.mpuClockTime += XEiJ.busWaitTime.romlong;
  5011:        a &= XEiJ.BUS_MOTHER_MASK;
  5012:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5013:          return MainMemory.mmrBuffer.getInt (a);
  5014:        } else {
  5015:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  5016:        }
  5017:      }
  5018:   },  //MMD_CG2
  5019: 
  5020:   //--------------------------------------------------------------------------------
  5021:   //MMD_ROM ROM
  5022:   MMD_ROM {
  5023:     @Override public String toString () {
  5024:       return Multilingual.mlnJapanese ? "ROM" : "ROM";
  5025:     }
  5026:     //ピーク
  5027:     @Override protected byte mmdPbs (int a) {
  5028:       a &= XEiJ.BUS_MOTHER_MASK;
  5029:       return MainMemory.mmrM8[a];
  5030:     }
  5031:     @Override protected int mmdPbz (int a) {
  5032:       a &= XEiJ.BUS_MOTHER_MASK;
  5033:       return MainMemory.mmrM8[a] & 0xff;
  5034:     }
  5035:     @Override protected int mmdPws (int a) {
  5036:       a &= XEiJ.BUS_MOTHER_MASK;
  5037:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5038:         return MainMemory.mmrBuffer.getShort (a);
  5039:       } else {
  5040:         return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  5041:       }
  5042:     }
  5043:     @Override protected int mmdPwz (int a) {
  5044:       a &= XEiJ.BUS_MOTHER_MASK;
  5045:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5046:         return MainMemory.mmrBuffer.getChar (a);
  5047:       } else {
  5048:         return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  5049:       }
  5050:     }
  5051:     @Override protected int mmdPls (int a) {
  5052:       a &= XEiJ.BUS_MOTHER_MASK;
  5053:       if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5054:         return MainMemory.mmrBuffer.getInt (a);
  5055:       } else {
  5056:         return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  5057:       }
  5058:     }
  5059:     //リード
  5060:     @Override protected byte mmdRbs (int a) throws M68kException {
  5061:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5062:        a &= XEiJ.BUS_MOTHER_MASK;
  5063:        return MainMemory.mmrM8[a];
  5064:      }
  5065:     @Override protected int mmdRbz (int a) throws M68kException {
  5066:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5067:        a &= XEiJ.BUS_MOTHER_MASK;
  5068:        return MainMemory.mmrM8[a] & 0xff;
  5069:      }
  5070:     @Override protected int mmdRws (int a) throws M68kException {
  5071:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5072:        a &= XEiJ.BUS_MOTHER_MASK;
  5073:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5074:          return MainMemory.mmrBuffer.getShort (a);
  5075:        } else {
  5076:          return MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff);
  5077:        }
  5078:      }
  5079:     @Override protected int mmdRwz (int a) throws M68kException {
  5080:        XEiJ.mpuClockTime += XEiJ.busWaitTime.rom;
  5081:        a &= XEiJ.BUS_MOTHER_MASK;
  5082:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5083:          return MainMemory.mmrBuffer.getChar (a);
  5084:        } else {
  5085:          return (char) (MainMemory.mmrM8[a] << 8 | (MainMemory.mmrM8[a + 1] & 0xff));
  5086:        }
  5087:      }
  5088:     @Override protected int mmdRls (int a) throws M68kException {
  5089:        XEiJ.mpuClockTime += XEiJ.busWaitTime.romlong;
  5090:        a &= XEiJ.BUS_MOTHER_MASK;
  5091:        if (MainMemory.MMR_USE_BYTE_BUFFER) {
  5092:          return MainMemory.mmrBuffer.getInt (a);
  5093:        } else {
  5094:          return MainMemory.mmrM8[a] << 24 | (MainMemory.mmrM8[a + 1] & 0xff) << 16 | (char) (MainMemory.mmrM8[a + 2] << 8 | (MainMemory.mmrM8[a + 3] & 0xff));
  5095:        }
  5096:      }
  5097:   },  //MMD_ROM
  5098: 
  5099:   //--------------------------------------------------------------------------------
  5100:   //MMD_IBP 命令ブレークポイント
  5101:   MMD_IBP {
  5102:     @Override public String toString () {
  5103:       return Multilingual.mlnJapanese ? "命令ブレークポイント" : "Instruction Break Point";
  5104:     }
  5105:     @Override protected int mmdRwz (int a) throws M68kException {
  5106:        if (InstructionBreakPoint.IBP_ON) {
  5107:          InstructionBreakPoint.InstructionBreakRecord[] hashTable = (XEiJ.regSRS != 0 ?
  5108:                                                                      InstructionBreakPoint.ibpSuperHashTable :
  5109:                                                                      InstructionBreakPoint.ibpUserHashTable);
  5110:          for (InstructionBreakPoint.InstructionBreakRecord r = hashTable[a >> 1 & InstructionBreakPoint.IBP_HASH_MASK];
  5111:               r != null;
  5112:               r = r.ibrNext) {  //同じ物理ハッシュコードを持つ命令ブレークポイントについて
  5113:            if (r.ibrPhysicalAddress == a) {  //命令ブレークポイントが設定されているとき
  5114:              if (r.ibrValue == r.ibrTarget) {  //現在値が目標値と一致しているとき
  5115:                if (r.ibrThreshold < 0) {  //インスタントのとき
  5116:                  InstructionBreakPoint.ibpRemove (r.ibrLogicalAddress, XEiJ.regSRS);  //取り除く
  5117:                  XEiJ.mpuContinue = true;  //ステップ実行を継続する
  5118:                } else if (r.ibrTarget < r.ibrThreshold) {  //インスタント化しているとき
  5119:                  r.ibrTarget = r.ibrThreshold;  //目標値を閾値に戻す
  5120:                  XEiJ.mpuContinue = true;  //ステップ実行を継続する
  5121:                } else {  //インスタントでなくインスタント化していないとき
  5122:                  if (r.ibrScriptElement != null &&  //スクリプトが指定されていて
  5123:                      r.ibrScriptElement.exlEval (ExpressionEvaluator.EVM_EXPRESSION).exlFloatValue.iszero ()) {  //条件が成立していないとき
  5124:                    break;  //続行する
  5125:                  }
  5126:                  r.ibrTarget++;  //目標値を増やす
  5127:                  XEiJ.mpuContinue = false;  //ステップ実行を継続しない
  5128:                }
  5129:                M68kException.m6eNumber = M68kException.M6E_INSTRUCTION_BREAK_POINT;  //命令ブレークポイントによる停止。XEiJ.mpuContinueを設定すること
  5130:                throw M68kException.m6eSignal;  //停止する
  5131:              } else {  //現在値が目標値と一致していないとき
  5132:                if (r.ibrWaitInstruction != null) {  //待機ポイントがあるとき
  5133:                  WaitInstruction.instruction = r.ibrWaitInstruction;  //待機命令を設定して
  5134:                  return XEiJ.EMX_OPCODE_EMXWAIT;  //返す
  5135:                }
  5136:                r.ibrValue++;  //現在値を増やす
  5137:                break;  //続行する
  5138:              }
  5139:            }
  5140:          }
  5141:        }
  5142:        if (DataBreakPoint.DBP_ON) {
  5143:          return DataBreakPoint.dbpMemoryMap[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
  5144:        } else {
  5145:          return XEiJ.busMemoryMap[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
  5146:        }
  5147:      }
  5148:   },  //MMD_IBP
  5149: 
  5150:   //--------------------------------------------------------------------------------
  5151:   //MMD_DBP データブレークポイント
  5152:   MMD_DBP {
  5153:     @Override public String toString () {
  5154:       return Multilingual.mlnJapanese ? "データブレークポイント" : "Data Break Point";
  5155:     }
  5156:     //ピーク
  5157:     @Override protected byte mmdPbs (int a) {
  5158:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPbs (a);
  5159:     }
  5160:     @Override protected int mmdPbz (int a) {
  5161:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPbz (a);
  5162:     }
  5163:     @Override protected int mmdPws (int a) {
  5164:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPws (a);
  5165:     }
  5166:     @Override protected int mmdPwz (int a) {
  5167:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPwz (a);
  5168:     }
  5169:     @Override protected int mmdPls (int a) {
  5170:       return (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdPls (a);
  5171:     }
  5172:     //リード
  5173:     @Override protected byte mmdRbs (int a) throws M68kException {
  5174:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRbs (a);
  5175:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_BYTE, a, d);
  5176:        return (byte) d;
  5177:      }
  5178:     @Override protected int mmdRbz (int a) throws M68kException {
  5179:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRbz (a);
  5180:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_BYTE, a, d);
  5181:        return d;
  5182:      }
  5183:     @Override protected int mmdRws (int a) throws M68kException {
  5184:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRws (a);
  5185:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_WORD, a, d);
  5186:        return d;
  5187:      }
  5188:     @Override protected int mmdRwz (int a) throws M68kException {
  5189:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRwz (a);
  5190:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_WORD, a, d);
  5191:        return d;
  5192:      }
  5193:     @Override protected int mmdRls (int a) throws M68kException {
  5194:        int d = (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdRls (a);
  5195:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_LONG, a, d);
  5196:        return d;
  5197:      }
  5198:     //ライト
  5199:     @Override protected void mmdWb (int a, int d) throws M68kException {
  5200:        (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdWb (a, d);
  5201:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_BYTE, a, d);
  5202:      }
  5203:     @Override protected void mmdWw (int a, int d) throws M68kException {
  5204:        (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdWw (a, d);
  5205:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_WORD, a, d);
  5206:      }
  5207:     @Override protected void mmdWl (int a, int d) throws M68kException {
  5208:        (XEiJ.regSRS != 0 ? XEiJ.busSuperMap : XEiJ.busUserMap)[a >>> XEiJ.BUS_PAGE_BITS].mmdWl (a, d);
  5209:        DataBreakPoint.dbpBreak (DataBreakPoint.DBP_LONG, a, d);
  5210:      }
  5211:   },  //MMD_DBP
  5212: 
  5213:   //--------------------------------------------------------------------------------
  5214:   //MMD_NUL ヌルデバイス
  5215:   MMD_NUL {
  5216:     @Override public String toString () {
  5217:       return Multilingual.mlnJapanese ? "ヌルデバイス" : "Null Device";
  5218:     }
  5219:   };  //MMD_NUL
  5220: 
  5221:   //--------------------------------------------------------------------------------
  5222:   //ピークのデフォルト
  5223:   //  エラーや副作用なしでリードする
  5224:   //  バスエラーのときは-1をキャストした値を返す
  5225:   //  リードがデバイスの状態を変化させる可能性がある場合は個別に処理すること
  5226:   protected byte mmdPbs (int a) {
  5227:     try {
  5228:       return (byte) mmdRbz (a);
  5229:     } catch (M68kException e) {
  5230:     }
  5231:     return -1;
  5232:   }
  5233:   protected int mmdPbz (int a) {
  5234:     try {
  5235:       return mmdRbz (a);
  5236:     } catch (M68kException e) {
  5237:     }
  5238:     return 0xff;
  5239:   }
  5240:   protected int mmdPws (int a) {
  5241:     try {
  5242:       return (short) mmdRwz (a);
  5243:     } catch (M68kException e) {
  5244:     }
  5245:     return -1;
  5246:   }
  5247:   protected int mmdPwz (int a) {
  5248:     try {
  5249:       return mmdRwz (a);
  5250:     } catch (M68kException e) {
  5251:     }
  5252:     return 0xffff;
  5253:   }
  5254:   protected int mmdPls (int a) {
  5255:     try {
  5256:       return mmdRls (a);
  5257:     } catch (M68kException e) {
  5258:     }
  5259:     return -1;
  5260:   }
  5261:   //リードのデフォルト
  5262:   //  バイトとワードの符号拡張はゼロ拡張を呼び出す
  5263:   //  符号なしとロングはバスエラー
  5264:   protected byte mmdRbs (int a) throws M68kException {
  5265:     return (byte) mmdRbz (a);
  5266:   }
  5267:   protected int mmdRbz (int a) throws M68kException {
  5268:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_READ;  //サイズは設定済み。分割されている場合があることに注意
  5269:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5270:     M68kException.m6eAddress = a;
  5271:     M68kException.m6eDirection = XEiJ.MPU_WR_READ;
  5272:     M68kException.m6eSize = XEiJ.MPU_SS_BYTE;
  5273:     throw M68kException.m6eSignal;
  5274:   }
  5275:   protected int mmdRws (int a) throws M68kException {
  5276:     return (short) mmdRwz (a);
  5277:   }
  5278:   protected int mmdRwz (int a) throws M68kException {
  5279:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_READ;  //サイズは設定済み。分割されている場合があることに注意
  5280:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5281:     M68kException.m6eAddress = a;
  5282:     M68kException.m6eDirection = XEiJ.MPU_WR_READ;
  5283:     M68kException.m6eSize = XEiJ.MPU_SS_WORD;
  5284:     throw M68kException.m6eSignal;
  5285:   }
  5286:   protected int mmdRls (int a) throws M68kException {
  5287:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_READ;  //サイズは設定済み。分割されている場合があることに注意
  5288:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5289:     M68kException.m6eAddress = a;
  5290:     M68kException.m6eDirection = XEiJ.MPU_WR_READ;
  5291:     M68kException.m6eSize = XEiJ.MPU_SS_LONG;
  5292:     throw M68kException.m6eSignal;
  5293:   }
  5294:   //ポークのデフォルト
  5295:   //  エラーや副作用なしでライトする
  5296:   //  ライトがデバイスの状態を変化させる可能性がある場合は個別に処理すること
  5297:   protected void mmdVb (int a, int d) {
  5298:     try {
  5299:       mmdWb (a, d);
  5300:     } catch (M68kException e) {
  5301:     }
  5302:   }
  5303:   protected void mmdVw (int a, int d) {
  5304:     try {
  5305:       mmdWw (a, d);
  5306:     } catch (M68kException e) {
  5307:     }
  5308:   }
  5309:   protected void mmdVl (int a, int d) {
  5310:     try {
  5311:       mmdWl (a, d);
  5312:     } catch (M68kException e) {
  5313:     }
  5314:   }
  5315:   //ライトのデフォルト
  5316:   //  すべてバスエラー
  5317:   protected void mmdWb (int a, int d) throws M68kException {
  5318:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_WRITE;  //サイズは設定済み。分割されている場合があることに注意
  5319:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5320:     M68kException.m6eAddress = a;
  5321:     M68kException.m6eDirection = XEiJ.MPU_WR_WRITE;
  5322:     M68kException.m6eSize = XEiJ.MPU_SS_BYTE;
  5323:     throw M68kException.m6eSignal;
  5324:   }
  5325:   protected void mmdWw (int a, int d) throws M68kException {
  5326:     M68kException.m6eFSLW |= M68kException.M6E_FSLW_BUS_ERROR_ON_WRITE;  //サイズは設定済み。分割されている場合があることに注意
  5327:     M68kException.m6eNumber = M68kException.M6E_ACCESS_FAULT;
  5328:     M68kException.m6eAddress = a;
  5329:     M68kException.m6eDirection = XEiJ.MPU_WR_WRITE;
  5330:     M68kException.m6eSize = XEiJ.MPU_SS_WORD;
  5331:     throw M68kException.m6eSignal;
  5332:   }
  5333:   protected void mmdWl (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_LONG;
  5339:     throw M68kException.m6eSignal;
  5340:   }
  5341: }  //enum MemoryMappedDevice
  5342: 
  5343: 
  5344: