Annotation of generator/extra/z80-mz80-c/z80.c, revision 1.1

1.1     ! root        1: /* Multi-Z80 32 Bit emulator */
        !             2: 
        !             3: /* Copyright 1996-2000 Neil Bradley, All rights reserved
        !             4:  *
        !             5:  * License agreement:
        !             6:  *
        !             7:  * (MZ80 Refers to both the assembly code emitted by makeZ80.c and makeZ80.c
        !             8:  * itself)
        !             9:  *
        !            10:  * MZ80 May be distributed in unmodified form to any medium.
        !            11:  *
        !            12:  * MZ80 May not be sold, or sold as a part of a commercial package without
        !            13:  * the express written permission of Neil Bradley ([email protected]). This
        !            14:  * includes shareware.
        !            15:  *
        !            16:  * Modified versions of MZ80 may not be publicly redistributed without author
        !            17:  * approval ([email protected]). This includes distributing via a publicly
        !            18:  * accessible LAN. You may make your own source modifications and distribute
        !            19:  * MZ80 in source or object form, but if you make modifications to MZ80
        !            20:  * then it should be noted in the top as a comment in makeZ80.c.
        !            21:  *
        !            22:  * MZ80 Licensing for commercial applications is available. Please email
        !            23:  * [email protected] for details.
        !            24:  *
        !            25:  * Synthcom Systems, Inc, and Neil Bradley will not be held responsible for
        !            26:  * any damage done by the use of MZ80. It is purely "as-is".
        !            27:  *
        !            28:  * If you use MZ80 in a freeware application, credit in the following text:
        !            29:  *
        !            30:  * "Multi-Z80 CPU emulator by Neil Bradley ([email protected])"
        !            31:  *
        !            32:  * must accompany the freeware application within the application itself or
        !            33:  * in the documentation.
        !            34:  *
        !            35:  * Legal stuff aside:
        !            36:  *
        !            37:  * If you find problems with MZ80, please email the author so they can get
        !            38:  * resolved. If you find a bug and fix it, please also email the author so
        !            39:  * that those bug fixes can be propogated to the installed base of MZ80
        !            40:  * users. If you find performance improvements or problems with MZ80, please
        !            41:  * email the author with your changes/suggestions and they will be rolled in
        !            42:  * with subsequent releases of MZ80.
        !            43:  *
        !            44:  * The whole idea of this emulator is to have the fastest available 32 bit
        !            45:  * Multi-Z80 emulator for the PC, giving maximum performance. 
        !            46:  */
        !            47: 
        !            48: #include <stdio.h>
        !            49: #include <stdlib.h>
        !            50: #include <string.h>
        !            51: #include "mz80.h"
        !            52: UINT32 z80intAddr;
        !            53: UINT32 z80pc;
        !            54: 
        !            55: 
        !            56: /* Modular global variables go here*/
        !            57: 
        !            58: static CONTEXTMZ80 cpu;        /* CPU Context */
        !            59: static UINT8 *pbPC;                    /* Program counter normalized */
        !            60: static UINT8 *pbSP;                    /* Stack pointer normalized */
        !            61: static struct MemoryReadByte *psMemRead; /* Read memory structure */
        !            62: static struct MemoryWriteByte *psMemWrite; /* Write memory structure */
        !            63: static struct z80PortRead *psIoRead; /* Read I/O structure */
        !            64: static struct z80PortWrite *psIoWrite; /* Write memory structure */
        !            65: static INT32 sdwCyclesRemaining; /* Used as a countdown */
        !            66: static UINT32 dwReturnCode; /* Return code from exec() */
        !            67: static UINT32 dwOriginalCycles; /* How many cycles did we start with? */
        !            68: static UINT32 dwElapsedTicks;  /* How many ticks did we elapse? */
        !            69: static INT32 sdwAddr;          /* Temporary address storage */
        !            70: static UINT32 dwAddr;          /* Temporary stack address */
        !            71: static UINT8 *pbAddAdcTable;   /* Pointer to add/adc flag table */
        !            72: static UINT8 *pbSubSbcTable;   /* Pointer to sub/sbc flag table */
        !            73: static UINT32 dwTemp;                  /* Temporary value */
        !            74: 
        !            75: static UINT8 bTemp;                    /* Temporary value */
        !            76: 
        !            77: static UINT8 bTemp2;           /* Temporary value */
        !            78: 
        !            79: /* Precomputed flag tables */
        !            80: 
        !            81: static UINT8 bPostIncFlags[0x100] = 
        !            82: {
        !            83:        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
        !            84:        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
        !            85:        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
        !            86:        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
        !            87:        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
        !            88:        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
        !            89:        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,
        !            90:        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x94,
        !            91:        0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
        !            92:        0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
        !            93:        0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
        !            94:        0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
        !            95:        0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
        !            96:        0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
        !            97:        0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x90,
        !            98:        0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x50
        !            99: };
        !           100: 
        !           101: static UINT8 bPostDecFlags[0x100] = 
        !           102: {
        !           103:        0x92,0x42,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
        !           104:        0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
        !           105:        0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
        !           106:        0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
        !           107:        0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
        !           108:        0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
        !           109:        0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
        !           110:        0x12,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,
        !           111:        0x16,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
        !           112:        0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
        !           113:        0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
        !           114:        0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
        !           115:        0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
        !           116:        0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
        !           117:        0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,
        !           118:        0x92,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82,0x82
        !           119: };
        !           120: 
        !           121: static UINT8 bPostORFlags[0x100] = 
        !           122: {
        !           123:        0x44,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
        !           124:        0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
        !           125:        0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
        !           126:        0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
        !           127:        0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
        !           128:        0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
        !           129:        0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,
        !           130:        0x00,0x04,0x04,0x00,0x04,0x00,0x00,0x04,0x04,0x00,0x00,0x04,0x00,0x04,0x04,0x00,
        !           131:        0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
        !           132:        0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,
        !           133:        0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,
        !           134:        0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
        !           135:        0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,
        !           136:        0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
        !           137:        0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84,0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,
        !           138:        0x84,0x80,0x80,0x84,0x80,0x84,0x84,0x80,0x80,0x84,0x84,0x80,0x84,0x80,0x80,0x84
        !           139: };
        !           140: 
        !           141: static UINT8 bPostANDFlags[0x100] = 
        !           142: {
        !           143:        0x54,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
        !           144:        0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
        !           145:        0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
        !           146:        0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
        !           147:        0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
        !           148:        0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
        !           149:        0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,
        !           150:        0x10,0x14,0x14,0x10,0x14,0x10,0x10,0x14,0x14,0x10,0x10,0x14,0x10,0x14,0x14,0x10,
        !           151:        0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
        !           152:        0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,
        !           153:        0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,
        !           154:        0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
        !           155:        0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,
        !           156:        0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
        !           157:        0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94,0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,
        !           158:        0x94,0x90,0x90,0x94,0x90,0x94,0x94,0x90,0x90,0x94,0x94,0x90,0x94,0x90,0x90,0x94
        !           159: };
        !           160: 
        !           161: static UINT16 wDAATable[0x800] = 
        !           162: {
        !           163:        0x5400,0x1001,0x1002,0x1403,0x1004,0x1405,0x1406,0x1007,
        !           164:        0x1008,0x1409,0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,
        !           165:        0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,0x1016,0x1417,
        !           166:        0x1418,0x1019,0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,
        !           167:        0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,0x1026,0x1427,
        !           168:        0x1428,0x1029,0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,
        !           169:        0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,0x1436,0x1037,
        !           170:        0x1038,0x1439,0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,
        !           171:        0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,0x1046,0x1447,
        !           172:        0x1448,0x1049,0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,
        !           173:        0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,0x1456,0x1057,
        !           174:        0x1058,0x1459,0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,
        !           175:        0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,0x1466,0x1067,
        !           176:        0x1068,0x1469,0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,
        !           177:        0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,0x1076,0x1477,
        !           178:        0x1478,0x1079,0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,
        !           179:        0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,0x9086,0x9487,
        !           180:        0x9488,0x9089,0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,
        !           181:        0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,0x9496,0x9097,
        !           182:        0x9098,0x9499,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
        !           183:        0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,0x1506,0x1107,
        !           184:        0x1108,0x1509,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
        !           185:        0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,0x1116,0x1517,
        !           186:        0x1518,0x1119,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
        !           187:        0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,0x1126,0x1527,
        !           188:        0x1528,0x1129,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
        !           189:        0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,0x1536,0x1137,
        !           190:        0x1138,0x1539,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
        !           191:        0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,0x1146,0x1547,
        !           192:        0x1548,0x1149,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
        !           193:        0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,0x1556,0x1157,
        !           194:        0x1158,0x1559,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
        !           195:        0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,0x1566,0x1167,
        !           196:        0x1168,0x1569,0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,
        !           197:        0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,0x1176,0x1577,
        !           198:        0x1578,0x1179,0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,
        !           199:        0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,0x9186,0x9587,
        !           200:        0x9588,0x9189,0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,
        !           201:        0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,0x9596,0x9197,
        !           202:        0x9198,0x9599,0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,
        !           203:        0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,0x95a6,0x91a7,
        !           204:        0x91a8,0x95a9,0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,
        !           205:        0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,0x91b6,0x95b7,
        !           206:        0x95b8,0x91b9,0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,
        !           207:        0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,0x95c6,0x91c7,
        !           208:        0x91c8,0x95c9,0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,
        !           209:        0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,0x91d6,0x95d7,
        !           210:        0x95d8,0x91d9,0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,
        !           211:        0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,0x91e6,0x95e7,
        !           212:        0x95e8,0x91e9,0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,
        !           213:        0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,0x95f6,0x91f7,
        !           214:        0x91f8,0x95f9,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
        !           215:        0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,0x1506,0x1107,
        !           216:        0x1108,0x1509,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
        !           217:        0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,0x1116,0x1517,
        !           218:        0x1518,0x1119,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
        !           219:        0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,0x1126,0x1527,
        !           220:        0x1528,0x1129,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
        !           221:        0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,0x1536,0x1137,
        !           222:        0x1138,0x1539,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
        !           223:        0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,0x1146,0x1547,
        !           224:        0x1548,0x1149,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
        !           225:        0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,0x1556,0x1157,
        !           226:        0x1158,0x1559,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
        !           227:        0x1406,0x1007,0x1008,0x1409,0x140a,0x100b,0x140c,0x100d,
        !           228:        0x100e,0x140f,0x1010,0x1411,0x1412,0x1013,0x1414,0x1015,
        !           229:        0x1016,0x1417,0x1418,0x1019,0x101a,0x141b,0x101c,0x141d,
        !           230:        0x141e,0x101f,0x1020,0x1421,0x1422,0x1023,0x1424,0x1025,
        !           231:        0x1026,0x1427,0x1428,0x1029,0x102a,0x142b,0x102c,0x142d,
        !           232:        0x142e,0x102f,0x1430,0x1031,0x1032,0x1433,0x1034,0x1435,
        !           233:        0x1436,0x1037,0x1038,0x1439,0x143a,0x103b,0x143c,0x103d,
        !           234:        0x103e,0x143f,0x1040,0x1441,0x1442,0x1043,0x1444,0x1045,
        !           235:        0x1046,0x1447,0x1448,0x1049,0x104a,0x144b,0x104c,0x144d,
        !           236:        0x144e,0x104f,0x1450,0x1051,0x1052,0x1453,0x1054,0x1455,
        !           237:        0x1456,0x1057,0x1058,0x1459,0x145a,0x105b,0x145c,0x105d,
        !           238:        0x105e,0x145f,0x1460,0x1061,0x1062,0x1463,0x1064,0x1465,
        !           239:        0x1466,0x1067,0x1068,0x1469,0x146a,0x106b,0x146c,0x106d,
        !           240:        0x106e,0x146f,0x1070,0x1471,0x1472,0x1073,0x1474,0x1075,
        !           241:        0x1076,0x1477,0x1478,0x1079,0x107a,0x147b,0x107c,0x147d,
        !           242:        0x147e,0x107f,0x9080,0x9481,0x9482,0x9083,0x9484,0x9085,
        !           243:        0x9086,0x9487,0x9488,0x9089,0x908a,0x948b,0x908c,0x948d,
        !           244:        0x948e,0x908f,0x9490,0x9091,0x9092,0x9493,0x9094,0x9495,
        !           245:        0x9496,0x9097,0x9098,0x9499,0x949a,0x909b,0x949c,0x909d,
        !           246:        0x909e,0x949f,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
        !           247:        0x1506,0x1107,0x1108,0x1509,0x150a,0x110b,0x150c,0x110d,
        !           248:        0x110e,0x150f,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
        !           249:        0x1116,0x1517,0x1518,0x1119,0x111a,0x151b,0x111c,0x151d,
        !           250:        0x151e,0x111f,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
        !           251:        0x1126,0x1527,0x1528,0x1129,0x112a,0x152b,0x112c,0x152d,
        !           252:        0x152e,0x112f,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
        !           253:        0x1536,0x1137,0x1138,0x1539,0x153a,0x113b,0x153c,0x113d,
        !           254:        0x113e,0x153f,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
        !           255:        0x1146,0x1547,0x1548,0x1149,0x114a,0x154b,0x114c,0x154d,
        !           256:        0x154e,0x114f,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
        !           257:        0x1556,0x1157,0x1158,0x1559,0x155a,0x115b,0x155c,0x115d,
        !           258:        0x115e,0x155f,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
        !           259:        0x1566,0x1167,0x1168,0x1569,0x156a,0x116b,0x156c,0x116d,
        !           260:        0x116e,0x156f,0x1170,0x1571,0x1572,0x1173,0x1574,0x1175,
        !           261:        0x1176,0x1577,0x1578,0x1179,0x117a,0x157b,0x117c,0x157d,
        !           262:        0x157e,0x117f,0x9180,0x9581,0x9582,0x9183,0x9584,0x9185,
        !           263:        0x9186,0x9587,0x9588,0x9189,0x918a,0x958b,0x918c,0x958d,
        !           264:        0x958e,0x918f,0x9590,0x9191,0x9192,0x9593,0x9194,0x9595,
        !           265:        0x9596,0x9197,0x9198,0x9599,0x959a,0x919b,0x959c,0x919d,
        !           266:        0x919e,0x959f,0x95a0,0x91a1,0x91a2,0x95a3,0x91a4,0x95a5,
        !           267:        0x95a6,0x91a7,0x91a8,0x95a9,0x95aa,0x91ab,0x95ac,0x91ad,
        !           268:        0x91ae,0x95af,0x91b0,0x95b1,0x95b2,0x91b3,0x95b4,0x91b5,
        !           269:        0x91b6,0x95b7,0x95b8,0x91b9,0x91ba,0x95bb,0x91bc,0x95bd,
        !           270:        0x95be,0x91bf,0x95c0,0x91c1,0x91c2,0x95c3,0x91c4,0x95c5,
        !           271:        0x95c6,0x91c7,0x91c8,0x95c9,0x95ca,0x91cb,0x95cc,0x91cd,
        !           272:        0x91ce,0x95cf,0x91d0,0x95d1,0x95d2,0x91d3,0x95d4,0x91d5,
        !           273:        0x91d6,0x95d7,0x95d8,0x91d9,0x91da,0x95db,0x91dc,0x95dd,
        !           274:        0x95de,0x91df,0x91e0,0x95e1,0x95e2,0x91e3,0x95e4,0x91e5,
        !           275:        0x91e6,0x95e7,0x95e8,0x91e9,0x91ea,0x95eb,0x91ec,0x95ed,
        !           276:        0x95ee,0x91ef,0x95f0,0x91f1,0x91f2,0x95f3,0x91f4,0x95f5,
        !           277:        0x95f6,0x91f7,0x91f8,0x95f9,0x95fa,0x91fb,0x95fc,0x91fd,
        !           278:        0x91fe,0x95ff,0x5500,0x1101,0x1102,0x1503,0x1104,0x1505,
        !           279:        0x1506,0x1107,0x1108,0x1509,0x150a,0x110b,0x150c,0x110d,
        !           280:        0x110e,0x150f,0x1110,0x1511,0x1512,0x1113,0x1514,0x1115,
        !           281:        0x1116,0x1517,0x1518,0x1119,0x111a,0x151b,0x111c,0x151d,
        !           282:        0x151e,0x111f,0x1120,0x1521,0x1522,0x1123,0x1524,0x1125,
        !           283:        0x1126,0x1527,0x1528,0x1129,0x112a,0x152b,0x112c,0x152d,
        !           284:        0x152e,0x112f,0x1530,0x1131,0x1132,0x1533,0x1134,0x1535,
        !           285:        0x1536,0x1137,0x1138,0x1539,0x153a,0x113b,0x153c,0x113d,
        !           286:        0x113e,0x153f,0x1140,0x1541,0x1542,0x1143,0x1544,0x1145,
        !           287:        0x1146,0x1547,0x1548,0x1149,0x114a,0x154b,0x114c,0x154d,
        !           288:        0x154e,0x114f,0x1550,0x1151,0x1152,0x1553,0x1154,0x1555,
        !           289:        0x1556,0x1157,0x1158,0x1559,0x155a,0x115b,0x155c,0x115d,
        !           290:        0x115e,0x155f,0x1560,0x1161,0x1162,0x1563,0x1164,0x1565,
        !           291:        0x5600,0x1201,0x1202,0x1603,0x1204,0x1605,0x1606,0x1207,
        !           292:        0x1208,0x1609,0x1204,0x1605,0x1606,0x1207,0x1208,0x1609,
        !           293:        0x1210,0x1611,0x1612,0x1213,0x1614,0x1215,0x1216,0x1617,
        !           294:        0x1618,0x1219,0x1614,0x1215,0x1216,0x1617,0x1618,0x1219,
        !           295:        0x1220,0x1621,0x1622,0x1223,0x1624,0x1225,0x1226,0x1627,
        !           296:        0x1628,0x1229,0x1624,0x1225,0x1226,0x1627,0x1628,0x1229,
        !           297:        0x1630,0x1231,0x1232,0x1633,0x1234,0x1635,0x1636,0x1237,
        !           298:        0x1238,0x1639,0x1234,0x1635,0x1636,0x1237,0x1238,0x1639,
        !           299:        0x1240,0x1641,0x1642,0x1243,0x1644,0x1245,0x1246,0x1647,
        !           300:        0x1648,0x1249,0x1644,0x1245,0x1246,0x1647,0x1648,0x1249,
        !           301:        0x1650,0x1251,0x1252,0x1653,0x1254,0x1655,0x1656,0x1257,
        !           302:        0x1258,0x1659,0x1254,0x1655,0x1656,0x1257,0x1258,0x1659,
        !           303:        0x1660,0x1261,0x1262,0x1663,0x1264,0x1665,0x1666,0x1267,
        !           304:        0x1268,0x1669,0x1264,0x1665,0x1666,0x1267,0x1268,0x1669,
        !           305:        0x1270,0x1671,0x1672,0x1273,0x1674,0x1275,0x1276,0x1677,
        !           306:        0x1678,0x1279,0x1674,0x1275,0x1276,0x1677,0x1678,0x1279,
        !           307:        0x9280,0x9681,0x9682,0x9283,0x9684,0x9285,0x9286,0x9687,
        !           308:        0x9688,0x9289,0x9684,0x9285,0x9286,0x9687,0x9688,0x9289,
        !           309:        0x9690,0x9291,0x9292,0x9693,0x9294,0x9695,0x9696,0x9297,
        !           310:        0x9298,0x9699,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
        !           311:        0x1340,0x1741,0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,
        !           312:        0x1748,0x1349,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
        !           313:        0x1750,0x1351,0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,
        !           314:        0x1358,0x1759,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
        !           315:        0x1760,0x1361,0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,
        !           316:        0x1368,0x1769,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
        !           317:        0x1370,0x1771,0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,
        !           318:        0x1778,0x1379,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
        !           319:        0x9380,0x9781,0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,
        !           320:        0x9788,0x9389,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
        !           321:        0x9790,0x9391,0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,
        !           322:        0x9398,0x9799,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
        !           323:        0x97a0,0x93a1,0x93a2,0x97a3,0x93a4,0x97a5,0x97a6,0x93a7,
        !           324:        0x93a8,0x97a9,0x93a4,0x97a5,0x97a6,0x93a7,0x93a8,0x97a9,
        !           325:        0x93b0,0x97b1,0x97b2,0x93b3,0x97b4,0x93b5,0x93b6,0x97b7,
        !           326:        0x97b8,0x93b9,0x97b4,0x93b5,0x93b6,0x97b7,0x97b8,0x93b9,
        !           327:        0x97c0,0x93c1,0x93c2,0x97c3,0x93c4,0x97c5,0x97c6,0x93c7,
        !           328:        0x93c8,0x97c9,0x93c4,0x97c5,0x97c6,0x93c7,0x93c8,0x97c9,
        !           329:        0x93d0,0x97d1,0x97d2,0x93d3,0x97d4,0x93d5,0x93d6,0x97d7,
        !           330:        0x97d8,0x93d9,0x97d4,0x93d5,0x93d6,0x97d7,0x97d8,0x93d9,
        !           331:        0x93e0,0x97e1,0x97e2,0x93e3,0x97e4,0x93e5,0x93e6,0x97e7,
        !           332:        0x97e8,0x93e9,0x97e4,0x93e5,0x93e6,0x97e7,0x97e8,0x93e9,
        !           333:        0x97f0,0x93f1,0x93f2,0x97f3,0x93f4,0x97f5,0x97f6,0x93f7,
        !           334:        0x93f8,0x97f9,0x93f4,0x97f5,0x97f6,0x93f7,0x93f8,0x97f9,
        !           335:        0x5700,0x1301,0x1302,0x1703,0x1304,0x1705,0x1706,0x1307,
        !           336:        0x1308,0x1709,0x1304,0x1705,0x1706,0x1307,0x1308,0x1709,
        !           337:        0x1310,0x1711,0x1712,0x1313,0x1714,0x1315,0x1316,0x1717,
        !           338:        0x1718,0x1319,0x1714,0x1315,0x1316,0x1717,0x1718,0x1319,
        !           339:        0x1320,0x1721,0x1722,0x1323,0x1724,0x1325,0x1326,0x1727,
        !           340:        0x1728,0x1329,0x1724,0x1325,0x1326,0x1727,0x1728,0x1329,
        !           341:        0x1730,0x1331,0x1332,0x1733,0x1334,0x1735,0x1736,0x1337,
        !           342:        0x1338,0x1739,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
        !           343:        0x1340,0x1741,0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,
        !           344:        0x1748,0x1349,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
        !           345:        0x1750,0x1351,0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,
        !           346:        0x1358,0x1759,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
        !           347:        0x1760,0x1361,0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,
        !           348:        0x1368,0x1769,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
        !           349:        0x1370,0x1771,0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,
        !           350:        0x1778,0x1379,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
        !           351:        0x9380,0x9781,0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,
        !           352:        0x9788,0x9389,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
        !           353:        0x9790,0x9391,0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,
        !           354:        0x9398,0x9799,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
        !           355:        0x97fa,0x93fb,0x97fc,0x93fd,0x93fe,0x97ff,0x5600,0x1201,
        !           356:        0x1202,0x1603,0x1204,0x1605,0x1606,0x1207,0x1208,0x1609,
        !           357:        0x160a,0x120b,0x160c,0x120d,0x120e,0x160f,0x1210,0x1611,
        !           358:        0x1612,0x1213,0x1614,0x1215,0x1216,0x1617,0x1618,0x1219,
        !           359:        0x121a,0x161b,0x121c,0x161d,0x161e,0x121f,0x1220,0x1621,
        !           360:        0x1622,0x1223,0x1624,0x1225,0x1226,0x1627,0x1628,0x1229,
        !           361:        0x122a,0x162b,0x122c,0x162d,0x162e,0x122f,0x1630,0x1231,
        !           362:        0x1232,0x1633,0x1234,0x1635,0x1636,0x1237,0x1238,0x1639,
        !           363:        0x163a,0x123b,0x163c,0x123d,0x123e,0x163f,0x1240,0x1641,
        !           364:        0x1642,0x1243,0x1644,0x1245,0x1246,0x1647,0x1648,0x1249,
        !           365:        0x124a,0x164b,0x124c,0x164d,0x164e,0x124f,0x1650,0x1251,
        !           366:        0x1252,0x1653,0x1254,0x1655,0x1656,0x1257,0x1258,0x1659,
        !           367:        0x165a,0x125b,0x165c,0x125d,0x125e,0x165f,0x1660,0x1261,
        !           368:        0x1262,0x1663,0x1264,0x1665,0x1666,0x1267,0x1268,0x1669,
        !           369:        0x166a,0x126b,0x166c,0x126d,0x126e,0x166f,0x1270,0x1671,
        !           370:        0x1672,0x1273,0x1674,0x1275,0x1276,0x1677,0x1678,0x1279,
        !           371:        0x127a,0x167b,0x127c,0x167d,0x167e,0x127f,0x9280,0x9681,
        !           372:        0x9682,0x9283,0x9684,0x9285,0x9286,0x9687,0x9688,0x9289,
        !           373:        0x928a,0x968b,0x928c,0x968d,0x968e,0x928f,0x9690,0x9291,
        !           374:        0x9292,0x9693,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
        !           375:        0x173a,0x133b,0x173c,0x133d,0x133e,0x173f,0x1340,0x1741,
        !           376:        0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
        !           377:        0x134a,0x174b,0x134c,0x174d,0x174e,0x134f,0x1750,0x1351,
        !           378:        0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
        !           379:        0x175a,0x135b,0x175c,0x135d,0x135e,0x175f,0x1760,0x1361,
        !           380:        0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
        !           381:        0x176a,0x136b,0x176c,0x136d,0x136e,0x176f,0x1370,0x1771,
        !           382:        0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
        !           383:        0x137a,0x177b,0x137c,0x177d,0x177e,0x137f,0x9380,0x9781,
        !           384:        0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
        !           385:        0x938a,0x978b,0x938c,0x978d,0x978e,0x938f,0x9790,0x9391,
        !           386:        0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799,
        !           387:        0x979a,0x939b,0x979c,0x939d,0x939e,0x979f,0x97a0,0x93a1,
        !           388:        0x93a2,0x97a3,0x93a4,0x97a5,0x97a6,0x93a7,0x93a8,0x97a9,
        !           389:        0x97aa,0x93ab,0x97ac,0x93ad,0x93ae,0x97af,0x93b0,0x97b1,
        !           390:        0x97b2,0x93b3,0x97b4,0x93b5,0x93b6,0x97b7,0x97b8,0x93b9,
        !           391:        0x93ba,0x97bb,0x93bc,0x97bd,0x97be,0x93bf,0x97c0,0x93c1,
        !           392:        0x93c2,0x97c3,0x93c4,0x97c5,0x97c6,0x93c7,0x93c8,0x97c9,
        !           393:        0x97ca,0x93cb,0x97cc,0x93cd,0x93ce,0x97cf,0x93d0,0x97d1,
        !           394:        0x97d2,0x93d3,0x97d4,0x93d5,0x93d6,0x97d7,0x97d8,0x93d9,
        !           395:        0x93da,0x97db,0x93dc,0x97dd,0x97de,0x93df,0x93e0,0x97e1,
        !           396:        0x97e2,0x93e3,0x97e4,0x93e5,0x93e6,0x97e7,0x97e8,0x93e9,
        !           397:        0x93ea,0x97eb,0x93ec,0x97ed,0x97ee,0x93ef,0x97f0,0x93f1,
        !           398:        0x93f2,0x97f3,0x93f4,0x97f5,0x97f6,0x93f7,0x93f8,0x97f9,
        !           399:        0x97fa,0x93fb,0x97fc,0x93fd,0x93fe,0x97ff,0x5700,0x1301,
        !           400:        0x1302,0x1703,0x1304,0x1705,0x1706,0x1307,0x1308,0x1709,
        !           401:        0x170a,0x130b,0x170c,0x130d,0x130e,0x170f,0x1310,0x1711,
        !           402:        0x1712,0x1313,0x1714,0x1315,0x1316,0x1717,0x1718,0x1319,
        !           403:        0x131a,0x171b,0x131c,0x171d,0x171e,0x131f,0x1320,0x1721,
        !           404:        0x1722,0x1323,0x1724,0x1325,0x1326,0x1727,0x1728,0x1329,
        !           405:        0x132a,0x172b,0x132c,0x172d,0x172e,0x132f,0x1730,0x1331,
        !           406:        0x1332,0x1733,0x1334,0x1735,0x1736,0x1337,0x1338,0x1739,
        !           407:        0x173a,0x133b,0x173c,0x133d,0x133e,0x173f,0x1340,0x1741,
        !           408:        0x1742,0x1343,0x1744,0x1345,0x1346,0x1747,0x1748,0x1349,
        !           409:        0x134a,0x174b,0x134c,0x174d,0x174e,0x134f,0x1750,0x1351,
        !           410:        0x1352,0x1753,0x1354,0x1755,0x1756,0x1357,0x1358,0x1759,
        !           411:        0x175a,0x135b,0x175c,0x135d,0x135e,0x175f,0x1760,0x1361,
        !           412:        0x1362,0x1763,0x1364,0x1765,0x1766,0x1367,0x1368,0x1769,
        !           413:        0x176a,0x136b,0x176c,0x136d,0x136e,0x176f,0x1370,0x1771,
        !           414:        0x1772,0x1373,0x1774,0x1375,0x1376,0x1777,0x1778,0x1379,
        !           415:        0x137a,0x177b,0x137c,0x177d,0x177e,0x137f,0x9380,0x9781,
        !           416:        0x9782,0x9383,0x9784,0x9385,0x9386,0x9787,0x9788,0x9389,
        !           417:        0x938a,0x978b,0x938c,0x978d,0x978e,0x938f,0x9790,0x9391,
        !           418:        0x9392,0x9793,0x9394,0x9795,0x9796,0x9397,0x9398,0x9799 
        !           419: };
        !           420: 
        !           421: void DDFDCBHandler(UINT32 dwWhich);
        !           422: 
        !           423: 
        !           424: static void InvalidInstruction(UINT32 dwCount)
        !           425: {
        !           426:        pbPC -= dwCount; /* Invalid instruction - back up */
        !           427:        dwReturnCode = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           428:        dwOriginalCycles -= sdwCyclesRemaining;
        !           429:        sdwCyclesRemaining = 0;
        !           430: }
        !           431: 
        !           432: void CBHandler(void)
        !           433: {
        !           434:        switch (*pbPC++)
        !           435:        {
        !           436:                case 0x00:
        !           437:                {
        !           438:                        sdwCyclesRemaining -= 8;
        !           439:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           440:                                bTemp2 = (cpu.z80B >> 7);
        !           441:                                cpu.z80B = (cpu.z80B << 1) | bTemp2;
        !           442:                                cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80B];
        !           443:                        break;
        !           444:                }
        !           445:                case 0x01:
        !           446:                {
        !           447:                        sdwCyclesRemaining -= 8;
        !           448:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           449:                                bTemp2 = (cpu.z80C >> 7);
        !           450:                                cpu.z80C = (cpu.z80C << 1) | bTemp2;
        !           451:                                cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80C];
        !           452:                        break;
        !           453:                }
        !           454:                case 0x02:
        !           455:                {
        !           456:                        sdwCyclesRemaining -= 8;
        !           457:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           458:                                bTemp2 = (cpu.z80D >> 7);
        !           459:                                cpu.z80D = (cpu.z80D << 1) | bTemp2;
        !           460:                                cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80D];
        !           461:                        break;
        !           462:                }
        !           463:                case 0x03:
        !           464:                {
        !           465:                        sdwCyclesRemaining -= 8;
        !           466:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           467:                                bTemp2 = (cpu.z80E >> 7);
        !           468:                                cpu.z80E = (cpu.z80E << 1) | bTemp2;
        !           469:                                cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80E];
        !           470:                        break;
        !           471:                }
        !           472:                case 0x04:
        !           473:                {
        !           474:                        sdwCyclesRemaining -= 8;
        !           475:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           476:                                bTemp2 = (cpu.z80H >> 7);
        !           477:                                cpu.z80H = (cpu.z80H << 1) | bTemp2;
        !           478:                                cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80H];
        !           479:                        break;
        !           480:                }
        !           481:                case 0x05:
        !           482:                {
        !           483:                        sdwCyclesRemaining -= 8;
        !           484:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           485:                                bTemp2 = (cpu.z80L >> 7);
        !           486:                                cpu.z80L = (cpu.z80L << 1) | bTemp2;
        !           487:                                cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80L];
        !           488:                        break;
        !           489:                }
        !           490:                case 0x06:
        !           491:                {
        !           492:                        sdwCyclesRemaining -= 15;
        !           493:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !           494:                                while (psMemRead->lowAddr != 0xffffffff)
        !           495:                                {
        !           496:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !           497:                                        {
        !           498:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           499:                                                if (psMemRead->memoryCall)
        !           500:                                                {
        !           501:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !           502:                                                }
        !           503:                                                else
        !           504:                                                {
        !           505:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !           506:                                                }
        !           507:                                                psMemRead = NULL;
        !           508:                                                break;
        !           509:                                        }
        !           510:                                        ++psMemRead;
        !           511:                                }
        !           512: 
        !           513:                                if (psMemRead)
        !           514:                                {
        !           515:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !           516:                                }
        !           517: 
        !           518:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           519:                                bTemp2 = (bTemp >> 7);
        !           520:                                bTemp = (bTemp << 1) | bTemp2;
        !           521:                                cpu.z80F |= bTemp2 | bPostORFlags[bTemp];
        !           522:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !           523:                                while (psMemWrite->lowAddr != 0xffffffff)
        !           524:                                {
        !           525:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !           526:                                        {
        !           527:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           528:                                                if (psMemWrite->memoryCall)
        !           529:                                                {
        !           530:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !           531:                                                }
        !           532:                                                else
        !           533:                                                {
        !           534:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !           535:                                                }
        !           536:                                                psMemWrite = NULL;
        !           537:                                                break;
        !           538:                                        }
        !           539:                                        ++psMemWrite;
        !           540:                                }
        !           541: 
        !           542:                                if (psMemWrite)
        !           543:                                {
        !           544:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !           545:                                }
        !           546: 
        !           547:                        break;
        !           548:                }
        !           549:                case 0x07:
        !           550:                {
        !           551:                        sdwCyclesRemaining -= 8;
        !           552:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           553:                                bTemp2 = (cpu.z80A >> 7);
        !           554:                                cpu.z80A = (cpu.z80A << 1) | bTemp2;
        !           555:                                cpu.z80F |= bTemp2 | bPostORFlags[cpu.z80A];
        !           556:                        break;
        !           557:                }
        !           558:                case 0x08:
        !           559:                {
        !           560:                        sdwCyclesRemaining -= 8;
        !           561:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           562:                                cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY);
        !           563:                                cpu.z80B = (cpu.z80B >> 1) | (cpu.z80B << 7);
        !           564:                                cpu.z80F |= bPostORFlags[cpu.z80B];
        !           565:                        break;
        !           566:                }
        !           567:                case 0x09:
        !           568:                {
        !           569:                        sdwCyclesRemaining -= 8;
        !           570:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           571:                                cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY);
        !           572:                                cpu.z80C = (cpu.z80C >> 1) | (cpu.z80C << 7);
        !           573:                                cpu.z80F |= bPostORFlags[cpu.z80C];
        !           574:                        break;
        !           575:                }
        !           576:                case 0x0a:
        !           577:                {
        !           578:                        sdwCyclesRemaining -= 8;
        !           579:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           580:                                cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY);
        !           581:                                cpu.z80D = (cpu.z80D >> 1) | (cpu.z80D << 7);
        !           582:                                cpu.z80F |= bPostORFlags[cpu.z80D];
        !           583:                        break;
        !           584:                }
        !           585:                case 0x0b:
        !           586:                {
        !           587:                        sdwCyclesRemaining -= 8;
        !           588:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           589:                                cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY);
        !           590:                                cpu.z80E = (cpu.z80E >> 1) | (cpu.z80E << 7);
        !           591:                                cpu.z80F |= bPostORFlags[cpu.z80E];
        !           592:                        break;
        !           593:                }
        !           594:                case 0x0c:
        !           595:                {
        !           596:                        sdwCyclesRemaining -= 8;
        !           597:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           598:                                cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY);
        !           599:                                cpu.z80H = (cpu.z80H >> 1) | (cpu.z80H << 7);
        !           600:                                cpu.z80F |= bPostORFlags[cpu.z80H];
        !           601:                        break;
        !           602:                }
        !           603:                case 0x0d:
        !           604:                {
        !           605:                        sdwCyclesRemaining -= 8;
        !           606:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           607:                                cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY);
        !           608:                                cpu.z80L = (cpu.z80L >> 1) | (cpu.z80L << 7);
        !           609:                                cpu.z80F |= bPostORFlags[cpu.z80L];
        !           610:                        break;
        !           611:                }
        !           612:                case 0x0e:
        !           613:                {
        !           614:                        sdwCyclesRemaining -= 15;
        !           615:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !           616:                                while (psMemRead->lowAddr != 0xffffffff)
        !           617:                                {
        !           618:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !           619:                                        {
        !           620:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           621:                                                if (psMemRead->memoryCall)
        !           622:                                                {
        !           623:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !           624:                                                }
        !           625:                                                else
        !           626:                                                {
        !           627:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !           628:                                                }
        !           629:                                                psMemRead = NULL;
        !           630:                                                break;
        !           631:                                        }
        !           632:                                        ++psMemRead;
        !           633:                                }
        !           634: 
        !           635:                                if (psMemRead)
        !           636:                                {
        !           637:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !           638:                                }
        !           639: 
        !           640:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           641:                                cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
        !           642:                                bTemp = (bTemp >> 1) | (bTemp << 7);
        !           643:                                cpu.z80F |= bPostORFlags[bTemp];
        !           644:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !           645:                                while (psMemWrite->lowAddr != 0xffffffff)
        !           646:                                {
        !           647:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !           648:                                        {
        !           649:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           650:                                                if (psMemWrite->memoryCall)
        !           651:                                                {
        !           652:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !           653:                                                }
        !           654:                                                else
        !           655:                                                {
        !           656:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !           657:                                                }
        !           658:                                                psMemWrite = NULL;
        !           659:                                                break;
        !           660:                                        }
        !           661:                                        ++psMemWrite;
        !           662:                                }
        !           663: 
        !           664:                                if (psMemWrite)
        !           665:                                {
        !           666:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !           667:                                }
        !           668: 
        !           669:                        break;
        !           670:                }
        !           671:                case 0x0f:
        !           672:                {
        !           673:                        sdwCyclesRemaining -= 8;
        !           674:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           675:                                cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
        !           676:                                cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A << 7);
        !           677:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !           678:                        break;
        !           679:                }
        !           680:                case 0x10:
        !           681:                {
        !           682:                        sdwCyclesRemaining -= 8;
        !           683:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !           684:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           685:                                cpu.z80F |= (cpu.z80B >> 7);
        !           686:                                cpu.z80B = (cpu.z80B << 1) | bTemp2;
        !           687:                                cpu.z80F |= bPostORFlags[cpu.z80B];
        !           688:                        break;
        !           689:                }
        !           690:                case 0x11:
        !           691:                {
        !           692:                        sdwCyclesRemaining -= 8;
        !           693:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !           694:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           695:                                cpu.z80F |= (cpu.z80C >> 7);
        !           696:                                cpu.z80C = (cpu.z80C << 1) | bTemp2;
        !           697:                                cpu.z80F |= bPostORFlags[cpu.z80C];
        !           698:                        break;
        !           699:                }
        !           700:                case 0x12:
        !           701:                {
        !           702:                        sdwCyclesRemaining -= 8;
        !           703:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !           704:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           705:                                cpu.z80F |= (cpu.z80D >> 7);
        !           706:                                cpu.z80D = (cpu.z80D << 1) | bTemp2;
        !           707:                                cpu.z80F |= bPostORFlags[cpu.z80D];
        !           708:                        break;
        !           709:                }
        !           710:                case 0x13:
        !           711:                {
        !           712:                        sdwCyclesRemaining -= 8;
        !           713:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !           714:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           715:                                cpu.z80F |= (cpu.z80E >> 7);
        !           716:                                cpu.z80E = (cpu.z80E << 1) | bTemp2;
        !           717:                                cpu.z80F |= bPostORFlags[cpu.z80E];
        !           718:                        break;
        !           719:                }
        !           720:                case 0x14:
        !           721:                {
        !           722:                        sdwCyclesRemaining -= 8;
        !           723:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !           724:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           725:                                cpu.z80F |= (cpu.z80H >> 7);
        !           726:                                cpu.z80H = (cpu.z80H << 1) | bTemp2;
        !           727:                                cpu.z80F |= bPostORFlags[cpu.z80H];
        !           728:                        break;
        !           729:                }
        !           730:                case 0x15:
        !           731:                {
        !           732:                        sdwCyclesRemaining -= 8;
        !           733:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !           734:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           735:                                cpu.z80F |= (cpu.z80L >> 7);
        !           736:                                cpu.z80L = (cpu.z80L << 1) | bTemp2;
        !           737:                                cpu.z80F |= bPostORFlags[cpu.z80L];
        !           738:                        break;
        !           739:                }
        !           740:                case 0x16:
        !           741:                {
        !           742:                        sdwCyclesRemaining -= 15;
        !           743:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !           744:                                while (psMemRead->lowAddr != 0xffffffff)
        !           745:                                {
        !           746:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !           747:                                        {
        !           748:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           749:                                                if (psMemRead->memoryCall)
        !           750:                                                {
        !           751:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !           752:                                                }
        !           753:                                                else
        !           754:                                                {
        !           755:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !           756:                                                }
        !           757:                                                psMemRead = NULL;
        !           758:                                                break;
        !           759:                                        }
        !           760:                                        ++psMemRead;
        !           761:                                }
        !           762: 
        !           763:                                if (psMemRead)
        !           764:                                {
        !           765:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !           766:                                }
        !           767: 
        !           768:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !           769:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           770:                                cpu.z80F |= (bTemp >> 7);
        !           771:                                bTemp = (bTemp << 1) | bTemp2;
        !           772:                                cpu.z80F |= bPostORFlags[bTemp];
        !           773:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !           774:                                while (psMemWrite->lowAddr != 0xffffffff)
        !           775:                                {
        !           776:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !           777:                                        {
        !           778:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           779:                                                if (psMemWrite->memoryCall)
        !           780:                                                {
        !           781:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !           782:                                                }
        !           783:                                                else
        !           784:                                                {
        !           785:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !           786:                                                }
        !           787:                                                psMemWrite = NULL;
        !           788:                                                break;
        !           789:                                        }
        !           790:                                        ++psMemWrite;
        !           791:                                }
        !           792: 
        !           793:                                if (psMemWrite)
        !           794:                                {
        !           795:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !           796:                                }
        !           797: 
        !           798:                        break;
        !           799:                }
        !           800:                case 0x17:
        !           801:                {
        !           802:                        sdwCyclesRemaining -= 8;
        !           803:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !           804:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           805:                                cpu.z80F |= (cpu.z80A >> 7);
        !           806:                                cpu.z80A = (cpu.z80A << 1) | bTemp2;
        !           807:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !           808:                        break;
        !           809:                }
        !           810:                case 0x18:
        !           811:                {
        !           812:                        sdwCyclesRemaining -= 8;
        !           813:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !           814:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           815:                                cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY);
        !           816:                                cpu.z80B = (cpu.z80B >> 1) | bTemp2;
        !           817:                                cpu.z80F |= bPostORFlags[cpu.z80B];
        !           818:                        break;
        !           819:                }
        !           820:                case 0x19:
        !           821:                {
        !           822:                        sdwCyclesRemaining -= 8;
        !           823:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !           824:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           825:                                cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY);
        !           826:                                cpu.z80C = (cpu.z80C >> 1) | bTemp2;
        !           827:                                cpu.z80F |= bPostORFlags[cpu.z80C];
        !           828:                        break;
        !           829:                }
        !           830:                case 0x1a:
        !           831:                {
        !           832:                        sdwCyclesRemaining -= 8;
        !           833:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !           834:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           835:                                cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY);
        !           836:                                cpu.z80D = (cpu.z80D >> 1) | bTemp2;
        !           837:                                cpu.z80F |= bPostORFlags[cpu.z80D];
        !           838:                        break;
        !           839:                }
        !           840:                case 0x1b:
        !           841:                {
        !           842:                        sdwCyclesRemaining -= 8;
        !           843:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !           844:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           845:                                cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY);
        !           846:                                cpu.z80E = (cpu.z80E >> 1) | bTemp2;
        !           847:                                cpu.z80F |= bPostORFlags[cpu.z80E];
        !           848:                        break;
        !           849:                }
        !           850:                case 0x1c:
        !           851:                {
        !           852:                        sdwCyclesRemaining -= 8;
        !           853:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !           854:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           855:                                cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY);
        !           856:                                cpu.z80H = (cpu.z80H >> 1) | bTemp2;
        !           857:                                cpu.z80F |= bPostORFlags[cpu.z80H];
        !           858:                        break;
        !           859:                }
        !           860:                case 0x1d:
        !           861:                {
        !           862:                        sdwCyclesRemaining -= 8;
        !           863:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !           864:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           865:                                cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY);
        !           866:                                cpu.z80L = (cpu.z80L >> 1) | bTemp2;
        !           867:                                cpu.z80F |= bPostORFlags[cpu.z80L];
        !           868:                        break;
        !           869:                }
        !           870:                case 0x1e:
        !           871:                {
        !           872:                        sdwCyclesRemaining -= 15;
        !           873:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !           874:                                while (psMemRead->lowAddr != 0xffffffff)
        !           875:                                {
        !           876:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !           877:                                        {
        !           878:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           879:                                                if (psMemRead->memoryCall)
        !           880:                                                {
        !           881:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !           882:                                                }
        !           883:                                                else
        !           884:                                                {
        !           885:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !           886:                                                }
        !           887:                                                psMemRead = NULL;
        !           888:                                                break;
        !           889:                                        }
        !           890:                                        ++psMemRead;
        !           891:                                }
        !           892: 
        !           893:                                if (psMemRead)
        !           894:                                {
        !           895:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !           896:                                }
        !           897: 
        !           898:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !           899:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           900:                                cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
        !           901:                                bTemp = (bTemp >> 1) | bTemp2;
        !           902:                                cpu.z80F |= bPostORFlags[bTemp];
        !           903:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !           904:                                while (psMemWrite->lowAddr != 0xffffffff)
        !           905:                                {
        !           906:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !           907:                                        {
        !           908:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !           909:                                                if (psMemWrite->memoryCall)
        !           910:                                                {
        !           911:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !           912:                                                }
        !           913:                                                else
        !           914:                                                {
        !           915:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !           916:                                                }
        !           917:                                                psMemWrite = NULL;
        !           918:                                                break;
        !           919:                                        }
        !           920:                                        ++psMemWrite;
        !           921:                                }
        !           922: 
        !           923:                                if (psMemWrite)
        !           924:                                {
        !           925:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !           926:                                }
        !           927: 
        !           928:                        break;
        !           929:                }
        !           930:                case 0x1f:
        !           931:                {
        !           932:                        sdwCyclesRemaining -= 8;
        !           933:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !           934:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           935:                                cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
        !           936:                                cpu.z80A = (cpu.z80A >> 1) | bTemp2;
        !           937:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !           938:                        break;
        !           939:                }
        !           940:                case 0x20:
        !           941:                {
        !           942:                        sdwCyclesRemaining -= 8;
        !           943:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           944:                                cpu.z80F |= (cpu.z80B >> 7);
        !           945:                                cpu.z80B = (cpu.z80B << 1);
        !           946:                                cpu.z80F |= bPostORFlags[cpu.z80B];
        !           947:                        break;
        !           948:                }
        !           949:                case 0x21:
        !           950:                {
        !           951:                        sdwCyclesRemaining -= 8;
        !           952:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           953:                                cpu.z80F |= (cpu.z80C >> 7);
        !           954:                                cpu.z80C = (cpu.z80C << 1);
        !           955:                                cpu.z80F |= bPostORFlags[cpu.z80C];
        !           956:                        break;
        !           957:                }
        !           958:                case 0x22:
        !           959:                {
        !           960:                        sdwCyclesRemaining -= 8;
        !           961:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           962:                                cpu.z80F |= (cpu.z80D >> 7);
        !           963:                                cpu.z80D = (cpu.z80D << 1);
        !           964:                                cpu.z80F |= bPostORFlags[cpu.z80D];
        !           965:                        break;
        !           966:                }
        !           967:                case 0x23:
        !           968:                {
        !           969:                        sdwCyclesRemaining -= 8;
        !           970:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           971:                                cpu.z80F |= (cpu.z80E >> 7);
        !           972:                                cpu.z80E = (cpu.z80E << 1);
        !           973:                                cpu.z80F |= bPostORFlags[cpu.z80E];
        !           974:                        break;
        !           975:                }
        !           976:                case 0x24:
        !           977:                {
        !           978:                        sdwCyclesRemaining -= 8;
        !           979:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           980:                                cpu.z80F |= (cpu.z80H >> 7);
        !           981:                                cpu.z80H = (cpu.z80H << 1);
        !           982:                                cpu.z80F |= bPostORFlags[cpu.z80H];
        !           983:                        break;
        !           984:                }
        !           985:                case 0x25:
        !           986:                {
        !           987:                        sdwCyclesRemaining -= 8;
        !           988:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !           989:                                cpu.z80F |= (cpu.z80L >> 7);
        !           990:                                cpu.z80L = (cpu.z80L << 1);
        !           991:                                cpu.z80F |= bPostORFlags[cpu.z80L];
        !           992:                        break;
        !           993:                }
        !           994:                case 0x26:
        !           995:                {
        !           996:                        sdwCyclesRemaining -= 15;
        !           997:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !           998:                                while (psMemRead->lowAddr != 0xffffffff)
        !           999:                                {
        !          1000:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1001:                                        {
        !          1002:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1003:                                                if (psMemRead->memoryCall)
        !          1004:                                                {
        !          1005:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1006:                                                }
        !          1007:                                                else
        !          1008:                                                {
        !          1009:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1010:                                                }
        !          1011:                                                psMemRead = NULL;
        !          1012:                                                break;
        !          1013:                                        }
        !          1014:                                        ++psMemRead;
        !          1015:                                }
        !          1016: 
        !          1017:                                if (psMemRead)
        !          1018:                                {
        !          1019:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1020:                                }
        !          1021: 
        !          1022:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1023:                                cpu.z80F |= (bTemp >> 7);
        !          1024:                                bTemp = (bTemp << 1);
        !          1025:                                cpu.z80F |= bPostORFlags[bTemp];
        !          1026:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          1027:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          1028:                                {
        !          1029:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          1030:                                        {
        !          1031:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1032:                                                if (psMemWrite->memoryCall)
        !          1033:                                                {
        !          1034:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          1035:                                                }
        !          1036:                                                else
        !          1037:                                                {
        !          1038:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          1039:                                                }
        !          1040:                                                psMemWrite = NULL;
        !          1041:                                                break;
        !          1042:                                        }
        !          1043:                                        ++psMemWrite;
        !          1044:                                }
        !          1045: 
        !          1046:                                if (psMemWrite)
        !          1047:                                {
        !          1048:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          1049:                                }
        !          1050: 
        !          1051:                        break;
        !          1052:                }
        !          1053:                case 0x27:
        !          1054:                {
        !          1055:                        sdwCyclesRemaining -= 8;
        !          1056:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1057:                                cpu.z80F |= (cpu.z80A >> 7);
        !          1058:                                cpu.z80A = (cpu.z80A << 1);
        !          1059:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          1060:                        break;
        !          1061:                }
        !          1062:                case 0x28:
        !          1063:                {
        !          1064:                        sdwCyclesRemaining -= 8;
        !          1065:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1066:                                cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY);
        !          1067:                                cpu.z80B = (cpu.z80B >> 1) | (cpu.z80B & 0x80);
        !          1068:                                cpu.z80F |= bPostORFlags[cpu.z80B];
        !          1069:                        break;
        !          1070:                }
        !          1071:                case 0x29:
        !          1072:                {
        !          1073:                        sdwCyclesRemaining -= 8;
        !          1074:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1075:                                cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY);
        !          1076:                                cpu.z80C = (cpu.z80C >> 1) | (cpu.z80C & 0x80);
        !          1077:                                cpu.z80F |= bPostORFlags[cpu.z80C];
        !          1078:                        break;
        !          1079:                }
        !          1080:                case 0x2a:
        !          1081:                {
        !          1082:                        sdwCyclesRemaining -= 8;
        !          1083:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1084:                                cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY);
        !          1085:                                cpu.z80D = (cpu.z80D >> 1) | (cpu.z80D & 0x80);
        !          1086:                                cpu.z80F |= bPostORFlags[cpu.z80D];
        !          1087:                        break;
        !          1088:                }
        !          1089:                case 0x2b:
        !          1090:                {
        !          1091:                        sdwCyclesRemaining -= 8;
        !          1092:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1093:                                cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY);
        !          1094:                                cpu.z80E = (cpu.z80E >> 1) | (cpu.z80E & 0x80);
        !          1095:                                cpu.z80F |= bPostORFlags[cpu.z80E];
        !          1096:                        break;
        !          1097:                }
        !          1098:                case 0x2c:
        !          1099:                {
        !          1100:                        sdwCyclesRemaining -= 8;
        !          1101:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1102:                                cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY);
        !          1103:                                cpu.z80H = (cpu.z80H >> 1) | (cpu.z80H & 0x80);
        !          1104:                                cpu.z80F |= bPostORFlags[cpu.z80H];
        !          1105:                        break;
        !          1106:                }
        !          1107:                case 0x2d:
        !          1108:                {
        !          1109:                        sdwCyclesRemaining -= 8;
        !          1110:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1111:                                cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY);
        !          1112:                                cpu.z80L = (cpu.z80L >> 1) | (cpu.z80L & 0x80);
        !          1113:                                cpu.z80F |= bPostORFlags[cpu.z80L];
        !          1114:                        break;
        !          1115:                }
        !          1116:                case 0x2e:
        !          1117:                {
        !          1118:                        sdwCyclesRemaining -= 15;
        !          1119:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          1120:                                while (psMemRead->lowAddr != 0xffffffff)
        !          1121:                                {
        !          1122:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1123:                                        {
        !          1124:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1125:                                                if (psMemRead->memoryCall)
        !          1126:                                                {
        !          1127:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1128:                                                }
        !          1129:                                                else
        !          1130:                                                {
        !          1131:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1132:                                                }
        !          1133:                                                psMemRead = NULL;
        !          1134:                                                break;
        !          1135:                                        }
        !          1136:                                        ++psMemRead;
        !          1137:                                }
        !          1138: 
        !          1139:                                if (psMemRead)
        !          1140:                                {
        !          1141:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1142:                                }
        !          1143: 
        !          1144:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1145:                                cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
        !          1146:                                bTemp = (bTemp >> 1) | (bTemp & 0x80);
        !          1147:                                cpu.z80F |= bPostORFlags[bTemp];
        !          1148:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          1149:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          1150:                                {
        !          1151:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          1152:                                        {
        !          1153:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1154:                                                if (psMemWrite->memoryCall)
        !          1155:                                                {
        !          1156:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          1157:                                                }
        !          1158:                                                else
        !          1159:                                                {
        !          1160:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          1161:                                                }
        !          1162:                                                psMemWrite = NULL;
        !          1163:                                                break;
        !          1164:                                        }
        !          1165:                                        ++psMemWrite;
        !          1166:                                }
        !          1167: 
        !          1168:                                if (psMemWrite)
        !          1169:                                {
        !          1170:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          1171:                                }
        !          1172: 
        !          1173:                        break;
        !          1174:                }
        !          1175:                case 0x2f:
        !          1176:                {
        !          1177:                        sdwCyclesRemaining -= 8;
        !          1178:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1179:                                cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
        !          1180:                                cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A & 0x80);
        !          1181:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          1182:                        break;
        !          1183:                }
        !          1184:                case 0x30:
        !          1185:                {
        !          1186:                        sdwCyclesRemaining -= 8;
        !          1187:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1188:                                cpu.z80F |= (cpu.z80B >> 7);
        !          1189:                                cpu.z80B = (cpu.z80B << 1);
        !          1190:                                cpu.z80F |= bPostORFlags[cpu.z80B];
        !          1191:                        break;
        !          1192:                }
        !          1193:                case 0x31:
        !          1194:                {
        !          1195:                        sdwCyclesRemaining -= 8;
        !          1196:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1197:                                cpu.z80F |= (cpu.z80C >> 7);
        !          1198:                                cpu.z80C = (cpu.z80C << 1);
        !          1199:                                cpu.z80F |= bPostORFlags[cpu.z80C];
        !          1200:                        break;
        !          1201:                }
        !          1202:                case 0x32:
        !          1203:                {
        !          1204:                        sdwCyclesRemaining -= 8;
        !          1205:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1206:                                cpu.z80F |= (cpu.z80D >> 7);
        !          1207:                                cpu.z80D = (cpu.z80D << 1);
        !          1208:                                cpu.z80F |= bPostORFlags[cpu.z80D];
        !          1209:                        break;
        !          1210:                }
        !          1211:                case 0x33:
        !          1212:                {
        !          1213:                        sdwCyclesRemaining -= 8;
        !          1214:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1215:                                cpu.z80F |= (cpu.z80E >> 7);
        !          1216:                                cpu.z80E = (cpu.z80E << 1);
        !          1217:                                cpu.z80F |= bPostORFlags[cpu.z80E];
        !          1218:                        break;
        !          1219:                }
        !          1220:                case 0x34:
        !          1221:                {
        !          1222:                        sdwCyclesRemaining -= 8;
        !          1223:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1224:                                cpu.z80F |= (cpu.z80H >> 7);
        !          1225:                                cpu.z80H = (cpu.z80H << 1);
        !          1226:                                cpu.z80F |= bPostORFlags[cpu.z80H];
        !          1227:                        break;
        !          1228:                }
        !          1229:                case 0x35:
        !          1230:                {
        !          1231:                        sdwCyclesRemaining -= 8;
        !          1232:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1233:                                cpu.z80F |= (cpu.z80L >> 7);
        !          1234:                                cpu.z80L = (cpu.z80L << 1);
        !          1235:                                cpu.z80F |= bPostORFlags[cpu.z80L];
        !          1236:                        break;
        !          1237:                }
        !          1238:                case 0x36:
        !          1239:                {
        !          1240:                        sdwCyclesRemaining -= 15;
        !          1241:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          1242:                                while (psMemRead->lowAddr != 0xffffffff)
        !          1243:                                {
        !          1244:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1245:                                        {
        !          1246:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1247:                                                if (psMemRead->memoryCall)
        !          1248:                                                {
        !          1249:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1250:                                                }
        !          1251:                                                else
        !          1252:                                                {
        !          1253:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1254:                                                }
        !          1255:                                                psMemRead = NULL;
        !          1256:                                                break;
        !          1257:                                        }
        !          1258:                                        ++psMemRead;
        !          1259:                                }
        !          1260: 
        !          1261:                                if (psMemRead)
        !          1262:                                {
        !          1263:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1264:                                }
        !          1265: 
        !          1266:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1267:                                cpu.z80F |= (bTemp >> 7);
        !          1268:                                bTemp = (bTemp << 1);
        !          1269:                                cpu.z80F |= bPostORFlags[bTemp];
        !          1270:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          1271:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          1272:                                {
        !          1273:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          1274:                                        {
        !          1275:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1276:                                                if (psMemWrite->memoryCall)
        !          1277:                                                {
        !          1278:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          1279:                                                }
        !          1280:                                                else
        !          1281:                                                {
        !          1282:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          1283:                                                }
        !          1284:                                                psMemWrite = NULL;
        !          1285:                                                break;
        !          1286:                                        }
        !          1287:                                        ++psMemWrite;
        !          1288:                                }
        !          1289: 
        !          1290:                                if (psMemWrite)
        !          1291:                                {
        !          1292:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          1293:                                }
        !          1294: 
        !          1295:                        break;
        !          1296:                }
        !          1297:                case 0x37:
        !          1298:                {
        !          1299:                        sdwCyclesRemaining -= 8;
        !          1300:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1301:                                cpu.z80F |= (cpu.z80A >> 7);
        !          1302:                                cpu.z80A = (cpu.z80A << 1);
        !          1303:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          1304:                        break;
        !          1305:                }
        !          1306:                case 0x38:
        !          1307:                {
        !          1308:                        sdwCyclesRemaining -= 8;
        !          1309:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1310:                                cpu.z80F |= (cpu.z80B & Z80_FLAG_CARRY);
        !          1311:                                cpu.z80B = (cpu.z80B >> 1);
        !          1312:                                cpu.z80F |= bPostORFlags[cpu.z80B];
        !          1313:                        break;
        !          1314:                }
        !          1315:                case 0x39:
        !          1316:                {
        !          1317:                        sdwCyclesRemaining -= 8;
        !          1318:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1319:                                cpu.z80F |= (cpu.z80C & Z80_FLAG_CARRY);
        !          1320:                                cpu.z80C = (cpu.z80C >> 1);
        !          1321:                                cpu.z80F |= bPostORFlags[cpu.z80C];
        !          1322:                        break;
        !          1323:                }
        !          1324:                case 0x3a:
        !          1325:                {
        !          1326:                        sdwCyclesRemaining -= 8;
        !          1327:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1328:                                cpu.z80F |= (cpu.z80D & Z80_FLAG_CARRY);
        !          1329:                                cpu.z80D = (cpu.z80D >> 1);
        !          1330:                                cpu.z80F |= bPostORFlags[cpu.z80D];
        !          1331:                        break;
        !          1332:                }
        !          1333:                case 0x3b:
        !          1334:                {
        !          1335:                        sdwCyclesRemaining -= 8;
        !          1336:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1337:                                cpu.z80F |= (cpu.z80E & Z80_FLAG_CARRY);
        !          1338:                                cpu.z80E = (cpu.z80E >> 1);
        !          1339:                                cpu.z80F |= bPostORFlags[cpu.z80E];
        !          1340:                        break;
        !          1341:                }
        !          1342:                case 0x3c:
        !          1343:                {
        !          1344:                        sdwCyclesRemaining -= 8;
        !          1345:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1346:                                cpu.z80F |= (cpu.z80H & Z80_FLAG_CARRY);
        !          1347:                                cpu.z80H = (cpu.z80H >> 1);
        !          1348:                                cpu.z80F |= bPostORFlags[cpu.z80H];
        !          1349:                        break;
        !          1350:                }
        !          1351:                case 0x3d:
        !          1352:                {
        !          1353:                        sdwCyclesRemaining -= 8;
        !          1354:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1355:                                cpu.z80F |= (cpu.z80L & Z80_FLAG_CARRY);
        !          1356:                                cpu.z80L = (cpu.z80L >> 1);
        !          1357:                                cpu.z80F |= bPostORFlags[cpu.z80L];
        !          1358:                        break;
        !          1359:                }
        !          1360:                case 0x3e:
        !          1361:                {
        !          1362:                        sdwCyclesRemaining -= 15;
        !          1363:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          1364:                                while (psMemRead->lowAddr != 0xffffffff)
        !          1365:                                {
        !          1366:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1367:                                        {
        !          1368:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1369:                                                if (psMemRead->memoryCall)
        !          1370:                                                {
        !          1371:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1372:                                                }
        !          1373:                                                else
        !          1374:                                                {
        !          1375:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1376:                                                }
        !          1377:                                                psMemRead = NULL;
        !          1378:                                                break;
        !          1379:                                        }
        !          1380:                                        ++psMemRead;
        !          1381:                                }
        !          1382: 
        !          1383:                                if (psMemRead)
        !          1384:                                {
        !          1385:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1386:                                }
        !          1387: 
        !          1388:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1389:                                cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
        !          1390:                                bTemp = (bTemp >> 1);
        !          1391:                                cpu.z80F |= bPostORFlags[bTemp];
        !          1392:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          1393:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          1394:                                {
        !          1395:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          1396:                                        {
        !          1397:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1398:                                                if (psMemWrite->memoryCall)
        !          1399:                                                {
        !          1400:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          1401:                                                }
        !          1402:                                                else
        !          1403:                                                {
        !          1404:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          1405:                                                }
        !          1406:                                                psMemWrite = NULL;
        !          1407:                                                break;
        !          1408:                                        }
        !          1409:                                        ++psMemWrite;
        !          1410:                                }
        !          1411: 
        !          1412:                                if (psMemWrite)
        !          1413:                                {
        !          1414:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          1415:                                }
        !          1416: 
        !          1417:                        break;
        !          1418:                }
        !          1419:                case 0x3f:
        !          1420:                {
        !          1421:                        sdwCyclesRemaining -= 8;
        !          1422:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          1423:                                cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
        !          1424:                                cpu.z80A = (cpu.z80A >> 1);
        !          1425:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          1426:                        break;
        !          1427:                }
        !          1428:                case 0x40:
        !          1429:                {
        !          1430:                        sdwCyclesRemaining -= 8;
        !          1431:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1432:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1433:                                if (!(cpu.z80B & 0x01))
        !          1434:                                {
        !          1435:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1436:                                }
        !          1437:                        break;
        !          1438:                }
        !          1439:                case 0x41:
        !          1440:                {
        !          1441:                        sdwCyclesRemaining -= 8;
        !          1442:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1443:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1444:                                if (!(cpu.z80C & 0x01))
        !          1445:                                {
        !          1446:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1447:                                }
        !          1448:                        break;
        !          1449:                }
        !          1450:                case 0x42:
        !          1451:                {
        !          1452:                        sdwCyclesRemaining -= 8;
        !          1453:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1454:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1455:                                if (!(cpu.z80D & 0x01))
        !          1456:                                {
        !          1457:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1458:                                }
        !          1459:                        break;
        !          1460:                }
        !          1461:                case 0x43:
        !          1462:                {
        !          1463:                        sdwCyclesRemaining -= 8;
        !          1464:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1465:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1466:                                if (!(cpu.z80E & 0x01))
        !          1467:                                {
        !          1468:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1469:                                }
        !          1470:                        break;
        !          1471:                }
        !          1472:                case 0x44:
        !          1473:                {
        !          1474:                        sdwCyclesRemaining -= 8;
        !          1475:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1476:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1477:                                if (!(cpu.z80H & 0x01))
        !          1478:                                {
        !          1479:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1480:                                }
        !          1481:                        break;
        !          1482:                }
        !          1483:                case 0x45:
        !          1484:                {
        !          1485:                        sdwCyclesRemaining -= 8;
        !          1486:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1487:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1488:                                if (!(cpu.z80L & 0x01))
        !          1489:                                {
        !          1490:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1491:                                }
        !          1492:                        break;
        !          1493:                }
        !          1494:                case 0x46:
        !          1495:                {
        !          1496:                        sdwCyclesRemaining -= 12;
        !          1497:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          1498:                                while (psMemRead->lowAddr != 0xffffffff)
        !          1499:                                {
        !          1500:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1501:                                        {
        !          1502:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1503:                                                if (psMemRead->memoryCall)
        !          1504:                                                {
        !          1505:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1506:                                                }
        !          1507:                                                else
        !          1508:                                                {
        !          1509:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1510:                                                }
        !          1511:                                                psMemRead = NULL;
        !          1512:                                                break;
        !          1513:                                        }
        !          1514:                                        ++psMemRead;
        !          1515:                                }
        !          1516: 
        !          1517:                                if (psMemRead)
        !          1518:                                {
        !          1519:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1520:                                }
        !          1521: 
        !          1522:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1523:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1524:                                if (!(bTemp & 0x01))
        !          1525:                                {
        !          1526:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1527:                                }
        !          1528:                        break;
        !          1529:                }
        !          1530:                case 0x47:
        !          1531:                {
        !          1532:                        sdwCyclesRemaining -= 8;
        !          1533:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1534:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1535:                                if (!(cpu.z80A & 0x01))
        !          1536:                                {
        !          1537:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1538:                                }
        !          1539:                        break;
        !          1540:                }
        !          1541:                case 0x48:
        !          1542:                {
        !          1543:                        sdwCyclesRemaining -= 8;
        !          1544:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1545:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1546:                                if (!(cpu.z80B & 0x02))
        !          1547:                                {
        !          1548:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1549:                                }
        !          1550:                        break;
        !          1551:                }
        !          1552:                case 0x49:
        !          1553:                {
        !          1554:                        sdwCyclesRemaining -= 8;
        !          1555:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1556:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1557:                                if (!(cpu.z80C & 0x02))
        !          1558:                                {
        !          1559:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1560:                                }
        !          1561:                        break;
        !          1562:                }
        !          1563:                case 0x4a:
        !          1564:                {
        !          1565:                        sdwCyclesRemaining -= 8;
        !          1566:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1567:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1568:                                if (!(cpu.z80D & 0x02))
        !          1569:                                {
        !          1570:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1571:                                }
        !          1572:                        break;
        !          1573:                }
        !          1574:                case 0x4b:
        !          1575:                {
        !          1576:                        sdwCyclesRemaining -= 8;
        !          1577:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1578:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1579:                                if (!(cpu.z80E & 0x02))
        !          1580:                                {
        !          1581:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1582:                                }
        !          1583:                        break;
        !          1584:                }
        !          1585:                case 0x4c:
        !          1586:                {
        !          1587:                        sdwCyclesRemaining -= 8;
        !          1588:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1589:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1590:                                if (!(cpu.z80H & 0x02))
        !          1591:                                {
        !          1592:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1593:                                }
        !          1594:                        break;
        !          1595:                }
        !          1596:                case 0x4d:
        !          1597:                {
        !          1598:                        sdwCyclesRemaining -= 8;
        !          1599:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1600:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1601:                                if (!(cpu.z80L & 0x02))
        !          1602:                                {
        !          1603:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1604:                                }
        !          1605:                        break;
        !          1606:                }
        !          1607:                case 0x4e:
        !          1608:                {
        !          1609:                        sdwCyclesRemaining -= 12;
        !          1610:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          1611:                                while (psMemRead->lowAddr != 0xffffffff)
        !          1612:                                {
        !          1613:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1614:                                        {
        !          1615:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1616:                                                if (psMemRead->memoryCall)
        !          1617:                                                {
        !          1618:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1619:                                                }
        !          1620:                                                else
        !          1621:                                                {
        !          1622:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1623:                                                }
        !          1624:                                                psMemRead = NULL;
        !          1625:                                                break;
        !          1626:                                        }
        !          1627:                                        ++psMemRead;
        !          1628:                                }
        !          1629: 
        !          1630:                                if (psMemRead)
        !          1631:                                {
        !          1632:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1633:                                }
        !          1634: 
        !          1635:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1636:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1637:                                if (!(bTemp & 0x02))
        !          1638:                                {
        !          1639:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1640:                                }
        !          1641:                        break;
        !          1642:                }
        !          1643:                case 0x4f:
        !          1644:                {
        !          1645:                        sdwCyclesRemaining -= 8;
        !          1646:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1647:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1648:                                if (!(cpu.z80A & 0x02))
        !          1649:                                {
        !          1650:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1651:                                }
        !          1652:                        break;
        !          1653:                }
        !          1654:                case 0x50:
        !          1655:                {
        !          1656:                        sdwCyclesRemaining -= 8;
        !          1657:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1658:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1659:                                if (!(cpu.z80B & 0x04))
        !          1660:                                {
        !          1661:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1662:                                }
        !          1663:                        break;
        !          1664:                }
        !          1665:                case 0x51:
        !          1666:                {
        !          1667:                        sdwCyclesRemaining -= 8;
        !          1668:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1669:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1670:                                if (!(cpu.z80C & 0x04))
        !          1671:                                {
        !          1672:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1673:                                }
        !          1674:                        break;
        !          1675:                }
        !          1676:                case 0x52:
        !          1677:                {
        !          1678:                        sdwCyclesRemaining -= 8;
        !          1679:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1680:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1681:                                if (!(cpu.z80D & 0x04))
        !          1682:                                {
        !          1683:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1684:                                }
        !          1685:                        break;
        !          1686:                }
        !          1687:                case 0x53:
        !          1688:                {
        !          1689:                        sdwCyclesRemaining -= 8;
        !          1690:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1691:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1692:                                if (!(cpu.z80E & 0x04))
        !          1693:                                {
        !          1694:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1695:                                }
        !          1696:                        break;
        !          1697:                }
        !          1698:                case 0x54:
        !          1699:                {
        !          1700:                        sdwCyclesRemaining -= 8;
        !          1701:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1702:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1703:                                if (!(cpu.z80H & 0x04))
        !          1704:                                {
        !          1705:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1706:                                }
        !          1707:                        break;
        !          1708:                }
        !          1709:                case 0x55:
        !          1710:                {
        !          1711:                        sdwCyclesRemaining -= 8;
        !          1712:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1713:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1714:                                if (!(cpu.z80L & 0x04))
        !          1715:                                {
        !          1716:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1717:                                }
        !          1718:                        break;
        !          1719:                }
        !          1720:                case 0x56:
        !          1721:                {
        !          1722:                        sdwCyclesRemaining -= 12;
        !          1723:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          1724:                                while (psMemRead->lowAddr != 0xffffffff)
        !          1725:                                {
        !          1726:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1727:                                        {
        !          1728:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1729:                                                if (psMemRead->memoryCall)
        !          1730:                                                {
        !          1731:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1732:                                                }
        !          1733:                                                else
        !          1734:                                                {
        !          1735:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1736:                                                }
        !          1737:                                                psMemRead = NULL;
        !          1738:                                                break;
        !          1739:                                        }
        !          1740:                                        ++psMemRead;
        !          1741:                                }
        !          1742: 
        !          1743:                                if (psMemRead)
        !          1744:                                {
        !          1745:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1746:                                }
        !          1747: 
        !          1748:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1749:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1750:                                if (!(bTemp & 0x04))
        !          1751:                                {
        !          1752:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1753:                                }
        !          1754:                        break;
        !          1755:                }
        !          1756:                case 0x57:
        !          1757:                {
        !          1758:                        sdwCyclesRemaining -= 8;
        !          1759:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1760:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1761:                                if (!(cpu.z80A & 0x04))
        !          1762:                                {
        !          1763:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1764:                                }
        !          1765:                        break;
        !          1766:                }
        !          1767:                case 0x58:
        !          1768:                {
        !          1769:                        sdwCyclesRemaining -= 8;
        !          1770:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1771:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1772:                                if (!(cpu.z80B & 0x08))
        !          1773:                                {
        !          1774:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1775:                                }
        !          1776:                        break;
        !          1777:                }
        !          1778:                case 0x59:
        !          1779:                {
        !          1780:                        sdwCyclesRemaining -= 8;
        !          1781:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1782:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1783:                                if (!(cpu.z80C & 0x08))
        !          1784:                                {
        !          1785:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1786:                                }
        !          1787:                        break;
        !          1788:                }
        !          1789:                case 0x5a:
        !          1790:                {
        !          1791:                        sdwCyclesRemaining -= 8;
        !          1792:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1793:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1794:                                if (!(cpu.z80D & 0x08))
        !          1795:                                {
        !          1796:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1797:                                }
        !          1798:                        break;
        !          1799:                }
        !          1800:                case 0x5b:
        !          1801:                {
        !          1802:                        sdwCyclesRemaining -= 8;
        !          1803:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1804:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1805:                                if (!(cpu.z80E & 0x08))
        !          1806:                                {
        !          1807:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1808:                                }
        !          1809:                        break;
        !          1810:                }
        !          1811:                case 0x5c:
        !          1812:                {
        !          1813:                        sdwCyclesRemaining -= 8;
        !          1814:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1815:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1816:                                if (!(cpu.z80H & 0x08))
        !          1817:                                {
        !          1818:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1819:                                }
        !          1820:                        break;
        !          1821:                }
        !          1822:                case 0x5d:
        !          1823:                {
        !          1824:                        sdwCyclesRemaining -= 8;
        !          1825:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1826:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1827:                                if (!(cpu.z80L & 0x08))
        !          1828:                                {
        !          1829:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1830:                                }
        !          1831:                        break;
        !          1832:                }
        !          1833:                case 0x5e:
        !          1834:                {
        !          1835:                        sdwCyclesRemaining -= 12;
        !          1836:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          1837:                                while (psMemRead->lowAddr != 0xffffffff)
        !          1838:                                {
        !          1839:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1840:                                        {
        !          1841:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1842:                                                if (psMemRead->memoryCall)
        !          1843:                                                {
        !          1844:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1845:                                                }
        !          1846:                                                else
        !          1847:                                                {
        !          1848:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1849:                                                }
        !          1850:                                                psMemRead = NULL;
        !          1851:                                                break;
        !          1852:                                        }
        !          1853:                                        ++psMemRead;
        !          1854:                                }
        !          1855: 
        !          1856:                                if (psMemRead)
        !          1857:                                {
        !          1858:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1859:                                }
        !          1860: 
        !          1861:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1862:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1863:                                if (!(bTemp & 0x08))
        !          1864:                                {
        !          1865:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1866:                                }
        !          1867:                        break;
        !          1868:                }
        !          1869:                case 0x5f:
        !          1870:                {
        !          1871:                        sdwCyclesRemaining -= 8;
        !          1872:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1873:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1874:                                if (!(cpu.z80A & 0x08))
        !          1875:                                {
        !          1876:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1877:                                }
        !          1878:                        break;
        !          1879:                }
        !          1880:                case 0x60:
        !          1881:                {
        !          1882:                        sdwCyclesRemaining -= 8;
        !          1883:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1884:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1885:                                if (!(cpu.z80B & 0x10))
        !          1886:                                {
        !          1887:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1888:                                }
        !          1889:                        break;
        !          1890:                }
        !          1891:                case 0x61:
        !          1892:                {
        !          1893:                        sdwCyclesRemaining -= 8;
        !          1894:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1895:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1896:                                if (!(cpu.z80C & 0x10))
        !          1897:                                {
        !          1898:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1899:                                }
        !          1900:                        break;
        !          1901:                }
        !          1902:                case 0x62:
        !          1903:                {
        !          1904:                        sdwCyclesRemaining -= 8;
        !          1905:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1906:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1907:                                if (!(cpu.z80D & 0x10))
        !          1908:                                {
        !          1909:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1910:                                }
        !          1911:                        break;
        !          1912:                }
        !          1913:                case 0x63:
        !          1914:                {
        !          1915:                        sdwCyclesRemaining -= 8;
        !          1916:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1917:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1918:                                if (!(cpu.z80E & 0x10))
        !          1919:                                {
        !          1920:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1921:                                }
        !          1922:                        break;
        !          1923:                }
        !          1924:                case 0x64:
        !          1925:                {
        !          1926:                        sdwCyclesRemaining -= 8;
        !          1927:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1928:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1929:                                if (!(cpu.z80H & 0x10))
        !          1930:                                {
        !          1931:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1932:                                }
        !          1933:                        break;
        !          1934:                }
        !          1935:                case 0x65:
        !          1936:                {
        !          1937:                        sdwCyclesRemaining -= 8;
        !          1938:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1939:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1940:                                if (!(cpu.z80L & 0x10))
        !          1941:                                {
        !          1942:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1943:                                }
        !          1944:                        break;
        !          1945:                }
        !          1946:                case 0x66:
        !          1947:                {
        !          1948:                        sdwCyclesRemaining -= 12;
        !          1949:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          1950:                                while (psMemRead->lowAddr != 0xffffffff)
        !          1951:                                {
        !          1952:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          1953:                                        {
        !          1954:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          1955:                                                if (psMemRead->memoryCall)
        !          1956:                                                {
        !          1957:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          1958:                                                }
        !          1959:                                                else
        !          1960:                                                {
        !          1961:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          1962:                                                }
        !          1963:                                                psMemRead = NULL;
        !          1964:                                                break;
        !          1965:                                        }
        !          1966:                                        ++psMemRead;
        !          1967:                                }
        !          1968: 
        !          1969:                                if (psMemRead)
        !          1970:                                {
        !          1971:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          1972:                                }
        !          1973: 
        !          1974:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1975:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1976:                                if (!(bTemp & 0x10))
        !          1977:                                {
        !          1978:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1979:                                }
        !          1980:                        break;
        !          1981:                }
        !          1982:                case 0x67:
        !          1983:                {
        !          1984:                        sdwCyclesRemaining -= 8;
        !          1985:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1986:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1987:                                if (!(cpu.z80A & 0x10))
        !          1988:                                {
        !          1989:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          1990:                                }
        !          1991:                        break;
        !          1992:                }
        !          1993:                case 0x68:
        !          1994:                {
        !          1995:                        sdwCyclesRemaining -= 8;
        !          1996:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          1997:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          1998:                                if (!(cpu.z80B & 0x20))
        !          1999:                                {
        !          2000:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2001:                                }
        !          2002:                        break;
        !          2003:                }
        !          2004:                case 0x69:
        !          2005:                {
        !          2006:                        sdwCyclesRemaining -= 8;
        !          2007:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2008:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2009:                                if (!(cpu.z80C & 0x20))
        !          2010:                                {
        !          2011:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2012:                                }
        !          2013:                        break;
        !          2014:                }
        !          2015:                case 0x6a:
        !          2016:                {
        !          2017:                        sdwCyclesRemaining -= 8;
        !          2018:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2019:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2020:                                if (!(cpu.z80D & 0x20))
        !          2021:                                {
        !          2022:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2023:                                }
        !          2024:                        break;
        !          2025:                }
        !          2026:                case 0x6b:
        !          2027:                {
        !          2028:                        sdwCyclesRemaining -= 8;
        !          2029:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2030:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2031:                                if (!(cpu.z80E & 0x20))
        !          2032:                                {
        !          2033:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2034:                                }
        !          2035:                        break;
        !          2036:                }
        !          2037:                case 0x6c:
        !          2038:                {
        !          2039:                        sdwCyclesRemaining -= 8;
        !          2040:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2041:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2042:                                if (!(cpu.z80H & 0x20))
        !          2043:                                {
        !          2044:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2045:                                }
        !          2046:                        break;
        !          2047:                }
        !          2048:                case 0x6d:
        !          2049:                {
        !          2050:                        sdwCyclesRemaining -= 8;
        !          2051:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2052:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2053:                                if (!(cpu.z80L & 0x20))
        !          2054:                                {
        !          2055:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2056:                                }
        !          2057:                        break;
        !          2058:                }
        !          2059:                case 0x6e:
        !          2060:                {
        !          2061:                        sdwCyclesRemaining -= 12;
        !          2062:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2063:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2064:                                {
        !          2065:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2066:                                        {
        !          2067:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2068:                                                if (psMemRead->memoryCall)
        !          2069:                                                {
        !          2070:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2071:                                                }
        !          2072:                                                else
        !          2073:                                                {
        !          2074:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2075:                                                }
        !          2076:                                                psMemRead = NULL;
        !          2077:                                                break;
        !          2078:                                        }
        !          2079:                                        ++psMemRead;
        !          2080:                                }
        !          2081: 
        !          2082:                                if (psMemRead)
        !          2083:                                {
        !          2084:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2085:                                }
        !          2086: 
        !          2087:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2088:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2089:                                if (!(bTemp & 0x20))
        !          2090:                                {
        !          2091:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2092:                                }
        !          2093:                        break;
        !          2094:                }
        !          2095:                case 0x6f:
        !          2096:                {
        !          2097:                        sdwCyclesRemaining -= 8;
        !          2098:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2099:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2100:                                if (!(cpu.z80A & 0x20))
        !          2101:                                {
        !          2102:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2103:                                }
        !          2104:                        break;
        !          2105:                }
        !          2106:                case 0x70:
        !          2107:                {
        !          2108:                        sdwCyclesRemaining -= 8;
        !          2109:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2110:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2111:                                if (!(cpu.z80B & 0x40))
        !          2112:                                {
        !          2113:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2114:                                }
        !          2115:                        break;
        !          2116:                }
        !          2117:                case 0x71:
        !          2118:                {
        !          2119:                        sdwCyclesRemaining -= 8;
        !          2120:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2121:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2122:                                if (!(cpu.z80C & 0x40))
        !          2123:                                {
        !          2124:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2125:                                }
        !          2126:                        break;
        !          2127:                }
        !          2128:                case 0x72:
        !          2129:                {
        !          2130:                        sdwCyclesRemaining -= 8;
        !          2131:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2132:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2133:                                if (!(cpu.z80D & 0x40))
        !          2134:                                {
        !          2135:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2136:                                }
        !          2137:                        break;
        !          2138:                }
        !          2139:                case 0x73:
        !          2140:                {
        !          2141:                        sdwCyclesRemaining -= 8;
        !          2142:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2143:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2144:                                if (!(cpu.z80E & 0x40))
        !          2145:                                {
        !          2146:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2147:                                }
        !          2148:                        break;
        !          2149:                }
        !          2150:                case 0x74:
        !          2151:                {
        !          2152:                        sdwCyclesRemaining -= 8;
        !          2153:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2154:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2155:                                if (!(cpu.z80H & 0x40))
        !          2156:                                {
        !          2157:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2158:                                }
        !          2159:                        break;
        !          2160:                }
        !          2161:                case 0x75:
        !          2162:                {
        !          2163:                        sdwCyclesRemaining -= 8;
        !          2164:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2165:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2166:                                if (!(cpu.z80L & 0x40))
        !          2167:                                {
        !          2168:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2169:                                }
        !          2170:                        break;
        !          2171:                }
        !          2172:                case 0x76:
        !          2173:                {
        !          2174:                        sdwCyclesRemaining -= 12;
        !          2175:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2176:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2177:                                {
        !          2178:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2179:                                        {
        !          2180:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2181:                                                if (psMemRead->memoryCall)
        !          2182:                                                {
        !          2183:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2184:                                                }
        !          2185:                                                else
        !          2186:                                                {
        !          2187:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2188:                                                }
        !          2189:                                                psMemRead = NULL;
        !          2190:                                                break;
        !          2191:                                        }
        !          2192:                                        ++psMemRead;
        !          2193:                                }
        !          2194: 
        !          2195:                                if (psMemRead)
        !          2196:                                {
        !          2197:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2198:                                }
        !          2199: 
        !          2200:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2201:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2202:                                if (!(bTemp & 0x40))
        !          2203:                                {
        !          2204:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2205:                                }
        !          2206:                        break;
        !          2207:                }
        !          2208:                case 0x77:
        !          2209:                {
        !          2210:                        sdwCyclesRemaining -= 8;
        !          2211:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2212:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2213:                                if (!(cpu.z80A & 0x40))
        !          2214:                                {
        !          2215:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2216:                                }
        !          2217:                        break;
        !          2218:                }
        !          2219:                case 0x78:
        !          2220:                {
        !          2221:                        sdwCyclesRemaining -= 8;
        !          2222:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2223:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2224:                                if (!(cpu.z80B & 0x80))
        !          2225:                                {
        !          2226:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2227:                                }
        !          2228:                        break;
        !          2229:                }
        !          2230:                case 0x79:
        !          2231:                {
        !          2232:                        sdwCyclesRemaining -= 8;
        !          2233:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2234:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2235:                                if (!(cpu.z80C & 0x80))
        !          2236:                                {
        !          2237:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2238:                                }
        !          2239:                        break;
        !          2240:                }
        !          2241:                case 0x7a:
        !          2242:                {
        !          2243:                        sdwCyclesRemaining -= 8;
        !          2244:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2245:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2246:                                if (!(cpu.z80D & 0x80))
        !          2247:                                {
        !          2248:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2249:                                }
        !          2250:                        break;
        !          2251:                }
        !          2252:                case 0x7b:
        !          2253:                {
        !          2254:                        sdwCyclesRemaining -= 8;
        !          2255:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2256:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2257:                                if (!(cpu.z80E & 0x80))
        !          2258:                                {
        !          2259:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2260:                                }
        !          2261:                        break;
        !          2262:                }
        !          2263:                case 0x7c:
        !          2264:                {
        !          2265:                        sdwCyclesRemaining -= 8;
        !          2266:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2267:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2268:                                if (!(cpu.z80H & 0x80))
        !          2269:                                {
        !          2270:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2271:                                }
        !          2272:                        break;
        !          2273:                }
        !          2274:                case 0x7d:
        !          2275:                {
        !          2276:                        sdwCyclesRemaining -= 8;
        !          2277:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2278:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2279:                                if (!(cpu.z80L & 0x80))
        !          2280:                                {
        !          2281:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2282:                                }
        !          2283:                        break;
        !          2284:                }
        !          2285:                case 0x7e:
        !          2286:                {
        !          2287:                        sdwCyclesRemaining -= 12;
        !          2288:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2289:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2290:                                {
        !          2291:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2292:                                        {
        !          2293:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2294:                                                if (psMemRead->memoryCall)
        !          2295:                                                {
        !          2296:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2297:                                                }
        !          2298:                                                else
        !          2299:                                                {
        !          2300:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2301:                                                }
        !          2302:                                                psMemRead = NULL;
        !          2303:                                                break;
        !          2304:                                        }
        !          2305:                                        ++psMemRead;
        !          2306:                                }
        !          2307: 
        !          2308:                                if (psMemRead)
        !          2309:                                {
        !          2310:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2311:                                }
        !          2312: 
        !          2313:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2314:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2315:                                if (!(bTemp & 0x80))
        !          2316:                                {
        !          2317:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2318:                                }
        !          2319:                        break;
        !          2320:                }
        !          2321:                case 0x7f:
        !          2322:                {
        !          2323:                        sdwCyclesRemaining -= 8;
        !          2324:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO);
        !          2325:                                cpu.z80F |= (Z80_FLAG_HALF_CARRY);
        !          2326:                                if (!(cpu.z80A & 0x80))
        !          2327:                                {
        !          2328:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          2329:                                }
        !          2330:                        break;
        !          2331:                }
        !          2332:                case 0x80:
        !          2333:                {
        !          2334:                        sdwCyclesRemaining -= 8;
        !          2335:                                cpu.z80B &= 0xfe;
        !          2336:                        break;
        !          2337:                }
        !          2338:                case 0x81:
        !          2339:                {
        !          2340:                        sdwCyclesRemaining -= 8;
        !          2341:                                cpu.z80C &= 0xfe;
        !          2342:                        break;
        !          2343:                }
        !          2344:                case 0x82:
        !          2345:                {
        !          2346:                        sdwCyclesRemaining -= 8;
        !          2347:                                cpu.z80D &= 0xfe;
        !          2348:                        break;
        !          2349:                }
        !          2350:                case 0x83:
        !          2351:                {
        !          2352:                        sdwCyclesRemaining -= 8;
        !          2353:                                cpu.z80E &= 0xfe;
        !          2354:                        break;
        !          2355:                }
        !          2356:                case 0x84:
        !          2357:                {
        !          2358:                        sdwCyclesRemaining -= 8;
        !          2359:                                cpu.z80H &= 0xfe;
        !          2360:                        break;
        !          2361:                }
        !          2362:                case 0x85:
        !          2363:                {
        !          2364:                        sdwCyclesRemaining -= 8;
        !          2365:                                cpu.z80L &= 0xfe;
        !          2366:                        break;
        !          2367:                }
        !          2368:                case 0x86:
        !          2369:                {
        !          2370:                        sdwCyclesRemaining -= 15;
        !          2371:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2372:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2373:                                {
        !          2374:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2375:                                        {
        !          2376:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2377:                                                if (psMemRead->memoryCall)
        !          2378:                                                {
        !          2379:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2380:                                                }
        !          2381:                                                else
        !          2382:                                                {
        !          2383:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2384:                                                }
        !          2385:                                                psMemRead = NULL;
        !          2386:                                                break;
        !          2387:                                        }
        !          2388:                                        ++psMemRead;
        !          2389:                                }
        !          2390: 
        !          2391:                                if (psMemRead)
        !          2392:                                {
        !          2393:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2394:                                }
        !          2395: 
        !          2396:                                bTemp &= 0xfe;
        !          2397:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          2398:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          2399:                                {
        !          2400:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          2401:                                        {
        !          2402:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2403:                                                if (psMemWrite->memoryCall)
        !          2404:                                                {
        !          2405:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          2406:                                                }
        !          2407:                                                else
        !          2408:                                                {
        !          2409:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          2410:                                                }
        !          2411:                                                psMemWrite = NULL;
        !          2412:                                                break;
        !          2413:                                        }
        !          2414:                                        ++psMemWrite;
        !          2415:                                }
        !          2416: 
        !          2417:                                if (psMemWrite)
        !          2418:                                {
        !          2419:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          2420:                                }
        !          2421: 
        !          2422:                        break;
        !          2423:                }
        !          2424:                case 0x87:
        !          2425:                {
        !          2426:                        sdwCyclesRemaining -= 8;
        !          2427:                                cpu.z80A &= 0xfe;
        !          2428:                        break;
        !          2429:                }
        !          2430:                case 0x88:
        !          2431:                {
        !          2432:                        sdwCyclesRemaining -= 8;
        !          2433:                                cpu.z80B &= 0xfd;
        !          2434:                        break;
        !          2435:                }
        !          2436:                case 0x89:
        !          2437:                {
        !          2438:                        sdwCyclesRemaining -= 8;
        !          2439:                                cpu.z80C &= 0xfd;
        !          2440:                        break;
        !          2441:                }
        !          2442:                case 0x8a:
        !          2443:                {
        !          2444:                        sdwCyclesRemaining -= 8;
        !          2445:                                cpu.z80D &= 0xfd;
        !          2446:                        break;
        !          2447:                }
        !          2448:                case 0x8b:
        !          2449:                {
        !          2450:                        sdwCyclesRemaining -= 8;
        !          2451:                                cpu.z80E &= 0xfd;
        !          2452:                        break;
        !          2453:                }
        !          2454:                case 0x8c:
        !          2455:                {
        !          2456:                        sdwCyclesRemaining -= 8;
        !          2457:                                cpu.z80H &= 0xfd;
        !          2458:                        break;
        !          2459:                }
        !          2460:                case 0x8d:
        !          2461:                {
        !          2462:                        sdwCyclesRemaining -= 8;
        !          2463:                                cpu.z80L &= 0xfd;
        !          2464:                        break;
        !          2465:                }
        !          2466:                case 0x8e:
        !          2467:                {
        !          2468:                        sdwCyclesRemaining -= 15;
        !          2469:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2470:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2471:                                {
        !          2472:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2473:                                        {
        !          2474:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2475:                                                if (psMemRead->memoryCall)
        !          2476:                                                {
        !          2477:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2478:                                                }
        !          2479:                                                else
        !          2480:                                                {
        !          2481:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2482:                                                }
        !          2483:                                                psMemRead = NULL;
        !          2484:                                                break;
        !          2485:                                        }
        !          2486:                                        ++psMemRead;
        !          2487:                                }
        !          2488: 
        !          2489:                                if (psMemRead)
        !          2490:                                {
        !          2491:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2492:                                }
        !          2493: 
        !          2494:                                bTemp &= 0xfd;
        !          2495:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          2496:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          2497:                                {
        !          2498:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          2499:                                        {
        !          2500:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2501:                                                if (psMemWrite->memoryCall)
        !          2502:                                                {
        !          2503:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          2504:                                                }
        !          2505:                                                else
        !          2506:                                                {
        !          2507:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          2508:                                                }
        !          2509:                                                psMemWrite = NULL;
        !          2510:                                                break;
        !          2511:                                        }
        !          2512:                                        ++psMemWrite;
        !          2513:                                }
        !          2514: 
        !          2515:                                if (psMemWrite)
        !          2516:                                {
        !          2517:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          2518:                                }
        !          2519: 
        !          2520:                        break;
        !          2521:                }
        !          2522:                case 0x8f:
        !          2523:                {
        !          2524:                        sdwCyclesRemaining -= 8;
        !          2525:                                cpu.z80A &= 0xfd;
        !          2526:                        break;
        !          2527:                }
        !          2528:                case 0x90:
        !          2529:                {
        !          2530:                        sdwCyclesRemaining -= 8;
        !          2531:                                cpu.z80B &= 0xfb;
        !          2532:                        break;
        !          2533:                }
        !          2534:                case 0x91:
        !          2535:                {
        !          2536:                        sdwCyclesRemaining -= 8;
        !          2537:                                cpu.z80C &= 0xfb;
        !          2538:                        break;
        !          2539:                }
        !          2540:                case 0x92:
        !          2541:                {
        !          2542:                        sdwCyclesRemaining -= 8;
        !          2543:                                cpu.z80D &= 0xfb;
        !          2544:                        break;
        !          2545:                }
        !          2546:                case 0x93:
        !          2547:                {
        !          2548:                        sdwCyclesRemaining -= 8;
        !          2549:                                cpu.z80E &= 0xfb;
        !          2550:                        break;
        !          2551:                }
        !          2552:                case 0x94:
        !          2553:                {
        !          2554:                        sdwCyclesRemaining -= 8;
        !          2555:                                cpu.z80H &= 0xfb;
        !          2556:                        break;
        !          2557:                }
        !          2558:                case 0x95:
        !          2559:                {
        !          2560:                        sdwCyclesRemaining -= 8;
        !          2561:                                cpu.z80L &= 0xfb;
        !          2562:                        break;
        !          2563:                }
        !          2564:                case 0x96:
        !          2565:                {
        !          2566:                        sdwCyclesRemaining -= 15;
        !          2567:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2568:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2569:                                {
        !          2570:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2571:                                        {
        !          2572:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2573:                                                if (psMemRead->memoryCall)
        !          2574:                                                {
        !          2575:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2576:                                                }
        !          2577:                                                else
        !          2578:                                                {
        !          2579:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2580:                                                }
        !          2581:                                                psMemRead = NULL;
        !          2582:                                                break;
        !          2583:                                        }
        !          2584:                                        ++psMemRead;
        !          2585:                                }
        !          2586: 
        !          2587:                                if (psMemRead)
        !          2588:                                {
        !          2589:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2590:                                }
        !          2591: 
        !          2592:                                bTemp &= 0xfb;
        !          2593:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          2594:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          2595:                                {
        !          2596:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          2597:                                        {
        !          2598:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2599:                                                if (psMemWrite->memoryCall)
        !          2600:                                                {
        !          2601:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          2602:                                                }
        !          2603:                                                else
        !          2604:                                                {
        !          2605:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          2606:                                                }
        !          2607:                                                psMemWrite = NULL;
        !          2608:                                                break;
        !          2609:                                        }
        !          2610:                                        ++psMemWrite;
        !          2611:                                }
        !          2612: 
        !          2613:                                if (psMemWrite)
        !          2614:                                {
        !          2615:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          2616:                                }
        !          2617: 
        !          2618:                        break;
        !          2619:                }
        !          2620:                case 0x97:
        !          2621:                {
        !          2622:                        sdwCyclesRemaining -= 8;
        !          2623:                                cpu.z80A &= 0xfb;
        !          2624:                        break;
        !          2625:                }
        !          2626:                case 0x98:
        !          2627:                {
        !          2628:                        sdwCyclesRemaining -= 8;
        !          2629:                                cpu.z80B &= 0xf7;
        !          2630:                        break;
        !          2631:                }
        !          2632:                case 0x99:
        !          2633:                {
        !          2634:                        sdwCyclesRemaining -= 8;
        !          2635:                                cpu.z80C &= 0xf7;
        !          2636:                        break;
        !          2637:                }
        !          2638:                case 0x9a:
        !          2639:                {
        !          2640:                        sdwCyclesRemaining -= 8;
        !          2641:                                cpu.z80D &= 0xf7;
        !          2642:                        break;
        !          2643:                }
        !          2644:                case 0x9b:
        !          2645:                {
        !          2646:                        sdwCyclesRemaining -= 8;
        !          2647:                                cpu.z80E &= 0xf7;
        !          2648:                        break;
        !          2649:                }
        !          2650:                case 0x9c:
        !          2651:                {
        !          2652:                        sdwCyclesRemaining -= 8;
        !          2653:                                cpu.z80H &= 0xf7;
        !          2654:                        break;
        !          2655:                }
        !          2656:                case 0x9d:
        !          2657:                {
        !          2658:                        sdwCyclesRemaining -= 8;
        !          2659:                                cpu.z80L &= 0xf7;
        !          2660:                        break;
        !          2661:                }
        !          2662:                case 0x9e:
        !          2663:                {
        !          2664:                        sdwCyclesRemaining -= 15;
        !          2665:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2666:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2667:                                {
        !          2668:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2669:                                        {
        !          2670:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2671:                                                if (psMemRead->memoryCall)
        !          2672:                                                {
        !          2673:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2674:                                                }
        !          2675:                                                else
        !          2676:                                                {
        !          2677:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2678:                                                }
        !          2679:                                                psMemRead = NULL;
        !          2680:                                                break;
        !          2681:                                        }
        !          2682:                                        ++psMemRead;
        !          2683:                                }
        !          2684: 
        !          2685:                                if (psMemRead)
        !          2686:                                {
        !          2687:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2688:                                }
        !          2689: 
        !          2690:                                bTemp &= 0xf7;
        !          2691:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          2692:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          2693:                                {
        !          2694:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          2695:                                        {
        !          2696:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2697:                                                if (psMemWrite->memoryCall)
        !          2698:                                                {
        !          2699:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          2700:                                                }
        !          2701:                                                else
        !          2702:                                                {
        !          2703:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          2704:                                                }
        !          2705:                                                psMemWrite = NULL;
        !          2706:                                                break;
        !          2707:                                        }
        !          2708:                                        ++psMemWrite;
        !          2709:                                }
        !          2710: 
        !          2711:                                if (psMemWrite)
        !          2712:                                {
        !          2713:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          2714:                                }
        !          2715: 
        !          2716:                        break;
        !          2717:                }
        !          2718:                case 0x9f:
        !          2719:                {
        !          2720:                        sdwCyclesRemaining -= 8;
        !          2721:                                cpu.z80A &= 0xf7;
        !          2722:                        break;
        !          2723:                }
        !          2724:                case 0xa0:
        !          2725:                {
        !          2726:                        sdwCyclesRemaining -= 8;
        !          2727:                                cpu.z80B &= 0xef;
        !          2728:                        break;
        !          2729:                }
        !          2730:                case 0xa1:
        !          2731:                {
        !          2732:                        sdwCyclesRemaining -= 8;
        !          2733:                                cpu.z80C &= 0xef;
        !          2734:                        break;
        !          2735:                }
        !          2736:                case 0xa2:
        !          2737:                {
        !          2738:                        sdwCyclesRemaining -= 8;
        !          2739:                                cpu.z80D &= 0xef;
        !          2740:                        break;
        !          2741:                }
        !          2742:                case 0xa3:
        !          2743:                {
        !          2744:                        sdwCyclesRemaining -= 8;
        !          2745:                                cpu.z80E &= 0xef;
        !          2746:                        break;
        !          2747:                }
        !          2748:                case 0xa4:
        !          2749:                {
        !          2750:                        sdwCyclesRemaining -= 8;
        !          2751:                                cpu.z80H &= 0xef;
        !          2752:                        break;
        !          2753:                }
        !          2754:                case 0xa5:
        !          2755:                {
        !          2756:                        sdwCyclesRemaining -= 8;
        !          2757:                                cpu.z80L &= 0xef;
        !          2758:                        break;
        !          2759:                }
        !          2760:                case 0xa6:
        !          2761:                {
        !          2762:                        sdwCyclesRemaining -= 15;
        !          2763:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2764:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2765:                                {
        !          2766:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2767:                                        {
        !          2768:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2769:                                                if (psMemRead->memoryCall)
        !          2770:                                                {
        !          2771:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2772:                                                }
        !          2773:                                                else
        !          2774:                                                {
        !          2775:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2776:                                                }
        !          2777:                                                psMemRead = NULL;
        !          2778:                                                break;
        !          2779:                                        }
        !          2780:                                        ++psMemRead;
        !          2781:                                }
        !          2782: 
        !          2783:                                if (psMemRead)
        !          2784:                                {
        !          2785:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2786:                                }
        !          2787: 
        !          2788:                                bTemp &= 0xef;
        !          2789:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          2790:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          2791:                                {
        !          2792:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          2793:                                        {
        !          2794:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2795:                                                if (psMemWrite->memoryCall)
        !          2796:                                                {
        !          2797:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          2798:                                                }
        !          2799:                                                else
        !          2800:                                                {
        !          2801:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          2802:                                                }
        !          2803:                                                psMemWrite = NULL;
        !          2804:                                                break;
        !          2805:                                        }
        !          2806:                                        ++psMemWrite;
        !          2807:                                }
        !          2808: 
        !          2809:                                if (psMemWrite)
        !          2810:                                {
        !          2811:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          2812:                                }
        !          2813: 
        !          2814:                        break;
        !          2815:                }
        !          2816:                case 0xa7:
        !          2817:                {
        !          2818:                        sdwCyclesRemaining -= 8;
        !          2819:                                cpu.z80A &= 0xef;
        !          2820:                        break;
        !          2821:                }
        !          2822:                case 0xa8:
        !          2823:                {
        !          2824:                        sdwCyclesRemaining -= 8;
        !          2825:                                cpu.z80B &= 0xdf;
        !          2826:                        break;
        !          2827:                }
        !          2828:                case 0xa9:
        !          2829:                {
        !          2830:                        sdwCyclesRemaining -= 8;
        !          2831:                                cpu.z80C &= 0xdf;
        !          2832:                        break;
        !          2833:                }
        !          2834:                case 0xaa:
        !          2835:                {
        !          2836:                        sdwCyclesRemaining -= 8;
        !          2837:                                cpu.z80D &= 0xdf;
        !          2838:                        break;
        !          2839:                }
        !          2840:                case 0xab:
        !          2841:                {
        !          2842:                        sdwCyclesRemaining -= 8;
        !          2843:                                cpu.z80E &= 0xdf;
        !          2844:                        break;
        !          2845:                }
        !          2846:                case 0xac:
        !          2847:                {
        !          2848:                        sdwCyclesRemaining -= 8;
        !          2849:                                cpu.z80H &= 0xdf;
        !          2850:                        break;
        !          2851:                }
        !          2852:                case 0xad:
        !          2853:                {
        !          2854:                        sdwCyclesRemaining -= 8;
        !          2855:                                cpu.z80L &= 0xdf;
        !          2856:                        break;
        !          2857:                }
        !          2858:                case 0xae:
        !          2859:                {
        !          2860:                        sdwCyclesRemaining -= 15;
        !          2861:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2862:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2863:                                {
        !          2864:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2865:                                        {
        !          2866:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2867:                                                if (psMemRead->memoryCall)
        !          2868:                                                {
        !          2869:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2870:                                                }
        !          2871:                                                else
        !          2872:                                                {
        !          2873:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2874:                                                }
        !          2875:                                                psMemRead = NULL;
        !          2876:                                                break;
        !          2877:                                        }
        !          2878:                                        ++psMemRead;
        !          2879:                                }
        !          2880: 
        !          2881:                                if (psMemRead)
        !          2882:                                {
        !          2883:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2884:                                }
        !          2885: 
        !          2886:                                bTemp &= 0xdf;
        !          2887:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          2888:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          2889:                                {
        !          2890:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          2891:                                        {
        !          2892:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2893:                                                if (psMemWrite->memoryCall)
        !          2894:                                                {
        !          2895:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          2896:                                                }
        !          2897:                                                else
        !          2898:                                                {
        !          2899:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          2900:                                                }
        !          2901:                                                psMemWrite = NULL;
        !          2902:                                                break;
        !          2903:                                        }
        !          2904:                                        ++psMemWrite;
        !          2905:                                }
        !          2906: 
        !          2907:                                if (psMemWrite)
        !          2908:                                {
        !          2909:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          2910:                                }
        !          2911: 
        !          2912:                        break;
        !          2913:                }
        !          2914:                case 0xaf:
        !          2915:                {
        !          2916:                        sdwCyclesRemaining -= 8;
        !          2917:                                cpu.z80A &= 0xdf;
        !          2918:                        break;
        !          2919:                }
        !          2920:                case 0xb0:
        !          2921:                {
        !          2922:                        sdwCyclesRemaining -= 8;
        !          2923:                                cpu.z80B &= 0xbf;
        !          2924:                        break;
        !          2925:                }
        !          2926:                case 0xb1:
        !          2927:                {
        !          2928:                        sdwCyclesRemaining -= 8;
        !          2929:                                cpu.z80C &= 0xbf;
        !          2930:                        break;
        !          2931:                }
        !          2932:                case 0xb2:
        !          2933:                {
        !          2934:                        sdwCyclesRemaining -= 8;
        !          2935:                                cpu.z80D &= 0xbf;
        !          2936:                        break;
        !          2937:                }
        !          2938:                case 0xb3:
        !          2939:                {
        !          2940:                        sdwCyclesRemaining -= 8;
        !          2941:                                cpu.z80E &= 0xbf;
        !          2942:                        break;
        !          2943:                }
        !          2944:                case 0xb4:
        !          2945:                {
        !          2946:                        sdwCyclesRemaining -= 8;
        !          2947:                                cpu.z80H &= 0xbf;
        !          2948:                        break;
        !          2949:                }
        !          2950:                case 0xb5:
        !          2951:                {
        !          2952:                        sdwCyclesRemaining -= 8;
        !          2953:                                cpu.z80L &= 0xbf;
        !          2954:                        break;
        !          2955:                }
        !          2956:                case 0xb6:
        !          2957:                {
        !          2958:                        sdwCyclesRemaining -= 15;
        !          2959:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          2960:                                while (psMemRead->lowAddr != 0xffffffff)
        !          2961:                                {
        !          2962:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          2963:                                        {
        !          2964:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2965:                                                if (psMemRead->memoryCall)
        !          2966:                                                {
        !          2967:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          2968:                                                }
        !          2969:                                                else
        !          2970:                                                {
        !          2971:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          2972:                                                }
        !          2973:                                                psMemRead = NULL;
        !          2974:                                                break;
        !          2975:                                        }
        !          2976:                                        ++psMemRead;
        !          2977:                                }
        !          2978: 
        !          2979:                                if (psMemRead)
        !          2980:                                {
        !          2981:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          2982:                                }
        !          2983: 
        !          2984:                                bTemp &= 0xbf;
        !          2985:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          2986:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          2987:                                {
        !          2988:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          2989:                                        {
        !          2990:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          2991:                                                if (psMemWrite->memoryCall)
        !          2992:                                                {
        !          2993:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          2994:                                                }
        !          2995:                                                else
        !          2996:                                                {
        !          2997:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          2998:                                                }
        !          2999:                                                psMemWrite = NULL;
        !          3000:                                                break;
        !          3001:                                        }
        !          3002:                                        ++psMemWrite;
        !          3003:                                }
        !          3004: 
        !          3005:                                if (psMemWrite)
        !          3006:                                {
        !          3007:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3008:                                }
        !          3009: 
        !          3010:                        break;
        !          3011:                }
        !          3012:                case 0xb7:
        !          3013:                {
        !          3014:                        sdwCyclesRemaining -= 8;
        !          3015:                                cpu.z80A &= 0xbf;
        !          3016:                        break;
        !          3017:                }
        !          3018:                case 0xb8:
        !          3019:                {
        !          3020:                        sdwCyclesRemaining -= 8;
        !          3021:                                cpu.z80B &= 0x7f;
        !          3022:                        break;
        !          3023:                }
        !          3024:                case 0xb9:
        !          3025:                {
        !          3026:                        sdwCyclesRemaining -= 8;
        !          3027:                                cpu.z80C &= 0x7f;
        !          3028:                        break;
        !          3029:                }
        !          3030:                case 0xba:
        !          3031:                {
        !          3032:                        sdwCyclesRemaining -= 8;
        !          3033:                                cpu.z80D &= 0x7f;
        !          3034:                        break;
        !          3035:                }
        !          3036:                case 0xbb:
        !          3037:                {
        !          3038:                        sdwCyclesRemaining -= 8;
        !          3039:                                cpu.z80E &= 0x7f;
        !          3040:                        break;
        !          3041:                }
        !          3042:                case 0xbc:
        !          3043:                {
        !          3044:                        sdwCyclesRemaining -= 8;
        !          3045:                                cpu.z80H &= 0x7f;
        !          3046:                        break;
        !          3047:                }
        !          3048:                case 0xbd:
        !          3049:                {
        !          3050:                        sdwCyclesRemaining -= 8;
        !          3051:                                cpu.z80L &= 0x7f;
        !          3052:                        break;
        !          3053:                }
        !          3054:                case 0xbe:
        !          3055:                {
        !          3056:                        sdwCyclesRemaining -= 15;
        !          3057:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3058:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3059:                                {
        !          3060:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3061:                                        {
        !          3062:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3063:                                                if (psMemRead->memoryCall)
        !          3064:                                                {
        !          3065:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3066:                                                }
        !          3067:                                                else
        !          3068:                                                {
        !          3069:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3070:                                                }
        !          3071:                                                psMemRead = NULL;
        !          3072:                                                break;
        !          3073:                                        }
        !          3074:                                        ++psMemRead;
        !          3075:                                }
        !          3076: 
        !          3077:                                if (psMemRead)
        !          3078:                                {
        !          3079:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3080:                                }
        !          3081: 
        !          3082:                                bTemp &= 0x7f;
        !          3083:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3084:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3085:                                {
        !          3086:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3087:                                        {
        !          3088:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3089:                                                if (psMemWrite->memoryCall)
        !          3090:                                                {
        !          3091:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3092:                                                }
        !          3093:                                                else
        !          3094:                                                {
        !          3095:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3096:                                                }
        !          3097:                                                psMemWrite = NULL;
        !          3098:                                                break;
        !          3099:                                        }
        !          3100:                                        ++psMemWrite;
        !          3101:                                }
        !          3102: 
        !          3103:                                if (psMemWrite)
        !          3104:                                {
        !          3105:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3106:                                }
        !          3107: 
        !          3108:                        break;
        !          3109:                }
        !          3110:                case 0xbf:
        !          3111:                {
        !          3112:                        sdwCyclesRemaining -= 8;
        !          3113:                                cpu.z80A &= 0x7f;
        !          3114:                        break;
        !          3115:                }
        !          3116:                case 0xc0:
        !          3117:                {
        !          3118:                        sdwCyclesRemaining -= 8;
        !          3119:                                cpu.z80B |= 0x01;
        !          3120:                        break;
        !          3121:                }
        !          3122:                case 0xc1:
        !          3123:                {
        !          3124:                        sdwCyclesRemaining -= 8;
        !          3125:                                cpu.z80C |= 0x01;
        !          3126:                        break;
        !          3127:                }
        !          3128:                case 0xc2:
        !          3129:                {
        !          3130:                        sdwCyclesRemaining -= 8;
        !          3131:                                cpu.z80D |= 0x01;
        !          3132:                        break;
        !          3133:                }
        !          3134:                case 0xc3:
        !          3135:                {
        !          3136:                        sdwCyclesRemaining -= 8;
        !          3137:                                cpu.z80E |= 0x01;
        !          3138:                        break;
        !          3139:                }
        !          3140:                case 0xc4:
        !          3141:                {
        !          3142:                        sdwCyclesRemaining -= 8;
        !          3143:                                cpu.z80H |= 0x01;
        !          3144:                        break;
        !          3145:                }
        !          3146:                case 0xc5:
        !          3147:                {
        !          3148:                        sdwCyclesRemaining -= 8;
        !          3149:                                cpu.z80L |= 0x01;
        !          3150:                        break;
        !          3151:                }
        !          3152:                case 0xc6:
        !          3153:                {
        !          3154:                        sdwCyclesRemaining -= 15;
        !          3155:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3156:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3157:                                {
        !          3158:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3159:                                        {
        !          3160:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3161:                                                if (psMemRead->memoryCall)
        !          3162:                                                {
        !          3163:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3164:                                                }
        !          3165:                                                else
        !          3166:                                                {
        !          3167:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3168:                                                }
        !          3169:                                                psMemRead = NULL;
        !          3170:                                                break;
        !          3171:                                        }
        !          3172:                                        ++psMemRead;
        !          3173:                                }
        !          3174: 
        !          3175:                                if (psMemRead)
        !          3176:                                {
        !          3177:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3178:                                }
        !          3179: 
        !          3180:                                bTemp |= 0x01;
        !          3181:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3182:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3183:                                {
        !          3184:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3185:                                        {
        !          3186:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3187:                                                if (psMemWrite->memoryCall)
        !          3188:                                                {
        !          3189:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3190:                                                }
        !          3191:                                                else
        !          3192:                                                {
        !          3193:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3194:                                                }
        !          3195:                                                psMemWrite = NULL;
        !          3196:                                                break;
        !          3197:                                        }
        !          3198:                                        ++psMemWrite;
        !          3199:                                }
        !          3200: 
        !          3201:                                if (psMemWrite)
        !          3202:                                {
        !          3203:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3204:                                }
        !          3205: 
        !          3206:                        break;
        !          3207:                }
        !          3208:                case 0xc7:
        !          3209:                {
        !          3210:                        sdwCyclesRemaining -= 8;
        !          3211:                                cpu.z80A |= 0x01;
        !          3212:                        break;
        !          3213:                }
        !          3214:                case 0xc8:
        !          3215:                {
        !          3216:                        sdwCyclesRemaining -= 8;
        !          3217:                                cpu.z80B |= 0x02;
        !          3218:                        break;
        !          3219:                }
        !          3220:                case 0xc9:
        !          3221:                {
        !          3222:                        sdwCyclesRemaining -= 8;
        !          3223:                                cpu.z80C |= 0x02;
        !          3224:                        break;
        !          3225:                }
        !          3226:                case 0xca:
        !          3227:                {
        !          3228:                        sdwCyclesRemaining -= 8;
        !          3229:                                cpu.z80D |= 0x02;
        !          3230:                        break;
        !          3231:                }
        !          3232:                case 0xcb:
        !          3233:                {
        !          3234:                        sdwCyclesRemaining -= 8;
        !          3235:                                cpu.z80E |= 0x02;
        !          3236:                        break;
        !          3237:                }
        !          3238:                case 0xcc:
        !          3239:                {
        !          3240:                        sdwCyclesRemaining -= 8;
        !          3241:                                cpu.z80H |= 0x02;
        !          3242:                        break;
        !          3243:                }
        !          3244:                case 0xcd:
        !          3245:                {
        !          3246:                        sdwCyclesRemaining -= 8;
        !          3247:                                cpu.z80L |= 0x02;
        !          3248:                        break;
        !          3249:                }
        !          3250:                case 0xce:
        !          3251:                {
        !          3252:                        sdwCyclesRemaining -= 15;
        !          3253:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3254:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3255:                                {
        !          3256:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3257:                                        {
        !          3258:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3259:                                                if (psMemRead->memoryCall)
        !          3260:                                                {
        !          3261:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3262:                                                }
        !          3263:                                                else
        !          3264:                                                {
        !          3265:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3266:                                                }
        !          3267:                                                psMemRead = NULL;
        !          3268:                                                break;
        !          3269:                                        }
        !          3270:                                        ++psMemRead;
        !          3271:                                }
        !          3272: 
        !          3273:                                if (psMemRead)
        !          3274:                                {
        !          3275:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3276:                                }
        !          3277: 
        !          3278:                                bTemp |= 0x02;
        !          3279:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3280:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3281:                                {
        !          3282:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3283:                                        {
        !          3284:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3285:                                                if (psMemWrite->memoryCall)
        !          3286:                                                {
        !          3287:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3288:                                                }
        !          3289:                                                else
        !          3290:                                                {
        !          3291:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3292:                                                }
        !          3293:                                                psMemWrite = NULL;
        !          3294:                                                break;
        !          3295:                                        }
        !          3296:                                        ++psMemWrite;
        !          3297:                                }
        !          3298: 
        !          3299:                                if (psMemWrite)
        !          3300:                                {
        !          3301:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3302:                                }
        !          3303: 
        !          3304:                        break;
        !          3305:                }
        !          3306:                case 0xcf:
        !          3307:                {
        !          3308:                        sdwCyclesRemaining -= 8;
        !          3309:                                cpu.z80A |= 0x02;
        !          3310:                        break;
        !          3311:                }
        !          3312:                case 0xd0:
        !          3313:                {
        !          3314:                        sdwCyclesRemaining -= 8;
        !          3315:                                cpu.z80B |= 0x04;
        !          3316:                        break;
        !          3317:                }
        !          3318:                case 0xd1:
        !          3319:                {
        !          3320:                        sdwCyclesRemaining -= 8;
        !          3321:                                cpu.z80C |= 0x04;
        !          3322:                        break;
        !          3323:                }
        !          3324:                case 0xd2:
        !          3325:                {
        !          3326:                        sdwCyclesRemaining -= 8;
        !          3327:                                cpu.z80D |= 0x04;
        !          3328:                        break;
        !          3329:                }
        !          3330:                case 0xd3:
        !          3331:                {
        !          3332:                        sdwCyclesRemaining -= 8;
        !          3333:                                cpu.z80E |= 0x04;
        !          3334:                        break;
        !          3335:                }
        !          3336:                case 0xd4:
        !          3337:                {
        !          3338:                        sdwCyclesRemaining -= 8;
        !          3339:                                cpu.z80H |= 0x04;
        !          3340:                        break;
        !          3341:                }
        !          3342:                case 0xd5:
        !          3343:                {
        !          3344:                        sdwCyclesRemaining -= 8;
        !          3345:                                cpu.z80L |= 0x04;
        !          3346:                        break;
        !          3347:                }
        !          3348:                case 0xd6:
        !          3349:                {
        !          3350:                        sdwCyclesRemaining -= 15;
        !          3351:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3352:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3353:                                {
        !          3354:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3355:                                        {
        !          3356:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3357:                                                if (psMemRead->memoryCall)
        !          3358:                                                {
        !          3359:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3360:                                                }
        !          3361:                                                else
        !          3362:                                                {
        !          3363:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3364:                                                }
        !          3365:                                                psMemRead = NULL;
        !          3366:                                                break;
        !          3367:                                        }
        !          3368:                                        ++psMemRead;
        !          3369:                                }
        !          3370: 
        !          3371:                                if (psMemRead)
        !          3372:                                {
        !          3373:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3374:                                }
        !          3375: 
        !          3376:                                bTemp |= 0x04;
        !          3377:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3378:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3379:                                {
        !          3380:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3381:                                        {
        !          3382:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3383:                                                if (psMemWrite->memoryCall)
        !          3384:                                                {
        !          3385:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3386:                                                }
        !          3387:                                                else
        !          3388:                                                {
        !          3389:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3390:                                                }
        !          3391:                                                psMemWrite = NULL;
        !          3392:                                                break;
        !          3393:                                        }
        !          3394:                                        ++psMemWrite;
        !          3395:                                }
        !          3396: 
        !          3397:                                if (psMemWrite)
        !          3398:                                {
        !          3399:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3400:                                }
        !          3401: 
        !          3402:                        break;
        !          3403:                }
        !          3404:                case 0xd7:
        !          3405:                {
        !          3406:                        sdwCyclesRemaining -= 8;
        !          3407:                                cpu.z80A |= 0x04;
        !          3408:                        break;
        !          3409:                }
        !          3410:                case 0xd8:
        !          3411:                {
        !          3412:                        sdwCyclesRemaining -= 8;
        !          3413:                                cpu.z80B |= 0x08;
        !          3414:                        break;
        !          3415:                }
        !          3416:                case 0xd9:
        !          3417:                {
        !          3418:                        sdwCyclesRemaining -= 8;
        !          3419:                                cpu.z80C |= 0x08;
        !          3420:                        break;
        !          3421:                }
        !          3422:                case 0xda:
        !          3423:                {
        !          3424:                        sdwCyclesRemaining -= 8;
        !          3425:                                cpu.z80D |= 0x08;
        !          3426:                        break;
        !          3427:                }
        !          3428:                case 0xdb:
        !          3429:                {
        !          3430:                        sdwCyclesRemaining -= 8;
        !          3431:                                cpu.z80E |= 0x08;
        !          3432:                        break;
        !          3433:                }
        !          3434:                case 0xdc:
        !          3435:                {
        !          3436:                        sdwCyclesRemaining -= 8;
        !          3437:                                cpu.z80H |= 0x08;
        !          3438:                        break;
        !          3439:                }
        !          3440:                case 0xdd:
        !          3441:                {
        !          3442:                        sdwCyclesRemaining -= 8;
        !          3443:                                cpu.z80L |= 0x08;
        !          3444:                        break;
        !          3445:                }
        !          3446:                case 0xde:
        !          3447:                {
        !          3448:                        sdwCyclesRemaining -= 15;
        !          3449:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3450:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3451:                                {
        !          3452:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3453:                                        {
        !          3454:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3455:                                                if (psMemRead->memoryCall)
        !          3456:                                                {
        !          3457:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3458:                                                }
        !          3459:                                                else
        !          3460:                                                {
        !          3461:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3462:                                                }
        !          3463:                                                psMemRead = NULL;
        !          3464:                                                break;
        !          3465:                                        }
        !          3466:                                        ++psMemRead;
        !          3467:                                }
        !          3468: 
        !          3469:                                if (psMemRead)
        !          3470:                                {
        !          3471:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3472:                                }
        !          3473: 
        !          3474:                                bTemp |= 0x08;
        !          3475:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3476:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3477:                                {
        !          3478:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3479:                                        {
        !          3480:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3481:                                                if (psMemWrite->memoryCall)
        !          3482:                                                {
        !          3483:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3484:                                                }
        !          3485:                                                else
        !          3486:                                                {
        !          3487:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3488:                                                }
        !          3489:                                                psMemWrite = NULL;
        !          3490:                                                break;
        !          3491:                                        }
        !          3492:                                        ++psMemWrite;
        !          3493:                                }
        !          3494: 
        !          3495:                                if (psMemWrite)
        !          3496:                                {
        !          3497:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3498:                                }
        !          3499: 
        !          3500:                        break;
        !          3501:                }
        !          3502:                case 0xdf:
        !          3503:                {
        !          3504:                        sdwCyclesRemaining -= 8;
        !          3505:                                cpu.z80A |= 0x08;
        !          3506:                        break;
        !          3507:                }
        !          3508:                case 0xe0:
        !          3509:                {
        !          3510:                        sdwCyclesRemaining -= 8;
        !          3511:                                cpu.z80B |= 0x10;
        !          3512:                        break;
        !          3513:                }
        !          3514:                case 0xe1:
        !          3515:                {
        !          3516:                        sdwCyclesRemaining -= 8;
        !          3517:                                cpu.z80C |= 0x10;
        !          3518:                        break;
        !          3519:                }
        !          3520:                case 0xe2:
        !          3521:                {
        !          3522:                        sdwCyclesRemaining -= 8;
        !          3523:                                cpu.z80D |= 0x10;
        !          3524:                        break;
        !          3525:                }
        !          3526:                case 0xe3:
        !          3527:                {
        !          3528:                        sdwCyclesRemaining -= 8;
        !          3529:                                cpu.z80E |= 0x10;
        !          3530:                        break;
        !          3531:                }
        !          3532:                case 0xe4:
        !          3533:                {
        !          3534:                        sdwCyclesRemaining -= 8;
        !          3535:                                cpu.z80H |= 0x10;
        !          3536:                        break;
        !          3537:                }
        !          3538:                case 0xe5:
        !          3539:                {
        !          3540:                        sdwCyclesRemaining -= 8;
        !          3541:                                cpu.z80L |= 0x10;
        !          3542:                        break;
        !          3543:                }
        !          3544:                case 0xe6:
        !          3545:                {
        !          3546:                        sdwCyclesRemaining -= 15;
        !          3547:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3548:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3549:                                {
        !          3550:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3551:                                        {
        !          3552:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3553:                                                if (psMemRead->memoryCall)
        !          3554:                                                {
        !          3555:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3556:                                                }
        !          3557:                                                else
        !          3558:                                                {
        !          3559:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3560:                                                }
        !          3561:                                                psMemRead = NULL;
        !          3562:                                                break;
        !          3563:                                        }
        !          3564:                                        ++psMemRead;
        !          3565:                                }
        !          3566: 
        !          3567:                                if (psMemRead)
        !          3568:                                {
        !          3569:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3570:                                }
        !          3571: 
        !          3572:                                bTemp |= 0x10;
        !          3573:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3574:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3575:                                {
        !          3576:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3577:                                        {
        !          3578:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3579:                                                if (psMemWrite->memoryCall)
        !          3580:                                                {
        !          3581:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3582:                                                }
        !          3583:                                                else
        !          3584:                                                {
        !          3585:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3586:                                                }
        !          3587:                                                psMemWrite = NULL;
        !          3588:                                                break;
        !          3589:                                        }
        !          3590:                                        ++psMemWrite;
        !          3591:                                }
        !          3592: 
        !          3593:                                if (psMemWrite)
        !          3594:                                {
        !          3595:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3596:                                }
        !          3597: 
        !          3598:                        break;
        !          3599:                }
        !          3600:                case 0xe7:
        !          3601:                {
        !          3602:                        sdwCyclesRemaining -= 8;
        !          3603:                                cpu.z80A |= 0x10;
        !          3604:                        break;
        !          3605:                }
        !          3606:                case 0xe8:
        !          3607:                {
        !          3608:                        sdwCyclesRemaining -= 8;
        !          3609:                                cpu.z80B |= 0x20;
        !          3610:                        break;
        !          3611:                }
        !          3612:                case 0xe9:
        !          3613:                {
        !          3614:                        sdwCyclesRemaining -= 8;
        !          3615:                                cpu.z80C |= 0x20;
        !          3616:                        break;
        !          3617:                }
        !          3618:                case 0xea:
        !          3619:                {
        !          3620:                        sdwCyclesRemaining -= 8;
        !          3621:                                cpu.z80D |= 0x20;
        !          3622:                        break;
        !          3623:                }
        !          3624:                case 0xeb:
        !          3625:                {
        !          3626:                        sdwCyclesRemaining -= 8;
        !          3627:                                cpu.z80E |= 0x20;
        !          3628:                        break;
        !          3629:                }
        !          3630:                case 0xec:
        !          3631:                {
        !          3632:                        sdwCyclesRemaining -= 8;
        !          3633:                                cpu.z80H |= 0x20;
        !          3634:                        break;
        !          3635:                }
        !          3636:                case 0xed:
        !          3637:                {
        !          3638:                        sdwCyclesRemaining -= 8;
        !          3639:                                cpu.z80L |= 0x20;
        !          3640:                        break;
        !          3641:                }
        !          3642:                case 0xee:
        !          3643:                {
        !          3644:                        sdwCyclesRemaining -= 15;
        !          3645:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3646:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3647:                                {
        !          3648:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3649:                                        {
        !          3650:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3651:                                                if (psMemRead->memoryCall)
        !          3652:                                                {
        !          3653:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3654:                                                }
        !          3655:                                                else
        !          3656:                                                {
        !          3657:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3658:                                                }
        !          3659:                                                psMemRead = NULL;
        !          3660:                                                break;
        !          3661:                                        }
        !          3662:                                        ++psMemRead;
        !          3663:                                }
        !          3664: 
        !          3665:                                if (psMemRead)
        !          3666:                                {
        !          3667:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3668:                                }
        !          3669: 
        !          3670:                                bTemp |= 0x20;
        !          3671:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3672:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3673:                                {
        !          3674:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3675:                                        {
        !          3676:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3677:                                                if (psMemWrite->memoryCall)
        !          3678:                                                {
        !          3679:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3680:                                                }
        !          3681:                                                else
        !          3682:                                                {
        !          3683:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3684:                                                }
        !          3685:                                                psMemWrite = NULL;
        !          3686:                                                break;
        !          3687:                                        }
        !          3688:                                        ++psMemWrite;
        !          3689:                                }
        !          3690: 
        !          3691:                                if (psMemWrite)
        !          3692:                                {
        !          3693:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3694:                                }
        !          3695: 
        !          3696:                        break;
        !          3697:                }
        !          3698:                case 0xef:
        !          3699:                {
        !          3700:                        sdwCyclesRemaining -= 8;
        !          3701:                                cpu.z80A |= 0x20;
        !          3702:                        break;
        !          3703:                }
        !          3704:                case 0xf0:
        !          3705:                {
        !          3706:                        sdwCyclesRemaining -= 8;
        !          3707:                                cpu.z80B |= 0x40;
        !          3708:                        break;
        !          3709:                }
        !          3710:                case 0xf1:
        !          3711:                {
        !          3712:                        sdwCyclesRemaining -= 8;
        !          3713:                                cpu.z80C |= 0x40;
        !          3714:                        break;
        !          3715:                }
        !          3716:                case 0xf2:
        !          3717:                {
        !          3718:                        sdwCyclesRemaining -= 8;
        !          3719:                                cpu.z80D |= 0x40;
        !          3720:                        break;
        !          3721:                }
        !          3722:                case 0xf3:
        !          3723:                {
        !          3724:                        sdwCyclesRemaining -= 8;
        !          3725:                                cpu.z80E |= 0x40;
        !          3726:                        break;
        !          3727:                }
        !          3728:                case 0xf4:
        !          3729:                {
        !          3730:                        sdwCyclesRemaining -= 8;
        !          3731:                                cpu.z80H |= 0x40;
        !          3732:                        break;
        !          3733:                }
        !          3734:                case 0xf5:
        !          3735:                {
        !          3736:                        sdwCyclesRemaining -= 8;
        !          3737:                                cpu.z80L |= 0x40;
        !          3738:                        break;
        !          3739:                }
        !          3740:                case 0xf6:
        !          3741:                {
        !          3742:                        sdwCyclesRemaining -= 15;
        !          3743:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3744:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3745:                                {
        !          3746:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3747:                                        {
        !          3748:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3749:                                                if (psMemRead->memoryCall)
        !          3750:                                                {
        !          3751:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3752:                                                }
        !          3753:                                                else
        !          3754:                                                {
        !          3755:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3756:                                                }
        !          3757:                                                psMemRead = NULL;
        !          3758:                                                break;
        !          3759:                                        }
        !          3760:                                        ++psMemRead;
        !          3761:                                }
        !          3762: 
        !          3763:                                if (psMemRead)
        !          3764:                                {
        !          3765:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3766:                                }
        !          3767: 
        !          3768:                                bTemp |= 0x40;
        !          3769:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3770:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3771:                                {
        !          3772:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3773:                                        {
        !          3774:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3775:                                                if (psMemWrite->memoryCall)
        !          3776:                                                {
        !          3777:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3778:                                                }
        !          3779:                                                else
        !          3780:                                                {
        !          3781:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3782:                                                }
        !          3783:                                                psMemWrite = NULL;
        !          3784:                                                break;
        !          3785:                                        }
        !          3786:                                        ++psMemWrite;
        !          3787:                                }
        !          3788: 
        !          3789:                                if (psMemWrite)
        !          3790:                                {
        !          3791:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3792:                                }
        !          3793: 
        !          3794:                        break;
        !          3795:                }
        !          3796:                case 0xf7:
        !          3797:                {
        !          3798:                        sdwCyclesRemaining -= 8;
        !          3799:                                cpu.z80A |= 0x40;
        !          3800:                        break;
        !          3801:                }
        !          3802:                case 0xf8:
        !          3803:                {
        !          3804:                        sdwCyclesRemaining -= 8;
        !          3805:                                cpu.z80B |= 0x80;
        !          3806:                        break;
        !          3807:                }
        !          3808:                case 0xf9:
        !          3809:                {
        !          3810:                        sdwCyclesRemaining -= 8;
        !          3811:                                cpu.z80C |= 0x80;
        !          3812:                        break;
        !          3813:                }
        !          3814:                case 0xfa:
        !          3815:                {
        !          3816:                        sdwCyclesRemaining -= 8;
        !          3817:                                cpu.z80D |= 0x80;
        !          3818:                        break;
        !          3819:                }
        !          3820:                case 0xfb:
        !          3821:                {
        !          3822:                        sdwCyclesRemaining -= 8;
        !          3823:                                cpu.z80E |= 0x80;
        !          3824:                        break;
        !          3825:                }
        !          3826:                case 0xfc:
        !          3827:                {
        !          3828:                        sdwCyclesRemaining -= 8;
        !          3829:                                cpu.z80H |= 0x80;
        !          3830:                        break;
        !          3831:                }
        !          3832:                case 0xfd:
        !          3833:                {
        !          3834:                        sdwCyclesRemaining -= 8;
        !          3835:                                cpu.z80L |= 0x80;
        !          3836:                        break;
        !          3837:                }
        !          3838:                case 0xfe:
        !          3839:                {
        !          3840:                        sdwCyclesRemaining -= 15;
        !          3841:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          3842:                                while (psMemRead->lowAddr != 0xffffffff)
        !          3843:                                {
        !          3844:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          3845:                                        {
        !          3846:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3847:                                                if (psMemRead->memoryCall)
        !          3848:                                                {
        !          3849:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          3850:                                                }
        !          3851:                                                else
        !          3852:                                                {
        !          3853:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          3854:                                                }
        !          3855:                                                psMemRead = NULL;
        !          3856:                                                break;
        !          3857:                                        }
        !          3858:                                        ++psMemRead;
        !          3859:                                }
        !          3860: 
        !          3861:                                if (psMemRead)
        !          3862:                                {
        !          3863:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          3864:                                }
        !          3865: 
        !          3866:                                bTemp |= 0x80;
        !          3867:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          3868:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          3869:                                {
        !          3870:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          3871:                                        {
        !          3872:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          3873:                                                if (psMemWrite->memoryCall)
        !          3874:                                                {
        !          3875:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          3876:                                                }
        !          3877:                                                else
        !          3878:                                                {
        !          3879:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          3880:                                                }
        !          3881:                                                psMemWrite = NULL;
        !          3882:                                                break;
        !          3883:                                        }
        !          3884:                                        ++psMemWrite;
        !          3885:                                }
        !          3886: 
        !          3887:                                if (psMemWrite)
        !          3888:                                {
        !          3889:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          3890:                                }
        !          3891: 
        !          3892:                        break;
        !          3893:                }
        !          3894:                case 0xff:
        !          3895:                {
        !          3896:                        sdwCyclesRemaining -= 8;
        !          3897:                                cpu.z80A |= 0x80;
        !          3898:                        break;
        !          3899:                }
        !          3900:        }
        !          3901: }
        !          3902: void EDHandler(void)
        !          3903: {
        !          3904:        switch (*pbPC++)
        !          3905:        {
        !          3906:                case 0x00:
        !          3907:                {
        !          3908:                                InvalidInstruction(2);
        !          3909:                        break;
        !          3910:                }
        !          3911:                case 0x01:
        !          3912:                {
        !          3913:                                InvalidInstruction(2);
        !          3914:                        break;
        !          3915:                }
        !          3916:                case 0x02:
        !          3917:                {
        !          3918:                                InvalidInstruction(2);
        !          3919:                        break;
        !          3920:                }
        !          3921:                case 0x03:
        !          3922:                {
        !          3923:                                InvalidInstruction(2);
        !          3924:                        break;
        !          3925:                }
        !          3926:                case 0x04:
        !          3927:                {
        !          3928:                                InvalidInstruction(2);
        !          3929:                        break;
        !          3930:                }
        !          3931:                case 0x05:
        !          3932:                {
        !          3933:                                InvalidInstruction(2);
        !          3934:                        break;
        !          3935:                }
        !          3936:                case 0x06:
        !          3937:                {
        !          3938:                                InvalidInstruction(2);
        !          3939:                        break;
        !          3940:                }
        !          3941:                case 0x07:
        !          3942:                {
        !          3943:                                InvalidInstruction(2);
        !          3944:                        break;
        !          3945:                }
        !          3946:                case 0x08:
        !          3947:                {
        !          3948:                                InvalidInstruction(2);
        !          3949:                        break;
        !          3950:                }
        !          3951:                case 0x09:
        !          3952:                {
        !          3953:                                InvalidInstruction(2);
        !          3954:                        break;
        !          3955:                }
        !          3956:                case 0x0a:
        !          3957:                {
        !          3958:                                InvalidInstruction(2);
        !          3959:                        break;
        !          3960:                }
        !          3961:                case 0x0b:
        !          3962:                {
        !          3963:                                InvalidInstruction(2);
        !          3964:                        break;
        !          3965:                }
        !          3966:                case 0x0c:
        !          3967:                {
        !          3968:                                InvalidInstruction(2);
        !          3969:                        break;
        !          3970:                }
        !          3971:                case 0x0d:
        !          3972:                {
        !          3973:                                InvalidInstruction(2);
        !          3974:                        break;
        !          3975:                }
        !          3976:                case 0x0e:
        !          3977:                {
        !          3978:                                InvalidInstruction(2);
        !          3979:                        break;
        !          3980:                }
        !          3981:                case 0x0f:
        !          3982:                {
        !          3983:                                InvalidInstruction(2);
        !          3984:                        break;
        !          3985:                }
        !          3986:                case 0x10:
        !          3987:                {
        !          3988:                                InvalidInstruction(2);
        !          3989:                        break;
        !          3990:                }
        !          3991:                case 0x11:
        !          3992:                {
        !          3993:                                InvalidInstruction(2);
        !          3994:                        break;
        !          3995:                }
        !          3996:                case 0x12:
        !          3997:                {
        !          3998:                                InvalidInstruction(2);
        !          3999:                        break;
        !          4000:                }
        !          4001:                case 0x13:
        !          4002:                {
        !          4003:                                InvalidInstruction(2);
        !          4004:                        break;
        !          4005:                }
        !          4006:                case 0x14:
        !          4007:                {
        !          4008:                                InvalidInstruction(2);
        !          4009:                        break;
        !          4010:                }
        !          4011:                case 0x15:
        !          4012:                {
        !          4013:                                InvalidInstruction(2);
        !          4014:                        break;
        !          4015:                }
        !          4016:                case 0x16:
        !          4017:                {
        !          4018:                                InvalidInstruction(2);
        !          4019:                        break;
        !          4020:                }
        !          4021:                case 0x17:
        !          4022:                {
        !          4023:                                InvalidInstruction(2);
        !          4024:                        break;
        !          4025:                }
        !          4026:                case 0x18:
        !          4027:                {
        !          4028:                                InvalidInstruction(2);
        !          4029:                        break;
        !          4030:                }
        !          4031:                case 0x19:
        !          4032:                {
        !          4033:                                InvalidInstruction(2);
        !          4034:                        break;
        !          4035:                }
        !          4036:                case 0x1a:
        !          4037:                {
        !          4038:                                InvalidInstruction(2);
        !          4039:                        break;
        !          4040:                }
        !          4041:                case 0x1b:
        !          4042:                {
        !          4043:                                InvalidInstruction(2);
        !          4044:                        break;
        !          4045:                }
        !          4046:                case 0x1c:
        !          4047:                {
        !          4048:                                InvalidInstruction(2);
        !          4049:                        break;
        !          4050:                }
        !          4051:                case 0x1d:
        !          4052:                {
        !          4053:                                InvalidInstruction(2);
        !          4054:                        break;
        !          4055:                }
        !          4056:                case 0x1e:
        !          4057:                {
        !          4058:                                InvalidInstruction(2);
        !          4059:                        break;
        !          4060:                }
        !          4061:                case 0x1f:
        !          4062:                {
        !          4063:                                InvalidInstruction(2);
        !          4064:                        break;
        !          4065:                }
        !          4066:                case 0x20:
        !          4067:                {
        !          4068:                                InvalidInstruction(2);
        !          4069:                        break;
        !          4070:                }
        !          4071:                case 0x21:
        !          4072:                {
        !          4073:                                InvalidInstruction(2);
        !          4074:                        break;
        !          4075:                }
        !          4076:                case 0x22:
        !          4077:                {
        !          4078:                                InvalidInstruction(2);
        !          4079:                        break;
        !          4080:                }
        !          4081:                case 0x23:
        !          4082:                {
        !          4083:                                InvalidInstruction(2);
        !          4084:                        break;
        !          4085:                }
        !          4086:                case 0x24:
        !          4087:                {
        !          4088:                                InvalidInstruction(2);
        !          4089:                        break;
        !          4090:                }
        !          4091:                case 0x25:
        !          4092:                {
        !          4093:                                InvalidInstruction(2);
        !          4094:                        break;
        !          4095:                }
        !          4096:                case 0x26:
        !          4097:                {
        !          4098:                                InvalidInstruction(2);
        !          4099:                        break;
        !          4100:                }
        !          4101:                case 0x27:
        !          4102:                {
        !          4103:                                InvalidInstruction(2);
        !          4104:                        break;
        !          4105:                }
        !          4106:                case 0x28:
        !          4107:                {
        !          4108:                                InvalidInstruction(2);
        !          4109:                        break;
        !          4110:                }
        !          4111:                case 0x29:
        !          4112:                {
        !          4113:                                InvalidInstruction(2);
        !          4114:                        break;
        !          4115:                }
        !          4116:                case 0x2a:
        !          4117:                {
        !          4118:                                InvalidInstruction(2);
        !          4119:                        break;
        !          4120:                }
        !          4121:                case 0x2b:
        !          4122:                {
        !          4123:                                InvalidInstruction(2);
        !          4124:                        break;
        !          4125:                }
        !          4126:                case 0x2c:
        !          4127:                {
        !          4128:                                InvalidInstruction(2);
        !          4129:                        break;
        !          4130:                }
        !          4131:                case 0x2d:
        !          4132:                {
        !          4133:                                InvalidInstruction(2);
        !          4134:                        break;
        !          4135:                }
        !          4136:                case 0x2e:
        !          4137:                {
        !          4138:                                InvalidInstruction(2);
        !          4139:                        break;
        !          4140:                }
        !          4141:                case 0x2f:
        !          4142:                {
        !          4143:                                InvalidInstruction(2);
        !          4144:                        break;
        !          4145:                }
        !          4146:                case 0x30:
        !          4147:                {
        !          4148:                                InvalidInstruction(2);
        !          4149:                        break;
        !          4150:                }
        !          4151:                case 0x31:
        !          4152:                {
        !          4153:                                InvalidInstruction(2);
        !          4154:                        break;
        !          4155:                }
        !          4156:                case 0x32:
        !          4157:                {
        !          4158:                                InvalidInstruction(2);
        !          4159:                        break;
        !          4160:                }
        !          4161:                case 0x33:
        !          4162:                {
        !          4163:                                InvalidInstruction(2);
        !          4164:                        break;
        !          4165:                }
        !          4166:                case 0x34:
        !          4167:                {
        !          4168:                                InvalidInstruction(2);
        !          4169:                        break;
        !          4170:                }
        !          4171:                case 0x35:
        !          4172:                {
        !          4173:                                InvalidInstruction(2);
        !          4174:                        break;
        !          4175:                }
        !          4176:                case 0x36:
        !          4177:                {
        !          4178:                                InvalidInstruction(2);
        !          4179:                        break;
        !          4180:                }
        !          4181:                case 0x37:
        !          4182:                {
        !          4183:                                InvalidInstruction(2);
        !          4184:                        break;
        !          4185:                }
        !          4186:                case 0x38:
        !          4187:                {
        !          4188:                                InvalidInstruction(2);
        !          4189:                        break;
        !          4190:                }
        !          4191:                case 0x39:
        !          4192:                {
        !          4193:                                InvalidInstruction(2);
        !          4194:                        break;
        !          4195:                }
        !          4196:                case 0x3a:
        !          4197:                {
        !          4198:                                InvalidInstruction(2);
        !          4199:                        break;
        !          4200:                }
        !          4201:                case 0x3b:
        !          4202:                {
        !          4203:                                InvalidInstruction(2);
        !          4204:                        break;
        !          4205:                }
        !          4206:                case 0x3c:
        !          4207:                {
        !          4208:                                InvalidInstruction(2);
        !          4209:                        break;
        !          4210:                }
        !          4211:                case 0x3d:
        !          4212:                {
        !          4213:                                InvalidInstruction(2);
        !          4214:                        break;
        !          4215:                }
        !          4216:                case 0x3e:
        !          4217:                {
        !          4218:                                InvalidInstruction(2);
        !          4219:                        break;
        !          4220:                }
        !          4221:                case 0x3f:
        !          4222:                {
        !          4223:                                InvalidInstruction(2);
        !          4224:                        break;
        !          4225:                }
        !          4226:                case 0x40:
        !          4227:                {
        !          4228:                        sdwCyclesRemaining -= 12;
        !          4229:                                dwAddr = cpu.z80C;
        !          4230:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          4231:                                while (psIoRead->lowIoAddr != 0xffff)
        !          4232:                                {
        !          4233:                                        if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
        !          4234:                                        {
        !          4235:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4236:                                                cpu.z80B = psIoRead->IOCall(dwAddr, psIoRead);
        !          4237:                                                psIoRead = NULL;
        !          4238:                                                break;
        !          4239:                                        }
        !          4240:                                        ++psIoRead;
        !          4241:                                }
        !          4242: 
        !          4243:                                if (psIoRead)
        !          4244:                                {
        !          4245:                                        cpu.z80B = 0xff; /* Unclaimed I/O read */
        !          4246:                                }
        !          4247: 
        !          4248:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          4249:                                cpu.z80F |= bPostORFlags[cpu.z80B];
        !          4250:                        break;
        !          4251:                }
        !          4252:                case 0x41:
        !          4253:                {
        !          4254:                        sdwCyclesRemaining -= 12;
        !          4255:                                dwAddr = cpu.z80C;
        !          4256:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          4257:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          4258:                                {
        !          4259:                                        if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
        !          4260:                                        {
        !          4261:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4262:                                                psIoWrite->IOCall(dwAddr, cpu.z80B, psIoWrite);
        !          4263:                                                psIoWrite = NULL;
        !          4264:                                                break;
        !          4265:                                        }
        !          4266:                                        ++psIoWrite;
        !          4267:                                }
        !          4268: 
        !          4269:                        break;
        !          4270:                }
        !          4271:                case 0x42:
        !          4272:                {
        !          4273:                        sdwCyclesRemaining -= 15;
        !          4274:                                dwTemp = cpu.z80HL - cpu.z80BC - (cpu.z80F & Z80_FLAG_CARRY);
        !          4275:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          4276:                                cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
        !          4277:                                if (0 == (dwTemp & 0xffff))
        !          4278:                                {
        !          4279:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          4280:                                }
        !          4281:                                cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
        !          4282:                                cpu.z80F |= ((((cpu.z80BC ^ cpu.z80HL) & (cpu.z80BC ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
        !          4283:                                cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
        !          4284:                                cpu.z80HL = dwTemp & 0xffff;
        !          4285:                        break;
        !          4286:                }
        !          4287:                case 0x43:
        !          4288:                {
        !          4289:                        sdwCyclesRemaining -= 20;
        !          4290:                dwTemp = *pbPC++;
        !          4291:                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          4292:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          4293:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          4294:                                {
        !          4295:                                        if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
        !          4296:                                        {
        !          4297:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4298:                                                if (psMemWrite->memoryCall)
        !          4299:                                                {
        !          4300:                                                        psMemWrite->memoryCall(dwTemp, (cpu.z80BC & 0xff), psMemWrite);
        !          4301:                                                        psMemWrite->memoryCall(dwTemp + 1, (cpu.z80BC >> 8), psMemWrite);
        !          4302:                                                }
        !          4303:                                                else
        !          4304:                                                {
        !          4305:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80BC;
        !          4306:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80BC >> 8;
        !          4307:                                                }
        !          4308:                                                psMemWrite = NULL;
        !          4309:                                                break;
        !          4310:                                        }
        !          4311:                                        ++psMemWrite;
        !          4312:                                }
        !          4313: 
        !          4314:                                if (psMemWrite)
        !          4315:                                {
        !          4316:                                        cpu.z80Base[dwTemp] = (UINT8) cpu.z80BC;
        !          4317:                                        cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80BC >> 8);
        !          4318:                                }
        !          4319: 
        !          4320:                        break;
        !          4321:                }
        !          4322:                case 0x44:
        !          4323:                {
        !          4324:                        sdwCyclesRemaining -= 8;
        !          4325:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          4326:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          4327:                                                                pbSubSbcTable[((UINT32) 0 << 8) | cpu.z80A];
        !          4328:                                cpu.z80A = 0 - cpu.z80A;
        !          4329:                        break;
        !          4330:                }
        !          4331:                case 0x45:
        !          4332:                {
        !          4333:                        sdwCyclesRemaining -= 14;
        !          4334:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          4335:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          4336:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          4337:                                cpu.z80sp += 2; /* Pop the word off */
        !          4338:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          4339:                                cpu.z80iff &= ~(IFF1);  /* Keep IFF2 around */
        !          4340:                                cpu.z80iff |= ((cpu.z80iff >> 1) & IFF1);       /* IFF2->IFF1 */
        !          4341:                        break;
        !          4342:                }
        !          4343:                case 0x46:
        !          4344:                {
        !          4345:                        sdwCyclesRemaining -= 8;
        !          4346:                                cpu.z80interruptMode = 0;
        !          4347:                        break;
        !          4348:                }
        !          4349:                case 0x47:
        !          4350:                {
        !          4351:                        sdwCyclesRemaining -= 9;
        !          4352:                                cpu.z80i = cpu.z80A;
        !          4353:                        break;
        !          4354:                }
        !          4355:                case 0x48:
        !          4356:                {
        !          4357:                        sdwCyclesRemaining -= 12;
        !          4358:                                dwAddr = cpu.z80C;
        !          4359:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          4360:                                while (psIoRead->lowIoAddr != 0xffff)
        !          4361:                                {
        !          4362:                                        if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
        !          4363:                                        {
        !          4364:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4365:                                                cpu.z80C = psIoRead->IOCall(dwAddr, psIoRead);
        !          4366:                                                psIoRead = NULL;
        !          4367:                                                break;
        !          4368:                                        }
        !          4369:                                        ++psIoRead;
        !          4370:                                }
        !          4371: 
        !          4372:                                if (psIoRead)
        !          4373:                                {
        !          4374:                                        cpu.z80C = 0xff; /* Unclaimed I/O read */
        !          4375:                                }
        !          4376: 
        !          4377:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          4378:                                cpu.z80F |= bPostORFlags[cpu.z80C];
        !          4379:                        break;
        !          4380:                }
        !          4381:                case 0x49:
        !          4382:                {
        !          4383:                        sdwCyclesRemaining -= 12;
        !          4384:                                dwAddr = cpu.z80C;
        !          4385:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          4386:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          4387:                                {
        !          4388:                                        if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
        !          4389:                                        {
        !          4390:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4391:                                                psIoWrite->IOCall(dwAddr, cpu.z80C, psIoWrite);
        !          4392:                                                psIoWrite = NULL;
        !          4393:                                                break;
        !          4394:                                        }
        !          4395:                                        ++psIoWrite;
        !          4396:                                }
        !          4397: 
        !          4398:                        break;
        !          4399:                }
        !          4400:                case 0x4a:
        !          4401:                {
        !          4402:                        sdwCyclesRemaining -= 15;
        !          4403:                                dwTemp = cpu.z80HL + cpu.z80BC + (cpu.z80F & Z80_FLAG_CARRY);
        !          4404:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          4405:                                cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
        !          4406:                                if (0 == (dwTemp & 0xffff))
        !          4407:                                {
        !          4408:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          4409:                                }
        !          4410:                                cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
        !          4411:                                cpu.z80F |= ((((cpu.z80BC ^ cpu.z80HL ^ 0x8000) & (cpu.z80BC ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
        !          4412:                                cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
        !          4413:                                cpu.z80HL = dwTemp & 0xffff;
        !          4414:                        break;
        !          4415:                }
        !          4416:                case 0x4b:
        !          4417:                {
        !          4418:                        sdwCyclesRemaining -= 20;
        !          4419:                dwTemp = *pbPC++;
        !          4420:                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          4421:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          4422:                                while (psMemRead->lowAddr != 0xffffffff)
        !          4423:                                {
        !          4424:                                        if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr))
        !          4425:                                        {
        !          4426:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4427:                                                if (psMemRead->memoryCall)
        !          4428:                                                {
        !          4429:                                                        cpu.z80BC = psMemRead->memoryCall(dwTemp, psMemRead);
        !          4430:                                                        cpu.z80BC |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8);
        !          4431:                                                }
        !          4432:                                                else
        !          4433:                                                {
        !          4434:                                                        cpu.z80BC = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr));
        !          4435:                                                        cpu.z80BC |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8);
        !          4436:                                                }
        !          4437:                                                psMemRead = NULL;
        !          4438:                                                break;
        !          4439:                                        }
        !          4440:                                        ++psMemRead;
        !          4441:                                }
        !          4442: 
        !          4443:                                if (psMemRead)
        !          4444:                                {
        !          4445:                                        cpu.z80BC = cpu.z80Base[dwTemp];
        !          4446:                                        cpu.z80BC |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8);
        !          4447:                                }
        !          4448: 
        !          4449:                        break;
        !          4450:                }
        !          4451:                case 0x4c:
        !          4452:                {
        !          4453:                        sdwCyclesRemaining -= 8;
        !          4454:                                InvalidInstruction(2);
        !          4455:                        break;
        !          4456:                }
        !          4457:                case 0x4d:
        !          4458:                {
        !          4459:                        sdwCyclesRemaining -= 14;
        !          4460:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          4461:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          4462:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          4463:                                cpu.z80sp += 2; /* Pop the word off */
        !          4464:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          4465:                        break;
        !          4466:                }
        !          4467:                case 0x4e:
        !          4468:                {
        !          4469:                        sdwCyclesRemaining -= 8;
        !          4470:                                InvalidInstruction(2);
        !          4471:                        break;
        !          4472:                }
        !          4473:                case 0x4f:
        !          4474:                {
        !          4475:                        sdwCyclesRemaining -= 9;
        !          4476:                                cpu.z80r = cpu.z80A;
        !          4477:                        break;
        !          4478:                }
        !          4479:                case 0x50:
        !          4480:                {
        !          4481:                        sdwCyclesRemaining -= 12;
        !          4482:                                dwAddr = cpu.z80C;
        !          4483:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          4484:                                while (psIoRead->lowIoAddr != 0xffff)
        !          4485:                                {
        !          4486:                                        if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
        !          4487:                                        {
        !          4488:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4489:                                                cpu.z80D = psIoRead->IOCall(dwAddr, psIoRead);
        !          4490:                                                psIoRead = NULL;
        !          4491:                                                break;
        !          4492:                                        }
        !          4493:                                        ++psIoRead;
        !          4494:                                }
        !          4495: 
        !          4496:                                if (psIoRead)
        !          4497:                                {
        !          4498:                                        cpu.z80D = 0xff; /* Unclaimed I/O read */
        !          4499:                                }
        !          4500: 
        !          4501:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          4502:                                cpu.z80F |= bPostORFlags[cpu.z80D];
        !          4503:                        break;
        !          4504:                }
        !          4505:                case 0x51:
        !          4506:                {
        !          4507:                        sdwCyclesRemaining -= 12;
        !          4508:                                dwAddr = cpu.z80C;
        !          4509:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          4510:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          4511:                                {
        !          4512:                                        if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
        !          4513:                                        {
        !          4514:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4515:                                                psIoWrite->IOCall(dwAddr, cpu.z80D, psIoWrite);
        !          4516:                                                psIoWrite = NULL;
        !          4517:                                                break;
        !          4518:                                        }
        !          4519:                                        ++psIoWrite;
        !          4520:                                }
        !          4521: 
        !          4522:                        break;
        !          4523:                }
        !          4524:                case 0x52:
        !          4525:                {
        !          4526:                        sdwCyclesRemaining -= 15;
        !          4527:                                dwTemp = cpu.z80HL - cpu.z80DE - (cpu.z80F & Z80_FLAG_CARRY);
        !          4528:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          4529:                                cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
        !          4530:                                if (0 == (dwTemp & 0xffff))
        !          4531:                                {
        !          4532:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          4533:                                }
        !          4534:                                cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
        !          4535:                                cpu.z80F |= ((((cpu.z80DE ^ cpu.z80HL) & (cpu.z80DE ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
        !          4536:                                cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
        !          4537:                                cpu.z80HL = dwTemp & 0xffff;
        !          4538:                        break;
        !          4539:                }
        !          4540:                case 0x53:
        !          4541:                {
        !          4542:                        sdwCyclesRemaining -= 20;
        !          4543:                dwTemp = *pbPC++;
        !          4544:                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          4545:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          4546:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          4547:                                {
        !          4548:                                        if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
        !          4549:                                        {
        !          4550:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4551:                                                if (psMemWrite->memoryCall)
        !          4552:                                                {
        !          4553:                                                        psMemWrite->memoryCall(dwTemp, (cpu.z80DE & 0xff), psMemWrite);
        !          4554:                                                        psMemWrite->memoryCall(dwTemp + 1, (cpu.z80DE >> 8), psMemWrite);
        !          4555:                                                }
        !          4556:                                                else
        !          4557:                                                {
        !          4558:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80DE;
        !          4559:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80DE >> 8;
        !          4560:                                                }
        !          4561:                                                psMemWrite = NULL;
        !          4562:                                                break;
        !          4563:                                        }
        !          4564:                                        ++psMemWrite;
        !          4565:                                }
        !          4566: 
        !          4567:                                if (psMemWrite)
        !          4568:                                {
        !          4569:                                        cpu.z80Base[dwTemp] = (UINT8) cpu.z80DE;
        !          4570:                                        cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80DE >> 8);
        !          4571:                                }
        !          4572: 
        !          4573:                        break;
        !          4574:                }
        !          4575:                case 0x54:
        !          4576:                {
        !          4577:                        sdwCyclesRemaining -= 8;
        !          4578:                                InvalidInstruction(2);
        !          4579:                        break;
        !          4580:                }
        !          4581:                case 0x55:
        !          4582:                {
        !          4583:                        sdwCyclesRemaining -= 8;
        !          4584:                                InvalidInstruction(2);
        !          4585:                        break;
        !          4586:                }
        !          4587:                case 0x56:
        !          4588:                {
        !          4589:                        sdwCyclesRemaining -= 8;
        !          4590:                                cpu.z80interruptMode = 1;
        !          4591:                                cpu.z80intAddr = 0x38;
        !          4592:                        break;
        !          4593:                }
        !          4594:                case 0x57:
        !          4595:                {
        !          4596:                        sdwCyclesRemaining -= 9;
        !          4597:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          4598:                                cpu.z80F |= ((cpu.z80iff & IFF2) << 1);
        !          4599:                                cpu.z80A = cpu.z80i;
        !          4600:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          4601:                        break;
        !          4602:                }
        !          4603:                case 0x58:
        !          4604:                {
        !          4605:                        sdwCyclesRemaining -= 12;
        !          4606:                                dwAddr = cpu.z80C;
        !          4607:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          4608:                                while (psIoRead->lowIoAddr != 0xffff)
        !          4609:                                {
        !          4610:                                        if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
        !          4611:                                        {
        !          4612:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4613:                                                cpu.z80E = psIoRead->IOCall(dwAddr, psIoRead);
        !          4614:                                                psIoRead = NULL;
        !          4615:                                                break;
        !          4616:                                        }
        !          4617:                                        ++psIoRead;
        !          4618:                                }
        !          4619: 
        !          4620:                                if (psIoRead)
        !          4621:                                {
        !          4622:                                        cpu.z80E = 0xff; /* Unclaimed I/O read */
        !          4623:                                }
        !          4624: 
        !          4625:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          4626:                                cpu.z80F |= bPostORFlags[cpu.z80E];
        !          4627:                        break;
        !          4628:                }
        !          4629:                case 0x59:
        !          4630:                {
        !          4631:                        sdwCyclesRemaining -= 12;
        !          4632:                                dwAddr = cpu.z80C;
        !          4633:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          4634:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          4635:                                {
        !          4636:                                        if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
        !          4637:                                        {
        !          4638:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4639:                                                psIoWrite->IOCall(dwAddr, cpu.z80E, psIoWrite);
        !          4640:                                                psIoWrite = NULL;
        !          4641:                                                break;
        !          4642:                                        }
        !          4643:                                        ++psIoWrite;
        !          4644:                                }
        !          4645: 
        !          4646:                        break;
        !          4647:                }
        !          4648:                case 0x5a:
        !          4649:                {
        !          4650:                        sdwCyclesRemaining -= 15;
        !          4651:                                dwTemp = cpu.z80HL + cpu.z80DE + (cpu.z80F & Z80_FLAG_CARRY);
        !          4652:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          4653:                                cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
        !          4654:                                if (0 == (dwTemp & 0xffff))
        !          4655:                                {
        !          4656:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          4657:                                }
        !          4658:                                cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
        !          4659:                                cpu.z80F |= ((((cpu.z80DE ^ cpu.z80HL ^ 0x8000) & (cpu.z80DE ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
        !          4660:                                cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
        !          4661:                                cpu.z80HL = dwTemp & 0xffff;
        !          4662:                        break;
        !          4663:                }
        !          4664:                case 0x5b:
        !          4665:                {
        !          4666:                        sdwCyclesRemaining -= 20;
        !          4667:                dwTemp = *pbPC++;
        !          4668:                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          4669:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          4670:                                while (psMemRead->lowAddr != 0xffffffff)
        !          4671:                                {
        !          4672:                                        if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr))
        !          4673:                                        {
        !          4674:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4675:                                                if (psMemRead->memoryCall)
        !          4676:                                                {
        !          4677:                                                        cpu.z80DE = psMemRead->memoryCall(dwTemp, psMemRead);
        !          4678:                                                        cpu.z80DE |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8);
        !          4679:                                                }
        !          4680:                                                else
        !          4681:                                                {
        !          4682:                                                        cpu.z80DE = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr));
        !          4683:                                                        cpu.z80DE |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8);
        !          4684:                                                }
        !          4685:                                                psMemRead = NULL;
        !          4686:                                                break;
        !          4687:                                        }
        !          4688:                                        ++psMemRead;
        !          4689:                                }
        !          4690: 
        !          4691:                                if (psMemRead)
        !          4692:                                {
        !          4693:                                        cpu.z80DE = cpu.z80Base[dwTemp];
        !          4694:                                        cpu.z80DE |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8);
        !          4695:                                }
        !          4696: 
        !          4697:                        break;
        !          4698:                }
        !          4699:                case 0x5c:
        !          4700:                {
        !          4701:                        sdwCyclesRemaining -= 8;
        !          4702:                                InvalidInstruction(2);
        !          4703:                        break;
        !          4704:                }
        !          4705:                case 0x5d:
        !          4706:                {
        !          4707:                        sdwCyclesRemaining -= 8;
        !          4708:                                InvalidInstruction(2);
        !          4709:                        break;
        !          4710:                }
        !          4711:                case 0x5e:
        !          4712:                {
        !          4713:                        sdwCyclesRemaining -= 8;
        !          4714:                                cpu.z80interruptMode = 2;
        !          4715:                        break;
        !          4716:                }
        !          4717:                case 0x5f:
        !          4718:                {
        !          4719:                        sdwCyclesRemaining -= 9;
        !          4720:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          4721:                                cpu.z80F |= bPostORFlags[cpu.z80r];
        !          4722:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_OVERFLOW_PARITY)) | ((cpu.z80iff & IFF2) << 1);
        !          4723:                                cpu.z80A = cpu.z80r;
        !          4724:                                bTemp = (cpu.z80r + (cpu.z80B + sdwCyclesRemaining + 1 + cpu.z80H)) ^ cpu.z80A;
        !          4725:                                cpu.z80r = (cpu.z80r & 0x80) | (bTemp & 0x7f);
        !          4726:                        break;
        !          4727:                }
        !          4728:                case 0x60:
        !          4729:                {
        !          4730:                        sdwCyclesRemaining -= 12;
        !          4731:                                dwAddr = cpu.z80C;
        !          4732:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          4733:                                while (psIoRead->lowIoAddr != 0xffff)
        !          4734:                                {
        !          4735:                                        if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
        !          4736:                                        {
        !          4737:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4738:                                                cpu.z80H = psIoRead->IOCall(dwAddr, psIoRead);
        !          4739:                                                psIoRead = NULL;
        !          4740:                                                break;
        !          4741:                                        }
        !          4742:                                        ++psIoRead;
        !          4743:                                }
        !          4744: 
        !          4745:                                if (psIoRead)
        !          4746:                                {
        !          4747:                                        cpu.z80H = 0xff; /* Unclaimed I/O read */
        !          4748:                                }
        !          4749: 
        !          4750:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          4751:                                cpu.z80F |= bPostORFlags[cpu.z80H];
        !          4752:                        break;
        !          4753:                }
        !          4754:                case 0x61:
        !          4755:                {
        !          4756:                        sdwCyclesRemaining -= 12;
        !          4757:                                dwAddr = cpu.z80C;
        !          4758:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          4759:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          4760:                                {
        !          4761:                                        if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
        !          4762:                                        {
        !          4763:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4764:                                                psIoWrite->IOCall(dwAddr, cpu.z80H, psIoWrite);
        !          4765:                                                psIoWrite = NULL;
        !          4766:                                                break;
        !          4767:                                        }
        !          4768:                                        ++psIoWrite;
        !          4769:                                }
        !          4770: 
        !          4771:                        break;
        !          4772:                }
        !          4773:                case 0x62:
        !          4774:                {
        !          4775:                        sdwCyclesRemaining -= 15;
        !          4776:                                dwTemp = cpu.z80HL - cpu.z80HL - (cpu.z80F & Z80_FLAG_CARRY);
        !          4777:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          4778:                                cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
        !          4779:                                if (0 == (dwTemp & 0xffff))
        !          4780:                                {
        !          4781:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          4782:                                }
        !          4783:                                cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
        !          4784:                                cpu.z80F |= ((((cpu.z80HL ^ cpu.z80HL) & (cpu.z80HL ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
        !          4785:                                cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
        !          4786:                                cpu.z80HL = dwTemp & 0xffff;
        !          4787:                        break;
        !          4788:                }
        !          4789:                case 0x63:
        !          4790:                {
        !          4791:                        sdwCyclesRemaining -= 20;
        !          4792:                dwTemp = *pbPC++;
        !          4793:                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          4794:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          4795:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          4796:                                {
        !          4797:                                        if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
        !          4798:                                        {
        !          4799:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4800:                                                if (psMemWrite->memoryCall)
        !          4801:                                                {
        !          4802:                                                        psMemWrite->memoryCall(dwTemp, (cpu.z80HL & 0xff), psMemWrite);
        !          4803:                                                        psMemWrite->memoryCall(dwTemp + 1, (cpu.z80HL >> 8), psMemWrite);
        !          4804:                                                }
        !          4805:                                                else
        !          4806:                                                {
        !          4807:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80HL;
        !          4808:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8;
        !          4809:                                                }
        !          4810:                                                psMemWrite = NULL;
        !          4811:                                                break;
        !          4812:                                        }
        !          4813:                                        ++psMemWrite;
        !          4814:                                }
        !          4815: 
        !          4816:                                if (psMemWrite)
        !          4817:                                {
        !          4818:                                        cpu.z80Base[dwTemp] = (UINT8) cpu.z80HL;
        !          4819:                                        cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8);
        !          4820:                                }
        !          4821: 
        !          4822:                        break;
        !          4823:                }
        !          4824:                case 0x64:
        !          4825:                {
        !          4826:                        sdwCyclesRemaining -= 8;
        !          4827:                                InvalidInstruction(2);
        !          4828:                        break;
        !          4829:                }
        !          4830:                case 0x65:
        !          4831:                {
        !          4832:                        sdwCyclesRemaining -= 8;
        !          4833:                                InvalidInstruction(2);
        !          4834:                        break;
        !          4835:                }
        !          4836:                case 0x66:
        !          4837:                {
        !          4838:                        sdwCyclesRemaining -= 8;
        !          4839:                                InvalidInstruction(2);
        !          4840:                        break;
        !          4841:                }
        !          4842:                case 0x67:
        !          4843:                {
        !          4844:                        sdwCyclesRemaining -= 18;
        !          4845:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          4846:                                while (psMemRead->lowAddr != 0xffffffff)
        !          4847:                                {
        !          4848:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          4849:                                        {
        !          4850:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4851:                                                if (psMemRead->memoryCall)
        !          4852:                                                {
        !          4853:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          4854:                                                }
        !          4855:                                                else
        !          4856:                                                {
        !          4857:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          4858:                                                }
        !          4859:                                                psMemRead = NULL;
        !          4860:                                                break;
        !          4861:                                        }
        !          4862:                                        ++psMemRead;
        !          4863:                                }
        !          4864: 
        !          4865:                                if (psMemRead)
        !          4866:                                {
        !          4867:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          4868:                                }
        !          4869: 
        !          4870:                                bTemp2 = (cpu.z80A & 0x0f) << 4;
        !          4871:                                cpu.z80A = (cpu.z80A & 0xf0) | (bTemp & 0x0f);
        !          4872:                                bTemp = (bTemp >> 4) | bTemp2;
        !          4873:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          4874:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          4875:                                {
        !          4876:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          4877:                                        {
        !          4878:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4879:                                                if (psMemWrite->memoryCall)
        !          4880:                                                {
        !          4881:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          4882:                                                }
        !          4883:                                                else
        !          4884:                                                {
        !          4885:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          4886:                                                }
        !          4887:                                                psMemWrite = NULL;
        !          4888:                                                break;
        !          4889:                                        }
        !          4890:                                        ++psMemWrite;
        !          4891:                                }
        !          4892: 
        !          4893:                                if (psMemWrite)
        !          4894:                                {
        !          4895:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          4896:                                }
        !          4897: 
        !          4898:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          4899:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          4900:                        break;
        !          4901:                }
        !          4902:                case 0x68:
        !          4903:                {
        !          4904:                        sdwCyclesRemaining -= 12;
        !          4905:                                dwAddr = cpu.z80C;
        !          4906:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          4907:                                while (psIoRead->lowIoAddr != 0xffff)
        !          4908:                                {
        !          4909:                                        if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
        !          4910:                                        {
        !          4911:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4912:                                                cpu.z80L = psIoRead->IOCall(dwAddr, psIoRead);
        !          4913:                                                psIoRead = NULL;
        !          4914:                                                break;
        !          4915:                                        }
        !          4916:                                        ++psIoRead;
        !          4917:                                }
        !          4918: 
        !          4919:                                if (psIoRead)
        !          4920:                                {
        !          4921:                                        cpu.z80L = 0xff; /* Unclaimed I/O read */
        !          4922:                                }
        !          4923: 
        !          4924:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          4925:                                cpu.z80F |= bPostORFlags[cpu.z80L];
        !          4926:                        break;
        !          4927:                }
        !          4928:                case 0x69:
        !          4929:                {
        !          4930:                        sdwCyclesRemaining -= 12;
        !          4931:                                dwAddr = cpu.z80C;
        !          4932:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          4933:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          4934:                                {
        !          4935:                                        if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
        !          4936:                                        {
        !          4937:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4938:                                                psIoWrite->IOCall(dwAddr, cpu.z80L, psIoWrite);
        !          4939:                                                psIoWrite = NULL;
        !          4940:                                                break;
        !          4941:                                        }
        !          4942:                                        ++psIoWrite;
        !          4943:                                }
        !          4944: 
        !          4945:                        break;
        !          4946:                }
        !          4947:                case 0x6a:
        !          4948:                {
        !          4949:                        sdwCyclesRemaining -= 15;
        !          4950:                                dwTemp = cpu.z80HL + cpu.z80HL + (cpu.z80F & Z80_FLAG_CARRY);
        !          4951:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          4952:                                cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
        !          4953:                                if (0 == (dwTemp & 0xffff))
        !          4954:                                {
        !          4955:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          4956:                                }
        !          4957:                                cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
        !          4958:                                cpu.z80F |= ((((cpu.z80HL ^ cpu.z80HL ^ 0x8000) & (cpu.z80HL ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
        !          4959:                                cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
        !          4960:                                cpu.z80HL = dwTemp & 0xffff;
        !          4961:                        break;
        !          4962:                }
        !          4963:                case 0x6b:
        !          4964:                {
        !          4965:                        sdwCyclesRemaining -= 20;
        !          4966:                                InvalidInstruction(2);
        !          4967:                        break;
        !          4968:                }
        !          4969:                case 0x6c:
        !          4970:                {
        !          4971:                        sdwCyclesRemaining -= 8;
        !          4972:                                InvalidInstruction(2);
        !          4973:                        break;
        !          4974:                }
        !          4975:                case 0x6d:
        !          4976:                {
        !          4977:                        sdwCyclesRemaining -= 8;
        !          4978:                                InvalidInstruction(2);
        !          4979:                        break;
        !          4980:                }
        !          4981:                case 0x6e:
        !          4982:                {
        !          4983:                        sdwCyclesRemaining -= 8;
        !          4984:                                InvalidInstruction(2);
        !          4985:                        break;
        !          4986:                }
        !          4987:                case 0x6f:
        !          4988:                {
        !          4989:                        sdwCyclesRemaining -= 18;
        !          4990:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          4991:                                while (psMemRead->lowAddr != 0xffffffff)
        !          4992:                                {
        !          4993:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          4994:                                        {
        !          4995:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          4996:                                                if (psMemRead->memoryCall)
        !          4997:                                                {
        !          4998:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          4999:                                                }
        !          5000:                                                else
        !          5001:                                                {
        !          5002:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5003:                                                }
        !          5004:                                                psMemRead = NULL;
        !          5005:                                                break;
        !          5006:                                        }
        !          5007:                                        ++psMemRead;
        !          5008:                                }
        !          5009: 
        !          5010:                                if (psMemRead)
        !          5011:                                {
        !          5012:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          5013:                                }
        !          5014: 
        !          5015:                                bTemp2 = (cpu.z80A & 0x0f);
        !          5016:                                cpu.z80A = (cpu.z80A & 0xf0) | (bTemp >> 4);
        !          5017:                                bTemp = (bTemp << 4) | bTemp2;
        !          5018:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          5019:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          5020:                                {
        !          5021:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          5022:                                        {
        !          5023:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5024:                                                if (psMemWrite->memoryCall)
        !          5025:                                                {
        !          5026:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          5027:                                                }
        !          5028:                                                else
        !          5029:                                                {
        !          5030:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          5031:                                                }
        !          5032:                                                psMemWrite = NULL;
        !          5033:                                                break;
        !          5034:                                        }
        !          5035:                                        ++psMemWrite;
        !          5036:                                }
        !          5037: 
        !          5038:                                if (psMemWrite)
        !          5039:                                {
        !          5040:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          5041:                                }
        !          5042: 
        !          5043:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          5044:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          5045:                        break;
        !          5046:                }
        !          5047:                case 0x70:
        !          5048:                {
        !          5049:                        sdwCyclesRemaining -= 12;
        !          5050:                                InvalidInstruction(2);
        !          5051:                        break;
        !          5052:                }
        !          5053:                case 0x71:
        !          5054:                {
        !          5055:                        sdwCyclesRemaining -= 12;
        !          5056:                                InvalidInstruction(2);
        !          5057:                        break;
        !          5058:                }
        !          5059:                case 0x72:
        !          5060:                {
        !          5061:                        sdwCyclesRemaining -= 15;
        !          5062:                                dwTemp = cpu.z80HL - cpu.z80sp - (cpu.z80F & Z80_FLAG_CARRY);
        !          5063:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          5064:                                cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
        !          5065:                                if (0 == (dwTemp & 0xffff))
        !          5066:                                {
        !          5067:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          5068:                                }
        !          5069:                                cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
        !          5070:                                cpu.z80F |= ((((cpu.z80sp ^ cpu.z80HL) & (cpu.z80sp ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
        !          5071:                                cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
        !          5072:                                cpu.z80HL = dwTemp & 0xffff;
        !          5073:                        break;
        !          5074:                }
        !          5075:                case 0x73:
        !          5076:                {
        !          5077:                        sdwCyclesRemaining -= 20;
        !          5078:                dwTemp = *pbPC++;
        !          5079:                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          5080:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          5081:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          5082:                                {
        !          5083:                                        if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
        !          5084:                                        {
        !          5085:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5086:                                                if (psMemWrite->memoryCall)
        !          5087:                                                {
        !          5088:                                                        psMemWrite->memoryCall(dwTemp, (cpu.z80sp & 0xff), psMemWrite);
        !          5089:                                                        psMemWrite->memoryCall(dwTemp + 1, (cpu.z80sp >> 8), psMemWrite);
        !          5090:                                                }
        !          5091:                                                else
        !          5092:                                                {
        !          5093:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80sp;
        !          5094:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80sp >> 8;
        !          5095:                                                }
        !          5096:                                                psMemWrite = NULL;
        !          5097:                                                break;
        !          5098:                                        }
        !          5099:                                        ++psMemWrite;
        !          5100:                                }
        !          5101: 
        !          5102:                                if (psMemWrite)
        !          5103:                                {
        !          5104:                                        cpu.z80Base[dwTemp] = (UINT8) cpu.z80sp;
        !          5105:                                        cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80sp >> 8);
        !          5106:                                }
        !          5107: 
        !          5108:                        break;
        !          5109:                }
        !          5110:                case 0x74:
        !          5111:                {
        !          5112:                        sdwCyclesRemaining -= 8;
        !          5113:                                InvalidInstruction(2);
        !          5114:                        break;
        !          5115:                }
        !          5116:                case 0x75:
        !          5117:                {
        !          5118:                        sdwCyclesRemaining -= 8;
        !          5119:                                InvalidInstruction(2);
        !          5120:                        break;
        !          5121:                }
        !          5122:                case 0x76:
        !          5123:                {
        !          5124:                        sdwCyclesRemaining -= 8;
        !          5125:                                InvalidInstruction(2);
        !          5126:                        break;
        !          5127:                }
        !          5128:                case 0x77:
        !          5129:                {
        !          5130:                                InvalidInstruction(2);
        !          5131:                        break;
        !          5132:                }
        !          5133:                case 0x78:
        !          5134:                {
        !          5135:                        sdwCyclesRemaining -= 12;
        !          5136:                                dwAddr = cpu.z80C;
        !          5137:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          5138:                                while (psIoRead->lowIoAddr != 0xffff)
        !          5139:                                {
        !          5140:                                        if ((dwAddr >= psIoRead->lowIoAddr) && (dwAddr <= psIoRead->highIoAddr))
        !          5141:                                        {
        !          5142:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5143:                                                cpu.z80A = psIoRead->IOCall(dwAddr, psIoRead);
        !          5144:                                                psIoRead = NULL;
        !          5145:                                                break;
        !          5146:                                        }
        !          5147:                                        ++psIoRead;
        !          5148:                                }
        !          5149: 
        !          5150:                                if (psIoRead)
        !          5151:                                {
        !          5152:                                        cpu.z80A = 0xff; /* Unclaimed I/O read */
        !          5153:                                }
        !          5154: 
        !          5155:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          5156:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          5157:                        break;
        !          5158:                }
        !          5159:                case 0x79:
        !          5160:                {
        !          5161:                        sdwCyclesRemaining -= 12;
        !          5162:                                dwAddr = cpu.z80C;
        !          5163:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          5164:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          5165:                                {
        !          5166:                                        if ((dwAddr >= psIoWrite->lowIoAddr) && (dwAddr <= psIoWrite->highIoAddr))
        !          5167:                                        {
        !          5168:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5169:                                                psIoWrite->IOCall(dwAddr, cpu.z80A, psIoWrite);
        !          5170:                                                psIoWrite = NULL;
        !          5171:                                                break;
        !          5172:                                        }
        !          5173:                                        ++psIoWrite;
        !          5174:                                }
        !          5175: 
        !          5176:                        break;
        !          5177:                }
        !          5178:                case 0x7a:
        !          5179:                {
        !          5180:                        sdwCyclesRemaining -= 15;
        !          5181:                                dwTemp = cpu.z80HL + cpu.z80sp + (cpu.z80F & Z80_FLAG_CARRY);
        !          5182:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          5183:                                cpu.z80F |= ((dwTemp >> 8) & Z80_FLAG_SIGN);
        !          5184:                                if (0 == (dwTemp & 0xffff))
        !          5185:                                {
        !          5186:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          5187:                                }
        !          5188:                                cpu.z80F |= (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
        !          5189:                                cpu.z80F |= ((((cpu.z80sp ^ cpu.z80HL ^ 0x8000) & (cpu.z80sp ^ dwTemp)) >> 13) & Z80_FLAG_OVERFLOW_PARITY);
        !          5190:                                cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY);
        !          5191:                                cpu.z80HL = dwTemp & 0xffff;
        !          5192:                        break;
        !          5193:                }
        !          5194:                case 0x7b:
        !          5195:                {
        !          5196:                        sdwCyclesRemaining -= 20;
        !          5197:                dwTemp = *pbPC++;
        !          5198:                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          5199:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5200:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5201:                                {
        !          5202:                                        if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr))
        !          5203:                                        {
        !          5204:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5205:                                                if (psMemRead->memoryCall)
        !          5206:                                                {
        !          5207:                                                        cpu.z80sp = psMemRead->memoryCall(dwTemp, psMemRead);
        !          5208:                                                        cpu.z80sp |= (UINT32) ((UINT32) psMemRead->memoryCall(dwTemp + 1, psMemRead) << 8);
        !          5209:                                                }
        !          5210:                                                else
        !          5211:                                                {
        !          5212:                                                        cpu.z80sp = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr));
        !          5213:                                                        cpu.z80sp |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr + 1)) << 8);
        !          5214:                                                }
        !          5215:                                                psMemRead = NULL;
        !          5216:                                                break;
        !          5217:                                        }
        !          5218:                                        ++psMemRead;
        !          5219:                                }
        !          5220: 
        !          5221:                                if (psMemRead)
        !          5222:                                {
        !          5223:                                        cpu.z80sp = cpu.z80Base[dwTemp];
        !          5224:                                        cpu.z80sp |= (UINT32) ((UINT32) cpu.z80Base[dwTemp + 1] << 8);
        !          5225:                                }
        !          5226: 
        !          5227:                        break;
        !          5228:                }
        !          5229:                case 0x7c:
        !          5230:                {
        !          5231:                        sdwCyclesRemaining -= 8;
        !          5232:                                InvalidInstruction(2);
        !          5233:                        break;
        !          5234:                }
        !          5235:                case 0x7d:
        !          5236:                {
        !          5237:                        sdwCyclesRemaining -= 8;
        !          5238:                                InvalidInstruction(2);
        !          5239:                        break;
        !          5240:                }
        !          5241:                case 0x7e:
        !          5242:                {
        !          5243:                        sdwCyclesRemaining -= 8;
        !          5244:                                InvalidInstruction(2);
        !          5245:                        break;
        !          5246:                }
        !          5247:                case 0x7f:
        !          5248:                {
        !          5249:                                InvalidInstruction(2);
        !          5250:                        break;
        !          5251:                }
        !          5252:                case 0x80:
        !          5253:                {
        !          5254:                                InvalidInstruction(2);
        !          5255:                        break;
        !          5256:                }
        !          5257:                case 0x81:
        !          5258:                {
        !          5259:                                InvalidInstruction(2);
        !          5260:                        break;
        !          5261:                }
        !          5262:                case 0x82:
        !          5263:                {
        !          5264:                                InvalidInstruction(2);
        !          5265:                        break;
        !          5266:                }
        !          5267:                case 0x83:
        !          5268:                {
        !          5269:                                InvalidInstruction(2);
        !          5270:                        break;
        !          5271:                }
        !          5272:                case 0x84:
        !          5273:                {
        !          5274:                                InvalidInstruction(2);
        !          5275:                        break;
        !          5276:                }
        !          5277:                case 0x85:
        !          5278:                {
        !          5279:                                InvalidInstruction(2);
        !          5280:                        break;
        !          5281:                }
        !          5282:                case 0x86:
        !          5283:                {
        !          5284:                                InvalidInstruction(2);
        !          5285:                        break;
        !          5286:                }
        !          5287:                case 0x87:
        !          5288:                {
        !          5289:                                InvalidInstruction(2);
        !          5290:                        break;
        !          5291:                }
        !          5292:                case 0x88:
        !          5293:                {
        !          5294:                                InvalidInstruction(2);
        !          5295:                        break;
        !          5296:                }
        !          5297:                case 0x89:
        !          5298:                {
        !          5299:                                InvalidInstruction(2);
        !          5300:                        break;
        !          5301:                }
        !          5302:                case 0x8a:
        !          5303:                {
        !          5304:                                InvalidInstruction(2);
        !          5305:                        break;
        !          5306:                }
        !          5307:                case 0x8b:
        !          5308:                {
        !          5309:                                InvalidInstruction(2);
        !          5310:                        break;
        !          5311:                }
        !          5312:                case 0x8c:
        !          5313:                {
        !          5314:                                InvalidInstruction(2);
        !          5315:                        break;
        !          5316:                }
        !          5317:                case 0x8d:
        !          5318:                {
        !          5319:                                InvalidInstruction(2);
        !          5320:                        break;
        !          5321:                }
        !          5322:                case 0x8e:
        !          5323:                {
        !          5324:                                InvalidInstruction(2);
        !          5325:                        break;
        !          5326:                }
        !          5327:                case 0x8f:
        !          5328:                {
        !          5329:                                InvalidInstruction(2);
        !          5330:                        break;
        !          5331:                }
        !          5332:                case 0x90:
        !          5333:                {
        !          5334:                                InvalidInstruction(2);
        !          5335:                        break;
        !          5336:                }
        !          5337:                case 0x91:
        !          5338:                {
        !          5339:                                InvalidInstruction(2);
        !          5340:                        break;
        !          5341:                }
        !          5342:                case 0x92:
        !          5343:                {
        !          5344:                                InvalidInstruction(2);
        !          5345:                        break;
        !          5346:                }
        !          5347:                case 0x93:
        !          5348:                {
        !          5349:                                InvalidInstruction(2);
        !          5350:                        break;
        !          5351:                }
        !          5352:                case 0x94:
        !          5353:                {
        !          5354:                                InvalidInstruction(2);
        !          5355:                        break;
        !          5356:                }
        !          5357:                case 0x95:
        !          5358:                {
        !          5359:                                InvalidInstruction(2);
        !          5360:                        break;
        !          5361:                }
        !          5362:                case 0x96:
        !          5363:                {
        !          5364:                                InvalidInstruction(2);
        !          5365:                        break;
        !          5366:                }
        !          5367:                case 0x97:
        !          5368:                {
        !          5369:                                InvalidInstruction(2);
        !          5370:                        break;
        !          5371:                }
        !          5372:                case 0x98:
        !          5373:                {
        !          5374:                                InvalidInstruction(2);
        !          5375:                        break;
        !          5376:                }
        !          5377:                case 0x99:
        !          5378:                {
        !          5379:                                InvalidInstruction(2);
        !          5380:                        break;
        !          5381:                }
        !          5382:                case 0x9a:
        !          5383:                {
        !          5384:                                InvalidInstruction(2);
        !          5385:                        break;
        !          5386:                }
        !          5387:                case 0x9b:
        !          5388:                {
        !          5389:                                InvalidInstruction(2);
        !          5390:                        break;
        !          5391:                }
        !          5392:                case 0x9c:
        !          5393:                {
        !          5394:                                InvalidInstruction(2);
        !          5395:                        break;
        !          5396:                }
        !          5397:                case 0x9d:
        !          5398:                {
        !          5399:                                InvalidInstruction(2);
        !          5400:                        break;
        !          5401:                }
        !          5402:                case 0x9e:
        !          5403:                {
        !          5404:                                InvalidInstruction(2);
        !          5405:                        break;
        !          5406:                }
        !          5407:                case 0x9f:
        !          5408:                {
        !          5409:                                InvalidInstruction(2);
        !          5410:                        break;
        !          5411:                }
        !          5412:                case 0xa0:
        !          5413:                {
        !          5414:                        sdwCyclesRemaining -= 16;
        !          5415:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5416:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5417:                                {
        !          5418:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          5419:                                        {
        !          5420:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5421:                                                if (psMemRead->memoryCall)
        !          5422:                                                {
        !          5423:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          5424:                                                }
        !          5425:                                                else
        !          5426:                                                {
        !          5427:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5428:                                                }
        !          5429:                                                psMemRead = NULL;
        !          5430:                                                break;
        !          5431:                                        }
        !          5432:                                        ++psMemRead;
        !          5433:                                }
        !          5434: 
        !          5435:                                if (psMemRead)
        !          5436:                                {
        !          5437:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          5438:                                }
        !          5439: 
        !          5440:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          5441:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          5442:                                {
        !          5443:                                        if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
        !          5444:                                        {
        !          5445:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5446:                                                if (psMemWrite->memoryCall)
        !          5447:                                                {
        !          5448:                                                        psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite);
        !          5449:                                                }
        !          5450:                                                else
        !          5451:                                                {
        !          5452:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp;
        !          5453:                                                }
        !          5454:                                                psMemWrite = NULL;
        !          5455:                                                break;
        !          5456:                                        }
        !          5457:                                        ++psMemWrite;
        !          5458:                                }
        !          5459: 
        !          5460:                                if (psMemWrite)
        !          5461:                                {
        !          5462:                                        cpu.z80Base[cpu.z80DE] = (UINT8) bTemp;
        !          5463:                                }
        !          5464: 
        !          5465:                                        ++cpu.z80HL;
        !          5466:                                        ++cpu.z80DE;
        !          5467:                                --cpu.z80BC;
        !          5468:                                cpu.z80HL &= 0xffff;
        !          5469:                                cpu.z80DE &= 0xffff;
        !          5470:                                cpu.z80BC &= 0xffff;
        !          5471:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY);
        !          5472:                                if (cpu.z80BC)
        !          5473:                                {
        !          5474:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5475:                                }
        !          5476:                        break;
        !          5477:                }
        !          5478:                case 0xa1:
        !          5479:                {
        !          5480:                        sdwCyclesRemaining -= 16;
        !          5481:                                {
        !          5482:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5483:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5484:                                {
        !          5485:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          5486:                                        {
        !          5487:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5488:                                                if (psMemRead->memoryCall)
        !          5489:                                                {
        !          5490:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          5491:                                                }
        !          5492:                                                else
        !          5493:                                                {
        !          5494:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5495:                                                }
        !          5496:                                                psMemRead = NULL;
        !          5497:                                                break;
        !          5498:                                        }
        !          5499:                                        ++psMemRead;
        !          5500:                                }
        !          5501: 
        !          5502:                                if (psMemRead)
        !          5503:                                {
        !          5504:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          5505:                                }
        !          5506: 
        !          5507:                                cpu.z80HL++;
        !          5508:                                cpu.z80HL &= 0xffff;
        !          5509:                                cpu.z80BC--;
        !          5510:                                cpu.z80BC &= 0xffff;
        !          5511:                                }
        !          5512:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          5513:                                cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO));
        !          5514:                                if (cpu.z80BC)
        !          5515:                                {
        !          5516:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5517:                                }
        !          5518:                        break;
        !          5519:                }
        !          5520:                case 0xa2:
        !          5521:                {
        !          5522:                        sdwCyclesRemaining -= 16;
        !          5523:                                {
        !          5524:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          5525:                                while (psIoRead->lowIoAddr != 0xffff)
        !          5526:                                {
        !          5527:                                        if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr))
        !          5528:                                        {
        !          5529:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5530:                                                bTemp = psIoRead->IOCall(cpu.z80B, psIoRead);
        !          5531:                                                psIoRead = NULL;
        !          5532:                                                break;
        !          5533:                                        }
        !          5534:                                        ++psIoRead;
        !          5535:                                }
        !          5536: 
        !          5537:                                if (psIoRead)
        !          5538:                                {
        !          5539:                                        bTemp = 0xff; /* Unclaimed I/O read */
        !          5540:                                }
        !          5541: 
        !          5542:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          5543:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          5544:                                {
        !          5545:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          5546:                                        {
        !          5547:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5548:                                                if (psMemWrite->memoryCall)
        !          5549:                                                {
        !          5550:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          5551:                                                }
        !          5552:                                                else
        !          5553:                                                {
        !          5554:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          5555:                                                }
        !          5556:                                                psMemWrite = NULL;
        !          5557:                                                break;
        !          5558:                                        }
        !          5559:                                        ++psMemWrite;
        !          5560:                                }
        !          5561: 
        !          5562:                                if (psMemWrite)
        !          5563:                                {
        !          5564:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          5565:                                }
        !          5566: 
        !          5567:                                cpu.z80HL++;
        !          5568:                                cpu.z80HL &= 0xffff;
        !          5569:                                sdwCyclesRemaining -= 16;
        !          5570:                                cpu.z80B--;
        !          5571:                                }
        !          5572:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          5573:                                cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
        !          5574:                                if (cpu.z80B)
        !          5575:                                {
        !          5576:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5577:                                        pbPC -= 2;
        !          5578:                                }
        !          5579:                        break;
        !          5580:                }
        !          5581:                case 0xa3:
        !          5582:                {
        !          5583:                        sdwCyclesRemaining -= 16;
        !          5584:                                {
        !          5585:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5586:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5587:                                {
        !          5588:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          5589:                                        {
        !          5590:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5591:                                                if (psMemRead->memoryCall)
        !          5592:                                                {
        !          5593:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          5594:                                                }
        !          5595:                                                else
        !          5596:                                                {
        !          5597:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5598:                                                }
        !          5599:                                                psMemRead = NULL;
        !          5600:                                                break;
        !          5601:                                        }
        !          5602:                                        ++psMemRead;
        !          5603:                                }
        !          5604: 
        !          5605:                                if (psMemRead)
        !          5606:                                {
        !          5607:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          5608:                                }
        !          5609: 
        !          5610:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          5611:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          5612:                                {
        !          5613:                                        if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr))
        !          5614:                                        {
        !          5615:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5616:                                                psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite);
        !          5617:                                                psIoWrite = NULL;
        !          5618:                                                break;
        !          5619:                                        }
        !          5620:                                        ++psIoWrite;
        !          5621:                                }
        !          5622: 
        !          5623:                                cpu.z80HL++;
        !          5624:                                cpu.z80HL &= 0xffff;
        !          5625:                                sdwCyclesRemaining -= 16;
        !          5626:                                cpu.z80B--;
        !          5627:                                }
        !          5628:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          5629:                                cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
        !          5630:                                if (cpu.z80B)
        !          5631:                                {
        !          5632:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5633:                                }
        !          5634:                        break;
        !          5635:                }
        !          5636:                case 0xa4:
        !          5637:                {
        !          5638:                                InvalidInstruction(2);
        !          5639:                        break;
        !          5640:                }
        !          5641:                case 0xa5:
        !          5642:                {
        !          5643:                                InvalidInstruction(2);
        !          5644:                        break;
        !          5645:                }
        !          5646:                case 0xa6:
        !          5647:                {
        !          5648:                                InvalidInstruction(2);
        !          5649:                        break;
        !          5650:                }
        !          5651:                case 0xa7:
        !          5652:                {
        !          5653:                                InvalidInstruction(2);
        !          5654:                        break;
        !          5655:                }
        !          5656:                case 0xa8:
        !          5657:                {
        !          5658:                        sdwCyclesRemaining -= 16;
        !          5659:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5660:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5661:                                {
        !          5662:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          5663:                                        {
        !          5664:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5665:                                                if (psMemRead->memoryCall)
        !          5666:                                                {
        !          5667:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          5668:                                                }
        !          5669:                                                else
        !          5670:                                                {
        !          5671:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5672:                                                }
        !          5673:                                                psMemRead = NULL;
        !          5674:                                                break;
        !          5675:                                        }
        !          5676:                                        ++psMemRead;
        !          5677:                                }
        !          5678: 
        !          5679:                                if (psMemRead)
        !          5680:                                {
        !          5681:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          5682:                                }
        !          5683: 
        !          5684:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          5685:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          5686:                                {
        !          5687:                                        if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
        !          5688:                                        {
        !          5689:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5690:                                                if (psMemWrite->memoryCall)
        !          5691:                                                {
        !          5692:                                                        psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite);
        !          5693:                                                }
        !          5694:                                                else
        !          5695:                                                {
        !          5696:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp;
        !          5697:                                                }
        !          5698:                                                psMemWrite = NULL;
        !          5699:                                                break;
        !          5700:                                        }
        !          5701:                                        ++psMemWrite;
        !          5702:                                }
        !          5703: 
        !          5704:                                if (psMemWrite)
        !          5705:                                {
        !          5706:                                        cpu.z80Base[cpu.z80DE] = (UINT8) bTemp;
        !          5707:                                }
        !          5708: 
        !          5709:                                        --cpu.z80HL;
        !          5710:                                        --cpu.z80DE;
        !          5711:                                --cpu.z80BC;
        !          5712:                                cpu.z80HL &= 0xffff;
        !          5713:                                cpu.z80DE &= 0xffff;
        !          5714:                                cpu.z80BC &= 0xffff;
        !          5715:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY);
        !          5716:                                if (cpu.z80BC)
        !          5717:                                {
        !          5718:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5719:                                }
        !          5720:                        break;
        !          5721:                }
        !          5722:                case 0xa9:
        !          5723:                {
        !          5724:                        sdwCyclesRemaining -= 16;
        !          5725:                                {
        !          5726:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5727:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5728:                                {
        !          5729:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          5730:                                        {
        !          5731:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5732:                                                if (psMemRead->memoryCall)
        !          5733:                                                {
        !          5734:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          5735:                                                }
        !          5736:                                                else
        !          5737:                                                {
        !          5738:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5739:                                                }
        !          5740:                                                psMemRead = NULL;
        !          5741:                                                break;
        !          5742:                                        }
        !          5743:                                        ++psMemRead;
        !          5744:                                }
        !          5745: 
        !          5746:                                if (psMemRead)
        !          5747:                                {
        !          5748:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          5749:                                }
        !          5750: 
        !          5751:                                cpu.z80HL--;
        !          5752:                                cpu.z80HL &= 0xffff;
        !          5753:                                cpu.z80BC--;
        !          5754:                                cpu.z80BC &= 0xffff;
        !          5755:                                }
        !          5756:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          5757:                                cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO));
        !          5758:                                if (cpu.z80BC)
        !          5759:                                {
        !          5760:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5761:                                }
        !          5762:                        break;
        !          5763:                }
        !          5764:                case 0xaa:
        !          5765:                {
        !          5766:                        sdwCyclesRemaining -= 16;
        !          5767:                                {
        !          5768:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          5769:                                while (psIoRead->lowIoAddr != 0xffff)
        !          5770:                                {
        !          5771:                                        if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr))
        !          5772:                                        {
        !          5773:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5774:                                                bTemp = psIoRead->IOCall(cpu.z80B, psIoRead);
        !          5775:                                                psIoRead = NULL;
        !          5776:                                                break;
        !          5777:                                        }
        !          5778:                                        ++psIoRead;
        !          5779:                                }
        !          5780: 
        !          5781:                                if (psIoRead)
        !          5782:                                {
        !          5783:                                        bTemp = 0xff; /* Unclaimed I/O read */
        !          5784:                                }
        !          5785: 
        !          5786:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          5787:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          5788:                                {
        !          5789:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          5790:                                        {
        !          5791:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5792:                                                if (psMemWrite->memoryCall)
        !          5793:                                                {
        !          5794:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          5795:                                                }
        !          5796:                                                else
        !          5797:                                                {
        !          5798:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          5799:                                                }
        !          5800:                                                psMemWrite = NULL;
        !          5801:                                                break;
        !          5802:                                        }
        !          5803:                                        ++psMemWrite;
        !          5804:                                }
        !          5805: 
        !          5806:                                if (psMemWrite)
        !          5807:                                {
        !          5808:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          5809:                                }
        !          5810: 
        !          5811:                                cpu.z80HL--;
        !          5812:                                cpu.z80HL &= 0xffff;
        !          5813:                                sdwCyclesRemaining -= 16;
        !          5814:                                cpu.z80B--;
        !          5815:                                }
        !          5816:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          5817:                                cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
        !          5818:                                if (cpu.z80B)
        !          5819:                                {
        !          5820:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5821:                                        pbPC -= 2;
        !          5822:                                }
        !          5823:                        break;
        !          5824:                }
        !          5825:                case 0xab:
        !          5826:                {
        !          5827:                        sdwCyclesRemaining -= 16;
        !          5828:                                {
        !          5829:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5830:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5831:                                {
        !          5832:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          5833:                                        {
        !          5834:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5835:                                                if (psMemRead->memoryCall)
        !          5836:                                                {
        !          5837:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          5838:                                                }
        !          5839:                                                else
        !          5840:                                                {
        !          5841:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5842:                                                }
        !          5843:                                                psMemRead = NULL;
        !          5844:                                                break;
        !          5845:                                        }
        !          5846:                                        ++psMemRead;
        !          5847:                                }
        !          5848: 
        !          5849:                                if (psMemRead)
        !          5850:                                {
        !          5851:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          5852:                                }
        !          5853: 
        !          5854:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          5855:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          5856:                                {
        !          5857:                                        if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr))
        !          5858:                                        {
        !          5859:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5860:                                                psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite);
        !          5861:                                                psIoWrite = NULL;
        !          5862:                                                break;
        !          5863:                                        }
        !          5864:                                        ++psIoWrite;
        !          5865:                                }
        !          5866: 
        !          5867:                                cpu.z80HL--;
        !          5868:                                cpu.z80HL &= 0xffff;
        !          5869:                                sdwCyclesRemaining -= 16;
        !          5870:                                cpu.z80B--;
        !          5871:                                }
        !          5872:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          5873:                                cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
        !          5874:                                if (cpu.z80B)
        !          5875:                                {
        !          5876:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5877:                                }
        !          5878:                        break;
        !          5879:                }
        !          5880:                case 0xac:
        !          5881:                {
        !          5882:                                InvalidInstruction(2);
        !          5883:                        break;
        !          5884:                }
        !          5885:                case 0xad:
        !          5886:                {
        !          5887:                                InvalidInstruction(2);
        !          5888:                        break;
        !          5889:                }
        !          5890:                case 0xae:
        !          5891:                {
        !          5892:                                InvalidInstruction(2);
        !          5893:                        break;
        !          5894:                }
        !          5895:                case 0xaf:
        !          5896:                {
        !          5897:                                InvalidInstruction(2);
        !          5898:                        break;
        !          5899:                }
        !          5900:                case 0xb0:
        !          5901:                {
        !          5902:                        sdwCyclesRemaining -= 16;
        !          5903:                                while ((sdwCyclesRemaining > 0) && (cpu.z80BC))
        !          5904:                                {
        !          5905:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5906:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5907:                                {
        !          5908:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          5909:                                        {
        !          5910:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5911:                                                if (psMemRead->memoryCall)
        !          5912:                                                {
        !          5913:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          5914:                                                }
        !          5915:                                                else
        !          5916:                                                {
        !          5917:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5918:                                                }
        !          5919:                                                psMemRead = NULL;
        !          5920:                                                break;
        !          5921:                                        }
        !          5922:                                        ++psMemRead;
        !          5923:                                }
        !          5924: 
        !          5925:                                if (psMemRead)
        !          5926:                                {
        !          5927:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          5928:                                }
        !          5929: 
        !          5930:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          5931:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          5932:                                {
        !          5933:                                        if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
        !          5934:                                        {
        !          5935:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5936:                                                if (psMemWrite->memoryCall)
        !          5937:                                                {
        !          5938:                                                        psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite);
        !          5939:                                                }
        !          5940:                                                else
        !          5941:                                                {
        !          5942:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp;
        !          5943:                                                }
        !          5944:                                                psMemWrite = NULL;
        !          5945:                                                break;
        !          5946:                                        }
        !          5947:                                        ++psMemWrite;
        !          5948:                                }
        !          5949: 
        !          5950:                                if (psMemWrite)
        !          5951:                                {
        !          5952:                                        cpu.z80Base[cpu.z80DE] = (UINT8) bTemp;
        !          5953:                                }
        !          5954: 
        !          5955:                                        ++cpu.z80HL;
        !          5956:                                        ++cpu.z80DE;
        !          5957:                                --cpu.z80BC;
        !          5958:                                cpu.z80HL &= 0xffff;
        !          5959:                                cpu.z80DE &= 0xffff;
        !          5960:                                cpu.z80BC &= 0xffff;
        !          5961:                                sdwCyclesRemaining -= 21;
        !          5962:                                }
        !          5963:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY);
        !          5964:                                if (cpu.z80BC)
        !          5965:                                {
        !          5966:                                        pbPC -= 2;      /* Back up so we hit this instruction again */
        !          5967:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          5968:                                }
        !          5969:                                sdwCyclesRemaining -= 16;
        !          5970:                        break;
        !          5971:                }
        !          5972:                case 0xb1:
        !          5973:                {
        !          5974:                        sdwCyclesRemaining -= 16;
        !          5975:                                while ((sdwCyclesRemaining >= 0) && (cpu.z80BC))
        !          5976:                                {
        !          5977:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          5978:                                while (psMemRead->lowAddr != 0xffffffff)
        !          5979:                                {
        !          5980:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          5981:                                        {
        !          5982:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          5983:                                                if (psMemRead->memoryCall)
        !          5984:                                                {
        !          5985:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          5986:                                                }
        !          5987:                                                else
        !          5988:                                                {
        !          5989:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          5990:                                                }
        !          5991:                                                psMemRead = NULL;
        !          5992:                                                break;
        !          5993:                                        }
        !          5994:                                        ++psMemRead;
        !          5995:                                }
        !          5996: 
        !          5997:                                if (psMemRead)
        !          5998:                                {
        !          5999:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          6000:                                }
        !          6001: 
        !          6002:                                cpu.z80HL++;
        !          6003:                                cpu.z80HL &= 0xffff;
        !          6004:                                cpu.z80BC--;
        !          6005:                                cpu.z80BC &= 0xffff;
        !          6006:                                sdwCyclesRemaining -= 16;
        !          6007:                                if (cpu.z80A == bTemp)
        !          6008:                                {
        !          6009:                                        break;
        !          6010:                                }
        !          6011:                                }
        !          6012:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          6013:                                cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO));
        !          6014:                                if (cpu.z80BC)
        !          6015:                                {
        !          6016:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          6017:                                }
        !          6018:                        break;
        !          6019:                }
        !          6020:                case 0xb2:
        !          6021:                {
        !          6022:                        sdwCyclesRemaining -= 16;
        !          6023:                                while ((sdwCyclesRemaining > 0) && (cpu.z80B))
        !          6024:                                {
        !          6025:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          6026:                                while (psIoRead->lowIoAddr != 0xffff)
        !          6027:                                {
        !          6028:                                        if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr))
        !          6029:                                        {
        !          6030:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6031:                                                bTemp = psIoRead->IOCall(cpu.z80B, psIoRead);
        !          6032:                                                psIoRead = NULL;
        !          6033:                                                break;
        !          6034:                                        }
        !          6035:                                        ++psIoRead;
        !          6036:                                }
        !          6037: 
        !          6038:                                if (psIoRead)
        !          6039:                                {
        !          6040:                                        bTemp = 0xff; /* Unclaimed I/O read */
        !          6041:                                }
        !          6042: 
        !          6043:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          6044:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          6045:                                {
        !          6046:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          6047:                                        {
        !          6048:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6049:                                                if (psMemWrite->memoryCall)
        !          6050:                                                {
        !          6051:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          6052:                                                }
        !          6053:                                                else
        !          6054:                                                {
        !          6055:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          6056:                                                }
        !          6057:                                                psMemWrite = NULL;
        !          6058:                                                break;
        !          6059:                                        }
        !          6060:                                        ++psMemWrite;
        !          6061:                                }
        !          6062: 
        !          6063:                                if (psMemWrite)
        !          6064:                                {
        !          6065:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          6066:                                }
        !          6067: 
        !          6068:                                cpu.z80HL++;
        !          6069:                                cpu.z80HL &= 0xffff;
        !          6070:                                sdwCyclesRemaining -= 16;
        !          6071:                                cpu.z80B--;
        !          6072:                                }
        !          6073:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          6074:                                cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
        !          6075:                                if (cpu.z80B)
        !          6076:                                {
        !          6077:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          6078:                                        pbPC -= 2;
        !          6079:                                }
        !          6080:                        break;
        !          6081:                }
        !          6082:                case 0xb3:
        !          6083:                {
        !          6084:                        sdwCyclesRemaining -= 16;
        !          6085:                                while ((sdwCyclesRemaining > 0) && (cpu.z80B))
        !          6086:                                {
        !          6087:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          6088:                                while (psMemRead->lowAddr != 0xffffffff)
        !          6089:                                {
        !          6090:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          6091:                                        {
        !          6092:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6093:                                                if (psMemRead->memoryCall)
        !          6094:                                                {
        !          6095:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          6096:                                                }
        !          6097:                                                else
        !          6098:                                                {
        !          6099:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          6100:                                                }
        !          6101:                                                psMemRead = NULL;
        !          6102:                                                break;
        !          6103:                                        }
        !          6104:                                        ++psMemRead;
        !          6105:                                }
        !          6106: 
        !          6107:                                if (psMemRead)
        !          6108:                                {
        !          6109:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          6110:                                }
        !          6111: 
        !          6112:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          6113:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          6114:                                {
        !          6115:                                        if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr))
        !          6116:                                        {
        !          6117:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6118:                                                psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite);
        !          6119:                                                psIoWrite = NULL;
        !          6120:                                                break;
        !          6121:                                        }
        !          6122:                                        ++psIoWrite;
        !          6123:                                }
        !          6124: 
        !          6125:                                cpu.z80HL++;
        !          6126:                                cpu.z80HL &= 0xffff;
        !          6127:                                sdwCyclesRemaining -= 16;
        !          6128:                                cpu.z80B--;
        !          6129:                                }
        !          6130:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          6131:                                cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
        !          6132:                                if (cpu.z80B)
        !          6133:                                {
        !          6134:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          6135:                                }
        !          6136:                        break;
        !          6137:                }
        !          6138:                case 0xb4:
        !          6139:                {
        !          6140:                                InvalidInstruction(2);
        !          6141:                        break;
        !          6142:                }
        !          6143:                case 0xb5:
        !          6144:                {
        !          6145:                                InvalidInstruction(2);
        !          6146:                        break;
        !          6147:                }
        !          6148:                case 0xb6:
        !          6149:                {
        !          6150:                                InvalidInstruction(2);
        !          6151:                        break;
        !          6152:                }
        !          6153:                case 0xb7:
        !          6154:                {
        !          6155:                                InvalidInstruction(2);
        !          6156:                        break;
        !          6157:                }
        !          6158:                case 0xb8:
        !          6159:                {
        !          6160:                        sdwCyclesRemaining -= 16;
        !          6161:                                while ((sdwCyclesRemaining > 0) && (cpu.z80BC))
        !          6162:                                {
        !          6163:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          6164:                                while (psMemRead->lowAddr != 0xffffffff)
        !          6165:                                {
        !          6166:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          6167:                                        {
        !          6168:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6169:                                                if (psMemRead->memoryCall)
        !          6170:                                                {
        !          6171:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          6172:                                                }
        !          6173:                                                else
        !          6174:                                                {
        !          6175:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          6176:                                                }
        !          6177:                                                psMemRead = NULL;
        !          6178:                                                break;
        !          6179:                                        }
        !          6180:                                        ++psMemRead;
        !          6181:                                }
        !          6182: 
        !          6183:                                if (psMemRead)
        !          6184:                                {
        !          6185:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          6186:                                }
        !          6187: 
        !          6188:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          6189:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          6190:                                {
        !          6191:                                        if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
        !          6192:                                        {
        !          6193:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6194:                                                if (psMemWrite->memoryCall)
        !          6195:                                                {
        !          6196:                                                        psMemWrite->memoryCall(cpu.z80DE, bTemp, psMemWrite);
        !          6197:                                                }
        !          6198:                                                else
        !          6199:                                                {
        !          6200:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = bTemp;
        !          6201:                                                }
        !          6202:                                                psMemWrite = NULL;
        !          6203:                                                break;
        !          6204:                                        }
        !          6205:                                        ++psMemWrite;
        !          6206:                                }
        !          6207: 
        !          6208:                                if (psMemWrite)
        !          6209:                                {
        !          6210:                                        cpu.z80Base[cpu.z80DE] = (UINT8) bTemp;
        !          6211:                                }
        !          6212: 
        !          6213:                                        --cpu.z80HL;
        !          6214:                                        --cpu.z80DE;
        !          6215:                                --cpu.z80BC;
        !          6216:                                cpu.z80HL &= 0xffff;
        !          6217:                                cpu.z80DE &= 0xffff;
        !          6218:                                cpu.z80BC &= 0xffff;
        !          6219:                                sdwCyclesRemaining -= 21;
        !          6220:                                }
        !          6221:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY);
        !          6222:                                if (cpu.z80BC)
        !          6223:                                {
        !          6224:                                        pbPC -= 2;      /* Back up so we hit this instruction again */
        !          6225:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          6226:                                }
        !          6227:                                sdwCyclesRemaining -= 16;
        !          6228:                        break;
        !          6229:                }
        !          6230:                case 0xb9:
        !          6231:                {
        !          6232:                        sdwCyclesRemaining -= 16;
        !          6233:                                while ((sdwCyclesRemaining >= 0) && (cpu.z80BC))
        !          6234:                                {
        !          6235:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          6236:                                while (psMemRead->lowAddr != 0xffffffff)
        !          6237:                                {
        !          6238:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          6239:                                        {
        !          6240:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6241:                                                if (psMemRead->memoryCall)
        !          6242:                                                {
        !          6243:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          6244:                                                }
        !          6245:                                                else
        !          6246:                                                {
        !          6247:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          6248:                                                }
        !          6249:                                                psMemRead = NULL;
        !          6250:                                                break;
        !          6251:                                        }
        !          6252:                                        ++psMemRead;
        !          6253:                                }
        !          6254: 
        !          6255:                                if (psMemRead)
        !          6256:                                {
        !          6257:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          6258:                                }
        !          6259: 
        !          6260:                                cpu.z80HL--;
        !          6261:                                cpu.z80HL &= 0xffff;
        !          6262:                                cpu.z80BC--;
        !          6263:                                cpu.z80BC &= 0xffff;
        !          6264:                                sdwCyclesRemaining -= 16;
        !          6265:                                if (cpu.z80A == bTemp)
        !          6266:                                {
        !          6267:                                        break;
        !          6268:                                }
        !          6269:                                }
        !          6270:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          6271:                                cpu.z80F |= (pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_ZERO));
        !          6272:                                if (cpu.z80BC)
        !          6273:                                {
        !          6274:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          6275:                                }
        !          6276:                        break;
        !          6277:                }
        !          6278:                case 0xba:
        !          6279:                {
        !          6280:                        sdwCyclesRemaining -= 16;
        !          6281:                                while ((sdwCyclesRemaining > 0) && (cpu.z80B))
        !          6282:                                {
        !          6283:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          6284:                                while (psIoRead->lowIoAddr != 0xffff)
        !          6285:                                {
        !          6286:                                        if ((cpu.z80B >= psIoRead->lowIoAddr) && (cpu.z80B <= psIoRead->highIoAddr))
        !          6287:                                        {
        !          6288:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6289:                                                bTemp = psIoRead->IOCall(cpu.z80B, psIoRead);
        !          6290:                                                psIoRead = NULL;
        !          6291:                                                break;
        !          6292:                                        }
        !          6293:                                        ++psIoRead;
        !          6294:                                }
        !          6295: 
        !          6296:                                if (psIoRead)
        !          6297:                                {
        !          6298:                                        bTemp = 0xff; /* Unclaimed I/O read */
        !          6299:                                }
        !          6300: 
        !          6301:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          6302:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          6303:                                {
        !          6304:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          6305:                                        {
        !          6306:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6307:                                                if (psMemWrite->memoryCall)
        !          6308:                                                {
        !          6309:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          6310:                                                }
        !          6311:                                                else
        !          6312:                                                {
        !          6313:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          6314:                                                }
        !          6315:                                                psMemWrite = NULL;
        !          6316:                                                break;
        !          6317:                                        }
        !          6318:                                        ++psMemWrite;
        !          6319:                                }
        !          6320: 
        !          6321:                                if (psMemWrite)
        !          6322:                                {
        !          6323:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          6324:                                }
        !          6325: 
        !          6326:                                cpu.z80HL--;
        !          6327:                                cpu.z80HL &= 0xffff;
        !          6328:                                sdwCyclesRemaining -= 16;
        !          6329:                                cpu.z80B--;
        !          6330:                                }
        !          6331:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          6332:                                cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
        !          6333:                                if (cpu.z80B)
        !          6334:                                {
        !          6335:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          6336:                                        pbPC -= 2;
        !          6337:                                }
        !          6338:                        break;
        !          6339:                }
        !          6340:                case 0xbb:
        !          6341:                {
        !          6342:                        sdwCyclesRemaining -= 16;
        !          6343:                                while ((sdwCyclesRemaining > 0) && (cpu.z80B))
        !          6344:                                {
        !          6345:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          6346:                                while (psMemRead->lowAddr != 0xffffffff)
        !          6347:                                {
        !          6348:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          6349:                                        {
        !          6350:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6351:                                                if (psMemRead->memoryCall)
        !          6352:                                                {
        !          6353:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          6354:                                                }
        !          6355:                                                else
        !          6356:                                                {
        !          6357:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          6358:                                                }
        !          6359:                                                psMemRead = NULL;
        !          6360:                                                break;
        !          6361:                                        }
        !          6362:                                        ++psMemRead;
        !          6363:                                }
        !          6364: 
        !          6365:                                if (psMemRead)
        !          6366:                                {
        !          6367:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          6368:                                }
        !          6369: 
        !          6370:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          6371:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          6372:                                {
        !          6373:                                        if ((cpu.z80BC >= psIoWrite->lowIoAddr) && (cpu.z80BC <= psIoWrite->highIoAddr))
        !          6374:                                        {
        !          6375:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6376:                                                psIoWrite->IOCall(cpu.z80BC, bTemp, psIoWrite);
        !          6377:                                                psIoWrite = NULL;
        !          6378:                                                break;
        !          6379:                                        }
        !          6380:                                        ++psIoWrite;
        !          6381:                                }
        !          6382: 
        !          6383:                                cpu.z80HL--;
        !          6384:                                cpu.z80HL &= 0xffff;
        !          6385:                                sdwCyclesRemaining -= 16;
        !          6386:                                cpu.z80B--;
        !          6387:                                }
        !          6388:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          6389:                                cpu.z80F |= (bPostORFlags[bTemp] & (Z80_FLAG_SIGN | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY));
        !          6390:                                if (cpu.z80B)
        !          6391:                                {
        !          6392:                                        cpu.z80F |= Z80_FLAG_OVERFLOW_PARITY;
        !          6393:                                }
        !          6394:                        break;
        !          6395:                }
        !          6396:                case 0xbc:
        !          6397:                {
        !          6398:                                InvalidInstruction(2);
        !          6399:                        break;
        !          6400:                }
        !          6401:                case 0xbd:
        !          6402:                {
        !          6403:                                InvalidInstruction(2);
        !          6404:                        break;
        !          6405:                }
        !          6406:                case 0xbe:
        !          6407:                {
        !          6408:                                InvalidInstruction(2);
        !          6409:                        break;
        !          6410:                }
        !          6411:                case 0xbf:
        !          6412:                {
        !          6413:                                InvalidInstruction(2);
        !          6414:                        break;
        !          6415:                }
        !          6416:                case 0xc0:
        !          6417:                {
        !          6418:                                InvalidInstruction(2);
        !          6419:                        break;
        !          6420:                }
        !          6421:                case 0xc1:
        !          6422:                {
        !          6423:                                InvalidInstruction(2);
        !          6424:                        break;
        !          6425:                }
        !          6426:                case 0xc2:
        !          6427:                {
        !          6428:                                InvalidInstruction(2);
        !          6429:                        break;
        !          6430:                }
        !          6431:                case 0xc3:
        !          6432:                {
        !          6433:                                InvalidInstruction(2);
        !          6434:                        break;
        !          6435:                }
        !          6436:                case 0xc4:
        !          6437:                {
        !          6438:                                InvalidInstruction(2);
        !          6439:                        break;
        !          6440:                }
        !          6441:                case 0xc5:
        !          6442:                {
        !          6443:                                InvalidInstruction(2);
        !          6444:                        break;
        !          6445:                }
        !          6446:                case 0xc6:
        !          6447:                {
        !          6448:                                InvalidInstruction(2);
        !          6449:                        break;
        !          6450:                }
        !          6451:                case 0xc7:
        !          6452:                {
        !          6453:                                InvalidInstruction(2);
        !          6454:                        break;
        !          6455:                }
        !          6456:                case 0xc8:
        !          6457:                {
        !          6458:                                InvalidInstruction(2);
        !          6459:                        break;
        !          6460:                }
        !          6461:                case 0xc9:
        !          6462:                {
        !          6463:                                InvalidInstruction(2);
        !          6464:                        break;
        !          6465:                }
        !          6466:                case 0xca:
        !          6467:                {
        !          6468:                                InvalidInstruction(2);
        !          6469:                        break;
        !          6470:                }
        !          6471:                case 0xcb:
        !          6472:                {
        !          6473:                                InvalidInstruction(2);
        !          6474:                        break;
        !          6475:                }
        !          6476:                case 0xcc:
        !          6477:                {
        !          6478:                                InvalidInstruction(2);
        !          6479:                        break;
        !          6480:                }
        !          6481:                case 0xcd:
        !          6482:                {
        !          6483:                                InvalidInstruction(2);
        !          6484:                        break;
        !          6485:                }
        !          6486:                case 0xce:
        !          6487:                {
        !          6488:                                InvalidInstruction(2);
        !          6489:                        break;
        !          6490:                }
        !          6491:                case 0xcf:
        !          6492:                {
        !          6493:                                InvalidInstruction(2);
        !          6494:                        break;
        !          6495:                }
        !          6496:                case 0xd0:
        !          6497:                {
        !          6498:                                InvalidInstruction(2);
        !          6499:                        break;
        !          6500:                }
        !          6501:                case 0xd1:
        !          6502:                {
        !          6503:                                InvalidInstruction(2);
        !          6504:                        break;
        !          6505:                }
        !          6506:                case 0xd2:
        !          6507:                {
        !          6508:                                InvalidInstruction(2);
        !          6509:                        break;
        !          6510:                }
        !          6511:                case 0xd3:
        !          6512:                {
        !          6513:                                InvalidInstruction(2);
        !          6514:                        break;
        !          6515:                }
        !          6516:                case 0xd4:
        !          6517:                {
        !          6518:                                InvalidInstruction(2);
        !          6519:                        break;
        !          6520:                }
        !          6521:                case 0xd5:
        !          6522:                {
        !          6523:                                InvalidInstruction(2);
        !          6524:                        break;
        !          6525:                }
        !          6526:                case 0xd6:
        !          6527:                {
        !          6528:                                InvalidInstruction(2);
        !          6529:                        break;
        !          6530:                }
        !          6531:                case 0xd7:
        !          6532:                {
        !          6533:                                InvalidInstruction(2);
        !          6534:                        break;
        !          6535:                }
        !          6536:                case 0xd8:
        !          6537:                {
        !          6538:                                InvalidInstruction(2);
        !          6539:                        break;
        !          6540:                }
        !          6541:                case 0xd9:
        !          6542:                {
        !          6543:                                InvalidInstruction(2);
        !          6544:                        break;
        !          6545:                }
        !          6546:                case 0xda:
        !          6547:                {
        !          6548:                                InvalidInstruction(2);
        !          6549:                        break;
        !          6550:                }
        !          6551:                case 0xdb:
        !          6552:                {
        !          6553:                                InvalidInstruction(2);
        !          6554:                        break;
        !          6555:                }
        !          6556:                case 0xdc:
        !          6557:                {
        !          6558:                                InvalidInstruction(2);
        !          6559:                        break;
        !          6560:                }
        !          6561:                case 0xdd:
        !          6562:                {
        !          6563:                                InvalidInstruction(2);
        !          6564:                        break;
        !          6565:                }
        !          6566:                case 0xde:
        !          6567:                {
        !          6568:                                InvalidInstruction(2);
        !          6569:                        break;
        !          6570:                }
        !          6571:                case 0xdf:
        !          6572:                {
        !          6573:                                InvalidInstruction(2);
        !          6574:                        break;
        !          6575:                }
        !          6576:                case 0xe0:
        !          6577:                {
        !          6578:                                InvalidInstruction(2);
        !          6579:                        break;
        !          6580:                }
        !          6581:                case 0xe1:
        !          6582:                {
        !          6583:                                InvalidInstruction(2);
        !          6584:                        break;
        !          6585:                }
        !          6586:                case 0xe2:
        !          6587:                {
        !          6588:                                InvalidInstruction(2);
        !          6589:                        break;
        !          6590:                }
        !          6591:                case 0xe3:
        !          6592:                {
        !          6593:                                InvalidInstruction(2);
        !          6594:                        break;
        !          6595:                }
        !          6596:                case 0xe4:
        !          6597:                {
        !          6598:                                InvalidInstruction(2);
        !          6599:                        break;
        !          6600:                }
        !          6601:                case 0xe5:
        !          6602:                {
        !          6603:                                InvalidInstruction(2);
        !          6604:                        break;
        !          6605:                }
        !          6606:                case 0xe6:
        !          6607:                {
        !          6608:                                InvalidInstruction(2);
        !          6609:                        break;
        !          6610:                }
        !          6611:                case 0xe7:
        !          6612:                {
        !          6613:                                InvalidInstruction(2);
        !          6614:                        break;
        !          6615:                }
        !          6616:                case 0xe8:
        !          6617:                {
        !          6618:                                InvalidInstruction(2);
        !          6619:                        break;
        !          6620:                }
        !          6621:                case 0xe9:
        !          6622:                {
        !          6623:                                InvalidInstruction(2);
        !          6624:                        break;
        !          6625:                }
        !          6626:                case 0xea:
        !          6627:                {
        !          6628:                                InvalidInstruction(2);
        !          6629:                        break;
        !          6630:                }
        !          6631:                case 0xeb:
        !          6632:                {
        !          6633:                                InvalidInstruction(2);
        !          6634:                        break;
        !          6635:                }
        !          6636:                case 0xec:
        !          6637:                {
        !          6638:                                InvalidInstruction(2);
        !          6639:                        break;
        !          6640:                }
        !          6641:                case 0xed:
        !          6642:                {
        !          6643:                                InvalidInstruction(2);
        !          6644:                        break;
        !          6645:                }
        !          6646:                case 0xee:
        !          6647:                {
        !          6648:                                InvalidInstruction(2);
        !          6649:                        break;
        !          6650:                }
        !          6651:                case 0xef:
        !          6652:                {
        !          6653:                                InvalidInstruction(2);
        !          6654:                        break;
        !          6655:                }
        !          6656:                case 0xf0:
        !          6657:                {
        !          6658:                                InvalidInstruction(2);
        !          6659:                        break;
        !          6660:                }
        !          6661:                case 0xf1:
        !          6662:                {
        !          6663:                                InvalidInstruction(2);
        !          6664:                        break;
        !          6665:                }
        !          6666:                case 0xf2:
        !          6667:                {
        !          6668:                                InvalidInstruction(2);
        !          6669:                        break;
        !          6670:                }
        !          6671:                case 0xf3:
        !          6672:                {
        !          6673:                                InvalidInstruction(2);
        !          6674:                        break;
        !          6675:                }
        !          6676:                case 0xf4:
        !          6677:                {
        !          6678:                                InvalidInstruction(2);
        !          6679:                        break;
        !          6680:                }
        !          6681:                case 0xf5:
        !          6682:                {
        !          6683:                                InvalidInstruction(2);
        !          6684:                        break;
        !          6685:                }
        !          6686:                case 0xf6:
        !          6687:                {
        !          6688:                                InvalidInstruction(2);
        !          6689:                        break;
        !          6690:                }
        !          6691:                case 0xf7:
        !          6692:                {
        !          6693:                                InvalidInstruction(2);
        !          6694:                        break;
        !          6695:                }
        !          6696:                case 0xf8:
        !          6697:                {
        !          6698:                                InvalidInstruction(2);
        !          6699:                        break;
        !          6700:                }
        !          6701:                case 0xf9:
        !          6702:                {
        !          6703:                                InvalidInstruction(2);
        !          6704:                        break;
        !          6705:                }
        !          6706:                case 0xfa:
        !          6707:                {
        !          6708:                                InvalidInstruction(2);
        !          6709:                        break;
        !          6710:                }
        !          6711:                case 0xfb:
        !          6712:                {
        !          6713:                                InvalidInstruction(2);
        !          6714:                        break;
        !          6715:                }
        !          6716:                case 0xfc:
        !          6717:                {
        !          6718:                                InvalidInstruction(2);
        !          6719:                        break;
        !          6720:                }
        !          6721:                case 0xfd:
        !          6722:                {
        !          6723:                                InvalidInstruction(2);
        !          6724:                        break;
        !          6725:                }
        !          6726:                case 0xfe:
        !          6727:                {
        !          6728:                                InvalidInstruction(2);
        !          6729:                        break;
        !          6730:                }
        !          6731:                case 0xff:
        !          6732:                {
        !          6733:                                InvalidInstruction(2);
        !          6734:                        break;
        !          6735:                }
        !          6736:        }
        !          6737: }
        !          6738: 
        !          6739: void DDHandler(void)
        !          6740: {
        !          6741:        switch (*pbPC++)
        !          6742:        {
        !          6743:                case 0x00:
        !          6744:                {
        !          6745:                                InvalidInstruction(2);
        !          6746:                        break;
        !          6747:                }
        !          6748:                case 0x01:
        !          6749:                {
        !          6750:                                InvalidInstruction(2);
        !          6751:                        break;
        !          6752:                }
        !          6753:                case 0x02:
        !          6754:                {
        !          6755:                                InvalidInstruction(2);
        !          6756:                        break;
        !          6757:                }
        !          6758:                case 0x03:
        !          6759:                {
        !          6760:                                InvalidInstruction(2);
        !          6761:                        break;
        !          6762:                }
        !          6763:                case 0x04:
        !          6764:                {
        !          6765:                                InvalidInstruction(2);
        !          6766:                        break;
        !          6767:                }
        !          6768:                case 0x05:
        !          6769:                {
        !          6770:                                InvalidInstruction(2);
        !          6771:                        break;
        !          6772:                }
        !          6773:                case 0x06:
        !          6774:                {
        !          6775:                                InvalidInstruction(2);
        !          6776:                        break;
        !          6777:                }
        !          6778:                case 0x07:
        !          6779:                {
        !          6780:                                InvalidInstruction(2);
        !          6781:                        break;
        !          6782:                }
        !          6783:                case 0x08:
        !          6784:                {
        !          6785:                                InvalidInstruction(2);
        !          6786:                        break;
        !          6787:                }
        !          6788:                case 0x09:
        !          6789:                {
        !          6790:                        sdwCyclesRemaining -= 15;
        !          6791:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          6792:                        dwTemp = cpu.z80IX + cpu.z80BC;
        !          6793:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
        !          6794:                        cpu.z80IX = dwTemp & 0xffff;
        !          6795:                        break;
        !          6796:                }
        !          6797:                case 0x0a:
        !          6798:                {
        !          6799:                                InvalidInstruction(2);
        !          6800:                        break;
        !          6801:                }
        !          6802:                case 0x0b:
        !          6803:                {
        !          6804:                                InvalidInstruction(2);
        !          6805:                        break;
        !          6806:                }
        !          6807:                case 0x0c:
        !          6808:                {
        !          6809:                                InvalidInstruction(2);
        !          6810:                        break;
        !          6811:                }
        !          6812:                case 0x0d:
        !          6813:                {
        !          6814:                                InvalidInstruction(2);
        !          6815:                        break;
        !          6816:                }
        !          6817:                case 0x0e:
        !          6818:                {
        !          6819:                                InvalidInstruction(2);
        !          6820:                        break;
        !          6821:                }
        !          6822:                case 0x0f:
        !          6823:                {
        !          6824:                                InvalidInstruction(2);
        !          6825:                        break;
        !          6826:                }
        !          6827:                case 0x10:
        !          6828:                {
        !          6829:                                InvalidInstruction(2);
        !          6830:                        break;
        !          6831:                }
        !          6832:                case 0x11:
        !          6833:                {
        !          6834:                                InvalidInstruction(2);
        !          6835:                        break;
        !          6836:                }
        !          6837:                case 0x12:
        !          6838:                {
        !          6839:                                InvalidInstruction(2);
        !          6840:                        break;
        !          6841:                }
        !          6842:                case 0x13:
        !          6843:                {
        !          6844:                                InvalidInstruction(2);
        !          6845:                        break;
        !          6846:                }
        !          6847:                case 0x14:
        !          6848:                {
        !          6849:                                InvalidInstruction(2);
        !          6850:                        break;
        !          6851:                }
        !          6852:                case 0x15:
        !          6853:                {
        !          6854:                                InvalidInstruction(2);
        !          6855:                        break;
        !          6856:                }
        !          6857:                case 0x16:
        !          6858:                {
        !          6859:                                InvalidInstruction(2);
        !          6860:                        break;
        !          6861:                }
        !          6862:                case 0x17:
        !          6863:                {
        !          6864:                                InvalidInstruction(2);
        !          6865:                        break;
        !          6866:                }
        !          6867:                case 0x18:
        !          6868:                {
        !          6869:                                InvalidInstruction(2);
        !          6870:                        break;
        !          6871:                }
        !          6872:                case 0x19:
        !          6873:                {
        !          6874:                        sdwCyclesRemaining -= 15;
        !          6875:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          6876:                        dwTemp = cpu.z80IX + cpu.z80DE;
        !          6877:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
        !          6878:                        cpu.z80IX = dwTemp & 0xffff;
        !          6879:                        break;
        !          6880:                }
        !          6881:                case 0x1a:
        !          6882:                {
        !          6883:                                InvalidInstruction(2);
        !          6884:                        break;
        !          6885:                }
        !          6886:                case 0x1b:
        !          6887:                {
        !          6888:                                InvalidInstruction(2);
        !          6889:                        break;
        !          6890:                }
        !          6891:                case 0x1c:
        !          6892:                {
        !          6893:                                InvalidInstruction(2);
        !          6894:                        break;
        !          6895:                }
        !          6896:                case 0x1d:
        !          6897:                {
        !          6898:                                InvalidInstruction(2);
        !          6899:                        break;
        !          6900:                }
        !          6901:                case 0x1e:
        !          6902:                {
        !          6903:                                InvalidInstruction(2);
        !          6904:                        break;
        !          6905:                }
        !          6906:                case 0x1f:
        !          6907:                {
        !          6908:                                InvalidInstruction(2);
        !          6909:                        break;
        !          6910:                }
        !          6911:                case 0x20:
        !          6912:                {
        !          6913:                                InvalidInstruction(2);
        !          6914:                        break;
        !          6915:                }
        !          6916:                case 0x21:
        !          6917:                {
        !          6918:                        sdwCyclesRemaining -= 14;
        !          6919:                cpu.z80IX = *pbPC++;
        !          6920:                cpu.z80IX |= ((UINT32) *pbPC++ << 8);
        !          6921:                        break;
        !          6922:                }
        !          6923:                case 0x22:
        !          6924:                {
        !          6925:                        sdwCyclesRemaining -= 20;
        !          6926:                                dwAddr = *pbPC++;
        !          6927:                                dwAddr |= ((UINT32) *pbPC++ << 8);
        !          6928:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          6929:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          6930:                                {
        !          6931:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          6932:                                        {
        !          6933:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          6934:                                                if (psMemWrite->memoryCall)
        !          6935:                                                {
        !          6936:                                                        psMemWrite->memoryCall(dwAddr, (cpu.z80IX & 0xff), psMemWrite);
        !          6937:                                                        psMemWrite->memoryCall(dwAddr + 1, (cpu.z80IX >> 8), psMemWrite);
        !          6938:                                                }
        !          6939:                                                else
        !          6940:                                                {
        !          6941:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = cpu.z80IX;
        !          6942:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8;
        !          6943:                                                }
        !          6944:                                                psMemWrite = NULL;
        !          6945:                                                break;
        !          6946:                                        }
        !          6947:                                        ++psMemWrite;
        !          6948:                                }
        !          6949: 
        !          6950:                                if (psMemWrite)
        !          6951:                                {
        !          6952:                                        cpu.z80Base[dwAddr] = (UINT8) cpu.z80IX;
        !          6953:                                        cpu.z80Base[dwAddr + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8);
        !          6954:                                }
        !          6955: 
        !          6956:                        break;
        !          6957:                }
        !          6958:                case 0x23:
        !          6959:                {
        !          6960:                        sdwCyclesRemaining -= 10;
        !          6961:                                cpu.z80IX++;
        !          6962:                                cpu.z80IX &= 0xffff;
        !          6963:                        break;
        !          6964:                }
        !          6965:                case 0x24:
        !          6966:                {
        !          6967:                        sdwCyclesRemaining -= 9;
        !          6968:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          6969:                                cpu.z80F |= bPostIncFlags[cpu.z80XH++];
        !          6970:                        break;
        !          6971:                }
        !          6972:                case 0x25:
        !          6973:                {
        !          6974:                        sdwCyclesRemaining -= 9;
        !          6975:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          6976:                                cpu.z80F |= bPostDecFlags[cpu.z80XH--];
        !          6977:                        break;
        !          6978:                }
        !          6979:                case 0x26:
        !          6980:                {
        !          6981:                        sdwCyclesRemaining -= 9;
        !          6982:                        cpu.z80XH = *pbPC++;
        !          6983:                        break;
        !          6984:                }
        !          6985:                case 0x27:
        !          6986:                {
        !          6987:                                InvalidInstruction(2);
        !          6988:                        break;
        !          6989:                }
        !          6990:                case 0x28:
        !          6991:                {
        !          6992:                                InvalidInstruction(2);
        !          6993:                        break;
        !          6994:                }
        !          6995:                case 0x29:
        !          6996:                {
        !          6997:                        sdwCyclesRemaining -= 15;
        !          6998:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          6999:                        dwTemp = cpu.z80IX + cpu.z80IX;
        !          7000:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
        !          7001:                        cpu.z80IX = dwTemp & 0xffff;
        !          7002:                        break;
        !          7003:                }
        !          7004:                case 0x2a:
        !          7005:                {
        !          7006:                        sdwCyclesRemaining -= 20;
        !          7007:                                dwAddr = *pbPC++;
        !          7008:                                dwAddr |= ((UINT32) *pbPC++ << 8);
        !          7009:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7010:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7011:                                {
        !          7012:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          7013:                                        {
        !          7014:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7015:                                                if (psMemRead->memoryCall)
        !          7016:                                                {
        !          7017:                                                        cpu.z80IX = psMemRead->memoryCall(dwAddr, psMemRead);
        !          7018:                                                        cpu.z80IX |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8);
        !          7019:                                                }
        !          7020:                                                else
        !          7021:                                                {
        !          7022:                                                        cpu.z80IX = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          7023:                                                        cpu.z80IX |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8);
        !          7024:                                                }
        !          7025:                                                psMemRead = NULL;
        !          7026:                                                break;
        !          7027:                                        }
        !          7028:                                        ++psMemRead;
        !          7029:                                }
        !          7030: 
        !          7031:                                if (psMemRead)
        !          7032:                                {
        !          7033:                                        cpu.z80IX = cpu.z80Base[dwAddr];
        !          7034:                                        cpu.z80IX |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8);
        !          7035:                                }
        !          7036: 
        !          7037:                        break;
        !          7038:                }
        !          7039:                case 0x2b:
        !          7040:                {
        !          7041:                        sdwCyclesRemaining -= 10;
        !          7042:                                cpu.z80IX--;
        !          7043:                                cpu.z80IX &= 0xffff;
        !          7044:                        break;
        !          7045:                }
        !          7046:                case 0x2c:
        !          7047:                {
        !          7048:                        sdwCyclesRemaining -= 9;
        !          7049:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          7050:                                cpu.z80F |= bPostIncFlags[cpu.z80XL++];
        !          7051:                        break;
        !          7052:                }
        !          7053:                case 0x2d:
        !          7054:                {
        !          7055:                        sdwCyclesRemaining -= 9;
        !          7056:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          7057:                                cpu.z80F |= bPostDecFlags[cpu.z80XL--];
        !          7058:                        break;
        !          7059:                }
        !          7060:                case 0x2e:
        !          7061:                {
        !          7062:                        sdwCyclesRemaining -= 9;
        !          7063:                        cpu.z80XL = *pbPC++;
        !          7064:                        break;
        !          7065:                }
        !          7066:                case 0x2f:
        !          7067:                {
        !          7068:                                InvalidInstruction(2);
        !          7069:                        break;
        !          7070:                }
        !          7071:                case 0x30:
        !          7072:                {
        !          7073:                                InvalidInstruction(2);
        !          7074:                        break;
        !          7075:                }
        !          7076:                case 0x31:
        !          7077:                {
        !          7078:                                InvalidInstruction(2);
        !          7079:                        break;
        !          7080:                }
        !          7081:                case 0x32:
        !          7082:                {
        !          7083:                                InvalidInstruction(2);
        !          7084:                        break;
        !          7085:                }
        !          7086:                case 0x33:
        !          7087:                {
        !          7088:                                InvalidInstruction(2);
        !          7089:                        break;
        !          7090:                }
        !          7091:                case 0x34:
        !          7092:                {
        !          7093:                        sdwCyclesRemaining -= 23;
        !          7094:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          7095:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          7096:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7097:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7098:                                {
        !          7099:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          7100:                                        {
        !          7101:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7102:                                                if (psMemRead->memoryCall)
        !          7103:                                                {
        !          7104:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          7105:                                                }
        !          7106:                                                else
        !          7107:                                                {
        !          7108:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          7109:                                                }
        !          7110:                                                psMemRead = NULL;
        !          7111:                                                break;
        !          7112:                                        }
        !          7113:                                        ++psMemRead;
        !          7114:                                }
        !          7115: 
        !          7116:                                if (psMemRead)
        !          7117:                                {
        !          7118:                                        bTemp = cpu.z80Base[dwAddr];
        !          7119:                                }
        !          7120: 
        !          7121:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          7122:                                cpu.z80F |= bPostIncFlags[bTemp++];
        !          7123:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7124:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7125:                                {
        !          7126:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          7127:                                        {
        !          7128:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7129:                                                if (psMemWrite->memoryCall)
        !          7130:                                                {
        !          7131:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          7132:                                                }
        !          7133:                                                else
        !          7134:                                                {
        !          7135:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          7136:                                                }
        !          7137:                                                psMemWrite = NULL;
        !          7138:                                                break;
        !          7139:                                        }
        !          7140:                                        ++psMemWrite;
        !          7141:                                }
        !          7142: 
        !          7143:                                if (psMemWrite)
        !          7144:                                {
        !          7145:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          7146:                                }
        !          7147: 
        !          7148:                        break;
        !          7149:                }
        !          7150:                case 0x35:
        !          7151:                {
        !          7152:                        sdwCyclesRemaining -= 23;
        !          7153:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          7154:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          7155:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7156:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7157:                                {
        !          7158:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          7159:                                        {
        !          7160:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7161:                                                if (psMemRead->memoryCall)
        !          7162:                                                {
        !          7163:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          7164:                                                }
        !          7165:                                                else
        !          7166:                                                {
        !          7167:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          7168:                                                }
        !          7169:                                                psMemRead = NULL;
        !          7170:                                                break;
        !          7171:                                        }
        !          7172:                                        ++psMemRead;
        !          7173:                                }
        !          7174: 
        !          7175:                                if (psMemRead)
        !          7176:                                {
        !          7177:                                        bTemp = cpu.z80Base[dwAddr];
        !          7178:                                }
        !          7179: 
        !          7180:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          7181:                                cpu.z80F |= bPostDecFlags[bTemp--];
        !          7182:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7183:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7184:                                {
        !          7185:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          7186:                                        {
        !          7187:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7188:                                                if (psMemWrite->memoryCall)
        !          7189:                                                {
        !          7190:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          7191:                                                }
        !          7192:                                                else
        !          7193:                                                {
        !          7194:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          7195:                                                }
        !          7196:                                                psMemWrite = NULL;
        !          7197:                                                break;
        !          7198:                                        }
        !          7199:                                        ++psMemWrite;
        !          7200:                                }
        !          7201: 
        !          7202:                                if (psMemWrite)
        !          7203:                                {
        !          7204:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          7205:                                }
        !          7206: 
        !          7207:                        break;
        !          7208:                }
        !          7209:                case 0x36:
        !          7210:                {
        !          7211:                        sdwCyclesRemaining -= 19;
        !          7212:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7213:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7214:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7215:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7216:                                {
        !          7217:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          7218:                                        {
        !          7219:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7220:                                                if (psMemWrite->memoryCall)
        !          7221:                                                {
        !          7222:                                                        psMemWrite->memoryCall(sdwAddr, *pbPC++, psMemWrite);
        !          7223:                                                }
        !          7224:                                                else
        !          7225:                                                {
        !          7226:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = *pbPC++;
        !          7227:                                                }
        !          7228:                                                psMemWrite = NULL;
        !          7229:                                                break;
        !          7230:                                        }
        !          7231:                                        ++psMemWrite;
        !          7232:                                }
        !          7233: 
        !          7234:                                if (psMemWrite)
        !          7235:                                {
        !          7236:                                        cpu.z80Base[sdwAddr] = (UINT8) *pbPC++;
        !          7237:                                }
        !          7238: 
        !          7239:                        break;
        !          7240:                }
        !          7241:                case 0x37:
        !          7242:                {
        !          7243:                                InvalidInstruction(2);
        !          7244:                        break;
        !          7245:                }
        !          7246:                case 0x38:
        !          7247:                {
        !          7248:                                InvalidInstruction(2);
        !          7249:                        break;
        !          7250:                }
        !          7251:                case 0x39:
        !          7252:                {
        !          7253:                        sdwCyclesRemaining -= 15;
        !          7254:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          7255:                        dwTemp = cpu.z80IX + cpu.z80sp;
        !          7256:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IX ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
        !          7257:                        cpu.z80IX = dwTemp & 0xffff;
        !          7258:                        break;
        !          7259:                }
        !          7260:                case 0x3a:
        !          7261:                {
        !          7262:                                InvalidInstruction(2);
        !          7263:                        break;
        !          7264:                }
        !          7265:                case 0x3b:
        !          7266:                {
        !          7267:                                InvalidInstruction(2);
        !          7268:                        break;
        !          7269:                }
        !          7270:                case 0x3c:
        !          7271:                {
        !          7272:                                InvalidInstruction(2);
        !          7273:                        break;
        !          7274:                }
        !          7275:                case 0x3d:
        !          7276:                {
        !          7277:                                InvalidInstruction(2);
        !          7278:                        break;
        !          7279:                }
        !          7280:                case 0x3e:
        !          7281:                {
        !          7282:                                InvalidInstruction(2);
        !          7283:                        break;
        !          7284:                }
        !          7285:                case 0x3f:
        !          7286:                {
        !          7287:                                InvalidInstruction(2);
        !          7288:                        break;
        !          7289:                }
        !          7290:                case 0x40:
        !          7291:                {
        !          7292:                                InvalidInstruction(2);
        !          7293:                        break;
        !          7294:                }
        !          7295:                case 0x41:
        !          7296:                {
        !          7297:                                InvalidInstruction(2);
        !          7298:                        break;
        !          7299:                }
        !          7300:                case 0x42:
        !          7301:                {
        !          7302:                                InvalidInstruction(2);
        !          7303:                        break;
        !          7304:                }
        !          7305:                case 0x43:
        !          7306:                {
        !          7307:                                InvalidInstruction(2);
        !          7308:                        break;
        !          7309:                }
        !          7310:                case 0x44:
        !          7311:                {
        !          7312:                        sdwCyclesRemaining -= 9;
        !          7313:                        cpu.z80B = cpu.z80XH;
        !          7314:                        break;
        !          7315:                }
        !          7316:                case 0x45:
        !          7317:                {
        !          7318:                        sdwCyclesRemaining -= 9;
        !          7319:                        cpu.z80B = cpu.z80XL;
        !          7320:                        break;
        !          7321:                }
        !          7322:                case 0x46:
        !          7323:                {
        !          7324:                        sdwCyclesRemaining -= 19;
        !          7325:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7326:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7327:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7328:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7329:                                {
        !          7330:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          7331:                                        {
        !          7332:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7333:                                                if (psMemRead->memoryCall)
        !          7334:                                                {
        !          7335:                                                        cpu.z80B = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          7336:                                                }
        !          7337:                                                else
        !          7338:                                                {
        !          7339:                                                        cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          7340:                                                }
        !          7341:                                                psMemRead = NULL;
        !          7342:                                                break;
        !          7343:                                        }
        !          7344:                                        ++psMemRead;
        !          7345:                                }
        !          7346: 
        !          7347:                                if (psMemRead)
        !          7348:                                {
        !          7349:                                        cpu.z80B = cpu.z80Base[sdwAddr];
        !          7350:                                }
        !          7351: 
        !          7352:                        break;
        !          7353:                }
        !          7354:                case 0x47:
        !          7355:                {
        !          7356:                                InvalidInstruction(2);
        !          7357:                        break;
        !          7358:                }
        !          7359:                case 0x48:
        !          7360:                {
        !          7361:                                InvalidInstruction(2);
        !          7362:                        break;
        !          7363:                }
        !          7364:                case 0x49:
        !          7365:                {
        !          7366:                                InvalidInstruction(2);
        !          7367:                        break;
        !          7368:                }
        !          7369:                case 0x4a:
        !          7370:                {
        !          7371:                                InvalidInstruction(2);
        !          7372:                        break;
        !          7373:                }
        !          7374:                case 0x4b:
        !          7375:                {
        !          7376:                                InvalidInstruction(2);
        !          7377:                        break;
        !          7378:                }
        !          7379:                case 0x4c:
        !          7380:                {
        !          7381:                        sdwCyclesRemaining -= 9;
        !          7382:                        cpu.z80C = cpu.z80XH;
        !          7383:                        break;
        !          7384:                }
        !          7385:                case 0x4d:
        !          7386:                {
        !          7387:                        sdwCyclesRemaining -= 9;
        !          7388:                        cpu.z80C = cpu.z80XL;
        !          7389:                        break;
        !          7390:                }
        !          7391:                case 0x4e:
        !          7392:                {
        !          7393:                        sdwCyclesRemaining -= 19;
        !          7394:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7395:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7396:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7397:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7398:                                {
        !          7399:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          7400:                                        {
        !          7401:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7402:                                                if (psMemRead->memoryCall)
        !          7403:                                                {
        !          7404:                                                        cpu.z80C = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          7405:                                                }
        !          7406:                                                else
        !          7407:                                                {
        !          7408:                                                        cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          7409:                                                }
        !          7410:                                                psMemRead = NULL;
        !          7411:                                                break;
        !          7412:                                        }
        !          7413:                                        ++psMemRead;
        !          7414:                                }
        !          7415: 
        !          7416:                                if (psMemRead)
        !          7417:                                {
        !          7418:                                        cpu.z80C = cpu.z80Base[sdwAddr];
        !          7419:                                }
        !          7420: 
        !          7421:                        break;
        !          7422:                }
        !          7423:                case 0x4f:
        !          7424:                {
        !          7425:                                InvalidInstruction(2);
        !          7426:                        break;
        !          7427:                }
        !          7428:                case 0x50:
        !          7429:                {
        !          7430:                                InvalidInstruction(2);
        !          7431:                        break;
        !          7432:                }
        !          7433:                case 0x51:
        !          7434:                {
        !          7435:                                InvalidInstruction(2);
        !          7436:                        break;
        !          7437:                }
        !          7438:                case 0x52:
        !          7439:                {
        !          7440:                                InvalidInstruction(2);
        !          7441:                        break;
        !          7442:                }
        !          7443:                case 0x53:
        !          7444:                {
        !          7445:                                InvalidInstruction(2);
        !          7446:                        break;
        !          7447:                }
        !          7448:                case 0x54:
        !          7449:                {
        !          7450:                        sdwCyclesRemaining -= 9;
        !          7451:                        cpu.z80D = cpu.z80XH;
        !          7452:                        break;
        !          7453:                }
        !          7454:                case 0x55:
        !          7455:                {
        !          7456:                        sdwCyclesRemaining -= 9;
        !          7457:                        cpu.z80D = cpu.z80XL;
        !          7458:                        break;
        !          7459:                }
        !          7460:                case 0x56:
        !          7461:                {
        !          7462:                        sdwCyclesRemaining -= 19;
        !          7463:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7464:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7465:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7466:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7467:                                {
        !          7468:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          7469:                                        {
        !          7470:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7471:                                                if (psMemRead->memoryCall)
        !          7472:                                                {
        !          7473:                                                        cpu.z80D = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          7474:                                                }
        !          7475:                                                else
        !          7476:                                                {
        !          7477:                                                        cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          7478:                                                }
        !          7479:                                                psMemRead = NULL;
        !          7480:                                                break;
        !          7481:                                        }
        !          7482:                                        ++psMemRead;
        !          7483:                                }
        !          7484: 
        !          7485:                                if (psMemRead)
        !          7486:                                {
        !          7487:                                        cpu.z80D = cpu.z80Base[sdwAddr];
        !          7488:                                }
        !          7489: 
        !          7490:                        break;
        !          7491:                }
        !          7492:                case 0x57:
        !          7493:                {
        !          7494:                                InvalidInstruction(2);
        !          7495:                        break;
        !          7496:                }
        !          7497:                case 0x58:
        !          7498:                {
        !          7499:                                InvalidInstruction(2);
        !          7500:                        break;
        !          7501:                }
        !          7502:                case 0x59:
        !          7503:                {
        !          7504:                                InvalidInstruction(2);
        !          7505:                        break;
        !          7506:                }
        !          7507:                case 0x5a:
        !          7508:                {
        !          7509:                                InvalidInstruction(2);
        !          7510:                        break;
        !          7511:                }
        !          7512:                case 0x5b:
        !          7513:                {
        !          7514:                                InvalidInstruction(2);
        !          7515:                        break;
        !          7516:                }
        !          7517:                case 0x5c:
        !          7518:                {
        !          7519:                        sdwCyclesRemaining -= 9;
        !          7520:                        cpu.z80E = cpu.z80XH;
        !          7521:                        break;
        !          7522:                }
        !          7523:                case 0x5d:
        !          7524:                {
        !          7525:                        sdwCyclesRemaining -= 9;
        !          7526:                        cpu.z80E = cpu.z80XL;
        !          7527:                        break;
        !          7528:                }
        !          7529:                case 0x5e:
        !          7530:                {
        !          7531:                        sdwCyclesRemaining -= 19;
        !          7532:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7533:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7534:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7535:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7536:                                {
        !          7537:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          7538:                                        {
        !          7539:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7540:                                                if (psMemRead->memoryCall)
        !          7541:                                                {
        !          7542:                                                        cpu.z80E = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          7543:                                                }
        !          7544:                                                else
        !          7545:                                                {
        !          7546:                                                        cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          7547:                                                }
        !          7548:                                                psMemRead = NULL;
        !          7549:                                                break;
        !          7550:                                        }
        !          7551:                                        ++psMemRead;
        !          7552:                                }
        !          7553: 
        !          7554:                                if (psMemRead)
        !          7555:                                {
        !          7556:                                        cpu.z80E = cpu.z80Base[sdwAddr];
        !          7557:                                }
        !          7558: 
        !          7559:                        break;
        !          7560:                }
        !          7561:                case 0x5f:
        !          7562:                {
        !          7563:                                InvalidInstruction(2);
        !          7564:                        break;
        !          7565:                }
        !          7566:                case 0x60:
        !          7567:                {
        !          7568:                        sdwCyclesRemaining -= 9;
        !          7569:                        cpu.z80XH = cpu.z80B;
        !          7570:                        break;
        !          7571:                }
        !          7572:                case 0x61:
        !          7573:                {
        !          7574:                        sdwCyclesRemaining -= 9;
        !          7575:                        cpu.z80XH = cpu.z80C;
        !          7576:                        break;
        !          7577:                }
        !          7578:                case 0x62:
        !          7579:                {
        !          7580:                        sdwCyclesRemaining -= 9;
        !          7581:                        cpu.z80XH = cpu.z80D;
        !          7582:                        break;
        !          7583:                }
        !          7584:                case 0x63:
        !          7585:                {
        !          7586:                        sdwCyclesRemaining -= 9;
        !          7587:                        cpu.z80XH = cpu.z80E;
        !          7588:                        break;
        !          7589:                }
        !          7590:                case 0x64:
        !          7591:                {
        !          7592:                        sdwCyclesRemaining -= 9;
        !          7593:                        break;
        !          7594:                }
        !          7595:                case 0x65:
        !          7596:                {
        !          7597:                        sdwCyclesRemaining -= 9;
        !          7598:                        cpu.z80XH = cpu.z80XL;
        !          7599:                        break;
        !          7600:                }
        !          7601:                case 0x66:
        !          7602:                {
        !          7603:                        sdwCyclesRemaining -= 19;
        !          7604:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7605:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7606:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7607:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7608:                                {
        !          7609:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          7610:                                        {
        !          7611:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7612:                                                if (psMemRead->memoryCall)
        !          7613:                                                {
        !          7614:                                                        cpu.z80H = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          7615:                                                }
        !          7616:                                                else
        !          7617:                                                {
        !          7618:                                                        cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          7619:                                                }
        !          7620:                                                psMemRead = NULL;
        !          7621:                                                break;
        !          7622:                                        }
        !          7623:                                        ++psMemRead;
        !          7624:                                }
        !          7625: 
        !          7626:                                if (psMemRead)
        !          7627:                                {
        !          7628:                                        cpu.z80H = cpu.z80Base[sdwAddr];
        !          7629:                                }
        !          7630: 
        !          7631:                        break;
        !          7632:                }
        !          7633:                case 0x67:
        !          7634:                {
        !          7635:                        sdwCyclesRemaining -= 9;
        !          7636:                        cpu.z80XH = cpu.z80A;
        !          7637:                        break;
        !          7638:                }
        !          7639:                case 0x68:
        !          7640:                {
        !          7641:                        sdwCyclesRemaining -= 9;
        !          7642:                        cpu.z80XL = cpu.z80B;
        !          7643:                        break;
        !          7644:                }
        !          7645:                case 0x69:
        !          7646:                {
        !          7647:                        sdwCyclesRemaining -= 9;
        !          7648:                        cpu.z80XL = cpu.z80C;
        !          7649:                        break;
        !          7650:                }
        !          7651:                case 0x6a:
        !          7652:                {
        !          7653:                        sdwCyclesRemaining -= 9;
        !          7654:                        cpu.z80XL = cpu.z80D;
        !          7655:                        break;
        !          7656:                }
        !          7657:                case 0x6b:
        !          7658:                {
        !          7659:                        sdwCyclesRemaining -= 9;
        !          7660:                        cpu.z80XL = cpu.z80E;
        !          7661:                        break;
        !          7662:                }
        !          7663:                case 0x6c:
        !          7664:                {
        !          7665:                        sdwCyclesRemaining -= 9;
        !          7666:                        cpu.z80XL = cpu.z80XH;
        !          7667:                        break;
        !          7668:                }
        !          7669:                case 0x6d:
        !          7670:                {
        !          7671:                        sdwCyclesRemaining -= 9;
        !          7672:                        break;
        !          7673:                }
        !          7674:                case 0x6e:
        !          7675:                {
        !          7676:                        sdwCyclesRemaining -= 19;
        !          7677:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7678:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7679:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7680:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7681:                                {
        !          7682:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          7683:                                        {
        !          7684:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7685:                                                if (psMemRead->memoryCall)
        !          7686:                                                {
        !          7687:                                                        cpu.z80L = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          7688:                                                }
        !          7689:                                                else
        !          7690:                                                {
        !          7691:                                                        cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          7692:                                                }
        !          7693:                                                psMemRead = NULL;
        !          7694:                                                break;
        !          7695:                                        }
        !          7696:                                        ++psMemRead;
        !          7697:                                }
        !          7698: 
        !          7699:                                if (psMemRead)
        !          7700:                                {
        !          7701:                                        cpu.z80L = cpu.z80Base[sdwAddr];
        !          7702:                                }
        !          7703: 
        !          7704:                        break;
        !          7705:                }
        !          7706:                case 0x6f:
        !          7707:                {
        !          7708:                        sdwCyclesRemaining -= 9;
        !          7709:                        cpu.z80XL = cpu.z80A;
        !          7710:                        break;
        !          7711:                }
        !          7712:                case 0x70:
        !          7713:                {
        !          7714:                        sdwCyclesRemaining -= 19;
        !          7715:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7716:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7717:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7718:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7719:                                {
        !          7720:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          7721:                                        {
        !          7722:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7723:                                                if (psMemWrite->memoryCall)
        !          7724:                                                {
        !          7725:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80B, psMemWrite);
        !          7726:                                                }
        !          7727:                                                else
        !          7728:                                                {
        !          7729:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80B;
        !          7730:                                                }
        !          7731:                                                psMemWrite = NULL;
        !          7732:                                                break;
        !          7733:                                        }
        !          7734:                                        ++psMemWrite;
        !          7735:                                }
        !          7736: 
        !          7737:                                if (psMemWrite)
        !          7738:                                {
        !          7739:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80B;
        !          7740:                                }
        !          7741: 
        !          7742:                        break;
        !          7743:                }
        !          7744:                case 0x71:
        !          7745:                {
        !          7746:                        sdwCyclesRemaining -= 19;
        !          7747:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7748:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7749:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7750:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7751:                                {
        !          7752:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          7753:                                        {
        !          7754:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7755:                                                if (psMemWrite->memoryCall)
        !          7756:                                                {
        !          7757:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80C, psMemWrite);
        !          7758:                                                }
        !          7759:                                                else
        !          7760:                                                {
        !          7761:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80C;
        !          7762:                                                }
        !          7763:                                                psMemWrite = NULL;
        !          7764:                                                break;
        !          7765:                                        }
        !          7766:                                        ++psMemWrite;
        !          7767:                                }
        !          7768: 
        !          7769:                                if (psMemWrite)
        !          7770:                                {
        !          7771:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80C;
        !          7772:                                }
        !          7773: 
        !          7774:                        break;
        !          7775:                }
        !          7776:                case 0x72:
        !          7777:                {
        !          7778:                        sdwCyclesRemaining -= 19;
        !          7779:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7780:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7781:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7782:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7783:                                {
        !          7784:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          7785:                                        {
        !          7786:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7787:                                                if (psMemWrite->memoryCall)
        !          7788:                                                {
        !          7789:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80D, psMemWrite);
        !          7790:                                                }
        !          7791:                                                else
        !          7792:                                                {
        !          7793:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80D;
        !          7794:                                                }
        !          7795:                                                psMemWrite = NULL;
        !          7796:                                                break;
        !          7797:                                        }
        !          7798:                                        ++psMemWrite;
        !          7799:                                }
        !          7800: 
        !          7801:                                if (psMemWrite)
        !          7802:                                {
        !          7803:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80D;
        !          7804:                                }
        !          7805: 
        !          7806:                        break;
        !          7807:                }
        !          7808:                case 0x73:
        !          7809:                {
        !          7810:                        sdwCyclesRemaining -= 19;
        !          7811:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7812:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7813:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7814:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7815:                                {
        !          7816:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          7817:                                        {
        !          7818:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7819:                                                if (psMemWrite->memoryCall)
        !          7820:                                                {
        !          7821:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80E, psMemWrite);
        !          7822:                                                }
        !          7823:                                                else
        !          7824:                                                {
        !          7825:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80E;
        !          7826:                                                }
        !          7827:                                                psMemWrite = NULL;
        !          7828:                                                break;
        !          7829:                                        }
        !          7830:                                        ++psMemWrite;
        !          7831:                                }
        !          7832: 
        !          7833:                                if (psMemWrite)
        !          7834:                                {
        !          7835:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80E;
        !          7836:                                }
        !          7837: 
        !          7838:                        break;
        !          7839:                }
        !          7840:                case 0x74:
        !          7841:                {
        !          7842:                        sdwCyclesRemaining -= 19;
        !          7843:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7844:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7845:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7846:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7847:                                {
        !          7848:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          7849:                                        {
        !          7850:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7851:                                                if (psMemWrite->memoryCall)
        !          7852:                                                {
        !          7853:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80H, psMemWrite);
        !          7854:                                                }
        !          7855:                                                else
        !          7856:                                                {
        !          7857:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80H;
        !          7858:                                                }
        !          7859:                                                psMemWrite = NULL;
        !          7860:                                                break;
        !          7861:                                        }
        !          7862:                                        ++psMemWrite;
        !          7863:                                }
        !          7864: 
        !          7865:                                if (psMemWrite)
        !          7866:                                {
        !          7867:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80H;
        !          7868:                                }
        !          7869: 
        !          7870:                        break;
        !          7871:                }
        !          7872:                case 0x75:
        !          7873:                {
        !          7874:                        sdwCyclesRemaining -= 19;
        !          7875:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7876:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7877:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7878:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7879:                                {
        !          7880:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          7881:                                        {
        !          7882:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7883:                                                if (psMemWrite->memoryCall)
        !          7884:                                                {
        !          7885:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80L, psMemWrite);
        !          7886:                                                }
        !          7887:                                                else
        !          7888:                                                {
        !          7889:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80L;
        !          7890:                                                }
        !          7891:                                                psMemWrite = NULL;
        !          7892:                                                break;
        !          7893:                                        }
        !          7894:                                        ++psMemWrite;
        !          7895:                                }
        !          7896: 
        !          7897:                                if (psMemWrite)
        !          7898:                                {
        !          7899:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80L;
        !          7900:                                }
        !          7901: 
        !          7902:                        break;
        !          7903:                }
        !          7904:                case 0x76:
        !          7905:                {
        !          7906:                        sdwCyclesRemaining -= 19;
        !          7907:                                InvalidInstruction(2);
        !          7908:                        break;
        !          7909:                }
        !          7910:                case 0x77:
        !          7911:                {
        !          7912:                        sdwCyclesRemaining -= 19;
        !          7913:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7914:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7915:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          7916:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          7917:                                {
        !          7918:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          7919:                                        {
        !          7920:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7921:                                                if (psMemWrite->memoryCall)
        !          7922:                                                {
        !          7923:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80A, psMemWrite);
        !          7924:                                                }
        !          7925:                                                else
        !          7926:                                                {
        !          7927:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80A;
        !          7928:                                                }
        !          7929:                                                psMemWrite = NULL;
        !          7930:                                                break;
        !          7931:                                        }
        !          7932:                                        ++psMemWrite;
        !          7933:                                }
        !          7934: 
        !          7935:                                if (psMemWrite)
        !          7936:                                {
        !          7937:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80A;
        !          7938:                                }
        !          7939: 
        !          7940:                        break;
        !          7941:                }
        !          7942:                case 0x78:
        !          7943:                {
        !          7944:                                InvalidInstruction(2);
        !          7945:                        break;
        !          7946:                }
        !          7947:                case 0x79:
        !          7948:                {
        !          7949:                                InvalidInstruction(2);
        !          7950:                        break;
        !          7951:                }
        !          7952:                case 0x7a:
        !          7953:                {
        !          7954:                                InvalidInstruction(2);
        !          7955:                        break;
        !          7956:                }
        !          7957:                case 0x7b:
        !          7958:                {
        !          7959:                                InvalidInstruction(2);
        !          7960:                        break;
        !          7961:                }
        !          7962:                case 0x7c:
        !          7963:                {
        !          7964:                        sdwCyclesRemaining -= 9;
        !          7965:                        cpu.z80A = cpu.z80XH;
        !          7966:                        break;
        !          7967:                }
        !          7968:                case 0x7d:
        !          7969:                {
        !          7970:                        sdwCyclesRemaining -= 9;
        !          7971:                        cpu.z80A = cpu.z80XL;
        !          7972:                        break;
        !          7973:                }
        !          7974:                case 0x7e:
        !          7975:                {
        !          7976:                        sdwCyclesRemaining -= 19;
        !          7977:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          7978:                                sdwAddr = ((INT32) cpu.z80IX + sdwAddr) & 0xffff;
        !          7979:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          7980:                                while (psMemRead->lowAddr != 0xffffffff)
        !          7981:                                {
        !          7982:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          7983:                                        {
        !          7984:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          7985:                                                if (psMemRead->memoryCall)
        !          7986:                                                {
        !          7987:                                                        cpu.z80A = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          7988:                                                }
        !          7989:                                                else
        !          7990:                                                {
        !          7991:                                                        cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          7992:                                                }
        !          7993:                                                psMemRead = NULL;
        !          7994:                                                break;
        !          7995:                                        }
        !          7996:                                        ++psMemRead;
        !          7997:                                }
        !          7998: 
        !          7999:                                if (psMemRead)
        !          8000:                                {
        !          8001:                                        cpu.z80A = cpu.z80Base[sdwAddr];
        !          8002:                                }
        !          8003: 
        !          8004:                        break;
        !          8005:                }
        !          8006:                case 0x7f:
        !          8007:                {
        !          8008:                                InvalidInstruction(2);
        !          8009:                        break;
        !          8010:                }
        !          8011:                case 0x80:
        !          8012:                {
        !          8013:                                InvalidInstruction(2);
        !          8014:                        break;
        !          8015:                }
        !          8016:                case 0x81:
        !          8017:                {
        !          8018:                                InvalidInstruction(2);
        !          8019:                        break;
        !          8020:                }
        !          8021:                case 0x82:
        !          8022:                {
        !          8023:                                InvalidInstruction(2);
        !          8024:                        break;
        !          8025:                }
        !          8026:                case 0x83:
        !          8027:                {
        !          8028:                                InvalidInstruction(2);
        !          8029:                        break;
        !          8030:                }
        !          8031:                case 0x84:
        !          8032:                {
        !          8033:                        sdwCyclesRemaining -= 9;
        !          8034:                                bTemp2 = cpu.z80A + cpu.z80XH;
        !          8035:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8036:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8037:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH];
        !          8038:                        break;
        !          8039:                }
        !          8040:                case 0x85:
        !          8041:                {
        !          8042:                        sdwCyclesRemaining -= 9;
        !          8043:                                bTemp2 = cpu.z80A + cpu.z80XL;
        !          8044:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8045:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8046:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL];
        !          8047:                        break;
        !          8048:                }
        !          8049:                case 0x86:
        !          8050:                {
        !          8051:                        sdwCyclesRemaining -= 19;
        !          8052:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          8053:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          8054:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8055:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8056:                                {
        !          8057:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          8058:                                        {
        !          8059:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8060:                                                if (psMemRead->memoryCall)
        !          8061:                                                {
        !          8062:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          8063:                                                }
        !          8064:                                                else
        !          8065:                                                {
        !          8066:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          8067:                                                }
        !          8068:                                                psMemRead = NULL;
        !          8069:                                                break;
        !          8070:                                        }
        !          8071:                                        ++psMemRead;
        !          8072:                                }
        !          8073: 
        !          8074:                                if (psMemRead)
        !          8075:                                {
        !          8076:                                        bTemp = cpu.z80Base[dwAddr];
        !          8077:                                }
        !          8078: 
        !          8079:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8080:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8081:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          8082:                                cpu.z80A += bTemp;
        !          8083:                        break;
        !          8084:                }
        !          8085:                case 0x87:
        !          8086:                {
        !          8087:                                InvalidInstruction(2);
        !          8088:                        break;
        !          8089:                }
        !          8090:                case 0x88:
        !          8091:                {
        !          8092:                                InvalidInstruction(2);
        !          8093:                        break;
        !          8094:                }
        !          8095:                case 0x89:
        !          8096:                {
        !          8097:                                InvalidInstruction(2);
        !          8098:                        break;
        !          8099:                }
        !          8100:                case 0x8a:
        !          8101:                {
        !          8102:                                InvalidInstruction(2);
        !          8103:                        break;
        !          8104:                }
        !          8105:                case 0x8b:
        !          8106:                {
        !          8107:                                InvalidInstruction(2);
        !          8108:                        break;
        !          8109:                }
        !          8110:                case 0x8c:
        !          8111:                {
        !          8112:                        sdwCyclesRemaining -= 9;
        !          8113:                                bTemp2 = cpu.z80A + cpu.z80XH + (cpu.z80F & Z80_FLAG_CARRY);
        !          8114:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8115:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8116:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          8117:                        break;
        !          8118:                }
        !          8119:                case 0x8d:
        !          8120:                {
        !          8121:                        sdwCyclesRemaining -= 9;
        !          8122:                                bTemp2 = cpu.z80A + cpu.z80XL + (cpu.z80F & Z80_FLAG_CARRY);
        !          8123:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8124:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8125:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          8126:                        break;
        !          8127:                }
        !          8128:                case 0x8e:
        !          8129:                {
        !          8130:                        sdwCyclesRemaining -= 19;
        !          8131:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          8132:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          8133:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8134:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8135:                                {
        !          8136:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          8137:                                        {
        !          8138:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8139:                                                if (psMemRead->memoryCall)
        !          8140:                                                {
        !          8141:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          8142:                                                }
        !          8143:                                                else
        !          8144:                                                {
        !          8145:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          8146:                                                }
        !          8147:                                                psMemRead = NULL;
        !          8148:                                                break;
        !          8149:                                        }
        !          8150:                                        ++psMemRead;
        !          8151:                                }
        !          8152: 
        !          8153:                                if (psMemRead)
        !          8154:                                {
        !          8155:                                        bTemp = cpu.z80Base[dwAddr];
        !          8156:                                }
        !          8157: 
        !          8158:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY);
        !          8159:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8160:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8161:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          8162:                                cpu.z80A += bTemp + bTemp2;
        !          8163:                        break;
        !          8164:                }
        !          8165:                case 0x8f:
        !          8166:                {
        !          8167:                                InvalidInstruction(2);
        !          8168:                        break;
        !          8169:                }
        !          8170:                case 0x90:
        !          8171:                {
        !          8172:                                InvalidInstruction(2);
        !          8173:                        break;
        !          8174:                }
        !          8175:                case 0x91:
        !          8176:                {
        !          8177:                                InvalidInstruction(2);
        !          8178:                        break;
        !          8179:                }
        !          8180:                case 0x92:
        !          8181:                {
        !          8182:                                InvalidInstruction(2);
        !          8183:                        break;
        !          8184:                }
        !          8185:                case 0x93:
        !          8186:                {
        !          8187:                                InvalidInstruction(2);
        !          8188:                        break;
        !          8189:                }
        !          8190:                case 0x94:
        !          8191:                {
        !          8192:                        sdwCyclesRemaining -= 9;
        !          8193:                                bTemp2 = cpu.z80A - cpu.z80XH;
        !          8194:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8195:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8196:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH];
        !          8197:                        break;
        !          8198:                }
        !          8199:                case 0x95:
        !          8200:                {
        !          8201:                        sdwCyclesRemaining -= 9;
        !          8202:                                bTemp2 = cpu.z80A - cpu.z80XL;
        !          8203:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8204:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8205:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL];
        !          8206:                        break;
        !          8207:                }
        !          8208:                case 0x96:
        !          8209:                {
        !          8210:                        sdwCyclesRemaining -= 19;
        !          8211:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          8212:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          8213:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8214:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8215:                                {
        !          8216:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          8217:                                        {
        !          8218:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8219:                                                if (psMemRead->memoryCall)
        !          8220:                                                {
        !          8221:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          8222:                                                }
        !          8223:                                                else
        !          8224:                                                {
        !          8225:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          8226:                                                }
        !          8227:                                                psMemRead = NULL;
        !          8228:                                                break;
        !          8229:                                        }
        !          8230:                                        ++psMemRead;
        !          8231:                                }
        !          8232: 
        !          8233:                                if (psMemRead)
        !          8234:                                {
        !          8235:                                        bTemp = cpu.z80Base[dwAddr];
        !          8236:                                }
        !          8237: 
        !          8238:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8239:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8240:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          8241:                                cpu.z80A -= bTemp;
        !          8242:                        break;
        !          8243:                }
        !          8244:                case 0x97:
        !          8245:                {
        !          8246:                                InvalidInstruction(2);
        !          8247:                        break;
        !          8248:                }
        !          8249:                case 0x98:
        !          8250:                {
        !          8251:                                InvalidInstruction(2);
        !          8252:                        break;
        !          8253:                }
        !          8254:                case 0x99:
        !          8255:                {
        !          8256:                                InvalidInstruction(2);
        !          8257:                        break;
        !          8258:                }
        !          8259:                case 0x9a:
        !          8260:                {
        !          8261:                                InvalidInstruction(2);
        !          8262:                        break;
        !          8263:                }
        !          8264:                case 0x9b:
        !          8265:                {
        !          8266:                                InvalidInstruction(2);
        !          8267:                        break;
        !          8268:                }
        !          8269:                case 0x9c:
        !          8270:                {
        !          8271:                        sdwCyclesRemaining -= 9;
        !          8272:                                bTemp2 = cpu.z80A - cpu.z80XH - (cpu.z80F & Z80_FLAG_CARRY);
        !          8273:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8274:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8275:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          8276:                        break;
        !          8277:                }
        !          8278:                case 0x9d:
        !          8279:                {
        !          8280:                        sdwCyclesRemaining -= 9;
        !          8281:                                bTemp2 = cpu.z80A - cpu.z80XL - (cpu.z80F & Z80_FLAG_CARRY);
        !          8282:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8283:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8284:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80XL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          8285:                        break;
        !          8286:                }
        !          8287:                case 0x9e:
        !          8288:                {
        !          8289:                        sdwCyclesRemaining -= 19;
        !          8290:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          8291:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          8292:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8293:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8294:                                {
        !          8295:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          8296:                                        {
        !          8297:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8298:                                                if (psMemRead->memoryCall)
        !          8299:                                                {
        !          8300:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          8301:                                                }
        !          8302:                                                else
        !          8303:                                                {
        !          8304:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          8305:                                                }
        !          8306:                                                psMemRead = NULL;
        !          8307:                                                break;
        !          8308:                                        }
        !          8309:                                        ++psMemRead;
        !          8310:                                }
        !          8311: 
        !          8312:                                if (psMemRead)
        !          8313:                                {
        !          8314:                                        bTemp = cpu.z80Base[dwAddr];
        !          8315:                                }
        !          8316: 
        !          8317:                                bTemp2 = cpu.z80A;
        !          8318:                                cpu.z80A = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY);
        !          8319:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8320:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8321:                                                                pbSubSbcTable[((UINT32) bTemp2 << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          8322:                        break;
        !          8323:                }
        !          8324:                case 0x9f:
        !          8325:                {
        !          8326:                                InvalidInstruction(2);
        !          8327:                        break;
        !          8328:                }
        !          8329:                case 0xa0:
        !          8330:                {
        !          8331:                                InvalidInstruction(2);
        !          8332:                        break;
        !          8333:                }
        !          8334:                case 0xa1:
        !          8335:                {
        !          8336:                                InvalidInstruction(2);
        !          8337:                        break;
        !          8338:                }
        !          8339:                case 0xa2:
        !          8340:                {
        !          8341:                                InvalidInstruction(2);
        !          8342:                        break;
        !          8343:                }
        !          8344:                case 0xa3:
        !          8345:                {
        !          8346:                                InvalidInstruction(2);
        !          8347:                        break;
        !          8348:                }
        !          8349:                case 0xa4:
        !          8350:                {
        !          8351:                        sdwCyclesRemaining -= 9;
        !          8352:                                cpu.z80A &= cpu.z80XH;
        !          8353:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8354:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          8355: 
        !          8356:                        break;
        !          8357:                }
        !          8358:                case 0xa5:
        !          8359:                {
        !          8360:                        sdwCyclesRemaining -= 9;
        !          8361:                                cpu.z80A &= cpu.z80XL;
        !          8362:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8363:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          8364: 
        !          8365:                        break;
        !          8366:                }
        !          8367:                case 0xa6:
        !          8368:                {
        !          8369:                        sdwCyclesRemaining -= 19;
        !          8370:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          8371:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          8372:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8373:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8374:                                {
        !          8375:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          8376:                                        {
        !          8377:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8378:                                                if (psMemRead->memoryCall)
        !          8379:                                                {
        !          8380:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          8381:                                                }
        !          8382:                                                else
        !          8383:                                                {
        !          8384:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          8385:                                                }
        !          8386:                                                psMemRead = NULL;
        !          8387:                                                break;
        !          8388:                                        }
        !          8389:                                        ++psMemRead;
        !          8390:                                }
        !          8391: 
        !          8392:                                if (psMemRead)
        !          8393:                                {
        !          8394:                                        bTemp = cpu.z80Base[dwAddr];
        !          8395:                                }
        !          8396: 
        !          8397:                                cpu.z80A &= bTemp;
        !          8398:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8399:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          8400: 
        !          8401:                        break;
        !          8402:                }
        !          8403:                case 0xa7:
        !          8404:                {
        !          8405:                                InvalidInstruction(2);
        !          8406:                        break;
        !          8407:                }
        !          8408:                case 0xa8:
        !          8409:                {
        !          8410:                                InvalidInstruction(2);
        !          8411:                        break;
        !          8412:                }
        !          8413:                case 0xa9:
        !          8414:                {
        !          8415:                                InvalidInstruction(2);
        !          8416:                        break;
        !          8417:                }
        !          8418:                case 0xaa:
        !          8419:                {
        !          8420:                                InvalidInstruction(2);
        !          8421:                        break;
        !          8422:                }
        !          8423:                case 0xab:
        !          8424:                {
        !          8425:                                InvalidInstruction(2);
        !          8426:                        break;
        !          8427:                }
        !          8428:                case 0xac:
        !          8429:                {
        !          8430:                        sdwCyclesRemaining -= 9;
        !          8431:                                cpu.z80A ^= cpu.z80XH;
        !          8432:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8433:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          8434: 
        !          8435:                        break;
        !          8436:                }
        !          8437:                case 0xad:
        !          8438:                {
        !          8439:                        sdwCyclesRemaining -= 9;
        !          8440:                                cpu.z80A ^= cpu.z80XL;
        !          8441:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8442:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          8443: 
        !          8444:                        break;
        !          8445:                }
        !          8446:                case 0xae:
        !          8447:                {
        !          8448:                        sdwCyclesRemaining -= 19;
        !          8449:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          8450:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          8451:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8452:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8453:                                {
        !          8454:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          8455:                                        {
        !          8456:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8457:                                                if (psMemRead->memoryCall)
        !          8458:                                                {
        !          8459:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          8460:                                                }
        !          8461:                                                else
        !          8462:                                                {
        !          8463:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          8464:                                                }
        !          8465:                                                psMemRead = NULL;
        !          8466:                                                break;
        !          8467:                                        }
        !          8468:                                        ++psMemRead;
        !          8469:                                }
        !          8470: 
        !          8471:                                if (psMemRead)
        !          8472:                                {
        !          8473:                                        bTemp = cpu.z80Base[dwAddr];
        !          8474:                                }
        !          8475: 
        !          8476:                                cpu.z80A ^= bTemp;
        !          8477:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8478:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          8479: 
        !          8480:                        break;
        !          8481:                }
        !          8482:                case 0xaf:
        !          8483:                {
        !          8484:                                InvalidInstruction(2);
        !          8485:                        break;
        !          8486:                }
        !          8487:                case 0xb0:
        !          8488:                {
        !          8489:                                InvalidInstruction(2);
        !          8490:                        break;
        !          8491:                }
        !          8492:                case 0xb1:
        !          8493:                {
        !          8494:                                InvalidInstruction(2);
        !          8495:                        break;
        !          8496:                }
        !          8497:                case 0xb2:
        !          8498:                {
        !          8499:                                InvalidInstruction(2);
        !          8500:                        break;
        !          8501:                }
        !          8502:                case 0xb3:
        !          8503:                {
        !          8504:                                InvalidInstruction(2);
        !          8505:                        break;
        !          8506:                }
        !          8507:                case 0xb4:
        !          8508:                {
        !          8509:                        sdwCyclesRemaining -= 9;
        !          8510:                                cpu.z80A |= cpu.z80XH;
        !          8511:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8512:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          8513: 
        !          8514:                        break;
        !          8515:                }
        !          8516:                case 0xb5:
        !          8517:                {
        !          8518:                        sdwCyclesRemaining -= 9;
        !          8519:                                cpu.z80A |= cpu.z80XL;
        !          8520:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8521:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          8522: 
        !          8523:                        break;
        !          8524:                }
        !          8525:                case 0xb6:
        !          8526:                {
        !          8527:                        sdwCyclesRemaining -= 19;
        !          8528:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          8529:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          8530:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8531:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8532:                                {
        !          8533:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          8534:                                        {
        !          8535:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8536:                                                if (psMemRead->memoryCall)
        !          8537:                                                {
        !          8538:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          8539:                                                }
        !          8540:                                                else
        !          8541:                                                {
        !          8542:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          8543:                                                }
        !          8544:                                                psMemRead = NULL;
        !          8545:                                                break;
        !          8546:                                        }
        !          8547:                                        ++psMemRead;
        !          8548:                                }
        !          8549: 
        !          8550:                                if (psMemRead)
        !          8551:                                {
        !          8552:                                        bTemp = cpu.z80Base[dwAddr];
        !          8553:                                }
        !          8554: 
        !          8555:                                cpu.z80A |= bTemp;
        !          8556:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8557:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          8558: 
        !          8559:                        break;
        !          8560:                }
        !          8561:                case 0xb7:
        !          8562:                {
        !          8563:                                InvalidInstruction(2);
        !          8564:                        break;
        !          8565:                }
        !          8566:                case 0xb8:
        !          8567:                {
        !          8568:                                InvalidInstruction(2);
        !          8569:                        break;
        !          8570:                }
        !          8571:                case 0xb9:
        !          8572:                {
        !          8573:                                InvalidInstruction(2);
        !          8574:                        break;
        !          8575:                }
        !          8576:                case 0xba:
        !          8577:                {
        !          8578:                                InvalidInstruction(2);
        !          8579:                        break;
        !          8580:                }
        !          8581:                case 0xbb:
        !          8582:                {
        !          8583:                                InvalidInstruction(2);
        !          8584:                        break;
        !          8585:                }
        !          8586:                case 0xbc:
        !          8587:                {
        !          8588:                        sdwCyclesRemaining -= 9;
        !          8589:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8590:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          8591: 
        !          8592:                        break;
        !          8593:                }
        !          8594:                case 0xbd:
        !          8595:                {
        !          8596:                        sdwCyclesRemaining -= 9;
        !          8597:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          8598:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          8599: 
        !          8600:                        break;
        !          8601:                }
        !          8602:                case 0xbe:
        !          8603:                {
        !          8604:                        sdwCyclesRemaining -= 19;
        !          8605:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          8606:                                dwAddr = (sdwAddr + (INT32) cpu.z80IX) & 0xffff;
        !          8607:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8608:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8609:                                {
        !          8610:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          8611:                                        {
        !          8612:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8613:                                                if (psMemRead->memoryCall)
        !          8614:                                                {
        !          8615:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          8616:                                                }
        !          8617:                                                else
        !          8618:                                                {
        !          8619:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          8620:                                                }
        !          8621:                                                psMemRead = NULL;
        !          8622:                                                break;
        !          8623:                                        }
        !          8624:                                        ++psMemRead;
        !          8625:                                }
        !          8626: 
        !          8627:                                if (psMemRead)
        !          8628:                                {
        !          8629:                                        bTemp = cpu.z80Base[dwAddr];
        !          8630:                                }
        !          8631: 
        !          8632:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          8633:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          8634:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          8635:                        break;
        !          8636:                }
        !          8637:                case 0xbf:
        !          8638:                {
        !          8639:                                InvalidInstruction(2);
        !          8640:                        break;
        !          8641:                }
        !          8642:                case 0xc0:
        !          8643:                {
        !          8644:                                InvalidInstruction(2);
        !          8645:                        break;
        !          8646:                }
        !          8647:                case 0xc1:
        !          8648:                {
        !          8649:                                InvalidInstruction(2);
        !          8650:                        break;
        !          8651:                }
        !          8652:                case 0xc2:
        !          8653:                {
        !          8654:                                InvalidInstruction(2);
        !          8655:                        break;
        !          8656:                }
        !          8657:                case 0xc3:
        !          8658:                {
        !          8659:                                InvalidInstruction(2);
        !          8660:                        break;
        !          8661:                }
        !          8662:                case 0xc4:
        !          8663:                {
        !          8664:                                InvalidInstruction(2);
        !          8665:                        break;
        !          8666:                }
        !          8667:                case 0xc5:
        !          8668:                {
        !          8669:                                InvalidInstruction(2);
        !          8670:                        break;
        !          8671:                }
        !          8672:                case 0xc6:
        !          8673:                {
        !          8674:                                InvalidInstruction(2);
        !          8675:                        break;
        !          8676:                }
        !          8677:                case 0xc7:
        !          8678:                {
        !          8679:                                InvalidInstruction(2);
        !          8680:                        break;
        !          8681:                }
        !          8682:                case 0xc8:
        !          8683:                {
        !          8684:                                InvalidInstruction(2);
        !          8685:                        break;
        !          8686:                }
        !          8687:                case 0xc9:
        !          8688:                {
        !          8689:                                InvalidInstruction(2);
        !          8690:                        break;
        !          8691:                }
        !          8692:                case 0xca:
        !          8693:                {
        !          8694:                                InvalidInstruction(2);
        !          8695:                        break;
        !          8696:                }
        !          8697:                case 0xcb:
        !          8698:                {
        !          8699:                                DDFDCBHandler(0);
        !          8700:                        break;
        !          8701:                }
        !          8702:                case 0xcc:
        !          8703:                {
        !          8704:                                InvalidInstruction(2);
        !          8705:                        break;
        !          8706:                }
        !          8707:                case 0xcd:
        !          8708:                {
        !          8709:                                InvalidInstruction(2);
        !          8710:                        break;
        !          8711:                }
        !          8712:                case 0xce:
        !          8713:                {
        !          8714:                                InvalidInstruction(2);
        !          8715:                        break;
        !          8716:                }
        !          8717:                case 0xcf:
        !          8718:                {
        !          8719:                                InvalidInstruction(2);
        !          8720:                        break;
        !          8721:                }
        !          8722:                case 0xd0:
        !          8723:                {
        !          8724:                                InvalidInstruction(2);
        !          8725:                        break;
        !          8726:                }
        !          8727:                case 0xd1:
        !          8728:                {
        !          8729:                                InvalidInstruction(2);
        !          8730:                        break;
        !          8731:                }
        !          8732:                case 0xd2:
        !          8733:                {
        !          8734:                                InvalidInstruction(2);
        !          8735:                        break;
        !          8736:                }
        !          8737:                case 0xd3:
        !          8738:                {
        !          8739:                                InvalidInstruction(2);
        !          8740:                        break;
        !          8741:                }
        !          8742:                case 0xd4:
        !          8743:                {
        !          8744:                                InvalidInstruction(2);
        !          8745:                        break;
        !          8746:                }
        !          8747:                case 0xd5:
        !          8748:                {
        !          8749:                                InvalidInstruction(2);
        !          8750:                        break;
        !          8751:                }
        !          8752:                case 0xd6:
        !          8753:                {
        !          8754:                                InvalidInstruction(2);
        !          8755:                        break;
        !          8756:                }
        !          8757:                case 0xd7:
        !          8758:                {
        !          8759:                                InvalidInstruction(2);
        !          8760:                        break;
        !          8761:                }
        !          8762:                case 0xd8:
        !          8763:                {
        !          8764:                                InvalidInstruction(2);
        !          8765:                        break;
        !          8766:                }
        !          8767:                case 0xd9:
        !          8768:                {
        !          8769:                                InvalidInstruction(2);
        !          8770:                        break;
        !          8771:                }
        !          8772:                case 0xda:
        !          8773:                {
        !          8774:                                InvalidInstruction(2);
        !          8775:                        break;
        !          8776:                }
        !          8777:                case 0xdb:
        !          8778:                {
        !          8779:                                InvalidInstruction(2);
        !          8780:                        break;
        !          8781:                }
        !          8782:                case 0xdc:
        !          8783:                {
        !          8784:                                InvalidInstruction(2);
        !          8785:                        break;
        !          8786:                }
        !          8787:                case 0xdd:
        !          8788:                {
        !          8789:                                InvalidInstruction(2);
        !          8790:                        break;
        !          8791:                }
        !          8792:                case 0xde:
        !          8793:                {
        !          8794:                                InvalidInstruction(2);
        !          8795:                        break;
        !          8796:                }
        !          8797:                case 0xdf:
        !          8798:                {
        !          8799:                                InvalidInstruction(2);
        !          8800:                        break;
        !          8801:                }
        !          8802:                case 0xe0:
        !          8803:                {
        !          8804:                                InvalidInstruction(2);
        !          8805:                        break;
        !          8806:                }
        !          8807:                case 0xe1:
        !          8808:                {
        !          8809:                        sdwCyclesRemaining -= 14;
        !          8810:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8811:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8812:                                {
        !          8813:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          8814:                                        {
        !          8815:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8816:                                                if (psMemRead->memoryCall)
        !          8817:                                                {
        !          8818:                                                        cpu.z80IX = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          8819:                                                        cpu.z80IX |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          8820:                                                }
        !          8821:                                                else
        !          8822:                                                {
        !          8823:                                                        cpu.z80IX = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          8824:                                                        cpu.z80IX |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          8825:                                                }
        !          8826:                                                psMemRead = NULL;
        !          8827:                                                break;
        !          8828:                                        }
        !          8829:                                        ++psMemRead;
        !          8830:                                }
        !          8831: 
        !          8832:                                if (psMemRead)
        !          8833:                                {
        !          8834:                                        cpu.z80IX = cpu.z80Base[cpu.z80sp];
        !          8835:                                        cpu.z80IX |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          8836:                                }
        !          8837: 
        !          8838:                                        cpu.z80sp += 2;
        !          8839:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          8840:                        break;
        !          8841:                }
        !          8842:                case 0xe2:
        !          8843:                {
        !          8844:                                InvalidInstruction(2);
        !          8845:                        break;
        !          8846:                }
        !          8847:                case 0xe3:
        !          8848:                {
        !          8849:                        sdwCyclesRemaining -= 23;
        !          8850:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          8851:                                while (psMemRead->lowAddr != 0xffffffff)
        !          8852:                                {
        !          8853:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          8854:                                        {
        !          8855:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8856:                                                if (psMemRead->memoryCall)
        !          8857:                                                {
        !          8858:                                                        dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          8859:                                                        dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          8860:                                                }
        !          8861:                                                else
        !          8862:                                                {
        !          8863:                                                        dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          8864:                                                        dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          8865:                                                }
        !          8866:                                                psMemRead = NULL;
        !          8867:                                                break;
        !          8868:                                        }
        !          8869:                                        ++psMemRead;
        !          8870:                                }
        !          8871: 
        !          8872:                                if (psMemRead)
        !          8873:                                {
        !          8874:                                        dwAddr = cpu.z80Base[cpu.z80sp];
        !          8875:                                        dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          8876:                                }
        !          8877: 
        !          8878:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          8879:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          8880:                                {
        !          8881:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          8882:                                        {
        !          8883:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8884:                                                if (psMemWrite->memoryCall)
        !          8885:                                                {
        !          8886:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IX & 0xff), psMemWrite);
        !          8887:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IX >> 8), psMemWrite);
        !          8888:                                                }
        !          8889:                                                else
        !          8890:                                                {
        !          8891:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IX;
        !          8892:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8;
        !          8893:                                                }
        !          8894:                                                psMemWrite = NULL;
        !          8895:                                                break;
        !          8896:                                        }
        !          8897:                                        ++psMemWrite;
        !          8898:                                }
        !          8899: 
        !          8900:                                if (psMemWrite)
        !          8901:                                {
        !          8902:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IX;
        !          8903:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8);
        !          8904:                                }
        !          8905: 
        !          8906:                                cpu.z80IX = dwAddr;
        !          8907:                        break;
        !          8908:                }
        !          8909:                case 0xe4:
        !          8910:                {
        !          8911:                                InvalidInstruction(2);
        !          8912:                        break;
        !          8913:                }
        !          8914:                case 0xe5:
        !          8915:                {
        !          8916:                        sdwCyclesRemaining -= 15;
        !          8917:                                        cpu.z80sp -= 2;
        !          8918:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          8919:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          8920:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          8921:                                {
        !          8922:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          8923:                                        {
        !          8924:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          8925:                                                if (psMemWrite->memoryCall)
        !          8926:                                                {
        !          8927:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IX & 0xff), psMemWrite);
        !          8928:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IX >> 8), psMemWrite);
        !          8929:                                                }
        !          8930:                                                else
        !          8931:                                                {
        !          8932:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IX;
        !          8933:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IX >> 8;
        !          8934:                                                }
        !          8935:                                                psMemWrite = NULL;
        !          8936:                                                break;
        !          8937:                                        }
        !          8938:                                        ++psMemWrite;
        !          8939:                                }
        !          8940: 
        !          8941:                                if (psMemWrite)
        !          8942:                                {
        !          8943:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IX;
        !          8944:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IX >> 8);
        !          8945:                                }
        !          8946: 
        !          8947:                        break;
        !          8948:                }
        !          8949:                case 0xe6:
        !          8950:                {
        !          8951:                                InvalidInstruction(2);
        !          8952:                        break;
        !          8953:                }
        !          8954:                case 0xe7:
        !          8955:                {
        !          8956:                                InvalidInstruction(2);
        !          8957:                        break;
        !          8958:                }
        !          8959:                case 0xe8:
        !          8960:                {
        !          8961:                                InvalidInstruction(2);
        !          8962:                        break;
        !          8963:                }
        !          8964:                case 0xe9:
        !          8965:                {
        !          8966:                        sdwCyclesRemaining -= 8;
        !          8967:                                pbPC = cpu.z80Base + cpu.z80IX;
        !          8968:                        break;
        !          8969:                }
        !          8970:                case 0xea:
        !          8971:                {
        !          8972:                                InvalidInstruction(2);
        !          8973:                        break;
        !          8974:                }
        !          8975:                case 0xeb:
        !          8976:                {
        !          8977:                                InvalidInstruction(2);
        !          8978:                        break;
        !          8979:                }
        !          8980:                case 0xec:
        !          8981:                {
        !          8982:                                InvalidInstruction(2);
        !          8983:                        break;
        !          8984:                }
        !          8985:                case 0xed:
        !          8986:                {
        !          8987:                                InvalidInstruction(2);
        !          8988:                        break;
        !          8989:                }
        !          8990:                case 0xee:
        !          8991:                {
        !          8992:                                InvalidInstruction(2);
        !          8993:                        break;
        !          8994:                }
        !          8995:                case 0xef:
        !          8996:                {
        !          8997:                                InvalidInstruction(2);
        !          8998:                        break;
        !          8999:                }
        !          9000:                case 0xf0:
        !          9001:                {
        !          9002:                                InvalidInstruction(2);
        !          9003:                        break;
        !          9004:                }
        !          9005:                case 0xf1:
        !          9006:                {
        !          9007:                                InvalidInstruction(2);
        !          9008:                        break;
        !          9009:                }
        !          9010:                case 0xf2:
        !          9011:                {
        !          9012:                                InvalidInstruction(2);
        !          9013:                        break;
        !          9014:                }
        !          9015:                case 0xf3:
        !          9016:                {
        !          9017:                                InvalidInstruction(2);
        !          9018:                        break;
        !          9019:                }
        !          9020:                case 0xf4:
        !          9021:                {
        !          9022:                                InvalidInstruction(2);
        !          9023:                        break;
        !          9024:                }
        !          9025:                case 0xf5:
        !          9026:                {
        !          9027:                                InvalidInstruction(2);
        !          9028:                        break;
        !          9029:                }
        !          9030:                case 0xf6:
        !          9031:                {
        !          9032:                                InvalidInstruction(2);
        !          9033:                        break;
        !          9034:                }
        !          9035:                case 0xf7:
        !          9036:                {
        !          9037:                                InvalidInstruction(2);
        !          9038:                        break;
        !          9039:                }
        !          9040:                case 0xf8:
        !          9041:                {
        !          9042:                                InvalidInstruction(2);
        !          9043:                        break;
        !          9044:                }
        !          9045:                case 0xf9:
        !          9046:                {
        !          9047:                        sdwCyclesRemaining -= 10;
        !          9048:                                cpu.z80sp = cpu.z80IX;
        !          9049:                        break;
        !          9050:                }
        !          9051:                case 0xfa:
        !          9052:                {
        !          9053:                                InvalidInstruction(2);
        !          9054:                        break;
        !          9055:                }
        !          9056:                case 0xfb:
        !          9057:                {
        !          9058:                                InvalidInstruction(2);
        !          9059:                        break;
        !          9060:                }
        !          9061:                case 0xfc:
        !          9062:                {
        !          9063:                                InvalidInstruction(2);
        !          9064:                        break;
        !          9065:                }
        !          9066:                case 0xfd:
        !          9067:                {
        !          9068:                                InvalidInstruction(2);
        !          9069:                        break;
        !          9070:                }
        !          9071:                case 0xfe:
        !          9072:                {
        !          9073:                                InvalidInstruction(2);
        !          9074:                        break;
        !          9075:                }
        !          9076:                case 0xff:
        !          9077:                {
        !          9078:                                InvalidInstruction(2);
        !          9079:                        break;
        !          9080:                }
        !          9081:        }
        !          9082: }
        !          9083: void DDFDCBHandler(UINT32 dwWhich)
        !          9084: {
        !          9085:        if (dwWhich)
        !          9086:        {
        !          9087:                dwAddr = (UINT32) ((INT32) cpu.z80IY + ((INT32) *pbPC++)) & 0xffff;
        !          9088:        }
        !          9089:        else
        !          9090:        {
        !          9091:                dwAddr = (UINT32) ((INT32) cpu.z80IX + ((INT32) *pbPC++)) & 0xffff;
        !          9092:        }
        !          9093: 
        !          9094:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          9095:                                while (psMemRead->lowAddr != 0xffffffff)
        !          9096:                                {
        !          9097:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          9098:                                        {
        !          9099:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          9100:                                                if (psMemRead->memoryCall)
        !          9101:                                                {
        !          9102:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          9103:                                                }
        !          9104:                                                else
        !          9105:                                                {
        !          9106:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          9107:                                                }
        !          9108:                                                psMemRead = NULL;
        !          9109:                                                break;
        !          9110:                                        }
        !          9111:                                        ++psMemRead;
        !          9112:                                }
        !          9113: 
        !          9114:                                if (psMemRead)
        !          9115:                                {
        !          9116:                                        bTemp = cpu.z80Base[dwAddr];
        !          9117:                                }
        !          9118: 
        !          9119:        switch (*pbPC++)
        !          9120:        {
        !          9121:                case 0x00:
        !          9122:                {
        !          9123:                                InvalidInstruction(4);
        !          9124:                        break;
        !          9125:                }
        !          9126:                case 0x01:
        !          9127:                {
        !          9128:                                InvalidInstruction(4);
        !          9129:                        break;
        !          9130:                }
        !          9131:                case 0x02:
        !          9132:                {
        !          9133:                                InvalidInstruction(4);
        !          9134:                        break;
        !          9135:                }
        !          9136:                case 0x03:
        !          9137:                {
        !          9138:                                InvalidInstruction(4);
        !          9139:                        break;
        !          9140:                }
        !          9141:                case 0x04:
        !          9142:                {
        !          9143:                                InvalidInstruction(4);
        !          9144:                        break;
        !          9145:                }
        !          9146:                case 0x05:
        !          9147:                {
        !          9148:                                InvalidInstruction(4);
        !          9149:                        break;
        !          9150:                }
        !          9151:                case 0x06:
        !          9152:                {
        !          9153:                        sdwCyclesRemaining -= 23;
        !          9154:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          9155:                                bTemp2 = (bTemp >> 7);
        !          9156:                                bTemp = (bTemp << 1) | bTemp2;
        !          9157:                                cpu.z80F |= bTemp2 | bPostORFlags[bTemp];
        !          9158:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          9159:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          9160:                                {
        !          9161:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          9162:                                        {
        !          9163:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          9164:                                                if (psMemWrite->memoryCall)
        !          9165:                                                {
        !          9166:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          9167:                                                }
        !          9168:                                                else
        !          9169:                                                {
        !          9170:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          9171:                                                }
        !          9172:                                                psMemWrite = NULL;
        !          9173:                                                break;
        !          9174:                                        }
        !          9175:                                        ++psMemWrite;
        !          9176:                                }
        !          9177: 
        !          9178:                                if (psMemWrite)
        !          9179:                                {
        !          9180:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          9181:                                }
        !          9182: 
        !          9183:                        break;
        !          9184:                }
        !          9185:                case 0x07:
        !          9186:                {
        !          9187:                                InvalidInstruction(4);
        !          9188:                        break;
        !          9189:                }
        !          9190:                case 0x08:
        !          9191:                {
        !          9192:                                InvalidInstruction(4);
        !          9193:                        break;
        !          9194:                }
        !          9195:                case 0x09:
        !          9196:                {
        !          9197:                                InvalidInstruction(4);
        !          9198:                        break;
        !          9199:                }
        !          9200:                case 0x0a:
        !          9201:                {
        !          9202:                                InvalidInstruction(4);
        !          9203:                        break;
        !          9204:                }
        !          9205:                case 0x0b:
        !          9206:                {
        !          9207:                                InvalidInstruction(4);
        !          9208:                        break;
        !          9209:                }
        !          9210:                case 0x0c:
        !          9211:                {
        !          9212:                                InvalidInstruction(4);
        !          9213:                        break;
        !          9214:                }
        !          9215:                case 0x0d:
        !          9216:                {
        !          9217:                                InvalidInstruction(4);
        !          9218:                        break;
        !          9219:                }
        !          9220:                case 0x0e:
        !          9221:                {
        !          9222:                        sdwCyclesRemaining -= 23;
        !          9223:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          9224:                                cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
        !          9225:                                bTemp = (bTemp >> 1) | (bTemp << 7);
        !          9226:                                cpu.z80F |= bPostORFlags[bTemp];
        !          9227:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          9228:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          9229:                                {
        !          9230:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          9231:                                        {
        !          9232:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          9233:                                                if (psMemWrite->memoryCall)
        !          9234:                                                {
        !          9235:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          9236:                                                }
        !          9237:                                                else
        !          9238:                                                {
        !          9239:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          9240:                                                }
        !          9241:                                                psMemWrite = NULL;
        !          9242:                                                break;
        !          9243:                                        }
        !          9244:                                        ++psMemWrite;
        !          9245:                                }
        !          9246: 
        !          9247:                                if (psMemWrite)
        !          9248:                                {
        !          9249:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          9250:                                }
        !          9251: 
        !          9252:                        break;
        !          9253:                }
        !          9254:                case 0x0f:
        !          9255:                {
        !          9256:                                InvalidInstruction(4);
        !          9257:                        break;
        !          9258:                }
        !          9259:                case 0x10:
        !          9260:                {
        !          9261:                                InvalidInstruction(4);
        !          9262:                        break;
        !          9263:                }
        !          9264:                case 0x11:
        !          9265:                {
        !          9266:                                InvalidInstruction(4);
        !          9267:                        break;
        !          9268:                }
        !          9269:                case 0x12:
        !          9270:                {
        !          9271:                                InvalidInstruction(4);
        !          9272:                        break;
        !          9273:                }
        !          9274:                case 0x13:
        !          9275:                {
        !          9276:                                InvalidInstruction(4);
        !          9277:                        break;
        !          9278:                }
        !          9279:                case 0x14:
        !          9280:                {
        !          9281:                                InvalidInstruction(4);
        !          9282:                        break;
        !          9283:                }
        !          9284:                case 0x15:
        !          9285:                {
        !          9286:                                InvalidInstruction(4);
        !          9287:                        break;
        !          9288:                }
        !          9289:                case 0x16:
        !          9290:                {
        !          9291:                        sdwCyclesRemaining -= 23;
        !          9292:                                bTemp2 = cpu.z80F & Z80_FLAG_CARRY;
        !          9293:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          9294:                                cpu.z80F |= (bTemp >> 7);
        !          9295:                                bTemp = (bTemp << 1) | bTemp2;
        !          9296:                                cpu.z80F |= bPostORFlags[bTemp];
        !          9297:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          9298:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          9299:                                {
        !          9300:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          9301:                                        {
        !          9302:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          9303:                                                if (psMemWrite->memoryCall)
        !          9304:                                                {
        !          9305:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          9306:                                                }
        !          9307:                                                else
        !          9308:                                                {
        !          9309:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          9310:                                                }
        !          9311:                                                psMemWrite = NULL;
        !          9312:                                                break;
        !          9313:                                        }
        !          9314:                                        ++psMemWrite;
        !          9315:                                }
        !          9316: 
        !          9317:                                if (psMemWrite)
        !          9318:                                {
        !          9319:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          9320:                                }
        !          9321: 
        !          9322:                        break;
        !          9323:                }
        !          9324:                case 0x17:
        !          9325:                {
        !          9326:                                InvalidInstruction(4);
        !          9327:                        break;
        !          9328:                }
        !          9329:                case 0x18:
        !          9330:                {
        !          9331:                                InvalidInstruction(4);
        !          9332:                        break;
        !          9333:                }
        !          9334:                case 0x19:
        !          9335:                {
        !          9336:                                InvalidInstruction(4);
        !          9337:                        break;
        !          9338:                }
        !          9339:                case 0x1a:
        !          9340:                {
        !          9341:                                InvalidInstruction(4);
        !          9342:                        break;
        !          9343:                }
        !          9344:                case 0x1b:
        !          9345:                {
        !          9346:                                InvalidInstruction(4);
        !          9347:                        break;
        !          9348:                }
        !          9349:                case 0x1c:
        !          9350:                {
        !          9351:                                InvalidInstruction(4);
        !          9352:                        break;
        !          9353:                }
        !          9354:                case 0x1d:
        !          9355:                {
        !          9356:                                InvalidInstruction(4);
        !          9357:                        break;
        !          9358:                }
        !          9359:                case 0x1e:
        !          9360:                {
        !          9361:                        sdwCyclesRemaining -= 23;
        !          9362:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !          9363:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          9364:                                cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
        !          9365:                                bTemp = (bTemp >> 1) | bTemp2;
        !          9366:                                cpu.z80F |= bPostORFlags[bTemp];
        !          9367:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          9368:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          9369:                                {
        !          9370:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          9371:                                        {
        !          9372:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          9373:                                                if (psMemWrite->memoryCall)
        !          9374:                                                {
        !          9375:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          9376:                                                }
        !          9377:                                                else
        !          9378:                                                {
        !          9379:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          9380:                                                }
        !          9381:                                                psMemWrite = NULL;
        !          9382:                                                break;
        !          9383:                                        }
        !          9384:                                        ++psMemWrite;
        !          9385:                                }
        !          9386: 
        !          9387:                                if (psMemWrite)
        !          9388:                                {
        !          9389:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          9390:                                }
        !          9391: 
        !          9392:                        break;
        !          9393:                }
        !          9394:                case 0x1f:
        !          9395:                {
        !          9396:                                InvalidInstruction(4);
        !          9397:                        break;
        !          9398:                }
        !          9399:                case 0x20:
        !          9400:                {
        !          9401:                                InvalidInstruction(4);
        !          9402:                        break;
        !          9403:                }
        !          9404:                case 0x21:
        !          9405:                {
        !          9406:                                InvalidInstruction(4);
        !          9407:                        break;
        !          9408:                }
        !          9409:                case 0x22:
        !          9410:                {
        !          9411:                                InvalidInstruction(4);
        !          9412:                        break;
        !          9413:                }
        !          9414:                case 0x23:
        !          9415:                {
        !          9416:                                InvalidInstruction(4);
        !          9417:                        break;
        !          9418:                }
        !          9419:                case 0x24:
        !          9420:                {
        !          9421:                                InvalidInstruction(4);
        !          9422:                        break;
        !          9423:                }
        !          9424:                case 0x25:
        !          9425:                {
        !          9426:                                InvalidInstruction(4);
        !          9427:                        break;
        !          9428:                }
        !          9429:                case 0x26:
        !          9430:                {
        !          9431:                        sdwCyclesRemaining -= 23;
        !          9432:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          9433:                                cpu.z80F |= (bTemp >> 7);
        !          9434:                                bTemp = (bTemp << 1);
        !          9435:                                cpu.z80F |= bPostORFlags[bTemp];
        !          9436:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          9437:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          9438:                                {
        !          9439:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          9440:                                        {
        !          9441:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          9442:                                                if (psMemWrite->memoryCall)
        !          9443:                                                {
        !          9444:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          9445:                                                }
        !          9446:                                                else
        !          9447:                                                {
        !          9448:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          9449:                                                }
        !          9450:                                                psMemWrite = NULL;
        !          9451:                                                break;
        !          9452:                                        }
        !          9453:                                        ++psMemWrite;
        !          9454:                                }
        !          9455: 
        !          9456:                                if (psMemWrite)
        !          9457:                                {
        !          9458:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          9459:                                }
        !          9460: 
        !          9461:                        break;
        !          9462:                }
        !          9463:                case 0x27:
        !          9464:                {
        !          9465:                                InvalidInstruction(4);
        !          9466:                        break;
        !          9467:                }
        !          9468:                case 0x28:
        !          9469:                {
        !          9470:                                InvalidInstruction(4);
        !          9471:                        break;
        !          9472:                }
        !          9473:                case 0x29:
        !          9474:                {
        !          9475:                                InvalidInstruction(4);
        !          9476:                        break;
        !          9477:                }
        !          9478:                case 0x2a:
        !          9479:                {
        !          9480:                                InvalidInstruction(4);
        !          9481:                        break;
        !          9482:                }
        !          9483:                case 0x2b:
        !          9484:                {
        !          9485:                                InvalidInstruction(4);
        !          9486:                        break;
        !          9487:                }
        !          9488:                case 0x2c:
        !          9489:                {
        !          9490:                                InvalidInstruction(4);
        !          9491:                        break;
        !          9492:                }
        !          9493:                case 0x2d:
        !          9494:                {
        !          9495:                                InvalidInstruction(4);
        !          9496:                        break;
        !          9497:                }
        !          9498:                case 0x2e:
        !          9499:                {
        !          9500:                        sdwCyclesRemaining -= 23;
        !          9501:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          9502:                                cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
        !          9503:                                bTemp = (bTemp >> 1) | (bTemp & 0x80);
        !          9504:                                cpu.z80F |= bPostORFlags[bTemp];
        !          9505:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          9506:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          9507:                                {
        !          9508:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          9509:                                        {
        !          9510:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          9511:                                                if (psMemWrite->memoryCall)
        !          9512:                                                {
        !          9513:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          9514:                                                }
        !          9515:                                                else
        !          9516:                                                {
        !          9517:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          9518:                                                }
        !          9519:                                                psMemWrite = NULL;
        !          9520:                                                break;
        !          9521:                                        }
        !          9522:                                        ++psMemWrite;
        !          9523:                                }
        !          9524: 
        !          9525:                                if (psMemWrite)
        !          9526:                                {
        !          9527:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          9528:                                }
        !          9529: 
        !          9530:                        break;
        !          9531:                }
        !          9532:                case 0x2f:
        !          9533:                {
        !          9534:                                InvalidInstruction(4);
        !          9535:                        break;
        !          9536:                }
        !          9537:                case 0x30:
        !          9538:                {
        !          9539:                                InvalidInstruction(4);
        !          9540:                        break;
        !          9541:                }
        !          9542:                case 0x31:
        !          9543:                {
        !          9544:                                InvalidInstruction(4);
        !          9545:                        break;
        !          9546:                }
        !          9547:                case 0x32:
        !          9548:                {
        !          9549:                                InvalidInstruction(4);
        !          9550:                        break;
        !          9551:                }
        !          9552:                case 0x33:
        !          9553:                {
        !          9554:                                InvalidInstruction(4);
        !          9555:                        break;
        !          9556:                }
        !          9557:                case 0x34:
        !          9558:                {
        !          9559:                                InvalidInstruction(4);
        !          9560:                        break;
        !          9561:                }
        !          9562:                case 0x35:
        !          9563:                {
        !          9564:                                InvalidInstruction(4);
        !          9565:                        break;
        !          9566:                }
        !          9567:                case 0x36:
        !          9568:                {
        !          9569:                        sdwCyclesRemaining -= 23;
        !          9570:                                InvalidInstruction(4);
        !          9571:                        break;
        !          9572:                }
        !          9573:                case 0x37:
        !          9574:                {
        !          9575:                                InvalidInstruction(4);
        !          9576:                        break;
        !          9577:                }
        !          9578:                case 0x38:
        !          9579:                {
        !          9580:                                InvalidInstruction(4);
        !          9581:                        break;
        !          9582:                }
        !          9583:                case 0x39:
        !          9584:                {
        !          9585:                                InvalidInstruction(4);
        !          9586:                        break;
        !          9587:                }
        !          9588:                case 0x3a:
        !          9589:                {
        !          9590:                                InvalidInstruction(4);
        !          9591:                        break;
        !          9592:                }
        !          9593:                case 0x3b:
        !          9594:                {
        !          9595:                                InvalidInstruction(4);
        !          9596:                        break;
        !          9597:                }
        !          9598:                case 0x3c:
        !          9599:                {
        !          9600:                                InvalidInstruction(4);
        !          9601:                        break;
        !          9602:                }
        !          9603:                case 0x3d:
        !          9604:                {
        !          9605:                                InvalidInstruction(4);
        !          9606:                        break;
        !          9607:                }
        !          9608:                case 0x3e:
        !          9609:                {
        !          9610:                        sdwCyclesRemaining -= 23;
        !          9611:                                cpu.z80F &= ~(Z80_FLAG_ZERO | Z80_FLAG_SIGN | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE | Z80_FLAG_CARRY);
        !          9612:                                cpu.z80F |= (bTemp & Z80_FLAG_CARRY);
        !          9613:                                bTemp = (bTemp >> 1);
        !          9614:                                cpu.z80F |= bPostORFlags[bTemp];
        !          9615:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          9616:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          9617:                                {
        !          9618:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          9619:                                        {
        !          9620:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          9621:                                                if (psMemWrite->memoryCall)
        !          9622:                                                {
        !          9623:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          9624:                                                }
        !          9625:                                                else
        !          9626:                                                {
        !          9627:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          9628:                                                }
        !          9629:                                                psMemWrite = NULL;
        !          9630:                                                break;
        !          9631:                                        }
        !          9632:                                        ++psMemWrite;
        !          9633:                                }
        !          9634: 
        !          9635:                                if (psMemWrite)
        !          9636:                                {
        !          9637:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          9638:                                }
        !          9639: 
        !          9640:                        break;
        !          9641:                }
        !          9642:                case 0x3f:
        !          9643:                {
        !          9644:                                InvalidInstruction(4);
        !          9645:                        break;
        !          9646:                }
        !          9647:                case 0x40:
        !          9648:                {
        !          9649:                        sdwCyclesRemaining -= 20;
        !          9650:                                InvalidInstruction(4);
        !          9651:                        break;
        !          9652:                }
        !          9653:                case 0x41:
        !          9654:                {
        !          9655:                        sdwCyclesRemaining -= 20;
        !          9656:                                InvalidInstruction(4);
        !          9657:                        break;
        !          9658:                }
        !          9659:                case 0x42:
        !          9660:                {
        !          9661:                        sdwCyclesRemaining -= 20;
        !          9662:                                InvalidInstruction(4);
        !          9663:                        break;
        !          9664:                }
        !          9665:                case 0x43:
        !          9666:                {
        !          9667:                        sdwCyclesRemaining -= 20;
        !          9668:                                InvalidInstruction(4);
        !          9669:                        break;
        !          9670:                }
        !          9671:                case 0x44:
        !          9672:                {
        !          9673:                        sdwCyclesRemaining -= 20;
        !          9674:                                InvalidInstruction(4);
        !          9675:                        break;
        !          9676:                }
        !          9677:                case 0x45:
        !          9678:                {
        !          9679:                        sdwCyclesRemaining -= 20;
        !          9680:                                InvalidInstruction(4);
        !          9681:                        break;
        !          9682:                }
        !          9683:                case 0x46:
        !          9684:                {
        !          9685:                        sdwCyclesRemaining -= 20;
        !          9686:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
        !          9687:                                if (!(bTemp & 0x01))
        !          9688:                                {
        !          9689:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          9690:                                }
        !          9691:                        break;
        !          9692:                }
        !          9693:                case 0x47:
        !          9694:                {
        !          9695:                        sdwCyclesRemaining -= 20;
        !          9696:                                InvalidInstruction(4);
        !          9697:                        break;
        !          9698:                }
        !          9699:                case 0x48:
        !          9700:                {
        !          9701:                        sdwCyclesRemaining -= 20;
        !          9702:                                InvalidInstruction(4);
        !          9703:                        break;
        !          9704:                }
        !          9705:                case 0x49:
        !          9706:                {
        !          9707:                        sdwCyclesRemaining -= 20;
        !          9708:                                InvalidInstruction(4);
        !          9709:                        break;
        !          9710:                }
        !          9711:                case 0x4a:
        !          9712:                {
        !          9713:                        sdwCyclesRemaining -= 20;
        !          9714:                                InvalidInstruction(4);
        !          9715:                        break;
        !          9716:                }
        !          9717:                case 0x4b:
        !          9718:                {
        !          9719:                        sdwCyclesRemaining -= 20;
        !          9720:                                InvalidInstruction(4);
        !          9721:                        break;
        !          9722:                }
        !          9723:                case 0x4c:
        !          9724:                {
        !          9725:                        sdwCyclesRemaining -= 20;
        !          9726:                                InvalidInstruction(4);
        !          9727:                        break;
        !          9728:                }
        !          9729:                case 0x4d:
        !          9730:                {
        !          9731:                        sdwCyclesRemaining -= 20;
        !          9732:                                InvalidInstruction(4);
        !          9733:                        break;
        !          9734:                }
        !          9735:                case 0x4e:
        !          9736:                {
        !          9737:                        sdwCyclesRemaining -= 20;
        !          9738:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
        !          9739:                                if (!(bTemp & 0x02))
        !          9740:                                {
        !          9741:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          9742:                                }
        !          9743:                        break;
        !          9744:                }
        !          9745:                case 0x4f:
        !          9746:                {
        !          9747:                        sdwCyclesRemaining -= 20;
        !          9748:                                InvalidInstruction(4);
        !          9749:                        break;
        !          9750:                }
        !          9751:                case 0x50:
        !          9752:                {
        !          9753:                        sdwCyclesRemaining -= 20;
        !          9754:                                InvalidInstruction(4);
        !          9755:                        break;
        !          9756:                }
        !          9757:                case 0x51:
        !          9758:                {
        !          9759:                        sdwCyclesRemaining -= 20;
        !          9760:                                InvalidInstruction(4);
        !          9761:                        break;
        !          9762:                }
        !          9763:                case 0x52:
        !          9764:                {
        !          9765:                        sdwCyclesRemaining -= 20;
        !          9766:                                InvalidInstruction(4);
        !          9767:                        break;
        !          9768:                }
        !          9769:                case 0x53:
        !          9770:                {
        !          9771:                        sdwCyclesRemaining -= 20;
        !          9772:                                InvalidInstruction(4);
        !          9773:                        break;
        !          9774:                }
        !          9775:                case 0x54:
        !          9776:                {
        !          9777:                        sdwCyclesRemaining -= 20;
        !          9778:                                InvalidInstruction(4);
        !          9779:                        break;
        !          9780:                }
        !          9781:                case 0x55:
        !          9782:                {
        !          9783:                        sdwCyclesRemaining -= 20;
        !          9784:                                InvalidInstruction(4);
        !          9785:                        break;
        !          9786:                }
        !          9787:                case 0x56:
        !          9788:                {
        !          9789:                        sdwCyclesRemaining -= 20;
        !          9790:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
        !          9791:                                if (!(bTemp & 0x04))
        !          9792:                                {
        !          9793:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          9794:                                }
        !          9795:                        break;
        !          9796:                }
        !          9797:                case 0x57:
        !          9798:                {
        !          9799:                        sdwCyclesRemaining -= 20;
        !          9800:                                InvalidInstruction(4);
        !          9801:                        break;
        !          9802:                }
        !          9803:                case 0x58:
        !          9804:                {
        !          9805:                        sdwCyclesRemaining -= 20;
        !          9806:                                InvalidInstruction(4);
        !          9807:                        break;
        !          9808:                }
        !          9809:                case 0x59:
        !          9810:                {
        !          9811:                        sdwCyclesRemaining -= 20;
        !          9812:                                InvalidInstruction(4);
        !          9813:                        break;
        !          9814:                }
        !          9815:                case 0x5a:
        !          9816:                {
        !          9817:                        sdwCyclesRemaining -= 20;
        !          9818:                                InvalidInstruction(4);
        !          9819:                        break;
        !          9820:                }
        !          9821:                case 0x5b:
        !          9822:                {
        !          9823:                        sdwCyclesRemaining -= 20;
        !          9824:                                InvalidInstruction(4);
        !          9825:                        break;
        !          9826:                }
        !          9827:                case 0x5c:
        !          9828:                {
        !          9829:                        sdwCyclesRemaining -= 20;
        !          9830:                                InvalidInstruction(4);
        !          9831:                        break;
        !          9832:                }
        !          9833:                case 0x5d:
        !          9834:                {
        !          9835:                        sdwCyclesRemaining -= 20;
        !          9836:                                InvalidInstruction(4);
        !          9837:                        break;
        !          9838:                }
        !          9839:                case 0x5e:
        !          9840:                {
        !          9841:                        sdwCyclesRemaining -= 20;
        !          9842:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
        !          9843:                                if (!(bTemp & 0x08))
        !          9844:                                {
        !          9845:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          9846:                                }
        !          9847:                        break;
        !          9848:                }
        !          9849:                case 0x5f:
        !          9850:                {
        !          9851:                        sdwCyclesRemaining -= 20;
        !          9852:                                InvalidInstruction(4);
        !          9853:                        break;
        !          9854:                }
        !          9855:                case 0x60:
        !          9856:                {
        !          9857:                        sdwCyclesRemaining -= 20;
        !          9858:                                InvalidInstruction(4);
        !          9859:                        break;
        !          9860:                }
        !          9861:                case 0x61:
        !          9862:                {
        !          9863:                        sdwCyclesRemaining -= 20;
        !          9864:                                InvalidInstruction(4);
        !          9865:                        break;
        !          9866:                }
        !          9867:                case 0x62:
        !          9868:                {
        !          9869:                        sdwCyclesRemaining -= 20;
        !          9870:                                InvalidInstruction(4);
        !          9871:                        break;
        !          9872:                }
        !          9873:                case 0x63:
        !          9874:                {
        !          9875:                        sdwCyclesRemaining -= 20;
        !          9876:                                InvalidInstruction(4);
        !          9877:                        break;
        !          9878:                }
        !          9879:                case 0x64:
        !          9880:                {
        !          9881:                        sdwCyclesRemaining -= 20;
        !          9882:                                InvalidInstruction(4);
        !          9883:                        break;
        !          9884:                }
        !          9885:                case 0x65:
        !          9886:                {
        !          9887:                        sdwCyclesRemaining -= 20;
        !          9888:                                InvalidInstruction(4);
        !          9889:                        break;
        !          9890:                }
        !          9891:                case 0x66:
        !          9892:                {
        !          9893:                        sdwCyclesRemaining -= 20;
        !          9894:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
        !          9895:                                if (!(bTemp & 0x10))
        !          9896:                                {
        !          9897:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          9898:                                }
        !          9899:                        break;
        !          9900:                }
        !          9901:                case 0x67:
        !          9902:                {
        !          9903:                        sdwCyclesRemaining -= 20;
        !          9904:                                InvalidInstruction(4);
        !          9905:                        break;
        !          9906:                }
        !          9907:                case 0x68:
        !          9908:                {
        !          9909:                        sdwCyclesRemaining -= 20;
        !          9910:                                InvalidInstruction(4);
        !          9911:                        break;
        !          9912:                }
        !          9913:                case 0x69:
        !          9914:                {
        !          9915:                        sdwCyclesRemaining -= 20;
        !          9916:                                InvalidInstruction(4);
        !          9917:                        break;
        !          9918:                }
        !          9919:                case 0x6a:
        !          9920:                {
        !          9921:                        sdwCyclesRemaining -= 20;
        !          9922:                                InvalidInstruction(4);
        !          9923:                        break;
        !          9924:                }
        !          9925:                case 0x6b:
        !          9926:                {
        !          9927:                        sdwCyclesRemaining -= 20;
        !          9928:                                InvalidInstruction(4);
        !          9929:                        break;
        !          9930:                }
        !          9931:                case 0x6c:
        !          9932:                {
        !          9933:                        sdwCyclesRemaining -= 20;
        !          9934:                                InvalidInstruction(4);
        !          9935:                        break;
        !          9936:                }
        !          9937:                case 0x6d:
        !          9938:                {
        !          9939:                        sdwCyclesRemaining -= 20;
        !          9940:                                InvalidInstruction(4);
        !          9941:                        break;
        !          9942:                }
        !          9943:                case 0x6e:
        !          9944:                {
        !          9945:                        sdwCyclesRemaining -= 20;
        !          9946:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
        !          9947:                                if (!(bTemp & 0x20))
        !          9948:                                {
        !          9949:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          9950:                                }
        !          9951:                        break;
        !          9952:                }
        !          9953:                case 0x6f:
        !          9954:                {
        !          9955:                        sdwCyclesRemaining -= 20;
        !          9956:                                InvalidInstruction(4);
        !          9957:                        break;
        !          9958:                }
        !          9959:                case 0x70:
        !          9960:                {
        !          9961:                        sdwCyclesRemaining -= 20;
        !          9962:                                InvalidInstruction(4);
        !          9963:                        break;
        !          9964:                }
        !          9965:                case 0x71:
        !          9966:                {
        !          9967:                        sdwCyclesRemaining -= 20;
        !          9968:                                InvalidInstruction(4);
        !          9969:                        break;
        !          9970:                }
        !          9971:                case 0x72:
        !          9972:                {
        !          9973:                        sdwCyclesRemaining -= 20;
        !          9974:                                InvalidInstruction(4);
        !          9975:                        break;
        !          9976:                }
        !          9977:                case 0x73:
        !          9978:                {
        !          9979:                        sdwCyclesRemaining -= 20;
        !          9980:                                InvalidInstruction(4);
        !          9981:                        break;
        !          9982:                }
        !          9983:                case 0x74:
        !          9984:                {
        !          9985:                        sdwCyclesRemaining -= 20;
        !          9986:                                InvalidInstruction(4);
        !          9987:                        break;
        !          9988:                }
        !          9989:                case 0x75:
        !          9990:                {
        !          9991:                        sdwCyclesRemaining -= 20;
        !          9992:                                InvalidInstruction(4);
        !          9993:                        break;
        !          9994:                }
        !          9995:                case 0x76:
        !          9996:                {
        !          9997:                        sdwCyclesRemaining -= 20;
        !          9998:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
        !          9999:                                if (!(bTemp & 0x40))
        !          10000:                                {
        !          10001:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          10002:                                }
        !          10003:                        break;
        !          10004:                }
        !          10005:                case 0x77:
        !          10006:                {
        !          10007:                        sdwCyclesRemaining -= 20;
        !          10008:                                InvalidInstruction(4);
        !          10009:                        break;
        !          10010:                }
        !          10011:                case 0x78:
        !          10012:                {
        !          10013:                        sdwCyclesRemaining -= 20;
        !          10014:                                InvalidInstruction(4);
        !          10015:                        break;
        !          10016:                }
        !          10017:                case 0x79:
        !          10018:                {
        !          10019:                        sdwCyclesRemaining -= 20;
        !          10020:                                InvalidInstruction(4);
        !          10021:                        break;
        !          10022:                }
        !          10023:                case 0x7a:
        !          10024:                {
        !          10025:                        sdwCyclesRemaining -= 20;
        !          10026:                                InvalidInstruction(4);
        !          10027:                        break;
        !          10028:                }
        !          10029:                case 0x7b:
        !          10030:                {
        !          10031:                        sdwCyclesRemaining -= 20;
        !          10032:                                InvalidInstruction(4);
        !          10033:                        break;
        !          10034:                }
        !          10035:                case 0x7c:
        !          10036:                {
        !          10037:                        sdwCyclesRemaining -= 20;
        !          10038:                                InvalidInstruction(4);
        !          10039:                        break;
        !          10040:                }
        !          10041:                case 0x7d:
        !          10042:                {
        !          10043:                        sdwCyclesRemaining -= 20;
        !          10044:                                InvalidInstruction(4);
        !          10045:                        break;
        !          10046:                }
        !          10047:                case 0x7e:
        !          10048:                {
        !          10049:                        sdwCyclesRemaining -= 20;
        !          10050:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_ZERO | Z80_FLAG_NEGATIVE)) | Z80_FLAG_HALF_CARRY;
        !          10051:                                if (!(bTemp & 0x80))
        !          10052:                                {
        !          10053:                                        cpu.z80F |= Z80_FLAG_ZERO;
        !          10054:                                }
        !          10055:                        break;
        !          10056:                }
        !          10057:                case 0x7f:
        !          10058:                {
        !          10059:                        sdwCyclesRemaining -= 20;
        !          10060:                                InvalidInstruction(4);
        !          10061:                        break;
        !          10062:                }
        !          10063:                case 0x80:
        !          10064:                {
        !          10065:                                InvalidInstruction(4);
        !          10066:                        break;
        !          10067:                }
        !          10068:                case 0x81:
        !          10069:                {
        !          10070:                                InvalidInstruction(4);
        !          10071:                        break;
        !          10072:                }
        !          10073:                case 0x82:
        !          10074:                {
        !          10075:                                InvalidInstruction(4);
        !          10076:                        break;
        !          10077:                }
        !          10078:                case 0x83:
        !          10079:                {
        !          10080:                                InvalidInstruction(4);
        !          10081:                        break;
        !          10082:                }
        !          10083:                case 0x84:
        !          10084:                {
        !          10085:                                InvalidInstruction(4);
        !          10086:                        break;
        !          10087:                }
        !          10088:                case 0x85:
        !          10089:                {
        !          10090:                                InvalidInstruction(4);
        !          10091:                        break;
        !          10092:                }
        !          10093:                case 0x86:
        !          10094:                {
        !          10095:                        sdwCyclesRemaining -= 23;
        !          10096:                                bTemp &= 0xfe;
        !          10097:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10098:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10099:                                {
        !          10100:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10101:                                        {
        !          10102:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10103:                                                if (psMemWrite->memoryCall)
        !          10104:                                                {
        !          10105:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10106:                                                }
        !          10107:                                                else
        !          10108:                                                {
        !          10109:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10110:                                                }
        !          10111:                                                psMemWrite = NULL;
        !          10112:                                                break;
        !          10113:                                        }
        !          10114:                                        ++psMemWrite;
        !          10115:                                }
        !          10116: 
        !          10117:                                if (psMemWrite)
        !          10118:                                {
        !          10119:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10120:                                }
        !          10121: 
        !          10122:                        break;
        !          10123:                }
        !          10124:                case 0x87:
        !          10125:                {
        !          10126:                                InvalidInstruction(4);
        !          10127:                        break;
        !          10128:                }
        !          10129:                case 0x88:
        !          10130:                {
        !          10131:                                InvalidInstruction(4);
        !          10132:                        break;
        !          10133:                }
        !          10134:                case 0x89:
        !          10135:                {
        !          10136:                                InvalidInstruction(4);
        !          10137:                        break;
        !          10138:                }
        !          10139:                case 0x8a:
        !          10140:                {
        !          10141:                                InvalidInstruction(4);
        !          10142:                        break;
        !          10143:                }
        !          10144:                case 0x8b:
        !          10145:                {
        !          10146:                                InvalidInstruction(4);
        !          10147:                        break;
        !          10148:                }
        !          10149:                case 0x8c:
        !          10150:                {
        !          10151:                                InvalidInstruction(4);
        !          10152:                        break;
        !          10153:                }
        !          10154:                case 0x8d:
        !          10155:                {
        !          10156:                                InvalidInstruction(4);
        !          10157:                        break;
        !          10158:                }
        !          10159:                case 0x8e:
        !          10160:                {
        !          10161:                        sdwCyclesRemaining -= 23;
        !          10162:                                bTemp &= 0xfd;
        !          10163:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10164:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10165:                                {
        !          10166:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10167:                                        {
        !          10168:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10169:                                                if (psMemWrite->memoryCall)
        !          10170:                                                {
        !          10171:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10172:                                                }
        !          10173:                                                else
        !          10174:                                                {
        !          10175:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10176:                                                }
        !          10177:                                                psMemWrite = NULL;
        !          10178:                                                break;
        !          10179:                                        }
        !          10180:                                        ++psMemWrite;
        !          10181:                                }
        !          10182: 
        !          10183:                                if (psMemWrite)
        !          10184:                                {
        !          10185:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10186:                                }
        !          10187: 
        !          10188:                        break;
        !          10189:                }
        !          10190:                case 0x8f:
        !          10191:                {
        !          10192:                                InvalidInstruction(4);
        !          10193:                        break;
        !          10194:                }
        !          10195:                case 0x90:
        !          10196:                {
        !          10197:                                InvalidInstruction(4);
        !          10198:                        break;
        !          10199:                }
        !          10200:                case 0x91:
        !          10201:                {
        !          10202:                                InvalidInstruction(4);
        !          10203:                        break;
        !          10204:                }
        !          10205:                case 0x92:
        !          10206:                {
        !          10207:                                InvalidInstruction(4);
        !          10208:                        break;
        !          10209:                }
        !          10210:                case 0x93:
        !          10211:                {
        !          10212:                                InvalidInstruction(4);
        !          10213:                        break;
        !          10214:                }
        !          10215:                case 0x94:
        !          10216:                {
        !          10217:                                InvalidInstruction(4);
        !          10218:                        break;
        !          10219:                }
        !          10220:                case 0x95:
        !          10221:                {
        !          10222:                                InvalidInstruction(4);
        !          10223:                        break;
        !          10224:                }
        !          10225:                case 0x96:
        !          10226:                {
        !          10227:                        sdwCyclesRemaining -= 23;
        !          10228:                                bTemp &= 0xfb;
        !          10229:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10230:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10231:                                {
        !          10232:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10233:                                        {
        !          10234:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10235:                                                if (psMemWrite->memoryCall)
        !          10236:                                                {
        !          10237:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10238:                                                }
        !          10239:                                                else
        !          10240:                                                {
        !          10241:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10242:                                                }
        !          10243:                                                psMemWrite = NULL;
        !          10244:                                                break;
        !          10245:                                        }
        !          10246:                                        ++psMemWrite;
        !          10247:                                }
        !          10248: 
        !          10249:                                if (psMemWrite)
        !          10250:                                {
        !          10251:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10252:                                }
        !          10253: 
        !          10254:                        break;
        !          10255:                }
        !          10256:                case 0x97:
        !          10257:                {
        !          10258:                                InvalidInstruction(4);
        !          10259:                        break;
        !          10260:                }
        !          10261:                case 0x98:
        !          10262:                {
        !          10263:                                InvalidInstruction(4);
        !          10264:                        break;
        !          10265:                }
        !          10266:                case 0x99:
        !          10267:                {
        !          10268:                                InvalidInstruction(4);
        !          10269:                        break;
        !          10270:                }
        !          10271:                case 0x9a:
        !          10272:                {
        !          10273:                                InvalidInstruction(4);
        !          10274:                        break;
        !          10275:                }
        !          10276:                case 0x9b:
        !          10277:                {
        !          10278:                                InvalidInstruction(4);
        !          10279:                        break;
        !          10280:                }
        !          10281:                case 0x9c:
        !          10282:                {
        !          10283:                                InvalidInstruction(4);
        !          10284:                        break;
        !          10285:                }
        !          10286:                case 0x9d:
        !          10287:                {
        !          10288:                                InvalidInstruction(4);
        !          10289:                        break;
        !          10290:                }
        !          10291:                case 0x9e:
        !          10292:                {
        !          10293:                        sdwCyclesRemaining -= 23;
        !          10294:                                bTemp &= 0xf7;
        !          10295:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10296:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10297:                                {
        !          10298:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10299:                                        {
        !          10300:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10301:                                                if (psMemWrite->memoryCall)
        !          10302:                                                {
        !          10303:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10304:                                                }
        !          10305:                                                else
        !          10306:                                                {
        !          10307:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10308:                                                }
        !          10309:                                                psMemWrite = NULL;
        !          10310:                                                break;
        !          10311:                                        }
        !          10312:                                        ++psMemWrite;
        !          10313:                                }
        !          10314: 
        !          10315:                                if (psMemWrite)
        !          10316:                                {
        !          10317:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10318:                                }
        !          10319: 
        !          10320:                        break;
        !          10321:                }
        !          10322:                case 0x9f:
        !          10323:                {
        !          10324:                                InvalidInstruction(4);
        !          10325:                        break;
        !          10326:                }
        !          10327:                case 0xa0:
        !          10328:                {
        !          10329:                                InvalidInstruction(4);
        !          10330:                        break;
        !          10331:                }
        !          10332:                case 0xa1:
        !          10333:                {
        !          10334:                                InvalidInstruction(4);
        !          10335:                        break;
        !          10336:                }
        !          10337:                case 0xa2:
        !          10338:                {
        !          10339:                                InvalidInstruction(4);
        !          10340:                        break;
        !          10341:                }
        !          10342:                case 0xa3:
        !          10343:                {
        !          10344:                                InvalidInstruction(4);
        !          10345:                        break;
        !          10346:                }
        !          10347:                case 0xa4:
        !          10348:                {
        !          10349:                                InvalidInstruction(4);
        !          10350:                        break;
        !          10351:                }
        !          10352:                case 0xa5:
        !          10353:                {
        !          10354:                                InvalidInstruction(4);
        !          10355:                        break;
        !          10356:                }
        !          10357:                case 0xa6:
        !          10358:                {
        !          10359:                        sdwCyclesRemaining -= 23;
        !          10360:                                bTemp &= 0xef;
        !          10361:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10362:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10363:                                {
        !          10364:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10365:                                        {
        !          10366:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10367:                                                if (psMemWrite->memoryCall)
        !          10368:                                                {
        !          10369:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10370:                                                }
        !          10371:                                                else
        !          10372:                                                {
        !          10373:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10374:                                                }
        !          10375:                                                psMemWrite = NULL;
        !          10376:                                                break;
        !          10377:                                        }
        !          10378:                                        ++psMemWrite;
        !          10379:                                }
        !          10380: 
        !          10381:                                if (psMemWrite)
        !          10382:                                {
        !          10383:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10384:                                }
        !          10385: 
        !          10386:                        break;
        !          10387:                }
        !          10388:                case 0xa7:
        !          10389:                {
        !          10390:                                InvalidInstruction(4);
        !          10391:                        break;
        !          10392:                }
        !          10393:                case 0xa8:
        !          10394:                {
        !          10395:                                InvalidInstruction(4);
        !          10396:                        break;
        !          10397:                }
        !          10398:                case 0xa9:
        !          10399:                {
        !          10400:                                InvalidInstruction(4);
        !          10401:                        break;
        !          10402:                }
        !          10403:                case 0xaa:
        !          10404:                {
        !          10405:                                InvalidInstruction(4);
        !          10406:                        break;
        !          10407:                }
        !          10408:                case 0xab:
        !          10409:                {
        !          10410:                                InvalidInstruction(4);
        !          10411:                        break;
        !          10412:                }
        !          10413:                case 0xac:
        !          10414:                {
        !          10415:                                InvalidInstruction(4);
        !          10416:                        break;
        !          10417:                }
        !          10418:                case 0xad:
        !          10419:                {
        !          10420:                                InvalidInstruction(4);
        !          10421:                        break;
        !          10422:                }
        !          10423:                case 0xae:
        !          10424:                {
        !          10425:                        sdwCyclesRemaining -= 23;
        !          10426:                                bTemp &= 0xdf;
        !          10427:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10428:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10429:                                {
        !          10430:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10431:                                        {
        !          10432:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10433:                                                if (psMemWrite->memoryCall)
        !          10434:                                                {
        !          10435:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10436:                                                }
        !          10437:                                                else
        !          10438:                                                {
        !          10439:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10440:                                                }
        !          10441:                                                psMemWrite = NULL;
        !          10442:                                                break;
        !          10443:                                        }
        !          10444:                                        ++psMemWrite;
        !          10445:                                }
        !          10446: 
        !          10447:                                if (psMemWrite)
        !          10448:                                {
        !          10449:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10450:                                }
        !          10451: 
        !          10452:                        break;
        !          10453:                }
        !          10454:                case 0xaf:
        !          10455:                {
        !          10456:                                InvalidInstruction(4);
        !          10457:                        break;
        !          10458:                }
        !          10459:                case 0xb0:
        !          10460:                {
        !          10461:                                InvalidInstruction(4);
        !          10462:                        break;
        !          10463:                }
        !          10464:                case 0xb1:
        !          10465:                {
        !          10466:                                InvalidInstruction(4);
        !          10467:                        break;
        !          10468:                }
        !          10469:                case 0xb2:
        !          10470:                {
        !          10471:                                InvalidInstruction(4);
        !          10472:                        break;
        !          10473:                }
        !          10474:                case 0xb3:
        !          10475:                {
        !          10476:                                InvalidInstruction(4);
        !          10477:                        break;
        !          10478:                }
        !          10479:                case 0xb4:
        !          10480:                {
        !          10481:                                InvalidInstruction(4);
        !          10482:                        break;
        !          10483:                }
        !          10484:                case 0xb5:
        !          10485:                {
        !          10486:                                InvalidInstruction(4);
        !          10487:                        break;
        !          10488:                }
        !          10489:                case 0xb6:
        !          10490:                {
        !          10491:                        sdwCyclesRemaining -= 23;
        !          10492:                                bTemp &= 0xbf;
        !          10493:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10494:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10495:                                {
        !          10496:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10497:                                        {
        !          10498:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10499:                                                if (psMemWrite->memoryCall)
        !          10500:                                                {
        !          10501:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10502:                                                }
        !          10503:                                                else
        !          10504:                                                {
        !          10505:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10506:                                                }
        !          10507:                                                psMemWrite = NULL;
        !          10508:                                                break;
        !          10509:                                        }
        !          10510:                                        ++psMemWrite;
        !          10511:                                }
        !          10512: 
        !          10513:                                if (psMemWrite)
        !          10514:                                {
        !          10515:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10516:                                }
        !          10517: 
        !          10518:                        break;
        !          10519:                }
        !          10520:                case 0xb7:
        !          10521:                {
        !          10522:                                InvalidInstruction(4);
        !          10523:                        break;
        !          10524:                }
        !          10525:                case 0xb8:
        !          10526:                {
        !          10527:                                InvalidInstruction(4);
        !          10528:                        break;
        !          10529:                }
        !          10530:                case 0xb9:
        !          10531:                {
        !          10532:                                InvalidInstruction(4);
        !          10533:                        break;
        !          10534:                }
        !          10535:                case 0xba:
        !          10536:                {
        !          10537:                                InvalidInstruction(4);
        !          10538:                        break;
        !          10539:                }
        !          10540:                case 0xbb:
        !          10541:                {
        !          10542:                                InvalidInstruction(4);
        !          10543:                        break;
        !          10544:                }
        !          10545:                case 0xbc:
        !          10546:                {
        !          10547:                                InvalidInstruction(4);
        !          10548:                        break;
        !          10549:                }
        !          10550:                case 0xbd:
        !          10551:                {
        !          10552:                                InvalidInstruction(4);
        !          10553:                        break;
        !          10554:                }
        !          10555:                case 0xbe:
        !          10556:                {
        !          10557:                        sdwCyclesRemaining -= 23;
        !          10558:                                bTemp &= 0x7f;
        !          10559:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10560:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10561:                                {
        !          10562:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10563:                                        {
        !          10564:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10565:                                                if (psMemWrite->memoryCall)
        !          10566:                                                {
        !          10567:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10568:                                                }
        !          10569:                                                else
        !          10570:                                                {
        !          10571:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10572:                                                }
        !          10573:                                                psMemWrite = NULL;
        !          10574:                                                break;
        !          10575:                                        }
        !          10576:                                        ++psMemWrite;
        !          10577:                                }
        !          10578: 
        !          10579:                                if (psMemWrite)
        !          10580:                                {
        !          10581:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10582:                                }
        !          10583: 
        !          10584:                        break;
        !          10585:                }
        !          10586:                case 0xbf:
        !          10587:                {
        !          10588:                                InvalidInstruction(4);
        !          10589:                        break;
        !          10590:                }
        !          10591:                case 0xc0:
        !          10592:                {
        !          10593:                                InvalidInstruction(4);
        !          10594:                        break;
        !          10595:                }
        !          10596:                case 0xc1:
        !          10597:                {
        !          10598:                                InvalidInstruction(4);
        !          10599:                        break;
        !          10600:                }
        !          10601:                case 0xc2:
        !          10602:                {
        !          10603:                                InvalidInstruction(4);
        !          10604:                        break;
        !          10605:                }
        !          10606:                case 0xc3:
        !          10607:                {
        !          10608:                                InvalidInstruction(4);
        !          10609:                        break;
        !          10610:                }
        !          10611:                case 0xc4:
        !          10612:                {
        !          10613:                                InvalidInstruction(4);
        !          10614:                        break;
        !          10615:                }
        !          10616:                case 0xc5:
        !          10617:                {
        !          10618:                                InvalidInstruction(4);
        !          10619:                        break;
        !          10620:                }
        !          10621:                case 0xc6:
        !          10622:                {
        !          10623:                        sdwCyclesRemaining -= 23;
        !          10624:                                bTemp |= 0x01;
        !          10625:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10626:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10627:                                {
        !          10628:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10629:                                        {
        !          10630:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10631:                                                if (psMemWrite->memoryCall)
        !          10632:                                                {
        !          10633:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10634:                                                }
        !          10635:                                                else
        !          10636:                                                {
        !          10637:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10638:                                                }
        !          10639:                                                psMemWrite = NULL;
        !          10640:                                                break;
        !          10641:                                        }
        !          10642:                                        ++psMemWrite;
        !          10643:                                }
        !          10644: 
        !          10645:                                if (psMemWrite)
        !          10646:                                {
        !          10647:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10648:                                }
        !          10649: 
        !          10650:                        break;
        !          10651:                }
        !          10652:                case 0xc7:
        !          10653:                {
        !          10654:                                InvalidInstruction(4);
        !          10655:                        break;
        !          10656:                }
        !          10657:                case 0xc8:
        !          10658:                {
        !          10659:                                InvalidInstruction(4);
        !          10660:                        break;
        !          10661:                }
        !          10662:                case 0xc9:
        !          10663:                {
        !          10664:                                InvalidInstruction(4);
        !          10665:                        break;
        !          10666:                }
        !          10667:                case 0xca:
        !          10668:                {
        !          10669:                                InvalidInstruction(4);
        !          10670:                        break;
        !          10671:                }
        !          10672:                case 0xcb:
        !          10673:                {
        !          10674:                                InvalidInstruction(4);
        !          10675:                        break;
        !          10676:                }
        !          10677:                case 0xcc:
        !          10678:                {
        !          10679:                                InvalidInstruction(4);
        !          10680:                        break;
        !          10681:                }
        !          10682:                case 0xcd:
        !          10683:                {
        !          10684:                                InvalidInstruction(4);
        !          10685:                        break;
        !          10686:                }
        !          10687:                case 0xce:
        !          10688:                {
        !          10689:                        sdwCyclesRemaining -= 23;
        !          10690:                                bTemp |= 0x02;
        !          10691:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10692:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10693:                                {
        !          10694:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10695:                                        {
        !          10696:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10697:                                                if (psMemWrite->memoryCall)
        !          10698:                                                {
        !          10699:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10700:                                                }
        !          10701:                                                else
        !          10702:                                                {
        !          10703:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10704:                                                }
        !          10705:                                                psMemWrite = NULL;
        !          10706:                                                break;
        !          10707:                                        }
        !          10708:                                        ++psMemWrite;
        !          10709:                                }
        !          10710: 
        !          10711:                                if (psMemWrite)
        !          10712:                                {
        !          10713:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10714:                                }
        !          10715: 
        !          10716:                        break;
        !          10717:                }
        !          10718:                case 0xcf:
        !          10719:                {
        !          10720:                                InvalidInstruction(4);
        !          10721:                        break;
        !          10722:                }
        !          10723:                case 0xd0:
        !          10724:                {
        !          10725:                                InvalidInstruction(4);
        !          10726:                        break;
        !          10727:                }
        !          10728:                case 0xd1:
        !          10729:                {
        !          10730:                                InvalidInstruction(4);
        !          10731:                        break;
        !          10732:                }
        !          10733:                case 0xd2:
        !          10734:                {
        !          10735:                                InvalidInstruction(4);
        !          10736:                        break;
        !          10737:                }
        !          10738:                case 0xd3:
        !          10739:                {
        !          10740:                                InvalidInstruction(4);
        !          10741:                        break;
        !          10742:                }
        !          10743:                case 0xd4:
        !          10744:                {
        !          10745:                                InvalidInstruction(4);
        !          10746:                        break;
        !          10747:                }
        !          10748:                case 0xd5:
        !          10749:                {
        !          10750:                                InvalidInstruction(4);
        !          10751:                        break;
        !          10752:                }
        !          10753:                case 0xd6:
        !          10754:                {
        !          10755:                        sdwCyclesRemaining -= 23;
        !          10756:                                bTemp |= 0x04;
        !          10757:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10758:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10759:                                {
        !          10760:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10761:                                        {
        !          10762:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10763:                                                if (psMemWrite->memoryCall)
        !          10764:                                                {
        !          10765:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10766:                                                }
        !          10767:                                                else
        !          10768:                                                {
        !          10769:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10770:                                                }
        !          10771:                                                psMemWrite = NULL;
        !          10772:                                                break;
        !          10773:                                        }
        !          10774:                                        ++psMemWrite;
        !          10775:                                }
        !          10776: 
        !          10777:                                if (psMemWrite)
        !          10778:                                {
        !          10779:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10780:                                }
        !          10781: 
        !          10782:                        break;
        !          10783:                }
        !          10784:                case 0xd7:
        !          10785:                {
        !          10786:                                InvalidInstruction(4);
        !          10787:                        break;
        !          10788:                }
        !          10789:                case 0xd8:
        !          10790:                {
        !          10791:                                InvalidInstruction(4);
        !          10792:                        break;
        !          10793:                }
        !          10794:                case 0xd9:
        !          10795:                {
        !          10796:                                InvalidInstruction(4);
        !          10797:                        break;
        !          10798:                }
        !          10799:                case 0xda:
        !          10800:                {
        !          10801:                                InvalidInstruction(4);
        !          10802:                        break;
        !          10803:                }
        !          10804:                case 0xdb:
        !          10805:                {
        !          10806:                                InvalidInstruction(4);
        !          10807:                        break;
        !          10808:                }
        !          10809:                case 0xdc:
        !          10810:                {
        !          10811:                                InvalidInstruction(4);
        !          10812:                        break;
        !          10813:                }
        !          10814:                case 0xdd:
        !          10815:                {
        !          10816:                                InvalidInstruction(4);
        !          10817:                        break;
        !          10818:                }
        !          10819:                case 0xde:
        !          10820:                {
        !          10821:                        sdwCyclesRemaining -= 23;
        !          10822:                                bTemp |= 0x08;
        !          10823:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10824:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10825:                                {
        !          10826:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10827:                                        {
        !          10828:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10829:                                                if (psMemWrite->memoryCall)
        !          10830:                                                {
        !          10831:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10832:                                                }
        !          10833:                                                else
        !          10834:                                                {
        !          10835:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10836:                                                }
        !          10837:                                                psMemWrite = NULL;
        !          10838:                                                break;
        !          10839:                                        }
        !          10840:                                        ++psMemWrite;
        !          10841:                                }
        !          10842: 
        !          10843:                                if (psMemWrite)
        !          10844:                                {
        !          10845:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10846:                                }
        !          10847: 
        !          10848:                        break;
        !          10849:                }
        !          10850:                case 0xdf:
        !          10851:                {
        !          10852:                                InvalidInstruction(4);
        !          10853:                        break;
        !          10854:                }
        !          10855:                case 0xe0:
        !          10856:                {
        !          10857:                                InvalidInstruction(4);
        !          10858:                        break;
        !          10859:                }
        !          10860:                case 0xe1:
        !          10861:                {
        !          10862:                                InvalidInstruction(4);
        !          10863:                        break;
        !          10864:                }
        !          10865:                case 0xe2:
        !          10866:                {
        !          10867:                                InvalidInstruction(4);
        !          10868:                        break;
        !          10869:                }
        !          10870:                case 0xe3:
        !          10871:                {
        !          10872:                                InvalidInstruction(4);
        !          10873:                        break;
        !          10874:                }
        !          10875:                case 0xe4:
        !          10876:                {
        !          10877:                                InvalidInstruction(4);
        !          10878:                        break;
        !          10879:                }
        !          10880:                case 0xe5:
        !          10881:                {
        !          10882:                                InvalidInstruction(4);
        !          10883:                        break;
        !          10884:                }
        !          10885:                case 0xe6:
        !          10886:                {
        !          10887:                        sdwCyclesRemaining -= 23;
        !          10888:                                bTemp |= 0x10;
        !          10889:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10890:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10891:                                {
        !          10892:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10893:                                        {
        !          10894:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10895:                                                if (psMemWrite->memoryCall)
        !          10896:                                                {
        !          10897:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10898:                                                }
        !          10899:                                                else
        !          10900:                                                {
        !          10901:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10902:                                                }
        !          10903:                                                psMemWrite = NULL;
        !          10904:                                                break;
        !          10905:                                        }
        !          10906:                                        ++psMemWrite;
        !          10907:                                }
        !          10908: 
        !          10909:                                if (psMemWrite)
        !          10910:                                {
        !          10911:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10912:                                }
        !          10913: 
        !          10914:                        break;
        !          10915:                }
        !          10916:                case 0xe7:
        !          10917:                {
        !          10918:                                InvalidInstruction(4);
        !          10919:                        break;
        !          10920:                }
        !          10921:                case 0xe8:
        !          10922:                {
        !          10923:                                InvalidInstruction(4);
        !          10924:                        break;
        !          10925:                }
        !          10926:                case 0xe9:
        !          10927:                {
        !          10928:                                InvalidInstruction(4);
        !          10929:                        break;
        !          10930:                }
        !          10931:                case 0xea:
        !          10932:                {
        !          10933:                                InvalidInstruction(4);
        !          10934:                        break;
        !          10935:                }
        !          10936:                case 0xeb:
        !          10937:                {
        !          10938:                                InvalidInstruction(4);
        !          10939:                        break;
        !          10940:                }
        !          10941:                case 0xec:
        !          10942:                {
        !          10943:                                InvalidInstruction(4);
        !          10944:                        break;
        !          10945:                }
        !          10946:                case 0xed:
        !          10947:                {
        !          10948:                                InvalidInstruction(4);
        !          10949:                        break;
        !          10950:                }
        !          10951:                case 0xee:
        !          10952:                {
        !          10953:                        sdwCyclesRemaining -= 23;
        !          10954:                                bTemp |= 0x20;
        !          10955:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          10956:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          10957:                                {
        !          10958:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          10959:                                        {
        !          10960:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          10961:                                                if (psMemWrite->memoryCall)
        !          10962:                                                {
        !          10963:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          10964:                                                }
        !          10965:                                                else
        !          10966:                                                {
        !          10967:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          10968:                                                }
        !          10969:                                                psMemWrite = NULL;
        !          10970:                                                break;
        !          10971:                                        }
        !          10972:                                        ++psMemWrite;
        !          10973:                                }
        !          10974: 
        !          10975:                                if (psMemWrite)
        !          10976:                                {
        !          10977:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          10978:                                }
        !          10979: 
        !          10980:                        break;
        !          10981:                }
        !          10982:                case 0xef:
        !          10983:                {
        !          10984:                                InvalidInstruction(4);
        !          10985:                        break;
        !          10986:                }
        !          10987:                case 0xf0:
        !          10988:                {
        !          10989:                                InvalidInstruction(4);
        !          10990:                        break;
        !          10991:                }
        !          10992:                case 0xf1:
        !          10993:                {
        !          10994:                                InvalidInstruction(4);
        !          10995:                        break;
        !          10996:                }
        !          10997:                case 0xf2:
        !          10998:                {
        !          10999:                                InvalidInstruction(4);
        !          11000:                        break;
        !          11001:                }
        !          11002:                case 0xf3:
        !          11003:                {
        !          11004:                                InvalidInstruction(4);
        !          11005:                        break;
        !          11006:                }
        !          11007:                case 0xf4:
        !          11008:                {
        !          11009:                                InvalidInstruction(4);
        !          11010:                        break;
        !          11011:                }
        !          11012:                case 0xf5:
        !          11013:                {
        !          11014:                                InvalidInstruction(4);
        !          11015:                        break;
        !          11016:                }
        !          11017:                case 0xf6:
        !          11018:                {
        !          11019:                        sdwCyclesRemaining -= 23;
        !          11020:                                bTemp |= 0x40;
        !          11021:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          11022:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          11023:                                {
        !          11024:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          11025:                                        {
        !          11026:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11027:                                                if (psMemWrite->memoryCall)
        !          11028:                                                {
        !          11029:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          11030:                                                }
        !          11031:                                                else
        !          11032:                                                {
        !          11033:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          11034:                                                }
        !          11035:                                                psMemWrite = NULL;
        !          11036:                                                break;
        !          11037:                                        }
        !          11038:                                        ++psMemWrite;
        !          11039:                                }
        !          11040: 
        !          11041:                                if (psMemWrite)
        !          11042:                                {
        !          11043:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          11044:                                }
        !          11045: 
        !          11046:                        break;
        !          11047:                }
        !          11048:                case 0xf7:
        !          11049:                {
        !          11050:                                InvalidInstruction(4);
        !          11051:                        break;
        !          11052:                }
        !          11053:                case 0xf8:
        !          11054:                {
        !          11055:                                InvalidInstruction(4);
        !          11056:                        break;
        !          11057:                }
        !          11058:                case 0xf9:
        !          11059:                {
        !          11060:                                InvalidInstruction(4);
        !          11061:                        break;
        !          11062:                }
        !          11063:                case 0xfa:
        !          11064:                {
        !          11065:                                InvalidInstruction(4);
        !          11066:                        break;
        !          11067:                }
        !          11068:                case 0xfb:
        !          11069:                {
        !          11070:                                InvalidInstruction(4);
        !          11071:                        break;
        !          11072:                }
        !          11073:                case 0xfc:
        !          11074:                {
        !          11075:                                InvalidInstruction(4);
        !          11076:                        break;
        !          11077:                }
        !          11078:                case 0xfd:
        !          11079:                {
        !          11080:                                InvalidInstruction(4);
        !          11081:                        break;
        !          11082:                }
        !          11083:                case 0xfe:
        !          11084:                {
        !          11085:                        sdwCyclesRemaining -= 23;
        !          11086:                                bTemp |= 0x80;
        !          11087:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          11088:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          11089:                                {
        !          11090:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          11091:                                        {
        !          11092:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11093:                                                if (psMemWrite->memoryCall)
        !          11094:                                                {
        !          11095:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          11096:                                                }
        !          11097:                                                else
        !          11098:                                                {
        !          11099:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          11100:                                                }
        !          11101:                                                psMemWrite = NULL;
        !          11102:                                                break;
        !          11103:                                        }
        !          11104:                                        ++psMemWrite;
        !          11105:                                }
        !          11106: 
        !          11107:                                if (psMemWrite)
        !          11108:                                {
        !          11109:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          11110:                                }
        !          11111: 
        !          11112:                        break;
        !          11113:                }
        !          11114:                case 0xff:
        !          11115:                {
        !          11116:                                InvalidInstruction(4);
        !          11117:                        break;
        !          11118:                }
        !          11119:        }
        !          11120: }
        !          11121: void FDHandler(void)
        !          11122: {
        !          11123:        switch (*pbPC++)
        !          11124:        {
        !          11125:                case 0x00:
        !          11126:                {
        !          11127:                                InvalidInstruction(2);
        !          11128:                        break;
        !          11129:                }
        !          11130:                case 0x01:
        !          11131:                {
        !          11132:                                InvalidInstruction(2);
        !          11133:                        break;
        !          11134:                }
        !          11135:                case 0x02:
        !          11136:                {
        !          11137:                                InvalidInstruction(2);
        !          11138:                        break;
        !          11139:                }
        !          11140:                case 0x03:
        !          11141:                {
        !          11142:                                InvalidInstruction(2);
        !          11143:                        break;
        !          11144:                }
        !          11145:                case 0x04:
        !          11146:                {
        !          11147:                                InvalidInstruction(2);
        !          11148:                        break;
        !          11149:                }
        !          11150:                case 0x05:
        !          11151:                {
        !          11152:                                InvalidInstruction(2);
        !          11153:                        break;
        !          11154:                }
        !          11155:                case 0x06:
        !          11156:                {
        !          11157:                                InvalidInstruction(2);
        !          11158:                        break;
        !          11159:                }
        !          11160:                case 0x07:
        !          11161:                {
        !          11162:                                InvalidInstruction(2);
        !          11163:                        break;
        !          11164:                }
        !          11165:                case 0x08:
        !          11166:                {
        !          11167:                                InvalidInstruction(2);
        !          11168:                        break;
        !          11169:                }
        !          11170:                case 0x09:
        !          11171:                {
        !          11172:                        sdwCyclesRemaining -= 15;
        !          11173:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          11174:                        dwTemp = cpu.z80IY + cpu.z80BC;
        !          11175:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
        !          11176:                        cpu.z80IY = dwTemp & 0xffff;
        !          11177:                        break;
        !          11178:                }
        !          11179:                case 0x0a:
        !          11180:                {
        !          11181:                                InvalidInstruction(2);
        !          11182:                        break;
        !          11183:                }
        !          11184:                case 0x0b:
        !          11185:                {
        !          11186:                                InvalidInstruction(2);
        !          11187:                        break;
        !          11188:                }
        !          11189:                case 0x0c:
        !          11190:                {
        !          11191:                                InvalidInstruction(2);
        !          11192:                        break;
        !          11193:                }
        !          11194:                case 0x0d:
        !          11195:                {
        !          11196:                                InvalidInstruction(2);
        !          11197:                        break;
        !          11198:                }
        !          11199:                case 0x0e:
        !          11200:                {
        !          11201:                                InvalidInstruction(2);
        !          11202:                        break;
        !          11203:                }
        !          11204:                case 0x0f:
        !          11205:                {
        !          11206:                                InvalidInstruction(2);
        !          11207:                        break;
        !          11208:                }
        !          11209:                case 0x10:
        !          11210:                {
        !          11211:                                InvalidInstruction(2);
        !          11212:                        break;
        !          11213:                }
        !          11214:                case 0x11:
        !          11215:                {
        !          11216:                                InvalidInstruction(2);
        !          11217:                        break;
        !          11218:                }
        !          11219:                case 0x12:
        !          11220:                {
        !          11221:                                InvalidInstruction(2);
        !          11222:                        break;
        !          11223:                }
        !          11224:                case 0x13:
        !          11225:                {
        !          11226:                                InvalidInstruction(2);
        !          11227:                        break;
        !          11228:                }
        !          11229:                case 0x14:
        !          11230:                {
        !          11231:                                InvalidInstruction(2);
        !          11232:                        break;
        !          11233:                }
        !          11234:                case 0x15:
        !          11235:                {
        !          11236:                                InvalidInstruction(2);
        !          11237:                        break;
        !          11238:                }
        !          11239:                case 0x16:
        !          11240:                {
        !          11241:                                InvalidInstruction(2);
        !          11242:                        break;
        !          11243:                }
        !          11244:                case 0x17:
        !          11245:                {
        !          11246:                                InvalidInstruction(2);
        !          11247:                        break;
        !          11248:                }
        !          11249:                case 0x18:
        !          11250:                {
        !          11251:                                InvalidInstruction(2);
        !          11252:                        break;
        !          11253:                }
        !          11254:                case 0x19:
        !          11255:                {
        !          11256:                        sdwCyclesRemaining -= 15;
        !          11257:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          11258:                        dwTemp = cpu.z80IY + cpu.z80DE;
        !          11259:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
        !          11260:                        cpu.z80IY = dwTemp & 0xffff;
        !          11261:                        break;
        !          11262:                }
        !          11263:                case 0x1a:
        !          11264:                {
        !          11265:                                InvalidInstruction(2);
        !          11266:                        break;
        !          11267:                }
        !          11268:                case 0x1b:
        !          11269:                {
        !          11270:                                InvalidInstruction(2);
        !          11271:                        break;
        !          11272:                }
        !          11273:                case 0x1c:
        !          11274:                {
        !          11275:                                InvalidInstruction(2);
        !          11276:                        break;
        !          11277:                }
        !          11278:                case 0x1d:
        !          11279:                {
        !          11280:                                InvalidInstruction(2);
        !          11281:                        break;
        !          11282:                }
        !          11283:                case 0x1e:
        !          11284:                {
        !          11285:                                InvalidInstruction(2);
        !          11286:                        break;
        !          11287:                }
        !          11288:                case 0x1f:
        !          11289:                {
        !          11290:                                InvalidInstruction(2);
        !          11291:                        break;
        !          11292:                }
        !          11293:                case 0x20:
        !          11294:                {
        !          11295:                                InvalidInstruction(2);
        !          11296:                        break;
        !          11297:                }
        !          11298:                case 0x21:
        !          11299:                {
        !          11300:                        sdwCyclesRemaining -= 14;
        !          11301:                cpu.z80IY = *pbPC++;
        !          11302:                cpu.z80IY |= ((UINT32) *pbPC++ << 8);
        !          11303:                        break;
        !          11304:                }
        !          11305:                case 0x22:
        !          11306:                {
        !          11307:                        sdwCyclesRemaining -= 20;
        !          11308:                                dwAddr = *pbPC++;
        !          11309:                                dwAddr |= ((UINT32) *pbPC++ << 8);
        !          11310:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          11311:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          11312:                                {
        !          11313:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          11314:                                        {
        !          11315:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11316:                                                if (psMemWrite->memoryCall)
        !          11317:                                                {
        !          11318:                                                        psMemWrite->memoryCall(dwAddr, (cpu.z80IY & 0xff), psMemWrite);
        !          11319:                                                        psMemWrite->memoryCall(dwAddr + 1, (cpu.z80IY >> 8), psMemWrite);
        !          11320:                                                }
        !          11321:                                                else
        !          11322:                                                {
        !          11323:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = cpu.z80IY;
        !          11324:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8;
        !          11325:                                                }
        !          11326:                                                psMemWrite = NULL;
        !          11327:                                                break;
        !          11328:                                        }
        !          11329:                                        ++psMemWrite;
        !          11330:                                }
        !          11331: 
        !          11332:                                if (psMemWrite)
        !          11333:                                {
        !          11334:                                        cpu.z80Base[dwAddr] = (UINT8) cpu.z80IY;
        !          11335:                                        cpu.z80Base[dwAddr + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8);
        !          11336:                                }
        !          11337: 
        !          11338:                        break;
        !          11339:                }
        !          11340:                case 0x23:
        !          11341:                {
        !          11342:                        sdwCyclesRemaining -= 10;
        !          11343:                                cpu.z80IY++;
        !          11344:                                cpu.z80IY &= 0xffff;
        !          11345:                        break;
        !          11346:                }
        !          11347:                case 0x24:
        !          11348:                {
        !          11349:                        sdwCyclesRemaining -= 9;
        !          11350:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          11351:                                cpu.z80F |= bPostIncFlags[cpu.z80YH++];
        !          11352:                        break;
        !          11353:                }
        !          11354:                case 0x25:
        !          11355:                {
        !          11356:                        sdwCyclesRemaining -= 9;
        !          11357:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          11358:                                cpu.z80F |= bPostDecFlags[cpu.z80YH--];
        !          11359:                        break;
        !          11360:                }
        !          11361:                case 0x26:
        !          11362:                {
        !          11363:                        sdwCyclesRemaining -= 9;
        !          11364:                        cpu.z80YH = *pbPC++;
        !          11365:                        break;
        !          11366:                }
        !          11367:                case 0x27:
        !          11368:                {
        !          11369:                                InvalidInstruction(2);
        !          11370:                        break;
        !          11371:                }
        !          11372:                case 0x28:
        !          11373:                {
        !          11374:                                InvalidInstruction(2);
        !          11375:                        break;
        !          11376:                }
        !          11377:                case 0x29:
        !          11378:                {
        !          11379:                        sdwCyclesRemaining -= 15;
        !          11380:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          11381:                        dwTemp = cpu.z80IY + cpu.z80IY;
        !          11382:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
        !          11383:                        cpu.z80IY = dwTemp & 0xffff;
        !          11384:                        break;
        !          11385:                }
        !          11386:                case 0x2a:
        !          11387:                {
        !          11388:                        sdwCyclesRemaining -= 20;
        !          11389:                                dwAddr = *pbPC++;
        !          11390:                                dwAddr |= ((UINT32) *pbPC++ << 8);
        !          11391:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          11392:                                while (psMemRead->lowAddr != 0xffffffff)
        !          11393:                                {
        !          11394:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          11395:                                        {
        !          11396:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11397:                                                if (psMemRead->memoryCall)
        !          11398:                                                {
        !          11399:                                                        cpu.z80IY = psMemRead->memoryCall(dwAddr, psMemRead);
        !          11400:                                                        cpu.z80IY |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8);
        !          11401:                                                }
        !          11402:                                                else
        !          11403:                                                {
        !          11404:                                                        cpu.z80IY = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          11405:                                                        cpu.z80IY |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8);
        !          11406:                                                }
        !          11407:                                                psMemRead = NULL;
        !          11408:                                                break;
        !          11409:                                        }
        !          11410:                                        ++psMemRead;
        !          11411:                                }
        !          11412: 
        !          11413:                                if (psMemRead)
        !          11414:                                {
        !          11415:                                        cpu.z80IY = cpu.z80Base[dwAddr];
        !          11416:                                        cpu.z80IY |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8);
        !          11417:                                }
        !          11418: 
        !          11419:                        break;
        !          11420:                }
        !          11421:                case 0x2b:
        !          11422:                {
        !          11423:                        sdwCyclesRemaining -= 10;
        !          11424:                                cpu.z80IY--;
        !          11425:                                cpu.z80IY &= 0xffff;
        !          11426:                        break;
        !          11427:                }
        !          11428:                case 0x2c:
        !          11429:                {
        !          11430:                        sdwCyclesRemaining -= 9;
        !          11431:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          11432:                                cpu.z80F |= bPostIncFlags[cpu.z80YL++];
        !          11433:                        break;
        !          11434:                }
        !          11435:                case 0x2d:
        !          11436:                {
        !          11437:                        sdwCyclesRemaining -= 9;
        !          11438:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          11439:                                cpu.z80F |= bPostDecFlags[cpu.z80YL--];
        !          11440:                        break;
        !          11441:                }
        !          11442:                case 0x2e:
        !          11443:                {
        !          11444:                        sdwCyclesRemaining -= 9;
        !          11445:                        cpu.z80YL = *pbPC++;
        !          11446:                        break;
        !          11447:                }
        !          11448:                case 0x2f:
        !          11449:                {
        !          11450:                                InvalidInstruction(2);
        !          11451:                        break;
        !          11452:                }
        !          11453:                case 0x30:
        !          11454:                {
        !          11455:                                InvalidInstruction(2);
        !          11456:                        break;
        !          11457:                }
        !          11458:                case 0x31:
        !          11459:                {
        !          11460:                                InvalidInstruction(2);
        !          11461:                        break;
        !          11462:                }
        !          11463:                case 0x32:
        !          11464:                {
        !          11465:                                InvalidInstruction(2);
        !          11466:                        break;
        !          11467:                }
        !          11468:                case 0x33:
        !          11469:                {
        !          11470:                                InvalidInstruction(2);
        !          11471:                        break;
        !          11472:                }
        !          11473:                case 0x34:
        !          11474:                {
        !          11475:                        sdwCyclesRemaining -= 23;
        !          11476:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          11477:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          11478:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          11479:                                while (psMemRead->lowAddr != 0xffffffff)
        !          11480:                                {
        !          11481:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          11482:                                        {
        !          11483:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11484:                                                if (psMemRead->memoryCall)
        !          11485:                                                {
        !          11486:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          11487:                                                }
        !          11488:                                                else
        !          11489:                                                {
        !          11490:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          11491:                                                }
        !          11492:                                                psMemRead = NULL;
        !          11493:                                                break;
        !          11494:                                        }
        !          11495:                                        ++psMemRead;
        !          11496:                                }
        !          11497: 
        !          11498:                                if (psMemRead)
        !          11499:                                {
        !          11500:                                        bTemp = cpu.z80Base[dwAddr];
        !          11501:                                }
        !          11502: 
        !          11503:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          11504:                                cpu.z80F |= bPostIncFlags[bTemp++];
        !          11505:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          11506:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          11507:                                {
        !          11508:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          11509:                                        {
        !          11510:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11511:                                                if (psMemWrite->memoryCall)
        !          11512:                                                {
        !          11513:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          11514:                                                }
        !          11515:                                                else
        !          11516:                                                {
        !          11517:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          11518:                                                }
        !          11519:                                                psMemWrite = NULL;
        !          11520:                                                break;
        !          11521:                                        }
        !          11522:                                        ++psMemWrite;
        !          11523:                                }
        !          11524: 
        !          11525:                                if (psMemWrite)
        !          11526:                                {
        !          11527:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          11528:                                }
        !          11529: 
        !          11530:                        break;
        !          11531:                }
        !          11532:                case 0x35:
        !          11533:                {
        !          11534:                        sdwCyclesRemaining -= 23;
        !          11535:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          11536:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          11537:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          11538:                                while (psMemRead->lowAddr != 0xffffffff)
        !          11539:                                {
        !          11540:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          11541:                                        {
        !          11542:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11543:                                                if (psMemRead->memoryCall)
        !          11544:                                                {
        !          11545:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          11546:                                                }
        !          11547:                                                else
        !          11548:                                                {
        !          11549:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          11550:                                                }
        !          11551:                                                psMemRead = NULL;
        !          11552:                                                break;
        !          11553:                                        }
        !          11554:                                        ++psMemRead;
        !          11555:                                }
        !          11556: 
        !          11557:                                if (psMemRead)
        !          11558:                                {
        !          11559:                                        bTemp = cpu.z80Base[dwAddr];
        !          11560:                                }
        !          11561: 
        !          11562:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          11563:                                cpu.z80F |= bPostDecFlags[bTemp--];
        !          11564:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          11565:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          11566:                                {
        !          11567:                                        if ((dwAddr >= psMemWrite->lowAddr) && (dwAddr <= psMemWrite->highAddr))
        !          11568:                                        {
        !          11569:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11570:                                                if (psMemWrite->memoryCall)
        !          11571:                                                {
        !          11572:                                                        psMemWrite->memoryCall(dwAddr, bTemp, psMemWrite);
        !          11573:                                                }
        !          11574:                                                else
        !          11575:                                                {
        !          11576:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwAddr - psMemWrite->lowAddr)) = bTemp;
        !          11577:                                                }
        !          11578:                                                psMemWrite = NULL;
        !          11579:                                                break;
        !          11580:                                        }
        !          11581:                                        ++psMemWrite;
        !          11582:                                }
        !          11583: 
        !          11584:                                if (psMemWrite)
        !          11585:                                {
        !          11586:                                        cpu.z80Base[dwAddr] = (UINT8) bTemp;
        !          11587:                                }
        !          11588: 
        !          11589:                        break;
        !          11590:                }
        !          11591:                case 0x36:
        !          11592:                {
        !          11593:                        sdwCyclesRemaining -= 19;
        !          11594:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          11595:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          11596:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          11597:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          11598:                                {
        !          11599:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          11600:                                        {
        !          11601:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11602:                                                if (psMemWrite->memoryCall)
        !          11603:                                                {
        !          11604:                                                        psMemWrite->memoryCall(sdwAddr, *pbPC++, psMemWrite);
        !          11605:                                                }
        !          11606:                                                else
        !          11607:                                                {
        !          11608:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = *pbPC++;
        !          11609:                                                }
        !          11610:                                                psMemWrite = NULL;
        !          11611:                                                break;
        !          11612:                                        }
        !          11613:                                        ++psMemWrite;
        !          11614:                                }
        !          11615: 
        !          11616:                                if (psMemWrite)
        !          11617:                                {
        !          11618:                                        cpu.z80Base[sdwAddr] = (UINT8) *pbPC++;
        !          11619:                                }
        !          11620: 
        !          11621:                        break;
        !          11622:                }
        !          11623:                case 0x37:
        !          11624:                {
        !          11625:                                InvalidInstruction(2);
        !          11626:                        break;
        !          11627:                }
        !          11628:                case 0x38:
        !          11629:                {
        !          11630:                                InvalidInstruction(2);
        !          11631:                        break;
        !          11632:                }
        !          11633:                case 0x39:
        !          11634:                {
        !          11635:                        sdwCyclesRemaining -= 15;
        !          11636:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          11637:                        dwTemp = cpu.z80IY + cpu.z80sp;
        !          11638:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80IY ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
        !          11639:                        cpu.z80IY = dwTemp & 0xffff;
        !          11640:                        break;
        !          11641:                }
        !          11642:                case 0x3a:
        !          11643:                {
        !          11644:                                InvalidInstruction(2);
        !          11645:                        break;
        !          11646:                }
        !          11647:                case 0x3b:
        !          11648:                {
        !          11649:                                InvalidInstruction(2);
        !          11650:                        break;
        !          11651:                }
        !          11652:                case 0x3c:
        !          11653:                {
        !          11654:                                InvalidInstruction(2);
        !          11655:                        break;
        !          11656:                }
        !          11657:                case 0x3d:
        !          11658:                {
        !          11659:                                InvalidInstruction(2);
        !          11660:                        break;
        !          11661:                }
        !          11662:                case 0x3e:
        !          11663:                {
        !          11664:                                InvalidInstruction(2);
        !          11665:                        break;
        !          11666:                }
        !          11667:                case 0x3f:
        !          11668:                {
        !          11669:                                InvalidInstruction(2);
        !          11670:                        break;
        !          11671:                }
        !          11672:                case 0x40:
        !          11673:                {
        !          11674:                                InvalidInstruction(2);
        !          11675:                        break;
        !          11676:                }
        !          11677:                case 0x41:
        !          11678:                {
        !          11679:                                InvalidInstruction(2);
        !          11680:                        break;
        !          11681:                }
        !          11682:                case 0x42:
        !          11683:                {
        !          11684:                                InvalidInstruction(2);
        !          11685:                        break;
        !          11686:                }
        !          11687:                case 0x43:
        !          11688:                {
        !          11689:                                InvalidInstruction(2);
        !          11690:                        break;
        !          11691:                }
        !          11692:                case 0x44:
        !          11693:                {
        !          11694:                        sdwCyclesRemaining -= 9;
        !          11695:                        cpu.z80B = cpu.z80YH;
        !          11696:                        break;
        !          11697:                }
        !          11698:                case 0x45:
        !          11699:                {
        !          11700:                        sdwCyclesRemaining -= 9;
        !          11701:                        cpu.z80B = cpu.z80YL;
        !          11702:                        break;
        !          11703:                }
        !          11704:                case 0x46:
        !          11705:                {
        !          11706:                        sdwCyclesRemaining -= 19;
        !          11707:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          11708:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          11709:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          11710:                                while (psMemRead->lowAddr != 0xffffffff)
        !          11711:                                {
        !          11712:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          11713:                                        {
        !          11714:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11715:                                                if (psMemRead->memoryCall)
        !          11716:                                                {
        !          11717:                                                        cpu.z80B = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          11718:                                                }
        !          11719:                                                else
        !          11720:                                                {
        !          11721:                                                        cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          11722:                                                }
        !          11723:                                                psMemRead = NULL;
        !          11724:                                                break;
        !          11725:                                        }
        !          11726:                                        ++psMemRead;
        !          11727:                                }
        !          11728: 
        !          11729:                                if (psMemRead)
        !          11730:                                {
        !          11731:                                        cpu.z80B = cpu.z80Base[sdwAddr];
        !          11732:                                }
        !          11733: 
        !          11734:                        break;
        !          11735:                }
        !          11736:                case 0x47:
        !          11737:                {
        !          11738:                                InvalidInstruction(2);
        !          11739:                        break;
        !          11740:                }
        !          11741:                case 0x48:
        !          11742:                {
        !          11743:                                InvalidInstruction(2);
        !          11744:                        break;
        !          11745:                }
        !          11746:                case 0x49:
        !          11747:                {
        !          11748:                                InvalidInstruction(2);
        !          11749:                        break;
        !          11750:                }
        !          11751:                case 0x4a:
        !          11752:                {
        !          11753:                                InvalidInstruction(2);
        !          11754:                        break;
        !          11755:                }
        !          11756:                case 0x4b:
        !          11757:                {
        !          11758:                                InvalidInstruction(2);
        !          11759:                        break;
        !          11760:                }
        !          11761:                case 0x4c:
        !          11762:                {
        !          11763:                        sdwCyclesRemaining -= 9;
        !          11764:                        cpu.z80C = cpu.z80YH;
        !          11765:                        break;
        !          11766:                }
        !          11767:                case 0x4d:
        !          11768:                {
        !          11769:                        sdwCyclesRemaining -= 9;
        !          11770:                        cpu.z80C = cpu.z80YL;
        !          11771:                        break;
        !          11772:                }
        !          11773:                case 0x4e:
        !          11774:                {
        !          11775:                        sdwCyclesRemaining -= 19;
        !          11776:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          11777:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          11778:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          11779:                                while (psMemRead->lowAddr != 0xffffffff)
        !          11780:                                {
        !          11781:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          11782:                                        {
        !          11783:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11784:                                                if (psMemRead->memoryCall)
        !          11785:                                                {
        !          11786:                                                        cpu.z80C = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          11787:                                                }
        !          11788:                                                else
        !          11789:                                                {
        !          11790:                                                        cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          11791:                                                }
        !          11792:                                                psMemRead = NULL;
        !          11793:                                                break;
        !          11794:                                        }
        !          11795:                                        ++psMemRead;
        !          11796:                                }
        !          11797: 
        !          11798:                                if (psMemRead)
        !          11799:                                {
        !          11800:                                        cpu.z80C = cpu.z80Base[sdwAddr];
        !          11801:                                }
        !          11802: 
        !          11803:                        break;
        !          11804:                }
        !          11805:                case 0x4f:
        !          11806:                {
        !          11807:                                InvalidInstruction(2);
        !          11808:                        break;
        !          11809:                }
        !          11810:                case 0x50:
        !          11811:                {
        !          11812:                                InvalidInstruction(2);
        !          11813:                        break;
        !          11814:                }
        !          11815:                case 0x51:
        !          11816:                {
        !          11817:                                InvalidInstruction(2);
        !          11818:                        break;
        !          11819:                }
        !          11820:                case 0x52:
        !          11821:                {
        !          11822:                                InvalidInstruction(2);
        !          11823:                        break;
        !          11824:                }
        !          11825:                case 0x53:
        !          11826:                {
        !          11827:                                InvalidInstruction(2);
        !          11828:                        break;
        !          11829:                }
        !          11830:                case 0x54:
        !          11831:                {
        !          11832:                        sdwCyclesRemaining -= 9;
        !          11833:                        cpu.z80D = cpu.z80YH;
        !          11834:                        break;
        !          11835:                }
        !          11836:                case 0x55:
        !          11837:                {
        !          11838:                        sdwCyclesRemaining -= 9;
        !          11839:                        cpu.z80D = cpu.z80YL;
        !          11840:                        break;
        !          11841:                }
        !          11842:                case 0x56:
        !          11843:                {
        !          11844:                        sdwCyclesRemaining -= 19;
        !          11845:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          11846:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          11847:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          11848:                                while (psMemRead->lowAddr != 0xffffffff)
        !          11849:                                {
        !          11850:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          11851:                                        {
        !          11852:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11853:                                                if (psMemRead->memoryCall)
        !          11854:                                                {
        !          11855:                                                        cpu.z80D = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          11856:                                                }
        !          11857:                                                else
        !          11858:                                                {
        !          11859:                                                        cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          11860:                                                }
        !          11861:                                                psMemRead = NULL;
        !          11862:                                                break;
        !          11863:                                        }
        !          11864:                                        ++psMemRead;
        !          11865:                                }
        !          11866: 
        !          11867:                                if (psMemRead)
        !          11868:                                {
        !          11869:                                        cpu.z80D = cpu.z80Base[sdwAddr];
        !          11870:                                }
        !          11871: 
        !          11872:                        break;
        !          11873:                }
        !          11874:                case 0x57:
        !          11875:                {
        !          11876:                                InvalidInstruction(2);
        !          11877:                        break;
        !          11878:                }
        !          11879:                case 0x58:
        !          11880:                {
        !          11881:                                InvalidInstruction(2);
        !          11882:                        break;
        !          11883:                }
        !          11884:                case 0x59:
        !          11885:                {
        !          11886:                                InvalidInstruction(2);
        !          11887:                        break;
        !          11888:                }
        !          11889:                case 0x5a:
        !          11890:                {
        !          11891:                                InvalidInstruction(2);
        !          11892:                        break;
        !          11893:                }
        !          11894:                case 0x5b:
        !          11895:                {
        !          11896:                                InvalidInstruction(2);
        !          11897:                        break;
        !          11898:                }
        !          11899:                case 0x5c:
        !          11900:                {
        !          11901:                        sdwCyclesRemaining -= 9;
        !          11902:                        cpu.z80E = cpu.z80YH;
        !          11903:                        break;
        !          11904:                }
        !          11905:                case 0x5d:
        !          11906:                {
        !          11907:                        sdwCyclesRemaining -= 9;
        !          11908:                        cpu.z80E = cpu.z80YL;
        !          11909:                        break;
        !          11910:                }
        !          11911:                case 0x5e:
        !          11912:                {
        !          11913:                        sdwCyclesRemaining -= 19;
        !          11914:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          11915:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          11916:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          11917:                                while (psMemRead->lowAddr != 0xffffffff)
        !          11918:                                {
        !          11919:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          11920:                                        {
        !          11921:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11922:                                                if (psMemRead->memoryCall)
        !          11923:                                                {
        !          11924:                                                        cpu.z80E = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          11925:                                                }
        !          11926:                                                else
        !          11927:                                                {
        !          11928:                                                        cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          11929:                                                }
        !          11930:                                                psMemRead = NULL;
        !          11931:                                                break;
        !          11932:                                        }
        !          11933:                                        ++psMemRead;
        !          11934:                                }
        !          11935: 
        !          11936:                                if (psMemRead)
        !          11937:                                {
        !          11938:                                        cpu.z80E = cpu.z80Base[sdwAddr];
        !          11939:                                }
        !          11940: 
        !          11941:                        break;
        !          11942:                }
        !          11943:                case 0x5f:
        !          11944:                {
        !          11945:                                InvalidInstruction(2);
        !          11946:                        break;
        !          11947:                }
        !          11948:                case 0x60:
        !          11949:                {
        !          11950:                        sdwCyclesRemaining -= 9;
        !          11951:                        cpu.z80YH = cpu.z80B;
        !          11952:                        break;
        !          11953:                }
        !          11954:                case 0x61:
        !          11955:                {
        !          11956:                        sdwCyclesRemaining -= 9;
        !          11957:                        cpu.z80YH = cpu.z80C;
        !          11958:                        break;
        !          11959:                }
        !          11960:                case 0x62:
        !          11961:                {
        !          11962:                        sdwCyclesRemaining -= 9;
        !          11963:                        cpu.z80YH = cpu.z80D;
        !          11964:                        break;
        !          11965:                }
        !          11966:                case 0x63:
        !          11967:                {
        !          11968:                        sdwCyclesRemaining -= 9;
        !          11969:                        cpu.z80YH = cpu.z80E;
        !          11970:                        break;
        !          11971:                }
        !          11972:                case 0x64:
        !          11973:                {
        !          11974:                        sdwCyclesRemaining -= 9;
        !          11975:                        break;
        !          11976:                }
        !          11977:                case 0x65:
        !          11978:                {
        !          11979:                        sdwCyclesRemaining -= 9;
        !          11980:                        cpu.z80YH = cpu.z80YL;
        !          11981:                        break;
        !          11982:                }
        !          11983:                case 0x66:
        !          11984:                {
        !          11985:                        sdwCyclesRemaining -= 19;
        !          11986:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          11987:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          11988:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          11989:                                while (psMemRead->lowAddr != 0xffffffff)
        !          11990:                                {
        !          11991:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          11992:                                        {
        !          11993:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          11994:                                                if (psMemRead->memoryCall)
        !          11995:                                                {
        !          11996:                                                        cpu.z80H = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          11997:                                                }
        !          11998:                                                else
        !          11999:                                                {
        !          12000:                                                        cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          12001:                                                }
        !          12002:                                                psMemRead = NULL;
        !          12003:                                                break;
        !          12004:                                        }
        !          12005:                                        ++psMemRead;
        !          12006:                                }
        !          12007: 
        !          12008:                                if (psMemRead)
        !          12009:                                {
        !          12010:                                        cpu.z80H = cpu.z80Base[sdwAddr];
        !          12011:                                }
        !          12012: 
        !          12013:                        break;
        !          12014:                }
        !          12015:                case 0x67:
        !          12016:                {
        !          12017:                        sdwCyclesRemaining -= 9;
        !          12018:                        cpu.z80YH = cpu.z80A;
        !          12019:                        break;
        !          12020:                }
        !          12021:                case 0x68:
        !          12022:                {
        !          12023:                        sdwCyclesRemaining -= 9;
        !          12024:                        cpu.z80YL = cpu.z80B;
        !          12025:                        break;
        !          12026:                }
        !          12027:                case 0x69:
        !          12028:                {
        !          12029:                        sdwCyclesRemaining -= 9;
        !          12030:                        cpu.z80YL = cpu.z80C;
        !          12031:                        break;
        !          12032:                }
        !          12033:                case 0x6a:
        !          12034:                {
        !          12035:                        sdwCyclesRemaining -= 9;
        !          12036:                        cpu.z80YL = cpu.z80D;
        !          12037:                        break;
        !          12038:                }
        !          12039:                case 0x6b:
        !          12040:                {
        !          12041:                        sdwCyclesRemaining -= 9;
        !          12042:                        cpu.z80YL = cpu.z80E;
        !          12043:                        break;
        !          12044:                }
        !          12045:                case 0x6c:
        !          12046:                {
        !          12047:                        sdwCyclesRemaining -= 9;
        !          12048:                        cpu.z80YL = cpu.z80YH;
        !          12049:                        break;
        !          12050:                }
        !          12051:                case 0x6d:
        !          12052:                {
        !          12053:                        sdwCyclesRemaining -= 9;
        !          12054:                        break;
        !          12055:                }
        !          12056:                case 0x6e:
        !          12057:                {
        !          12058:                        sdwCyclesRemaining -= 19;
        !          12059:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12060:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12061:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12062:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12063:                                {
        !          12064:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          12065:                                        {
        !          12066:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12067:                                                if (psMemRead->memoryCall)
        !          12068:                                                {
        !          12069:                                                        cpu.z80L = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          12070:                                                }
        !          12071:                                                else
        !          12072:                                                {
        !          12073:                                                        cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          12074:                                                }
        !          12075:                                                psMemRead = NULL;
        !          12076:                                                break;
        !          12077:                                        }
        !          12078:                                        ++psMemRead;
        !          12079:                                }
        !          12080: 
        !          12081:                                if (psMemRead)
        !          12082:                                {
        !          12083:                                        cpu.z80L = cpu.z80Base[sdwAddr];
        !          12084:                                }
        !          12085: 
        !          12086:                        break;
        !          12087:                }
        !          12088:                case 0x6f:
        !          12089:                {
        !          12090:                        sdwCyclesRemaining -= 9;
        !          12091:                        cpu.z80YL = cpu.z80A;
        !          12092:                        break;
        !          12093:                }
        !          12094:                case 0x70:
        !          12095:                {
        !          12096:                        sdwCyclesRemaining -= 19;
        !          12097:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12098:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12099:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          12100:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          12101:                                {
        !          12102:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          12103:                                        {
        !          12104:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12105:                                                if (psMemWrite->memoryCall)
        !          12106:                                                {
        !          12107:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80B, psMemWrite);
        !          12108:                                                }
        !          12109:                                                else
        !          12110:                                                {
        !          12111:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80B;
        !          12112:                                                }
        !          12113:                                                psMemWrite = NULL;
        !          12114:                                                break;
        !          12115:                                        }
        !          12116:                                        ++psMemWrite;
        !          12117:                                }
        !          12118: 
        !          12119:                                if (psMemWrite)
        !          12120:                                {
        !          12121:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80B;
        !          12122:                                }
        !          12123: 
        !          12124:                        break;
        !          12125:                }
        !          12126:                case 0x71:
        !          12127:                {
        !          12128:                        sdwCyclesRemaining -= 19;
        !          12129:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12130:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12131:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          12132:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          12133:                                {
        !          12134:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          12135:                                        {
        !          12136:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12137:                                                if (psMemWrite->memoryCall)
        !          12138:                                                {
        !          12139:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80C, psMemWrite);
        !          12140:                                                }
        !          12141:                                                else
        !          12142:                                                {
        !          12143:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80C;
        !          12144:                                                }
        !          12145:                                                psMemWrite = NULL;
        !          12146:                                                break;
        !          12147:                                        }
        !          12148:                                        ++psMemWrite;
        !          12149:                                }
        !          12150: 
        !          12151:                                if (psMemWrite)
        !          12152:                                {
        !          12153:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80C;
        !          12154:                                }
        !          12155: 
        !          12156:                        break;
        !          12157:                }
        !          12158:                case 0x72:
        !          12159:                {
        !          12160:                        sdwCyclesRemaining -= 19;
        !          12161:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12162:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12163:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          12164:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          12165:                                {
        !          12166:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          12167:                                        {
        !          12168:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12169:                                                if (psMemWrite->memoryCall)
        !          12170:                                                {
        !          12171:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80D, psMemWrite);
        !          12172:                                                }
        !          12173:                                                else
        !          12174:                                                {
        !          12175:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80D;
        !          12176:                                                }
        !          12177:                                                psMemWrite = NULL;
        !          12178:                                                break;
        !          12179:                                        }
        !          12180:                                        ++psMemWrite;
        !          12181:                                }
        !          12182: 
        !          12183:                                if (psMemWrite)
        !          12184:                                {
        !          12185:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80D;
        !          12186:                                }
        !          12187: 
        !          12188:                        break;
        !          12189:                }
        !          12190:                case 0x73:
        !          12191:                {
        !          12192:                        sdwCyclesRemaining -= 19;
        !          12193:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12194:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12195:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          12196:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          12197:                                {
        !          12198:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          12199:                                        {
        !          12200:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12201:                                                if (psMemWrite->memoryCall)
        !          12202:                                                {
        !          12203:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80E, psMemWrite);
        !          12204:                                                }
        !          12205:                                                else
        !          12206:                                                {
        !          12207:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80E;
        !          12208:                                                }
        !          12209:                                                psMemWrite = NULL;
        !          12210:                                                break;
        !          12211:                                        }
        !          12212:                                        ++psMemWrite;
        !          12213:                                }
        !          12214: 
        !          12215:                                if (psMemWrite)
        !          12216:                                {
        !          12217:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80E;
        !          12218:                                }
        !          12219: 
        !          12220:                        break;
        !          12221:                }
        !          12222:                case 0x74:
        !          12223:                {
        !          12224:                        sdwCyclesRemaining -= 19;
        !          12225:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12226:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12227:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          12228:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          12229:                                {
        !          12230:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          12231:                                        {
        !          12232:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12233:                                                if (psMemWrite->memoryCall)
        !          12234:                                                {
        !          12235:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80H, psMemWrite);
        !          12236:                                                }
        !          12237:                                                else
        !          12238:                                                {
        !          12239:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80H;
        !          12240:                                                }
        !          12241:                                                psMemWrite = NULL;
        !          12242:                                                break;
        !          12243:                                        }
        !          12244:                                        ++psMemWrite;
        !          12245:                                }
        !          12246: 
        !          12247:                                if (psMemWrite)
        !          12248:                                {
        !          12249:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80H;
        !          12250:                                }
        !          12251: 
        !          12252:                        break;
        !          12253:                }
        !          12254:                case 0x75:
        !          12255:                {
        !          12256:                        sdwCyclesRemaining -= 19;
        !          12257:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12258:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12259:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          12260:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          12261:                                {
        !          12262:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          12263:                                        {
        !          12264:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12265:                                                if (psMemWrite->memoryCall)
        !          12266:                                                {
        !          12267:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80L, psMemWrite);
        !          12268:                                                }
        !          12269:                                                else
        !          12270:                                                {
        !          12271:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80L;
        !          12272:                                                }
        !          12273:                                                psMemWrite = NULL;
        !          12274:                                                break;
        !          12275:                                        }
        !          12276:                                        ++psMemWrite;
        !          12277:                                }
        !          12278: 
        !          12279:                                if (psMemWrite)
        !          12280:                                {
        !          12281:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80L;
        !          12282:                                }
        !          12283: 
        !          12284:                        break;
        !          12285:                }
        !          12286:                case 0x76:
        !          12287:                {
        !          12288:                        sdwCyclesRemaining -= 19;
        !          12289:                                InvalidInstruction(2);
        !          12290:                        break;
        !          12291:                }
        !          12292:                case 0x77:
        !          12293:                {
        !          12294:                        sdwCyclesRemaining -= 19;
        !          12295:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12296:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12297:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          12298:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          12299:                                {
        !          12300:                                        if ((sdwAddr >= psMemWrite->lowAddr) && (sdwAddr <= psMemWrite->highAddr))
        !          12301:                                        {
        !          12302:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12303:                                                if (psMemWrite->memoryCall)
        !          12304:                                                {
        !          12305:                                                        psMemWrite->memoryCall(sdwAddr, cpu.z80A, psMemWrite);
        !          12306:                                                }
        !          12307:                                                else
        !          12308:                                                {
        !          12309:                                                        *((UINT8 *) psMemWrite->pUserArea + (sdwAddr - psMemWrite->lowAddr)) = cpu.z80A;
        !          12310:                                                }
        !          12311:                                                psMemWrite = NULL;
        !          12312:                                                break;
        !          12313:                                        }
        !          12314:                                        ++psMemWrite;
        !          12315:                                }
        !          12316: 
        !          12317:                                if (psMemWrite)
        !          12318:                                {
        !          12319:                                        cpu.z80Base[sdwAddr] = (UINT8) cpu.z80A;
        !          12320:                                }
        !          12321: 
        !          12322:                        break;
        !          12323:                }
        !          12324:                case 0x78:
        !          12325:                {
        !          12326:                                InvalidInstruction(2);
        !          12327:                        break;
        !          12328:                }
        !          12329:                case 0x79:
        !          12330:                {
        !          12331:                                InvalidInstruction(2);
        !          12332:                        break;
        !          12333:                }
        !          12334:                case 0x7a:
        !          12335:                {
        !          12336:                                InvalidInstruction(2);
        !          12337:                        break;
        !          12338:                }
        !          12339:                case 0x7b:
        !          12340:                {
        !          12341:                                InvalidInstruction(2);
        !          12342:                        break;
        !          12343:                }
        !          12344:                case 0x7c:
        !          12345:                {
        !          12346:                        sdwCyclesRemaining -= 9;
        !          12347:                        cpu.z80A = cpu.z80YH;
        !          12348:                        break;
        !          12349:                }
        !          12350:                case 0x7d:
        !          12351:                {
        !          12352:                        sdwCyclesRemaining -= 9;
        !          12353:                        cpu.z80A = cpu.z80YL;
        !          12354:                        break;
        !          12355:                }
        !          12356:                case 0x7e:
        !          12357:                {
        !          12358:                        sdwCyclesRemaining -= 19;
        !          12359:                                sdwAddr = (INT8) *pbPC++;       // Get the offset
        !          12360:                                sdwAddr = ((INT32) cpu.z80IY + sdwAddr) & 0xffff;
        !          12361:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12362:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12363:                                {
        !          12364:                                        if ((sdwAddr >= psMemRead->lowAddr) && (sdwAddr <= psMemRead->highAddr))
        !          12365:                                        {
        !          12366:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12367:                                                if (psMemRead->memoryCall)
        !          12368:                                                {
        !          12369:                                                        cpu.z80A = psMemRead->memoryCall(sdwAddr, psMemRead);
        !          12370:                                                }
        !          12371:                                                else
        !          12372:                                                {
        !          12373:                                                        cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (sdwAddr - psMemRead->lowAddr));
        !          12374:                                                }
        !          12375:                                                psMemRead = NULL;
        !          12376:                                                break;
        !          12377:                                        }
        !          12378:                                        ++psMemRead;
        !          12379:                                }
        !          12380: 
        !          12381:                                if (psMemRead)
        !          12382:                                {
        !          12383:                                        cpu.z80A = cpu.z80Base[sdwAddr];
        !          12384:                                }
        !          12385: 
        !          12386:                        break;
        !          12387:                }
        !          12388:                case 0x7f:
        !          12389:                {
        !          12390:                                InvalidInstruction(2);
        !          12391:                        break;
        !          12392:                }
        !          12393:                case 0x80:
        !          12394:                {
        !          12395:                                InvalidInstruction(2);
        !          12396:                        break;
        !          12397:                }
        !          12398:                case 0x81:
        !          12399:                {
        !          12400:                                InvalidInstruction(2);
        !          12401:                        break;
        !          12402:                }
        !          12403:                case 0x82:
        !          12404:                {
        !          12405:                                InvalidInstruction(2);
        !          12406:                        break;
        !          12407:                }
        !          12408:                case 0x83:
        !          12409:                {
        !          12410:                                InvalidInstruction(2);
        !          12411:                        break;
        !          12412:                }
        !          12413:                case 0x84:
        !          12414:                {
        !          12415:                        sdwCyclesRemaining -= 9;
        !          12416:                                bTemp2 = cpu.z80A + cpu.z80YH;
        !          12417:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12418:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12419:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH];
        !          12420:                        break;
        !          12421:                }
        !          12422:                case 0x85:
        !          12423:                {
        !          12424:                        sdwCyclesRemaining -= 9;
        !          12425:                                bTemp2 = cpu.z80A + cpu.z80YL;
        !          12426:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12427:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12428:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL];
        !          12429:                        break;
        !          12430:                }
        !          12431:                case 0x86:
        !          12432:                {
        !          12433:                        sdwCyclesRemaining -= 19;
        !          12434:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          12435:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          12436:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12437:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12438:                                {
        !          12439:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          12440:                                        {
        !          12441:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12442:                                                if (psMemRead->memoryCall)
        !          12443:                                                {
        !          12444:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          12445:                                                }
        !          12446:                                                else
        !          12447:                                                {
        !          12448:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          12449:                                                }
        !          12450:                                                psMemRead = NULL;
        !          12451:                                                break;
        !          12452:                                        }
        !          12453:                                        ++psMemRead;
        !          12454:                                }
        !          12455: 
        !          12456:                                if (psMemRead)
        !          12457:                                {
        !          12458:                                        bTemp = cpu.z80Base[dwAddr];
        !          12459:                                }
        !          12460: 
        !          12461:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12462:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12463:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          12464:                                cpu.z80A += bTemp;
        !          12465:                        break;
        !          12466:                }
        !          12467:                case 0x87:
        !          12468:                {
        !          12469:                                InvalidInstruction(2);
        !          12470:                        break;
        !          12471:                }
        !          12472:                case 0x88:
        !          12473:                {
        !          12474:                                InvalidInstruction(2);
        !          12475:                        break;
        !          12476:                }
        !          12477:                case 0x89:
        !          12478:                {
        !          12479:                                InvalidInstruction(2);
        !          12480:                        break;
        !          12481:                }
        !          12482:                case 0x8a:
        !          12483:                {
        !          12484:                                InvalidInstruction(2);
        !          12485:                        break;
        !          12486:                }
        !          12487:                case 0x8b:
        !          12488:                {
        !          12489:                                InvalidInstruction(2);
        !          12490:                        break;
        !          12491:                }
        !          12492:                case 0x8c:
        !          12493:                {
        !          12494:                        sdwCyclesRemaining -= 9;
        !          12495:                                bTemp2 = cpu.z80A + cpu.z80YH + (cpu.z80F & Z80_FLAG_CARRY);
        !          12496:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12497:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12498:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          12499:                        break;
        !          12500:                }
        !          12501:                case 0x8d:
        !          12502:                {
        !          12503:                        sdwCyclesRemaining -= 9;
        !          12504:                                bTemp2 = cpu.z80A + cpu.z80YL + (cpu.z80F & Z80_FLAG_CARRY);
        !          12505:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12506:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12507:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          12508:                        break;
        !          12509:                }
        !          12510:                case 0x8e:
        !          12511:                {
        !          12512:                        sdwCyclesRemaining -= 19;
        !          12513:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          12514:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          12515:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12516:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12517:                                {
        !          12518:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          12519:                                        {
        !          12520:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12521:                                                if (psMemRead->memoryCall)
        !          12522:                                                {
        !          12523:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          12524:                                                }
        !          12525:                                                else
        !          12526:                                                {
        !          12527:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          12528:                                                }
        !          12529:                                                psMemRead = NULL;
        !          12530:                                                break;
        !          12531:                                        }
        !          12532:                                        ++psMemRead;
        !          12533:                                }
        !          12534: 
        !          12535:                                if (psMemRead)
        !          12536:                                {
        !          12537:                                        bTemp = cpu.z80Base[dwAddr];
        !          12538:                                }
        !          12539: 
        !          12540:                                bTemp2 = (cpu.z80F & Z80_FLAG_CARRY);
        !          12541:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12542:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12543:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          12544:                                cpu.z80A += bTemp + bTemp2;
        !          12545:                        break;
        !          12546:                }
        !          12547:                case 0x8f:
        !          12548:                {
        !          12549:                                InvalidInstruction(2);
        !          12550:                        break;
        !          12551:                }
        !          12552:                case 0x90:
        !          12553:                {
        !          12554:                                InvalidInstruction(2);
        !          12555:                        break;
        !          12556:                }
        !          12557:                case 0x91:
        !          12558:                {
        !          12559:                                InvalidInstruction(2);
        !          12560:                        break;
        !          12561:                }
        !          12562:                case 0x92:
        !          12563:                {
        !          12564:                                InvalidInstruction(2);
        !          12565:                        break;
        !          12566:                }
        !          12567:                case 0x93:
        !          12568:                {
        !          12569:                                InvalidInstruction(2);
        !          12570:                        break;
        !          12571:                }
        !          12572:                case 0x94:
        !          12573:                {
        !          12574:                        sdwCyclesRemaining -= 9;
        !          12575:                                bTemp2 = cpu.z80A - cpu.z80YH;
        !          12576:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12577:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12578:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH];
        !          12579:                        break;
        !          12580:                }
        !          12581:                case 0x95:
        !          12582:                {
        !          12583:                        sdwCyclesRemaining -= 9;
        !          12584:                                bTemp2 = cpu.z80A - cpu.z80YL;
        !          12585:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12586:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12587:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL];
        !          12588:                        break;
        !          12589:                }
        !          12590:                case 0x96:
        !          12591:                {
        !          12592:                        sdwCyclesRemaining -= 19;
        !          12593:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          12594:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          12595:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12596:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12597:                                {
        !          12598:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          12599:                                        {
        !          12600:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12601:                                                if (psMemRead->memoryCall)
        !          12602:                                                {
        !          12603:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          12604:                                                }
        !          12605:                                                else
        !          12606:                                                {
        !          12607:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          12608:                                                }
        !          12609:                                                psMemRead = NULL;
        !          12610:                                                break;
        !          12611:                                        }
        !          12612:                                        ++psMemRead;
        !          12613:                                }
        !          12614: 
        !          12615:                                if (psMemRead)
        !          12616:                                {
        !          12617:                                        bTemp = cpu.z80Base[dwAddr];
        !          12618:                                }
        !          12619: 
        !          12620:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12621:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12622:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          12623:                                cpu.z80A -= bTemp;
        !          12624:                        break;
        !          12625:                }
        !          12626:                case 0x97:
        !          12627:                {
        !          12628:                                InvalidInstruction(2);
        !          12629:                        break;
        !          12630:                }
        !          12631:                case 0x98:
        !          12632:                {
        !          12633:                                InvalidInstruction(2);
        !          12634:                        break;
        !          12635:                }
        !          12636:                case 0x99:
        !          12637:                {
        !          12638:                                InvalidInstruction(2);
        !          12639:                        break;
        !          12640:                }
        !          12641:                case 0x9a:
        !          12642:                {
        !          12643:                                InvalidInstruction(2);
        !          12644:                        break;
        !          12645:                }
        !          12646:                case 0x9b:
        !          12647:                {
        !          12648:                                InvalidInstruction(2);
        !          12649:                        break;
        !          12650:                }
        !          12651:                case 0x9c:
        !          12652:                {
        !          12653:                        sdwCyclesRemaining -= 9;
        !          12654:                                bTemp2 = cpu.z80A - cpu.z80YH - (cpu.z80F & Z80_FLAG_CARRY);
        !          12655:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12656:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12657:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YH | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          12658:                        break;
        !          12659:                }
        !          12660:                case 0x9d:
        !          12661:                {
        !          12662:                        sdwCyclesRemaining -= 9;
        !          12663:                                bTemp2 = cpu.z80A - cpu.z80YL - (cpu.z80F & Z80_FLAG_CARRY);
        !          12664:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12665:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12666:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80YL | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          12667:                        break;
        !          12668:                }
        !          12669:                case 0x9e:
        !          12670:                {
        !          12671:                        sdwCyclesRemaining -= 19;
        !          12672:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          12673:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          12674:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12675:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12676:                                {
        !          12677:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          12678:                                        {
        !          12679:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12680:                                                if (psMemRead->memoryCall)
        !          12681:                                                {
        !          12682:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          12683:                                                }
        !          12684:                                                else
        !          12685:                                                {
        !          12686:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          12687:                                                }
        !          12688:                                                psMemRead = NULL;
        !          12689:                                                break;
        !          12690:                                        }
        !          12691:                                        ++psMemRead;
        !          12692:                                }
        !          12693: 
        !          12694:                                if (psMemRead)
        !          12695:                                {
        !          12696:                                        bTemp = cpu.z80Base[dwAddr];
        !          12697:                                }
        !          12698: 
        !          12699:                                bTemp2 = cpu.z80A;
        !          12700:                                cpu.z80A = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY);
        !          12701:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          12702:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          12703:                                                                pbSubSbcTable[((UINT32) bTemp2 << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          12704:                        break;
        !          12705:                }
        !          12706:                case 0x9f:
        !          12707:                {
        !          12708:                                InvalidInstruction(2);
        !          12709:                        break;
        !          12710:                }
        !          12711:                case 0xa0:
        !          12712:                {
        !          12713:                                InvalidInstruction(2);
        !          12714:                        break;
        !          12715:                }
        !          12716:                case 0xa1:
        !          12717:                {
        !          12718:                                InvalidInstruction(2);
        !          12719:                        break;
        !          12720:                }
        !          12721:                case 0xa2:
        !          12722:                {
        !          12723:                                InvalidInstruction(2);
        !          12724:                        break;
        !          12725:                }
        !          12726:                case 0xa3:
        !          12727:                {
        !          12728:                                InvalidInstruction(2);
        !          12729:                        break;
        !          12730:                }
        !          12731:                case 0xa4:
        !          12732:                {
        !          12733:                        sdwCyclesRemaining -= 9;
        !          12734:                                cpu.z80A &= cpu.z80YH;
        !          12735:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12736:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          12737: 
        !          12738:                        break;
        !          12739:                }
        !          12740:                case 0xa5:
        !          12741:                {
        !          12742:                        sdwCyclesRemaining -= 9;
        !          12743:                                cpu.z80A &= cpu.z80YL;
        !          12744:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12745:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          12746: 
        !          12747:                        break;
        !          12748:                }
        !          12749:                case 0xa6:
        !          12750:                {
        !          12751:                        sdwCyclesRemaining -= 19;
        !          12752:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          12753:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          12754:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12755:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12756:                                {
        !          12757:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          12758:                                        {
        !          12759:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12760:                                                if (psMemRead->memoryCall)
        !          12761:                                                {
        !          12762:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          12763:                                                }
        !          12764:                                                else
        !          12765:                                                {
        !          12766:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          12767:                                                }
        !          12768:                                                psMemRead = NULL;
        !          12769:                                                break;
        !          12770:                                        }
        !          12771:                                        ++psMemRead;
        !          12772:                                }
        !          12773: 
        !          12774:                                if (psMemRead)
        !          12775:                                {
        !          12776:                                        bTemp = cpu.z80Base[dwAddr];
        !          12777:                                }
        !          12778: 
        !          12779:                                cpu.z80A &= bTemp;
        !          12780:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12781:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          12782: 
        !          12783:                        break;
        !          12784:                }
        !          12785:                case 0xa7:
        !          12786:                {
        !          12787:                                InvalidInstruction(2);
        !          12788:                        break;
        !          12789:                }
        !          12790:                case 0xa8:
        !          12791:                {
        !          12792:                                InvalidInstruction(2);
        !          12793:                        break;
        !          12794:                }
        !          12795:                case 0xa9:
        !          12796:                {
        !          12797:                                InvalidInstruction(2);
        !          12798:                        break;
        !          12799:                }
        !          12800:                case 0xaa:
        !          12801:                {
        !          12802:                                InvalidInstruction(2);
        !          12803:                        break;
        !          12804:                }
        !          12805:                case 0xab:
        !          12806:                {
        !          12807:                                InvalidInstruction(2);
        !          12808:                        break;
        !          12809:                }
        !          12810:                case 0xac:
        !          12811:                {
        !          12812:                        sdwCyclesRemaining -= 9;
        !          12813:                                cpu.z80A ^= cpu.z80YH;
        !          12814:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12815:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          12816: 
        !          12817:                        break;
        !          12818:                }
        !          12819:                case 0xad:
        !          12820:                {
        !          12821:                        sdwCyclesRemaining -= 9;
        !          12822:                                cpu.z80A ^= cpu.z80YL;
        !          12823:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12824:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          12825: 
        !          12826:                        break;
        !          12827:                }
        !          12828:                case 0xae:
        !          12829:                {
        !          12830:                        sdwCyclesRemaining -= 19;
        !          12831:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          12832:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          12833:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12834:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12835:                                {
        !          12836:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          12837:                                        {
        !          12838:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12839:                                                if (psMemRead->memoryCall)
        !          12840:                                                {
        !          12841:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          12842:                                                }
        !          12843:                                                else
        !          12844:                                                {
        !          12845:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          12846:                                                }
        !          12847:                                                psMemRead = NULL;
        !          12848:                                                break;
        !          12849:                                        }
        !          12850:                                        ++psMemRead;
        !          12851:                                }
        !          12852: 
        !          12853:                                if (psMemRead)
        !          12854:                                {
        !          12855:                                        bTemp = cpu.z80Base[dwAddr];
        !          12856:                                }
        !          12857: 
        !          12858:                                cpu.z80A ^= bTemp;
        !          12859:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12860:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          12861: 
        !          12862:                        break;
        !          12863:                }
        !          12864:                case 0xaf:
        !          12865:                {
        !          12866:                                InvalidInstruction(2);
        !          12867:                        break;
        !          12868:                }
        !          12869:                case 0xb0:
        !          12870:                {
        !          12871:                                InvalidInstruction(2);
        !          12872:                        break;
        !          12873:                }
        !          12874:                case 0xb1:
        !          12875:                {
        !          12876:                                InvalidInstruction(2);
        !          12877:                        break;
        !          12878:                }
        !          12879:                case 0xb2:
        !          12880:                {
        !          12881:                                InvalidInstruction(2);
        !          12882:                        break;
        !          12883:                }
        !          12884:                case 0xb3:
        !          12885:                {
        !          12886:                                InvalidInstruction(2);
        !          12887:                        break;
        !          12888:                }
        !          12889:                case 0xb4:
        !          12890:                {
        !          12891:                        sdwCyclesRemaining -= 9;
        !          12892:                                cpu.z80A |= cpu.z80YH;
        !          12893:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12894:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          12895: 
        !          12896:                        break;
        !          12897:                }
        !          12898:                case 0xb5:
        !          12899:                {
        !          12900:                        sdwCyclesRemaining -= 9;
        !          12901:                                cpu.z80A |= cpu.z80YL;
        !          12902:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12903:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          12904: 
        !          12905:                        break;
        !          12906:                }
        !          12907:                case 0xb6:
        !          12908:                {
        !          12909:                        sdwCyclesRemaining -= 19;
        !          12910:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          12911:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          12912:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12913:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12914:                                {
        !          12915:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          12916:                                        {
        !          12917:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12918:                                                if (psMemRead->memoryCall)
        !          12919:                                                {
        !          12920:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          12921:                                                }
        !          12922:                                                else
        !          12923:                                                {
        !          12924:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          12925:                                                }
        !          12926:                                                psMemRead = NULL;
        !          12927:                                                break;
        !          12928:                                        }
        !          12929:                                        ++psMemRead;
        !          12930:                                }
        !          12931: 
        !          12932:                                if (psMemRead)
        !          12933:                                {
        !          12934:                                        bTemp = cpu.z80Base[dwAddr];
        !          12935:                                }
        !          12936: 
        !          12937:                                cpu.z80A |= bTemp;
        !          12938:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12939:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          12940: 
        !          12941:                        break;
        !          12942:                }
        !          12943:                case 0xb7:
        !          12944:                {
        !          12945:                                InvalidInstruction(2);
        !          12946:                        break;
        !          12947:                }
        !          12948:                case 0xb8:
        !          12949:                {
        !          12950:                                InvalidInstruction(2);
        !          12951:                        break;
        !          12952:                }
        !          12953:                case 0xb9:
        !          12954:                {
        !          12955:                                InvalidInstruction(2);
        !          12956:                        break;
        !          12957:                }
        !          12958:                case 0xba:
        !          12959:                {
        !          12960:                                InvalidInstruction(2);
        !          12961:                        break;
        !          12962:                }
        !          12963:                case 0xbb:
        !          12964:                {
        !          12965:                                InvalidInstruction(2);
        !          12966:                        break;
        !          12967:                }
        !          12968:                case 0xbc:
        !          12969:                {
        !          12970:                        sdwCyclesRemaining -= 9;
        !          12971:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12972:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          12973: 
        !          12974:                        break;
        !          12975:                }
        !          12976:                case 0xbd:
        !          12977:                {
        !          12978:                        sdwCyclesRemaining -= 9;
        !          12979:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          12980:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          12981: 
        !          12982:                        break;
        !          12983:                }
        !          12984:                case 0xbe:
        !          12985:                {
        !          12986:                        sdwCyclesRemaining -= 19;
        !          12987:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          12988:                                dwAddr = (sdwAddr + (INT32) cpu.z80IY) & 0xffff;
        !          12989:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          12990:                                while (psMemRead->lowAddr != 0xffffffff)
        !          12991:                                {
        !          12992:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          12993:                                        {
        !          12994:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          12995:                                                if (psMemRead->memoryCall)
        !          12996:                                                {
        !          12997:                                                        bTemp = psMemRead->memoryCall(dwAddr, psMemRead);
        !          12998:                                                }
        !          12999:                                                else
        !          13000:                                                {
        !          13001:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          13002:                                                }
        !          13003:                                                psMemRead = NULL;
        !          13004:                                                break;
        !          13005:                                        }
        !          13006:                                        ++psMemRead;
        !          13007:                                }
        !          13008: 
        !          13009:                                if (psMemRead)
        !          13010:                                {
        !          13011:                                        bTemp = cpu.z80Base[dwAddr];
        !          13012:                                }
        !          13013: 
        !          13014:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          13015:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          13016:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          13017:                        break;
        !          13018:                }
        !          13019:                case 0xbf:
        !          13020:                {
        !          13021:                                InvalidInstruction(2);
        !          13022:                        break;
        !          13023:                }
        !          13024:                case 0xc0:
        !          13025:                {
        !          13026:                                InvalidInstruction(2);
        !          13027:                        break;
        !          13028:                }
        !          13029:                case 0xc1:
        !          13030:                {
        !          13031:                                InvalidInstruction(2);
        !          13032:                        break;
        !          13033:                }
        !          13034:                case 0xc2:
        !          13035:                {
        !          13036:                                InvalidInstruction(2);
        !          13037:                        break;
        !          13038:                }
        !          13039:                case 0xc3:
        !          13040:                {
        !          13041:                                InvalidInstruction(2);
        !          13042:                        break;
        !          13043:                }
        !          13044:                case 0xc4:
        !          13045:                {
        !          13046:                                InvalidInstruction(2);
        !          13047:                        break;
        !          13048:                }
        !          13049:                case 0xc5:
        !          13050:                {
        !          13051:                                InvalidInstruction(2);
        !          13052:                        break;
        !          13053:                }
        !          13054:                case 0xc6:
        !          13055:                {
        !          13056:                                InvalidInstruction(2);
        !          13057:                        break;
        !          13058:                }
        !          13059:                case 0xc7:
        !          13060:                {
        !          13061:                                InvalidInstruction(2);
        !          13062:                        break;
        !          13063:                }
        !          13064:                case 0xc8:
        !          13065:                {
        !          13066:                                InvalidInstruction(2);
        !          13067:                        break;
        !          13068:                }
        !          13069:                case 0xc9:
        !          13070:                {
        !          13071:                                InvalidInstruction(2);
        !          13072:                        break;
        !          13073:                }
        !          13074:                case 0xca:
        !          13075:                {
        !          13076:                                InvalidInstruction(2);
        !          13077:                        break;
        !          13078:                }
        !          13079:                case 0xcb:
        !          13080:                {
        !          13081:                                DDFDCBHandler(1);
        !          13082:                        break;
        !          13083:                }
        !          13084:                case 0xcc:
        !          13085:                {
        !          13086:                                InvalidInstruction(2);
        !          13087:                        break;
        !          13088:                }
        !          13089:                case 0xcd:
        !          13090:                {
        !          13091:                                InvalidInstruction(2);
        !          13092:                        break;
        !          13093:                }
        !          13094:                case 0xce:
        !          13095:                {
        !          13096:                                InvalidInstruction(2);
        !          13097:                        break;
        !          13098:                }
        !          13099:                case 0xcf:
        !          13100:                {
        !          13101:                                InvalidInstruction(2);
        !          13102:                        break;
        !          13103:                }
        !          13104:                case 0xd0:
        !          13105:                {
        !          13106:                                InvalidInstruction(2);
        !          13107:                        break;
        !          13108:                }
        !          13109:                case 0xd1:
        !          13110:                {
        !          13111:                                InvalidInstruction(2);
        !          13112:                        break;
        !          13113:                }
        !          13114:                case 0xd2:
        !          13115:                {
        !          13116:                                InvalidInstruction(2);
        !          13117:                        break;
        !          13118:                }
        !          13119:                case 0xd3:
        !          13120:                {
        !          13121:                                InvalidInstruction(2);
        !          13122:                        break;
        !          13123:                }
        !          13124:                case 0xd4:
        !          13125:                {
        !          13126:                                InvalidInstruction(2);
        !          13127:                        break;
        !          13128:                }
        !          13129:                case 0xd5:
        !          13130:                {
        !          13131:                                InvalidInstruction(2);
        !          13132:                        break;
        !          13133:                }
        !          13134:                case 0xd6:
        !          13135:                {
        !          13136:                                InvalidInstruction(2);
        !          13137:                        break;
        !          13138:                }
        !          13139:                case 0xd7:
        !          13140:                {
        !          13141:                                InvalidInstruction(2);
        !          13142:                        break;
        !          13143:                }
        !          13144:                case 0xd8:
        !          13145:                {
        !          13146:                                InvalidInstruction(2);
        !          13147:                        break;
        !          13148:                }
        !          13149:                case 0xd9:
        !          13150:                {
        !          13151:                                InvalidInstruction(2);
        !          13152:                        break;
        !          13153:                }
        !          13154:                case 0xda:
        !          13155:                {
        !          13156:                                InvalidInstruction(2);
        !          13157:                        break;
        !          13158:                }
        !          13159:                case 0xdb:
        !          13160:                {
        !          13161:                                InvalidInstruction(2);
        !          13162:                        break;
        !          13163:                }
        !          13164:                case 0xdc:
        !          13165:                {
        !          13166:                                InvalidInstruction(2);
        !          13167:                        break;
        !          13168:                }
        !          13169:                case 0xdd:
        !          13170:                {
        !          13171:                                InvalidInstruction(2);
        !          13172:                        break;
        !          13173:                }
        !          13174:                case 0xde:
        !          13175:                {
        !          13176:                                InvalidInstruction(2);
        !          13177:                        break;
        !          13178:                }
        !          13179:                case 0xdf:
        !          13180:                {
        !          13181:                                InvalidInstruction(2);
        !          13182:                        break;
        !          13183:                }
        !          13184:                case 0xe0:
        !          13185:                {
        !          13186:                                InvalidInstruction(2);
        !          13187:                        break;
        !          13188:                }
        !          13189:                case 0xe1:
        !          13190:                {
        !          13191:                        sdwCyclesRemaining -= 14;
        !          13192:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          13193:                                while (psMemRead->lowAddr != 0xffffffff)
        !          13194:                                {
        !          13195:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          13196:                                        {
        !          13197:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13198:                                                if (psMemRead->memoryCall)
        !          13199:                                                {
        !          13200:                                                        cpu.z80IY = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          13201:                                                        cpu.z80IY |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          13202:                                                }
        !          13203:                                                else
        !          13204:                                                {
        !          13205:                                                        cpu.z80IY = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          13206:                                                        cpu.z80IY |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          13207:                                                }
        !          13208:                                                psMemRead = NULL;
        !          13209:                                                break;
        !          13210:                                        }
        !          13211:                                        ++psMemRead;
        !          13212:                                }
        !          13213: 
        !          13214:                                if (psMemRead)
        !          13215:                                {
        !          13216:                                        cpu.z80IY = cpu.z80Base[cpu.z80sp];
        !          13217:                                        cpu.z80IY |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          13218:                                }
        !          13219: 
        !          13220:                                        cpu.z80sp += 2;
        !          13221:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          13222:                        break;
        !          13223:                }
        !          13224:                case 0xe2:
        !          13225:                {
        !          13226:                                InvalidInstruction(2);
        !          13227:                        break;
        !          13228:                }
        !          13229:                case 0xe3:
        !          13230:                {
        !          13231:                        sdwCyclesRemaining -= 23;
        !          13232:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          13233:                                while (psMemRead->lowAddr != 0xffffffff)
        !          13234:                                {
        !          13235:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          13236:                                        {
        !          13237:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13238:                                                if (psMemRead->memoryCall)
        !          13239:                                                {
        !          13240:                                                        dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          13241:                                                        dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          13242:                                                }
        !          13243:                                                else
        !          13244:                                                {
        !          13245:                                                        dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          13246:                                                        dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          13247:                                                }
        !          13248:                                                psMemRead = NULL;
        !          13249:                                                break;
        !          13250:                                        }
        !          13251:                                        ++psMemRead;
        !          13252:                                }
        !          13253: 
        !          13254:                                if (psMemRead)
        !          13255:                                {
        !          13256:                                        dwAddr = cpu.z80Base[cpu.z80sp];
        !          13257:                                        dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          13258:                                }
        !          13259: 
        !          13260:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          13261:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          13262:                                {
        !          13263:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          13264:                                        {
        !          13265:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13266:                                                if (psMemWrite->memoryCall)
        !          13267:                                                {
        !          13268:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IY & 0xff), psMemWrite);
        !          13269:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IY >> 8), psMemWrite);
        !          13270:                                                }
        !          13271:                                                else
        !          13272:                                                {
        !          13273:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IY;
        !          13274:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8;
        !          13275:                                                }
        !          13276:                                                psMemWrite = NULL;
        !          13277:                                                break;
        !          13278:                                        }
        !          13279:                                        ++psMemWrite;
        !          13280:                                }
        !          13281: 
        !          13282:                                if (psMemWrite)
        !          13283:                                {
        !          13284:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IY;
        !          13285:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8);
        !          13286:                                }
        !          13287: 
        !          13288:                                cpu.z80IY = dwAddr;
        !          13289:                        break;
        !          13290:                }
        !          13291:                case 0xe4:
        !          13292:                {
        !          13293:                                InvalidInstruction(2);
        !          13294:                        break;
        !          13295:                }
        !          13296:                case 0xe5:
        !          13297:                {
        !          13298:                        sdwCyclesRemaining -= 15;
        !          13299:                                        cpu.z80sp -= 2;
        !          13300:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          13301:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          13302:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          13303:                                {
        !          13304:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          13305:                                        {
        !          13306:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13307:                                                if (psMemWrite->memoryCall)
        !          13308:                                                {
        !          13309:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80IY & 0xff), psMemWrite);
        !          13310:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80IY >> 8), psMemWrite);
        !          13311:                                                }
        !          13312:                                                else
        !          13313:                                                {
        !          13314:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80IY;
        !          13315:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80IY >> 8;
        !          13316:                                                }
        !          13317:                                                psMemWrite = NULL;
        !          13318:                                                break;
        !          13319:                                        }
        !          13320:                                        ++psMemWrite;
        !          13321:                                }
        !          13322: 
        !          13323:                                if (psMemWrite)
        !          13324:                                {
        !          13325:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80IY;
        !          13326:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80IY >> 8);
        !          13327:                                }
        !          13328: 
        !          13329:                        break;
        !          13330:                }
        !          13331:                case 0xe6:
        !          13332:                {
        !          13333:                                InvalidInstruction(2);
        !          13334:                        break;
        !          13335:                }
        !          13336:                case 0xe7:
        !          13337:                {
        !          13338:                                InvalidInstruction(2);
        !          13339:                        break;
        !          13340:                }
        !          13341:                case 0xe8:
        !          13342:                {
        !          13343:                                InvalidInstruction(2);
        !          13344:                        break;
        !          13345:                }
        !          13346:                case 0xe9:
        !          13347:                {
        !          13348:                        sdwCyclesRemaining -= 8;
        !          13349:                                pbPC = cpu.z80Base + cpu.z80IY;
        !          13350:                        break;
        !          13351:                }
        !          13352:                case 0xea:
        !          13353:                {
        !          13354:                                InvalidInstruction(2);
        !          13355:                        break;
        !          13356:                }
        !          13357:                case 0xeb:
        !          13358:                {
        !          13359:                                InvalidInstruction(2);
        !          13360:                        break;
        !          13361:                }
        !          13362:                case 0xec:
        !          13363:                {
        !          13364:                                InvalidInstruction(2);
        !          13365:                        break;
        !          13366:                }
        !          13367:                case 0xed:
        !          13368:                {
        !          13369:                                InvalidInstruction(2);
        !          13370:                        break;
        !          13371:                }
        !          13372:                case 0xee:
        !          13373:                {
        !          13374:                                InvalidInstruction(2);
        !          13375:                        break;
        !          13376:                }
        !          13377:                case 0xef:
        !          13378:                {
        !          13379:                                InvalidInstruction(2);
        !          13380:                        break;
        !          13381:                }
        !          13382:                case 0xf0:
        !          13383:                {
        !          13384:                                InvalidInstruction(2);
        !          13385:                        break;
        !          13386:                }
        !          13387:                case 0xf1:
        !          13388:                {
        !          13389:                                InvalidInstruction(2);
        !          13390:                        break;
        !          13391:                }
        !          13392:                case 0xf2:
        !          13393:                {
        !          13394:                                InvalidInstruction(2);
        !          13395:                        break;
        !          13396:                }
        !          13397:                case 0xf3:
        !          13398:                {
        !          13399:                                InvalidInstruction(2);
        !          13400:                        break;
        !          13401:                }
        !          13402:                case 0xf4:
        !          13403:                {
        !          13404:                                InvalidInstruction(2);
        !          13405:                        break;
        !          13406:                }
        !          13407:                case 0xf5:
        !          13408:                {
        !          13409:                                InvalidInstruction(2);
        !          13410:                        break;
        !          13411:                }
        !          13412:                case 0xf6:
        !          13413:                {
        !          13414:                                InvalidInstruction(2);
        !          13415:                        break;
        !          13416:                }
        !          13417:                case 0xf7:
        !          13418:                {
        !          13419:                                InvalidInstruction(2);
        !          13420:                        break;
        !          13421:                }
        !          13422:                case 0xf8:
        !          13423:                {
        !          13424:                                InvalidInstruction(2);
        !          13425:                        break;
        !          13426:                }
        !          13427:                case 0xf9:
        !          13428:                {
        !          13429:                        sdwCyclesRemaining -= 10;
        !          13430:                                cpu.z80sp = cpu.z80IY;
        !          13431:                        break;
        !          13432:                }
        !          13433:                case 0xfa:
        !          13434:                {
        !          13435:                                InvalidInstruction(2);
        !          13436:                        break;
        !          13437:                }
        !          13438:                case 0xfb:
        !          13439:                {
        !          13440:                                InvalidInstruction(2);
        !          13441:                        break;
        !          13442:                }
        !          13443:                case 0xfc:
        !          13444:                {
        !          13445:                                InvalidInstruction(2);
        !          13446:                        break;
        !          13447:                }
        !          13448:                case 0xfd:
        !          13449:                {
        !          13450:                                InvalidInstruction(2);
        !          13451:                        break;
        !          13452:                }
        !          13453:                case 0xfe:
        !          13454:                {
        !          13455:                                InvalidInstruction(2);
        !          13456:                        break;
        !          13457:                }
        !          13458:                case 0xff:
        !          13459:                {
        !          13460:                                InvalidInstruction(2);
        !          13461:                        break;
        !          13462:                }
        !          13463:        }
        !          13464: }
        !          13465: /* Main execution entry point */
        !          13466: 
        !          13467: UINT32 mz80exec(UINT32 dwCycles)
        !          13468: {
        !          13469:        UINT8 bOpcode;
        !          13470: 
        !          13471:        dwReturnCode = 0x80000000; /* Assume it'll work */
        !          13472:        sdwCyclesRemaining = dwCycles;
        !          13473:        dwOriginalCycles = dwCycles;
        !          13474:                if (cpu.z80halted)
        !          13475:                {
        !          13476:                dwElapsedTicks += dwCycles;
        !          13477:                return(0x80000000);
        !          13478:                }
        !          13479: 
        !          13480:        pbPC = cpu.z80Base + cpu.z80pc;
        !          13481: 
        !          13482:        while (sdwCyclesRemaining > 0)
        !          13483:        {
        !          13484:                bOpcode = *pbPC++;
        !          13485:                switch (bOpcode)
        !          13486:                {
        !          13487:                        case 0x00:
        !          13488:                        {
        !          13489:                                sdwCyclesRemaining -= 4;
        !          13490:                                /* Intentionally not doing anything - NOP! */
        !          13491:                                break;
        !          13492:                        }
        !          13493:                        case 0x01:
        !          13494:                        {
        !          13495:                                sdwCyclesRemaining -= 10;
        !          13496:                                cpu.z80BC = *pbPC++;    /* LSB First */
        !          13497:                                cpu.z80BC |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */
        !          13498:                                break;
        !          13499:                        }
        !          13500:                        case 0x02:
        !          13501:                        {
        !          13502:                                sdwCyclesRemaining -= 7;
        !          13503:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          13504:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          13505:                                {
        !          13506:                                        if ((cpu.z80BC >= psMemWrite->lowAddr) && (cpu.z80BC <= psMemWrite->highAddr))
        !          13507:                                        {
        !          13508:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13509:                                                if (psMemWrite->memoryCall)
        !          13510:                                                {
        !          13511:                                                        psMemWrite->memoryCall(cpu.z80BC, cpu.z80A, psMemWrite);
        !          13512:                                                }
        !          13513:                                                else
        !          13514:                                                {
        !          13515:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80BC - psMemWrite->lowAddr)) = cpu.z80A;
        !          13516:                                                }
        !          13517:                                                psMemWrite = NULL;
        !          13518:                                                break;
        !          13519:                                        }
        !          13520:                                        ++psMemWrite;
        !          13521:                                }
        !          13522: 
        !          13523:                                if (psMemWrite)
        !          13524:                                {
        !          13525:                                        cpu.z80Base[cpu.z80BC] = (UINT8) cpu.z80A;
        !          13526:                                }
        !          13527: 
        !          13528:                                break;
        !          13529:                        }
        !          13530:                        case 0x03:
        !          13531:                        {
        !          13532:                                sdwCyclesRemaining -= 6;
        !          13533:                                cpu.z80BC++;
        !          13534:                                cpu.z80BC &= 0xffff;
        !          13535:                                break;
        !          13536:                        }
        !          13537:                        case 0x04:
        !          13538:                        {
        !          13539:                                sdwCyclesRemaining -= 4;
        !          13540:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          13541:                                cpu.z80F |= bPostIncFlags[cpu.z80B++];
        !          13542:                                break;
        !          13543:                        }
        !          13544:                        case 0x05:
        !          13545:                        {
        !          13546:                                sdwCyclesRemaining -= 4;
        !          13547:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
        !          13548:                                cpu.z80F |= bPostDecFlags[cpu.z80B--];
        !          13549:                                break;
        !          13550:                        }
        !          13551:                        case 0x06:
        !          13552:                        {
        !          13553:                                sdwCyclesRemaining -= 7;
        !          13554:                                cpu.z80B = *pbPC++;     /* Get immediate byte into register */
        !          13555:                                break;
        !          13556:                        }
        !          13557:                        case 0x07:
        !          13558:                        {
        !          13559:                                sdwCyclesRemaining -= 4;
        !          13560:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          13561:                                cpu.z80F |= (cpu.z80A >> 7);
        !          13562:                                cpu.z80A = (cpu.z80A << 1) | (cpu.z80A >> 7);
        !          13563:                                break;
        !          13564:                        }
        !          13565:                        case 0x08:
        !          13566:                        {
        !          13567:                                sdwCyclesRemaining -= 4;
        !          13568:                                dwAddr = (UINT32) cpu.z80AF;
        !          13569:                                cpu.z80AF = cpu.z80afprime;
        !          13570:                                cpu.z80afprime = dwAddr;
        !          13571:                                break;
        !          13572:                        }
        !          13573:                        case 0x09:
        !          13574:                        {
        !          13575:                                sdwCyclesRemaining -= 11;
        !          13576:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          13577:                        dwTemp = cpu.z80HL + cpu.z80BC;
        !          13578:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80BC) >> 8) & Z80_FLAG_HALF_CARRY);
        !          13579:                        cpu.z80HL = dwTemp & 0xffff;
        !          13580:                                break;
        !          13581:                        }
        !          13582:                        case 0x0a:
        !          13583:                        {
        !          13584:                                sdwCyclesRemaining -= 7;
        !          13585:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          13586:                                while (psMemRead->lowAddr != 0xffffffff)
        !          13587:                                {
        !          13588:                                        if ((cpu.z80BC >= psMemRead->lowAddr) && (cpu.z80BC <= psMemRead->highAddr))
        !          13589:                                        {
        !          13590:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13591:                                                if (psMemRead->memoryCall)
        !          13592:                                                {
        !          13593:                                                        cpu.z80A = psMemRead->memoryCall(cpu.z80BC, psMemRead);
        !          13594:                                                }
        !          13595:                                                else
        !          13596:                                                {
        !          13597:                                                        cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80BC - psMemRead->lowAddr));
        !          13598:                                                }
        !          13599:                                                psMemRead = NULL;
        !          13600:                                                break;
        !          13601:                                        }
        !          13602:                                        ++psMemRead;
        !          13603:                                }
        !          13604: 
        !          13605:                                if (psMemRead)
        !          13606:                                {
        !          13607:                                        cpu.z80A = cpu.z80Base[cpu.z80BC];
        !          13608:                                }
        !          13609: 
        !          13610:                                break;
        !          13611:                        }
        !          13612:                        case 0x0b:
        !          13613:                        {
        !          13614:                                sdwCyclesRemaining -= 6;
        !          13615:                                cpu.z80BC--;
        !          13616:                                cpu.z80BC &= 0xffff;
        !          13617:                                break;
        !          13618:                        }
        !          13619:                        case 0x0c:
        !          13620:                        {
        !          13621:                                sdwCyclesRemaining -= 4;
        !          13622:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          13623:                                cpu.z80F |= bPostIncFlags[cpu.z80C++];
        !          13624:                                break;
        !          13625:                        }
        !          13626:                        case 0x0d:
        !          13627:                        {
        !          13628:                                sdwCyclesRemaining -= 4;
        !          13629:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
        !          13630:                                cpu.z80F |= bPostDecFlags[cpu.z80C--];
        !          13631:                                break;
        !          13632:                        }
        !          13633:                        case 0x0e:
        !          13634:                        {
        !          13635:                                sdwCyclesRemaining -= 7;
        !          13636:                                cpu.z80C = *pbPC++;     /* Get immediate byte into register */
        !          13637:                                break;
        !          13638:                        }
        !          13639:                        case 0x0f:
        !          13640:                        {
        !          13641:                                sdwCyclesRemaining -= 4;
        !          13642:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          13643:                                cpu.z80F |= (cpu.z80A & Z80_FLAG_CARRY);
        !          13644:                                cpu.z80A = (cpu.z80A >> 1) | (cpu.z80A << 7);
        !          13645:                                break;
        !          13646:                        }
        !          13647:                        case 0x10:
        !          13648:                        {
        !          13649:                                sdwCyclesRemaining -= 8;
        !          13650:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          13651:                                if (--cpu.z80B)
        !          13652:                                {
        !          13653:                                        dwElapsedTicks += 5;    /* 5 More for jump taken */
        !          13654:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13655:                                        sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
        !          13656:                                        pbPC = cpu.z80Base + sdwAddr;   /* Normalize the address */
        !          13657:                                }
        !          13658:                                break;
        !          13659:                        }
        !          13660:                        case 0x11:
        !          13661:                        {
        !          13662:                                sdwCyclesRemaining -= 10;
        !          13663:                                cpu.z80DE = *pbPC++;    /* LSB First */
        !          13664:                                cpu.z80DE |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */
        !          13665:                                break;
        !          13666:                        }
        !          13667:                        case 0x12:
        !          13668:                        {
        !          13669:                                sdwCyclesRemaining -= 7;
        !          13670:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          13671:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          13672:                                {
        !          13673:                                        if ((cpu.z80DE >= psMemWrite->lowAddr) && (cpu.z80DE <= psMemWrite->highAddr))
        !          13674:                                        {
        !          13675:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13676:                                                if (psMemWrite->memoryCall)
        !          13677:                                                {
        !          13678:                                                        psMemWrite->memoryCall(cpu.z80DE, cpu.z80A, psMemWrite);
        !          13679:                                                }
        !          13680:                                                else
        !          13681:                                                {
        !          13682:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80DE - psMemWrite->lowAddr)) = cpu.z80A;
        !          13683:                                                }
        !          13684:                                                psMemWrite = NULL;
        !          13685:                                                break;
        !          13686:                                        }
        !          13687:                                        ++psMemWrite;
        !          13688:                                }
        !          13689: 
        !          13690:                                if (psMemWrite)
        !          13691:                                {
        !          13692:                                        cpu.z80Base[cpu.z80DE] = (UINT8) cpu.z80A;
        !          13693:                                }
        !          13694: 
        !          13695:                                break;
        !          13696:                        }
        !          13697:                        case 0x13:
        !          13698:                        {
        !          13699:                                sdwCyclesRemaining -= 6;
        !          13700:                                cpu.z80DE++;
        !          13701:                                cpu.z80DE &= 0xffff;
        !          13702:                                break;
        !          13703:                        }
        !          13704:                        case 0x14:
        !          13705:                        {
        !          13706:                                sdwCyclesRemaining -= 4;
        !          13707:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          13708:                                cpu.z80F |= bPostIncFlags[cpu.z80D++];
        !          13709:                                break;
        !          13710:                        }
        !          13711:                        case 0x15:
        !          13712:                        {
        !          13713:                                sdwCyclesRemaining -= 4;
        !          13714:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
        !          13715:                                cpu.z80F |= bPostDecFlags[cpu.z80D--];
        !          13716:                                break;
        !          13717:                        }
        !          13718:                        case 0x16:
        !          13719:                        {
        !          13720:                                sdwCyclesRemaining -= 7;
        !          13721:                                cpu.z80D = *pbPC++;     /* Get immediate byte into register */
        !          13722:                                break;
        !          13723:                        }
        !          13724:                        case 0x17:
        !          13725:                        {
        !          13726:                                sdwCyclesRemaining -= 4;
        !          13727:                                bTemp = cpu.z80A >> 7;
        !          13728:                                cpu.z80A = (cpu.z80A << 1) | (cpu.z80F & Z80_FLAG_CARRY);
        !          13729:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY)) | bTemp;
        !          13730:                                break;
        !          13731:                        }
        !          13732:                        case 0x18:
        !          13733:                        {
        !          13734:                                sdwCyclesRemaining -= 12;
        !          13735:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          13736:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13737:                                sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
        !          13738:                                {
        !          13739:                                sdwCyclesRemaining -= 5;
        !          13740:                                        pbPC = cpu.z80Base + sdwAddr;   /* Normalize the address */
        !          13741:                                }
        !          13742:                                break;
        !          13743:                        }
        !          13744:                        case 0x19:
        !          13745:                        {
        !          13746:                                sdwCyclesRemaining -= 11;
        !          13747:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          13748:                        dwTemp = cpu.z80HL + cpu.z80DE;
        !          13749:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80DE) >> 8) & Z80_FLAG_HALF_CARRY);
        !          13750:                        cpu.z80HL = dwTemp & 0xffff;
        !          13751:                                break;
        !          13752:                        }
        !          13753:                        case 0x1a:
        !          13754:                        {
        !          13755:                                sdwCyclesRemaining -= 7;
        !          13756:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          13757:                                while (psMemRead->lowAddr != 0xffffffff)
        !          13758:                                {
        !          13759:                                        if ((cpu.z80DE >= psMemRead->lowAddr) && (cpu.z80DE <= psMemRead->highAddr))
        !          13760:                                        {
        !          13761:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13762:                                                if (psMemRead->memoryCall)
        !          13763:                                                {
        !          13764:                                                        cpu.z80A = psMemRead->memoryCall(cpu.z80DE, psMemRead);
        !          13765:                                                }
        !          13766:                                                else
        !          13767:                                                {
        !          13768:                                                        cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80DE - psMemRead->lowAddr));
        !          13769:                                                }
        !          13770:                                                psMemRead = NULL;
        !          13771:                                                break;
        !          13772:                                        }
        !          13773:                                        ++psMemRead;
        !          13774:                                }
        !          13775: 
        !          13776:                                if (psMemRead)
        !          13777:                                {
        !          13778:                                        cpu.z80A = cpu.z80Base[cpu.z80DE];
        !          13779:                                }
        !          13780: 
        !          13781:                                break;
        !          13782:                        }
        !          13783:                        case 0x1b:
        !          13784:                        {
        !          13785:                                sdwCyclesRemaining -= 6;
        !          13786:                                cpu.z80DE--;
        !          13787:                                cpu.z80DE &= 0xffff;
        !          13788:                                break;
        !          13789:                        }
        !          13790:                        case 0x1c:
        !          13791:                        {
        !          13792:                                sdwCyclesRemaining -= 4;
        !          13793:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          13794:                                cpu.z80F |= bPostIncFlags[cpu.z80E++];
        !          13795:                                break;
        !          13796:                        }
        !          13797:                        case 0x1d:
        !          13798:                        {
        !          13799:                                sdwCyclesRemaining -= 4;
        !          13800:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
        !          13801:                                cpu.z80F |= bPostDecFlags[cpu.z80E--];
        !          13802:                                break;
        !          13803:                        }
        !          13804:                        case 0x1e:
        !          13805:                        {
        !          13806:                                sdwCyclesRemaining -= 7;
        !          13807:                                cpu.z80E = *pbPC++;     /* Get immediate byte into register */
        !          13808:                                break;
        !          13809:                        }
        !          13810:                        case 0x1f:
        !          13811:                        {
        !          13812:                                sdwCyclesRemaining -= 4;
        !          13813:                                bTemp = (cpu.z80F & Z80_FLAG_CARRY) << 7;
        !          13814:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY)) | (cpu.z80A & Z80_FLAG_CARRY);
        !          13815:                                cpu.z80A = ((cpu.z80A >> 1) | bTemp);
        !          13816:                                break;
        !          13817:                        }
        !          13818:                        case 0x20:
        !          13819:                        {
        !          13820:                                sdwCyclesRemaining -= 7;
        !          13821:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          13822:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13823:                                sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
        !          13824:                                if (!(cpu.z80F & Z80_FLAG_ZERO))
        !          13825:                                {
        !          13826:                                sdwCyclesRemaining -= 5;
        !          13827:                                        pbPC = cpu.z80Base + sdwAddr;   /* Normalize the address */
        !          13828:                                }
        !          13829:                                break;
        !          13830:                        }
        !          13831:                        case 0x21:
        !          13832:                        {
        !          13833:                                sdwCyclesRemaining -= 10;
        !          13834:                                cpu.z80HL = *pbPC++;    /* LSB First */
        !          13835:                                cpu.z80HL |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */
        !          13836:                                break;
        !          13837:                        }
        !          13838:                        case 0x22:
        !          13839:                        {
        !          13840:                                sdwCyclesRemaining -= 16;
        !          13841:                                dwTemp = *pbPC++;
        !          13842:                                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          13843:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          13844:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          13845:                                {
        !          13846:                                        if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
        !          13847:                                        {
        !          13848:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13849:                                                if (psMemWrite->memoryCall)
        !          13850:                                                {
        !          13851:                                                        psMemWrite->memoryCall(dwTemp, (cpu.z80HL & 0xff), psMemWrite);
        !          13852:                                                        psMemWrite->memoryCall(dwTemp + 1, (cpu.z80HL >> 8), psMemWrite);
        !          13853:                                                }
        !          13854:                                                else
        !          13855:                                                {
        !          13856:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80HL;
        !          13857:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8;
        !          13858:                                                }
        !          13859:                                                psMemWrite = NULL;
        !          13860:                                                break;
        !          13861:                                        }
        !          13862:                                        ++psMemWrite;
        !          13863:                                }
        !          13864: 
        !          13865:                                if (psMemWrite)
        !          13866:                                {
        !          13867:                                        cpu.z80Base[dwTemp] = (UINT8) cpu.z80HL;
        !          13868:                                        cpu.z80Base[dwTemp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8);
        !          13869:                                }
        !          13870: 
        !          13871:                                break;
        !          13872:                        }
        !          13873:                        case 0x23:
        !          13874:                        {
        !          13875:                                sdwCyclesRemaining -= 6;
        !          13876:                                cpu.z80HL++;
        !          13877:                                cpu.z80HL &= 0xffff;
        !          13878:                                break;
        !          13879:                        }
        !          13880:                        case 0x24:
        !          13881:                        {
        !          13882:                                sdwCyclesRemaining -= 4;
        !          13883:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          13884:                                cpu.z80F |= bPostIncFlags[cpu.z80H++];
        !          13885:                                break;
        !          13886:                        }
        !          13887:                        case 0x25:
        !          13888:                        {
        !          13889:                                sdwCyclesRemaining -= 4;
        !          13890:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
        !          13891:                                cpu.z80F |= bPostDecFlags[cpu.z80H--];
        !          13892:                                break;
        !          13893:                        }
        !          13894:                        case 0x26:
        !          13895:                        {
        !          13896:                                sdwCyclesRemaining -= 7;
        !          13897:                                cpu.z80H = *pbPC++;     /* Get immediate byte into register */
        !          13898:                                break;
        !          13899:                        }
        !          13900:                        case 0x27:
        !          13901:                        {
        !          13902:                                sdwCyclesRemaining -= 4;
        !          13903:                                dwAddr = (((cpu.z80F & Z80_FLAG_CARRY) | 
        !          13904:                                                ((cpu.z80F & Z80_FLAG_HALF_CARRY) >> 3) | 
        !          13905:                                                ((cpu.z80F & Z80_FLAG_NEGATIVE) << 1)) << 8) | cpu.z80A;
        !          13906:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          13907:                                cpu.z80F |= (wDAATable[dwAddr] >> 8);
        !          13908:                                cpu.z80A = wDAATable[dwAddr] & 0xff;
        !          13909:                                break;
        !          13910:                        }
        !          13911:                        case 0x28:
        !          13912:                        {
        !          13913:                                sdwCyclesRemaining -= 7;
        !          13914:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          13915:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13916:                                sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
        !          13917:                                if (cpu.z80F & Z80_FLAG_ZERO)
        !          13918:                                {
        !          13919:                                sdwCyclesRemaining -= 5;
        !          13920:                                        pbPC = cpu.z80Base + sdwAddr;   /* Normalize the address */
        !          13921:                                }
        !          13922:                                break;
        !          13923:                        }
        !          13924:                        case 0x29:
        !          13925:                        {
        !          13926:                                sdwCyclesRemaining -= 11;
        !          13927:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          13928:                        dwTemp = cpu.z80HL + cpu.z80HL;
        !          13929:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80HL) >> 8) & Z80_FLAG_HALF_CARRY);
        !          13930:                        cpu.z80HL = dwTemp & 0xffff;
        !          13931:                                break;
        !          13932:                        }
        !          13933:                        case 0x2a:
        !          13934:                        {
        !          13935:                                sdwCyclesRemaining -= 16;
        !          13936:                                dwAddr = *pbPC++;
        !          13937:                                dwAddr |= ((UINT32) *pbPC++ << 8);
        !          13938:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          13939:                                while (psMemRead->lowAddr != 0xffffffff)
        !          13940:                                {
        !          13941:                                        if ((dwAddr >= psMemRead->lowAddr) && (dwAddr <= psMemRead->highAddr))
        !          13942:                                        {
        !          13943:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          13944:                                                if (psMemRead->memoryCall)
        !          13945:                                                {
        !          13946:                                                        cpu.z80HL = psMemRead->memoryCall(dwAddr, psMemRead);
        !          13947:                                                        cpu.z80HL |= (UINT32) ((UINT32) psMemRead->memoryCall(dwAddr + 1, psMemRead) << 8);
        !          13948:                                                }
        !          13949:                                                else
        !          13950:                                                {
        !          13951:                                                        cpu.z80HL = *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr));
        !          13952:                                                        cpu.z80HL |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (dwAddr - psMemRead->lowAddr + 1)) << 8);
        !          13953:                                                }
        !          13954:                                                psMemRead = NULL;
        !          13955:                                                break;
        !          13956:                                        }
        !          13957:                                        ++psMemRead;
        !          13958:                                }
        !          13959: 
        !          13960:                                if (psMemRead)
        !          13961:                                {
        !          13962:                                        cpu.z80HL = cpu.z80Base[dwAddr];
        !          13963:                                        cpu.z80HL |= (UINT32) ((UINT32) cpu.z80Base[dwAddr + 1] << 8);
        !          13964:                                }
        !          13965: 
        !          13966:                                break;
        !          13967:                        }
        !          13968:                        case 0x2b:
        !          13969:                        {
        !          13970:                                sdwCyclesRemaining -= 6;
        !          13971:                                cpu.z80HL--;
        !          13972:                                cpu.z80HL &= 0xffff;
        !          13973:                                break;
        !          13974:                        }
        !          13975:                        case 0x2c:
        !          13976:                        {
        !          13977:                                sdwCyclesRemaining -= 4;
        !          13978:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          13979:                                cpu.z80F |= bPostIncFlags[cpu.z80L++];
        !          13980:                                break;
        !          13981:                        }
        !          13982:                        case 0x2d:
        !          13983:                        {
        !          13984:                                sdwCyclesRemaining -= 4;
        !          13985:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
        !          13986:                                cpu.z80F |= bPostDecFlags[cpu.z80L--];
        !          13987:                                break;
        !          13988:                        }
        !          13989:                        case 0x2e:
        !          13990:                        {
        !          13991:                                sdwCyclesRemaining -= 7;
        !          13992:                                cpu.z80L = *pbPC++;     /* Get immediate byte into register */
        !          13993:                                break;
        !          13994:                        }
        !          13995:                        case 0x2f:
        !          13996:                        {
        !          13997:                                sdwCyclesRemaining -= 4;
        !          13998:                                cpu.z80A ^= 0xff;
        !          13999:                                cpu.z80F |= (Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          14000:                                break;
        !          14001:                        }
        !          14002:                        case 0x30:
        !          14003:                        {
        !          14004:                                sdwCyclesRemaining -= 7;
        !          14005:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          14006:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14007:                                sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
        !          14008:                                if (!(cpu.z80F & Z80_FLAG_CARRY))
        !          14009:                                {
        !          14010:                                sdwCyclesRemaining -= 5;
        !          14011:                                        pbPC = cpu.z80Base + sdwAddr;   /* Normalize the address */
        !          14012:                                }
        !          14013:                                break;
        !          14014:                        }
        !          14015:                        case 0x31:
        !          14016:                        {
        !          14017:                                sdwCyclesRemaining -= 10;
        !          14018:                                cpu.z80sp = *pbPC++;    /* LSB First */
        !          14019:                                cpu.z80sp |= (((UINT32) *pbPC++ << 8)); /* Now the MSB */
        !          14020:                                break;
        !          14021:                        }
        !          14022:                        case 0x32:
        !          14023:                        {
        !          14024:                                sdwCyclesRemaining -= 13;
        !          14025:                                dwTemp = *pbPC++;
        !          14026:                                dwTemp |= ((UINT32) *pbPC++ << 8);
        !          14027:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14028:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14029:                                {
        !          14030:                                        if ((dwTemp >= psMemWrite->lowAddr) && (dwTemp <= psMemWrite->highAddr))
        !          14031:                                        {
        !          14032:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14033:                                                if (psMemWrite->memoryCall)
        !          14034:                                                {
        !          14035:                                                        psMemWrite->memoryCall(dwTemp, cpu.z80A, psMemWrite);
        !          14036:                                                }
        !          14037:                                                else
        !          14038:                                                {
        !          14039:                                                        *((UINT8 *) psMemWrite->pUserArea + (dwTemp - psMemWrite->lowAddr)) = cpu.z80A;
        !          14040:                                                }
        !          14041:                                                psMemWrite = NULL;
        !          14042:                                                break;
        !          14043:                                        }
        !          14044:                                        ++psMemWrite;
        !          14045:                                }
        !          14046: 
        !          14047:                                if (psMemWrite)
        !          14048:                                {
        !          14049:                                        cpu.z80Base[dwTemp] = (UINT8) cpu.z80A;
        !          14050:                                }
        !          14051: 
        !          14052:                                break;
        !          14053:                        }
        !          14054:                        case 0x33:
        !          14055:                        {
        !          14056:                                sdwCyclesRemaining -= 6;
        !          14057:                                cpu.z80sp++;
        !          14058:                                cpu.z80sp &= 0xffff;
        !          14059:                                break;
        !          14060:                        }
        !          14061:                        case 0x34:
        !          14062:                        {
        !          14063:                                sdwCyclesRemaining -= 11;
        !          14064:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14065:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14066:                                {
        !          14067:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14068:                                        {
        !          14069:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14070:                                                if (psMemRead->memoryCall)
        !          14071:                                                {
        !          14072:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14073:                                                }
        !          14074:                                                else
        !          14075:                                                {
        !          14076:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14077:                                                }
        !          14078:                                                psMemRead = NULL;
        !          14079:                                                break;
        !          14080:                                        }
        !          14081:                                        ++psMemRead;
        !          14082:                                }
        !          14083: 
        !          14084:                                if (psMemRead)
        !          14085:                                {
        !          14086:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          14087:                                }
        !          14088: 
        !          14089:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          14090:                                cpu.z80F |= bPostIncFlags[bTemp];
        !          14091:                                bTemp++;
        !          14092:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14093:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14094:                                {
        !          14095:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14096:                                        {
        !          14097:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14098:                                                if (psMemWrite->memoryCall)
        !          14099:                                                {
        !          14100:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          14101:                                                }
        !          14102:                                                else
        !          14103:                                                {
        !          14104:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          14105:                                                }
        !          14106:                                                psMemWrite = NULL;
        !          14107:                                                break;
        !          14108:                                        }
        !          14109:                                        ++psMemWrite;
        !          14110:                                }
        !          14111: 
        !          14112:                                if (psMemWrite)
        !          14113:                                {
        !          14114:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          14115:                                }
        !          14116: 
        !          14117:                                break;
        !          14118:                        }
        !          14119:                        case 0x35:
        !          14120:                        {
        !          14121:                                sdwCyclesRemaining -= 11;
        !          14122:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14123:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14124:                                {
        !          14125:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14126:                                        {
        !          14127:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14128:                                                if (psMemRead->memoryCall)
        !          14129:                                                {
        !          14130:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14131:                                                }
        !          14132:                                                else
        !          14133:                                                {
        !          14134:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14135:                                                }
        !          14136:                                                psMemRead = NULL;
        !          14137:                                                break;
        !          14138:                                        }
        !          14139:                                        ++psMemRead;
        !          14140:                                }
        !          14141: 
        !          14142:                                if (psMemRead)
        !          14143:                                {
        !          14144:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          14145:                                }
        !          14146: 
        !          14147:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          14148:                                cpu.z80F |= bPostDecFlags[bTemp];
        !          14149:                                bTemp--;
        !          14150:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14151:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14152:                                {
        !          14153:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14154:                                        {
        !          14155:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14156:                                                if (psMemWrite->memoryCall)
        !          14157:                                                {
        !          14158:                                                        psMemWrite->memoryCall(cpu.z80HL, bTemp, psMemWrite);
        !          14159:                                                }
        !          14160:                                                else
        !          14161:                                                {
        !          14162:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = bTemp;
        !          14163:                                                }
        !          14164:                                                psMemWrite = NULL;
        !          14165:                                                break;
        !          14166:                                        }
        !          14167:                                        ++psMemWrite;
        !          14168:                                }
        !          14169: 
        !          14170:                                if (psMemWrite)
        !          14171:                                {
        !          14172:                                        cpu.z80Base[cpu.z80HL] = (UINT8) bTemp;
        !          14173:                                }
        !          14174: 
        !          14175:                                break;
        !          14176:                        }
        !          14177:                        case 0x36:
        !          14178:                        {
        !          14179:                                sdwCyclesRemaining -= 10;
        !          14180:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14181:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14182:                                {
        !          14183:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14184:                                        {
        !          14185:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14186:                                                if (psMemWrite->memoryCall)
        !          14187:                                                {
        !          14188:                                                        psMemWrite->memoryCall(cpu.z80HL, *pbPC++, psMemWrite);
        !          14189:                                                }
        !          14190:                                                else
        !          14191:                                                {
        !          14192:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = *pbPC++;
        !          14193:                                                }
        !          14194:                                                psMemWrite = NULL;
        !          14195:                                                break;
        !          14196:                                        }
        !          14197:                                        ++psMemWrite;
        !          14198:                                }
        !          14199: 
        !          14200:                                if (psMemWrite)
        !          14201:                                {
        !          14202:                                        cpu.z80Base[cpu.z80HL] = (UINT8) *pbPC++;
        !          14203:                                }
        !          14204: 
        !          14205:                                break;
        !          14206:                        }
        !          14207:                        case 0x37:
        !          14208:                        {
        !          14209:                                sdwCyclesRemaining -= 4;
        !          14210:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE);
        !          14211:                                cpu.z80F |= Z80_FLAG_CARRY;
        !          14212:                                break;
        !          14213:                        }
        !          14214:                        case 0x38:
        !          14215:                        {
        !          14216:                                sdwCyclesRemaining -= 7;
        !          14217:                                sdwAddr = (INT8) *pbPC++;       /* Get LSB first */
        !          14218:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14219:                                sdwAddr = (sdwAddr + (INT32) cpu.z80pc) & 0xffff;
        !          14220:                                if (cpu.z80F & Z80_FLAG_CARRY)
        !          14221:                                {
        !          14222:                                sdwCyclesRemaining -= 5;
        !          14223:                                        pbPC = cpu.z80Base + sdwAddr;   /* Normalize the address */
        !          14224:                                }
        !          14225:                                break;
        !          14226:                        }
        !          14227:                        case 0x39:
        !          14228:                        {
        !          14229:                                sdwCyclesRemaining -= 11;
        !          14230:                        cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_HALF_CARRY);
        !          14231:                        dwTemp = cpu.z80HL + cpu.z80sp;
        !          14232:                        cpu.z80F |= ((dwTemp >> 16) & Z80_FLAG_CARRY) | (((cpu.z80HL ^ dwTemp ^ cpu.z80sp) >> 8) & Z80_FLAG_HALF_CARRY);
        !          14233:                        cpu.z80HL = dwTemp & 0xffff;
        !          14234:                                break;
        !          14235:                        }
        !          14236:                        case 0x3a:
        !          14237:                        {
        !          14238:                                sdwCyclesRemaining -= 13;
        !          14239:                                dwTemp = *pbPC++;
        !          14240:                                dwTemp |= (((UINT32) *pbPC++) << 8);
        !          14241:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14242:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14243:                                {
        !          14244:                                        if ((dwTemp >= psMemRead->lowAddr) && (dwTemp <= psMemRead->highAddr))
        !          14245:                                        {
        !          14246:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14247:                                                if (psMemRead->memoryCall)
        !          14248:                                                {
        !          14249:                                                        cpu.z80A = psMemRead->memoryCall(dwTemp, psMemRead);
        !          14250:                                                }
        !          14251:                                                else
        !          14252:                                                {
        !          14253:                                                        cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (dwTemp - psMemRead->lowAddr));
        !          14254:                                                }
        !          14255:                                                psMemRead = NULL;
        !          14256:                                                break;
        !          14257:                                        }
        !          14258:                                        ++psMemRead;
        !          14259:                                }
        !          14260: 
        !          14261:                                if (psMemRead)
        !          14262:                                {
        !          14263:                                        cpu.z80A = cpu.z80Base[dwTemp];
        !          14264:                                }
        !          14265: 
        !          14266:                                break;
        !          14267:                        }
        !          14268:                        case 0x3b:
        !          14269:                        {
        !          14270:                                sdwCyclesRemaining -= 6;
        !          14271:                                cpu.z80sp--;
        !          14272:                                cpu.z80sp &= 0xffff;
        !          14273:                                break;
        !          14274:                        }
        !          14275:                        case 0x3c:
        !          14276:                        {
        !          14277:                                sdwCyclesRemaining -= 4;
        !          14278:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_NEGATIVE);
        !          14279:                                cpu.z80F |= bPostIncFlags[cpu.z80A++];
        !          14280:                                break;
        !          14281:                        }
        !          14282:                        case 0x3d:
        !          14283:                        {
        !          14284:                                sdwCyclesRemaining -= 4;
        !          14285:                                cpu.z80F &= ~(Z80_FLAG_SIGN | Z80_FLAG_ZERO | Z80_FLAG_HALF_CARRY | Z80_FLAG_OVERFLOW_PARITY);
        !          14286:                                cpu.z80F |= bPostDecFlags[cpu.z80A--];
        !          14287:                                break;
        !          14288:                        }
        !          14289:                        case 0x3e:
        !          14290:                        {
        !          14291:                                sdwCyclesRemaining -= 7;
        !          14292:                                cpu.z80A = *pbPC++;     /* Get immediate byte into register */
        !          14293:                                break;
        !          14294:                        }
        !          14295:                        case 0x3f:
        !          14296:                        {
        !          14297:                                sdwCyclesRemaining -= 4;
        !          14298:                                bTemp = (cpu.z80F & Z80_FLAG_CARRY) << 4;
        !          14299:                                cpu.z80F &= ~(Z80_FLAG_HALF_CARRY | Z80_FLAG_NEGATIVE);
        !          14300:                                cpu.z80F ^= Z80_FLAG_CARRY;
        !          14301:                                break;
        !          14302:                        }
        !          14303:                        case 0x40:
        !          14304:                        {
        !          14305:                                sdwCyclesRemaining -= 4;
        !          14306:                                break;
        !          14307:                        }
        !          14308:                        case 0x41:
        !          14309:                        {
        !          14310:                                sdwCyclesRemaining -= 4;
        !          14311:                                cpu.z80B = cpu.z80C;
        !          14312:                                break;
        !          14313:                        }
        !          14314:                        case 0x42:
        !          14315:                        {
        !          14316:                                sdwCyclesRemaining -= 4;
        !          14317:                                cpu.z80B = cpu.z80D;
        !          14318:                                break;
        !          14319:                        }
        !          14320:                        case 0x43:
        !          14321:                        {
        !          14322:                                sdwCyclesRemaining -= 4;
        !          14323:                                cpu.z80B = cpu.z80E;
        !          14324:                                break;
        !          14325:                        }
        !          14326:                        case 0x44:
        !          14327:                        {
        !          14328:                                sdwCyclesRemaining -= 4;
        !          14329:                                cpu.z80B = cpu.z80H;
        !          14330:                                break;
        !          14331:                        }
        !          14332:                        case 0x45:
        !          14333:                        {
        !          14334:                                sdwCyclesRemaining -= 4;
        !          14335:                                cpu.z80B = cpu.z80L;
        !          14336:                                break;
        !          14337:                        }
        !          14338:                        case 0x46:
        !          14339:                        {
        !          14340:                                sdwCyclesRemaining -= 7;
        !          14341:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14342:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14343:                                {
        !          14344:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14345:                                        {
        !          14346:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14347:                                                if (psMemRead->memoryCall)
        !          14348:                                                {
        !          14349:                                                        cpu.z80B = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14350:                                                }
        !          14351:                                                else
        !          14352:                                                {
        !          14353:                                                        cpu.z80B = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14354:                                                }
        !          14355:                                                psMemRead = NULL;
        !          14356:                                                break;
        !          14357:                                        }
        !          14358:                                        ++psMemRead;
        !          14359:                                }
        !          14360: 
        !          14361:                                if (psMemRead)
        !          14362:                                {
        !          14363:                                        cpu.z80B = cpu.z80Base[cpu.z80HL];
        !          14364:                                }
        !          14365: 
        !          14366:                                break;
        !          14367:                        }
        !          14368:                        case 0x47:
        !          14369:                        {
        !          14370:                                sdwCyclesRemaining -= 4;
        !          14371:                                cpu.z80B = cpu.z80A;
        !          14372:                                break;
        !          14373:                        }
        !          14374:                        case 0x48:
        !          14375:                        {
        !          14376:                                sdwCyclesRemaining -= 4;
        !          14377:                                cpu.z80C = cpu.z80B;
        !          14378:                                break;
        !          14379:                        }
        !          14380:                        case 0x49:
        !          14381:                        {
        !          14382:                                sdwCyclesRemaining -= 4;
        !          14383:                                break;
        !          14384:                        }
        !          14385:                        case 0x4a:
        !          14386:                        {
        !          14387:                                sdwCyclesRemaining -= 4;
        !          14388:                                cpu.z80C = cpu.z80D;
        !          14389:                                break;
        !          14390:                        }
        !          14391:                        case 0x4b:
        !          14392:                        {
        !          14393:                                sdwCyclesRemaining -= 4;
        !          14394:                                cpu.z80C = cpu.z80E;
        !          14395:                                break;
        !          14396:                        }
        !          14397:                        case 0x4c:
        !          14398:                        {
        !          14399:                                sdwCyclesRemaining -= 4;
        !          14400:                                cpu.z80C = cpu.z80H;
        !          14401:                                break;
        !          14402:                        }
        !          14403:                        case 0x4d:
        !          14404:                        {
        !          14405:                                sdwCyclesRemaining -= 4;
        !          14406:                                cpu.z80C = cpu.z80L;
        !          14407:                                break;
        !          14408:                        }
        !          14409:                        case 0x4e:
        !          14410:                        {
        !          14411:                                sdwCyclesRemaining -= 7;
        !          14412:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14413:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14414:                                {
        !          14415:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14416:                                        {
        !          14417:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14418:                                                if (psMemRead->memoryCall)
        !          14419:                                                {
        !          14420:                                                        cpu.z80C = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14421:                                                }
        !          14422:                                                else
        !          14423:                                                {
        !          14424:                                                        cpu.z80C = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14425:                                                }
        !          14426:                                                psMemRead = NULL;
        !          14427:                                                break;
        !          14428:                                        }
        !          14429:                                        ++psMemRead;
        !          14430:                                }
        !          14431: 
        !          14432:                                if (psMemRead)
        !          14433:                                {
        !          14434:                                        cpu.z80C = cpu.z80Base[cpu.z80HL];
        !          14435:                                }
        !          14436: 
        !          14437:                                break;
        !          14438:                        }
        !          14439:                        case 0x4f:
        !          14440:                        {
        !          14441:                                sdwCyclesRemaining -= 4;
        !          14442:                                cpu.z80C = cpu.z80A;
        !          14443:                                break;
        !          14444:                        }
        !          14445:                        case 0x50:
        !          14446:                        {
        !          14447:                                sdwCyclesRemaining -= 4;
        !          14448:                                cpu.z80D = cpu.z80B;
        !          14449:                                break;
        !          14450:                        }
        !          14451:                        case 0x51:
        !          14452:                        {
        !          14453:                                sdwCyclesRemaining -= 4;
        !          14454:                                cpu.z80D = cpu.z80C;
        !          14455:                                break;
        !          14456:                        }
        !          14457:                        case 0x52:
        !          14458:                        {
        !          14459:                                sdwCyclesRemaining -= 4;
        !          14460:                                break;
        !          14461:                        }
        !          14462:                        case 0x53:
        !          14463:                        {
        !          14464:                                sdwCyclesRemaining -= 4;
        !          14465:                                cpu.z80D = cpu.z80E;
        !          14466:                                break;
        !          14467:                        }
        !          14468:                        case 0x54:
        !          14469:                        {
        !          14470:                                sdwCyclesRemaining -= 4;
        !          14471:                                cpu.z80D = cpu.z80H;
        !          14472:                                break;
        !          14473:                        }
        !          14474:                        case 0x55:
        !          14475:                        {
        !          14476:                                sdwCyclesRemaining -= 4;
        !          14477:                                cpu.z80D = cpu.z80L;
        !          14478:                                break;
        !          14479:                        }
        !          14480:                        case 0x56:
        !          14481:                        {
        !          14482:                                sdwCyclesRemaining -= 7;
        !          14483:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14484:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14485:                                {
        !          14486:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14487:                                        {
        !          14488:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14489:                                                if (psMemRead->memoryCall)
        !          14490:                                                {
        !          14491:                                                        cpu.z80D = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14492:                                                }
        !          14493:                                                else
        !          14494:                                                {
        !          14495:                                                        cpu.z80D = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14496:                                                }
        !          14497:                                                psMemRead = NULL;
        !          14498:                                                break;
        !          14499:                                        }
        !          14500:                                        ++psMemRead;
        !          14501:                                }
        !          14502: 
        !          14503:                                if (psMemRead)
        !          14504:                                {
        !          14505:                                        cpu.z80D = cpu.z80Base[cpu.z80HL];
        !          14506:                                }
        !          14507: 
        !          14508:                                break;
        !          14509:                        }
        !          14510:                        case 0x57:
        !          14511:                        {
        !          14512:                                sdwCyclesRemaining -= 4;
        !          14513:                                cpu.z80D = cpu.z80A;
        !          14514:                                break;
        !          14515:                        }
        !          14516:                        case 0x58:
        !          14517:                        {
        !          14518:                                sdwCyclesRemaining -= 4;
        !          14519:                                cpu.z80E = cpu.z80B;
        !          14520:                                break;
        !          14521:                        }
        !          14522:                        case 0x59:
        !          14523:                        {
        !          14524:                                sdwCyclesRemaining -= 4;
        !          14525:                                cpu.z80E = cpu.z80C;
        !          14526:                                break;
        !          14527:                        }
        !          14528:                        case 0x5a:
        !          14529:                        {
        !          14530:                                sdwCyclesRemaining -= 4;
        !          14531:                                cpu.z80E = cpu.z80D;
        !          14532:                                break;
        !          14533:                        }
        !          14534:                        case 0x5b:
        !          14535:                        {
        !          14536:                                sdwCyclesRemaining -= 4;
        !          14537:                                break;
        !          14538:                        }
        !          14539:                        case 0x5c:
        !          14540:                        {
        !          14541:                                sdwCyclesRemaining -= 4;
        !          14542:                                cpu.z80E = cpu.z80H;
        !          14543:                                break;
        !          14544:                        }
        !          14545:                        case 0x5d:
        !          14546:                        {
        !          14547:                                sdwCyclesRemaining -= 4;
        !          14548:                                cpu.z80E = cpu.z80L;
        !          14549:                                break;
        !          14550:                        }
        !          14551:                        case 0x5e:
        !          14552:                        {
        !          14553:                                sdwCyclesRemaining -= 7;
        !          14554:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14555:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14556:                                {
        !          14557:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14558:                                        {
        !          14559:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14560:                                                if (psMemRead->memoryCall)
        !          14561:                                                {
        !          14562:                                                        cpu.z80E = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14563:                                                }
        !          14564:                                                else
        !          14565:                                                {
        !          14566:                                                        cpu.z80E = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14567:                                                }
        !          14568:                                                psMemRead = NULL;
        !          14569:                                                break;
        !          14570:                                        }
        !          14571:                                        ++psMemRead;
        !          14572:                                }
        !          14573: 
        !          14574:                                if (psMemRead)
        !          14575:                                {
        !          14576:                                        cpu.z80E = cpu.z80Base[cpu.z80HL];
        !          14577:                                }
        !          14578: 
        !          14579:                                break;
        !          14580:                        }
        !          14581:                        case 0x5f:
        !          14582:                        {
        !          14583:                                sdwCyclesRemaining -= 4;
        !          14584:                                cpu.z80E = cpu.z80A;
        !          14585:                                break;
        !          14586:                        }
        !          14587:                        case 0x60:
        !          14588:                        {
        !          14589:                                sdwCyclesRemaining -= 4;
        !          14590:                                cpu.z80H = cpu.z80B;
        !          14591:                                break;
        !          14592:                        }
        !          14593:                        case 0x61:
        !          14594:                        {
        !          14595:                                sdwCyclesRemaining -= 4;
        !          14596:                                cpu.z80H = cpu.z80C;
        !          14597:                                break;
        !          14598:                        }
        !          14599:                        case 0x62:
        !          14600:                        {
        !          14601:                                sdwCyclesRemaining -= 4;
        !          14602:                                cpu.z80H = cpu.z80D;
        !          14603:                                break;
        !          14604:                        }
        !          14605:                        case 0x63:
        !          14606:                        {
        !          14607:                                sdwCyclesRemaining -= 4;
        !          14608:                                cpu.z80H = cpu.z80E;
        !          14609:                                break;
        !          14610:                        }
        !          14611:                        case 0x64:
        !          14612:                        {
        !          14613:                                sdwCyclesRemaining -= 4;
        !          14614:                                break;
        !          14615:                        }
        !          14616:                        case 0x65:
        !          14617:                        {
        !          14618:                                sdwCyclesRemaining -= 4;
        !          14619:                                cpu.z80H = cpu.z80L;
        !          14620:                                break;
        !          14621:                        }
        !          14622:                        case 0x66:
        !          14623:                        {
        !          14624:                                sdwCyclesRemaining -= 7;
        !          14625:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14626:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14627:                                {
        !          14628:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14629:                                        {
        !          14630:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14631:                                                if (psMemRead->memoryCall)
        !          14632:                                                {
        !          14633:                                                        cpu.z80H = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14634:                                                }
        !          14635:                                                else
        !          14636:                                                {
        !          14637:                                                        cpu.z80H = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14638:                                                }
        !          14639:                                                psMemRead = NULL;
        !          14640:                                                break;
        !          14641:                                        }
        !          14642:                                        ++psMemRead;
        !          14643:                                }
        !          14644: 
        !          14645:                                if (psMemRead)
        !          14646:                                {
        !          14647:                                        cpu.z80H = cpu.z80Base[cpu.z80HL];
        !          14648:                                }
        !          14649: 
        !          14650:                                break;
        !          14651:                        }
        !          14652:                        case 0x67:
        !          14653:                        {
        !          14654:                                sdwCyclesRemaining -= 4;
        !          14655:                                cpu.z80H = cpu.z80A;
        !          14656:                                break;
        !          14657:                        }
        !          14658:                        case 0x68:
        !          14659:                        {
        !          14660:                                sdwCyclesRemaining -= 4;
        !          14661:                                cpu.z80L = cpu.z80B;
        !          14662:                                break;
        !          14663:                        }
        !          14664:                        case 0x69:
        !          14665:                        {
        !          14666:                                sdwCyclesRemaining -= 4;
        !          14667:                                cpu.z80L = cpu.z80C;
        !          14668:                                break;
        !          14669:                        }
        !          14670:                        case 0x6a:
        !          14671:                        {
        !          14672:                                sdwCyclesRemaining -= 4;
        !          14673:                                cpu.z80L = cpu.z80D;
        !          14674:                                break;
        !          14675:                        }
        !          14676:                        case 0x6b:
        !          14677:                        {
        !          14678:                                sdwCyclesRemaining -= 4;
        !          14679:                                cpu.z80L = cpu.z80E;
        !          14680:                                break;
        !          14681:                        }
        !          14682:                        case 0x6c:
        !          14683:                        {
        !          14684:                                sdwCyclesRemaining -= 4;
        !          14685:                                cpu.z80L = cpu.z80H;
        !          14686:                                break;
        !          14687:                        }
        !          14688:                        case 0x6d:
        !          14689:                        {
        !          14690:                                sdwCyclesRemaining -= 4;
        !          14691:                                break;
        !          14692:                        }
        !          14693:                        case 0x6e:
        !          14694:                        {
        !          14695:                                sdwCyclesRemaining -= 7;
        !          14696:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14697:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14698:                                {
        !          14699:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14700:                                        {
        !          14701:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14702:                                                if (psMemRead->memoryCall)
        !          14703:                                                {
        !          14704:                                                        cpu.z80L = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14705:                                                }
        !          14706:                                                else
        !          14707:                                                {
        !          14708:                                                        cpu.z80L = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14709:                                                }
        !          14710:                                                psMemRead = NULL;
        !          14711:                                                break;
        !          14712:                                        }
        !          14713:                                        ++psMemRead;
        !          14714:                                }
        !          14715: 
        !          14716:                                if (psMemRead)
        !          14717:                                {
        !          14718:                                        cpu.z80L = cpu.z80Base[cpu.z80HL];
        !          14719:                                }
        !          14720: 
        !          14721:                                break;
        !          14722:                        }
        !          14723:                        case 0x6f:
        !          14724:                        {
        !          14725:                                sdwCyclesRemaining -= 4;
        !          14726:                                cpu.z80L = cpu.z80A;
        !          14727:                                break;
        !          14728:                        }
        !          14729:                        case 0x70:
        !          14730:                        {
        !          14731:                                sdwCyclesRemaining -= 7;
        !          14732:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14733:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14734:                                {
        !          14735:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14736:                                        {
        !          14737:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14738:                                                if (psMemWrite->memoryCall)
        !          14739:                                                {
        !          14740:                                                        psMemWrite->memoryCall(cpu.z80HL, cpu.z80B, psMemWrite);
        !          14741:                                                }
        !          14742:                                                else
        !          14743:                                                {
        !          14744:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80B;
        !          14745:                                                }
        !          14746:                                                psMemWrite = NULL;
        !          14747:                                                break;
        !          14748:                                        }
        !          14749:                                        ++psMemWrite;
        !          14750:                                }
        !          14751: 
        !          14752:                                if (psMemWrite)
        !          14753:                                {
        !          14754:                                        cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80B;
        !          14755:                                }
        !          14756: 
        !          14757:                                break;
        !          14758:                        }
        !          14759:                        case 0x71:
        !          14760:                        {
        !          14761:                                sdwCyclesRemaining -= 7;
        !          14762:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14763:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14764:                                {
        !          14765:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14766:                                        {
        !          14767:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14768:                                                if (psMemWrite->memoryCall)
        !          14769:                                                {
        !          14770:                                                        psMemWrite->memoryCall(cpu.z80HL, cpu.z80C, psMemWrite);
        !          14771:                                                }
        !          14772:                                                else
        !          14773:                                                {
        !          14774:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80C;
        !          14775:                                                }
        !          14776:                                                psMemWrite = NULL;
        !          14777:                                                break;
        !          14778:                                        }
        !          14779:                                        ++psMemWrite;
        !          14780:                                }
        !          14781: 
        !          14782:                                if (psMemWrite)
        !          14783:                                {
        !          14784:                                        cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80C;
        !          14785:                                }
        !          14786: 
        !          14787:                                break;
        !          14788:                        }
        !          14789:                        case 0x72:
        !          14790:                        {
        !          14791:                                sdwCyclesRemaining -= 7;
        !          14792:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14793:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14794:                                {
        !          14795:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14796:                                        {
        !          14797:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14798:                                                if (psMemWrite->memoryCall)
        !          14799:                                                {
        !          14800:                                                        psMemWrite->memoryCall(cpu.z80HL, cpu.z80D, psMemWrite);
        !          14801:                                                }
        !          14802:                                                else
        !          14803:                                                {
        !          14804:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80D;
        !          14805:                                                }
        !          14806:                                                psMemWrite = NULL;
        !          14807:                                                break;
        !          14808:                                        }
        !          14809:                                        ++psMemWrite;
        !          14810:                                }
        !          14811: 
        !          14812:                                if (psMemWrite)
        !          14813:                                {
        !          14814:                                        cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80D;
        !          14815:                                }
        !          14816: 
        !          14817:                                break;
        !          14818:                        }
        !          14819:                        case 0x73:
        !          14820:                        {
        !          14821:                                sdwCyclesRemaining -= 7;
        !          14822:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14823:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14824:                                {
        !          14825:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14826:                                        {
        !          14827:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14828:                                                if (psMemWrite->memoryCall)
        !          14829:                                                {
        !          14830:                                                        psMemWrite->memoryCall(cpu.z80HL, cpu.z80E, psMemWrite);
        !          14831:                                                }
        !          14832:                                                else
        !          14833:                                                {
        !          14834:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80E;
        !          14835:                                                }
        !          14836:                                                psMemWrite = NULL;
        !          14837:                                                break;
        !          14838:                                        }
        !          14839:                                        ++psMemWrite;
        !          14840:                                }
        !          14841: 
        !          14842:                                if (psMemWrite)
        !          14843:                                {
        !          14844:                                        cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80E;
        !          14845:                                }
        !          14846: 
        !          14847:                                break;
        !          14848:                        }
        !          14849:                        case 0x74:
        !          14850:                        {
        !          14851:                                sdwCyclesRemaining -= 7;
        !          14852:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14853:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14854:                                {
        !          14855:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14856:                                        {
        !          14857:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14858:                                                if (psMemWrite->memoryCall)
        !          14859:                                                {
        !          14860:                                                        psMemWrite->memoryCall(cpu.z80HL, cpu.z80H, psMemWrite);
        !          14861:                                                }
        !          14862:                                                else
        !          14863:                                                {
        !          14864:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80H;
        !          14865:                                                }
        !          14866:                                                psMemWrite = NULL;
        !          14867:                                                break;
        !          14868:                                        }
        !          14869:                                        ++psMemWrite;
        !          14870:                                }
        !          14871: 
        !          14872:                                if (psMemWrite)
        !          14873:                                {
        !          14874:                                        cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80H;
        !          14875:                                }
        !          14876: 
        !          14877:                                break;
        !          14878:                        }
        !          14879:                        case 0x75:
        !          14880:                        {
        !          14881:                                sdwCyclesRemaining -= 7;
        !          14882:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14883:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14884:                                {
        !          14885:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14886:                                        {
        !          14887:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14888:                                                if (psMemWrite->memoryCall)
        !          14889:                                                {
        !          14890:                                                        psMemWrite->memoryCall(cpu.z80HL, cpu.z80L, psMemWrite);
        !          14891:                                                }
        !          14892:                                                else
        !          14893:                                                {
        !          14894:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80L;
        !          14895:                                                }
        !          14896:                                                psMemWrite = NULL;
        !          14897:                                                break;
        !          14898:                                        }
        !          14899:                                        ++psMemWrite;
        !          14900:                                }
        !          14901: 
        !          14902:                                if (psMemWrite)
        !          14903:                                {
        !          14904:                                        cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80L;
        !          14905:                                }
        !          14906: 
        !          14907:                                break;
        !          14908:                        }
        !          14909:                        case 0x76:
        !          14910:                        {
        !          14911:                                sdwCyclesRemaining -= 4;
        !          14912:                                cpu.z80halted = 1;
        !          14913:                                dwElapsedTicks += sdwCyclesRemaining;
        !          14914:                                sdwCyclesRemaining = 0;
        !          14915:                                break;
        !          14916:                        }
        !          14917:                        case 0x77:
        !          14918:                        {
        !          14919:                                sdwCyclesRemaining -= 7;
        !          14920:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          14921:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          14922:                                {
        !          14923:                                        if ((cpu.z80HL >= psMemWrite->lowAddr) && (cpu.z80HL <= psMemWrite->highAddr))
        !          14924:                                        {
        !          14925:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14926:                                                if (psMemWrite->memoryCall)
        !          14927:                                                {
        !          14928:                                                        psMemWrite->memoryCall(cpu.z80HL, cpu.z80A, psMemWrite);
        !          14929:                                                }
        !          14930:                                                else
        !          14931:                                                {
        !          14932:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80HL - psMemWrite->lowAddr)) = cpu.z80A;
        !          14933:                                                }
        !          14934:                                                psMemWrite = NULL;
        !          14935:                                                break;
        !          14936:                                        }
        !          14937:                                        ++psMemWrite;
        !          14938:                                }
        !          14939: 
        !          14940:                                if (psMemWrite)
        !          14941:                                {
        !          14942:                                        cpu.z80Base[cpu.z80HL] = (UINT8) cpu.z80A;
        !          14943:                                }
        !          14944: 
        !          14945:                                break;
        !          14946:                        }
        !          14947:                        case 0x78:
        !          14948:                        {
        !          14949:                                sdwCyclesRemaining -= 4;
        !          14950:                                cpu.z80A = cpu.z80B;
        !          14951:                                break;
        !          14952:                        }
        !          14953:                        case 0x79:
        !          14954:                        {
        !          14955:                                sdwCyclesRemaining -= 4;
        !          14956:                                cpu.z80A = cpu.z80C;
        !          14957:                                break;
        !          14958:                        }
        !          14959:                        case 0x7a:
        !          14960:                        {
        !          14961:                                sdwCyclesRemaining -= 4;
        !          14962:                                cpu.z80A = cpu.z80D;
        !          14963:                                break;
        !          14964:                        }
        !          14965:                        case 0x7b:
        !          14966:                        {
        !          14967:                                sdwCyclesRemaining -= 4;
        !          14968:                                cpu.z80A = cpu.z80E;
        !          14969:                                break;
        !          14970:                        }
        !          14971:                        case 0x7c:
        !          14972:                        {
        !          14973:                                sdwCyclesRemaining -= 4;
        !          14974:                                cpu.z80A = cpu.z80H;
        !          14975:                                break;
        !          14976:                        }
        !          14977:                        case 0x7d:
        !          14978:                        {
        !          14979:                                sdwCyclesRemaining -= 4;
        !          14980:                                cpu.z80A = cpu.z80L;
        !          14981:                                break;
        !          14982:                        }
        !          14983:                        case 0x7e:
        !          14984:                        {
        !          14985:                                sdwCyclesRemaining -= 7;
        !          14986:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          14987:                                while (psMemRead->lowAddr != 0xffffffff)
        !          14988:                                {
        !          14989:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          14990:                                        {
        !          14991:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          14992:                                                if (psMemRead->memoryCall)
        !          14993:                                                {
        !          14994:                                                        cpu.z80A = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          14995:                                                }
        !          14996:                                                else
        !          14997:                                                {
        !          14998:                                                        cpu.z80A = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          14999:                                                }
        !          15000:                                                psMemRead = NULL;
        !          15001:                                                break;
        !          15002:                                        }
        !          15003:                                        ++psMemRead;
        !          15004:                                }
        !          15005: 
        !          15006:                                if (psMemRead)
        !          15007:                                {
        !          15008:                                        cpu.z80A = cpu.z80Base[cpu.z80HL];
        !          15009:                                }
        !          15010: 
        !          15011:                                break;
        !          15012:                        }
        !          15013:                        case 0x7f:
        !          15014:                        {
        !          15015:                                sdwCyclesRemaining -= 4;
        !          15016:                                break;
        !          15017:                        }
        !          15018:                        case 0x80:
        !          15019:                        {
        !          15020:                                sdwCyclesRemaining -= 4;
        !          15021:                                bTemp2 = cpu.z80A + cpu.z80B;
        !          15022:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15023:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15024:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80B];
        !          15025:                                cpu.z80A = bTemp2;
        !          15026:                                break;
        !          15027:                        }
        !          15028:                        case 0x81:
        !          15029:                        {
        !          15030:                                sdwCyclesRemaining -= 4;
        !          15031:                                bTemp2 = cpu.z80A + cpu.z80C;
        !          15032:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15033:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15034:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80C];
        !          15035:                                cpu.z80A = bTemp2;
        !          15036:                                break;
        !          15037:                        }
        !          15038:                        case 0x82:
        !          15039:                        {
        !          15040:                                sdwCyclesRemaining -= 4;
        !          15041:                                bTemp2 = cpu.z80A + cpu.z80D;
        !          15042:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15043:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15044:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80D];
        !          15045:                                cpu.z80A = bTemp2;
        !          15046:                                break;
        !          15047:                        }
        !          15048:                        case 0x83:
        !          15049:                        {
        !          15050:                                sdwCyclesRemaining -= 4;
        !          15051:                                bTemp2 = cpu.z80A + cpu.z80E;
        !          15052:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15053:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15054:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80E];
        !          15055:                                cpu.z80A = bTemp2;
        !          15056:                                break;
        !          15057:                        }
        !          15058:                        case 0x84:
        !          15059:                        {
        !          15060:                                sdwCyclesRemaining -= 4;
        !          15061:                                bTemp2 = cpu.z80A + cpu.z80H;
        !          15062:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15063:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15064:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80H];
        !          15065:                                cpu.z80A = bTemp2;
        !          15066:                                break;
        !          15067:                        }
        !          15068:                        case 0x85:
        !          15069:                        {
        !          15070:                                sdwCyclesRemaining -= 4;
        !          15071:                                bTemp2 = cpu.z80A + cpu.z80L;
        !          15072:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15073:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15074:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80L];
        !          15075:                                cpu.z80A = bTemp2;
        !          15076:                                break;
        !          15077:                        }
        !          15078:                        case 0x86:
        !          15079:                        {
        !          15080:                                sdwCyclesRemaining -= 7;
        !          15081:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15082:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15083:                                {
        !          15084:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          15085:                                        {
        !          15086:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15087:                                                if (psMemRead->memoryCall)
        !          15088:                                                {
        !          15089:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          15090:                                                }
        !          15091:                                                else
        !          15092:                                                {
        !          15093:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          15094:                                                }
        !          15095:                                                psMemRead = NULL;
        !          15096:                                                break;
        !          15097:                                        }
        !          15098:                                        ++psMemRead;
        !          15099:                                }
        !          15100: 
        !          15101:                                if (psMemRead)
        !          15102:                                {
        !          15103:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          15104:                                }
        !          15105: 
        !          15106:                                bTemp2 = cpu.z80A + bTemp;
        !          15107:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15108:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15109:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          15110:                                cpu.z80A = bTemp2;
        !          15111:                                break;
        !          15112:                        }
        !          15113:                        case 0x87:
        !          15114:                        {
        !          15115:                                sdwCyclesRemaining -= 4;
        !          15116:                                bTemp2 = cpu.z80A + cpu.z80A;
        !          15117:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15118:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15119:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80A];
        !          15120:                                cpu.z80A = bTemp2;
        !          15121:                                break;
        !          15122:                        }
        !          15123:                        case 0x88:
        !          15124:                        {
        !          15125:                                sdwCyclesRemaining -= 4;
        !          15126:                                bTemp2 = cpu.z80A + cpu.z80B + (cpu.z80F & Z80_FLAG_CARRY);
        !          15127:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15128:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15129:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80B | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15130:                                cpu.z80A = bTemp2;
        !          15131:                                break;
        !          15132:                        }
        !          15133:                        case 0x89:
        !          15134:                        {
        !          15135:                                sdwCyclesRemaining -= 4;
        !          15136:                                bTemp2 = cpu.z80A + cpu.z80C + (cpu.z80F & Z80_FLAG_CARRY);
        !          15137:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15138:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15139:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80C | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15140:                                cpu.z80A = bTemp2;
        !          15141:                                break;
        !          15142:                        }
        !          15143:                        case 0x8a:
        !          15144:                        {
        !          15145:                                sdwCyclesRemaining -= 4;
        !          15146:                                bTemp2 = cpu.z80A + cpu.z80D + (cpu.z80F & Z80_FLAG_CARRY);
        !          15147:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15148:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15149:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80D | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15150:                                cpu.z80A = bTemp2;
        !          15151:                                break;
        !          15152:                        }
        !          15153:                        case 0x8b:
        !          15154:                        {
        !          15155:                                sdwCyclesRemaining -= 4;
        !          15156:                                bTemp2 = cpu.z80A + cpu.z80E + (cpu.z80F & Z80_FLAG_CARRY);
        !          15157:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15158:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15159:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80E | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15160:                                cpu.z80A = bTemp2;
        !          15161:                                break;
        !          15162:                        }
        !          15163:                        case 0x8c:
        !          15164:                        {
        !          15165:                                sdwCyclesRemaining -= 4;
        !          15166:                                bTemp2 = cpu.z80A + cpu.z80H + (cpu.z80F & Z80_FLAG_CARRY);
        !          15167:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15168:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15169:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80H | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15170:                                cpu.z80A = bTemp2;
        !          15171:                                break;
        !          15172:                        }
        !          15173:                        case 0x8d:
        !          15174:                        {
        !          15175:                                sdwCyclesRemaining -= 4;
        !          15176:                                bTemp2 = cpu.z80A + cpu.z80L + (cpu.z80F & Z80_FLAG_CARRY);
        !          15177:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15178:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15179:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80L | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15180:                                cpu.z80A = bTemp2;
        !          15181:                                break;
        !          15182:                        }
        !          15183:                        case 0x8e:
        !          15184:                        {
        !          15185:                                sdwCyclesRemaining -= 7;
        !          15186:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15187:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15188:                                {
        !          15189:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          15190:                                        {
        !          15191:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15192:                                                if (psMemRead->memoryCall)
        !          15193:                                                {
        !          15194:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          15195:                                                }
        !          15196:                                                else
        !          15197:                                                {
        !          15198:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          15199:                                                }
        !          15200:                                                psMemRead = NULL;
        !          15201:                                                break;
        !          15202:                                        }
        !          15203:                                        ++psMemRead;
        !          15204:                                }
        !          15205: 
        !          15206:                                if (psMemRead)
        !          15207:                                {
        !          15208:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          15209:                                }
        !          15210: 
        !          15211:                                bTemp2 = cpu.z80A + bTemp + (cpu.z80F & Z80_FLAG_CARRY);
        !          15212:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15213:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15214:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15215:                                cpu.z80A = bTemp2;
        !          15216:                                break;
        !          15217:                        }
        !          15218:                        case 0x8f:
        !          15219:                        {
        !          15220:                                sdwCyclesRemaining -= 4;
        !          15221:                                bTemp2 = cpu.z80A + cpu.z80A + (cpu.z80F & Z80_FLAG_CARRY);
        !          15222:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15223:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15224:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | cpu.z80A | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15225:                                cpu.z80A = bTemp2;
        !          15226:                                break;
        !          15227:                        }
        !          15228:                        case 0x90:
        !          15229:                        {
        !          15230:                                sdwCyclesRemaining -= 4;
        !          15231:                                bTemp2 = cpu.z80A - cpu.z80B;
        !          15232:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15233:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15234:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B];
        !          15235:                                cpu.z80A = bTemp2;
        !          15236:                                break;
        !          15237:                        }
        !          15238:                        case 0x91:
        !          15239:                        {
        !          15240:                                sdwCyclesRemaining -= 4;
        !          15241:                                bTemp2 = cpu.z80A - cpu.z80C;
        !          15242:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15243:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15244:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C];
        !          15245:                                cpu.z80A = bTemp2;
        !          15246:                                break;
        !          15247:                        }
        !          15248:                        case 0x92:
        !          15249:                        {
        !          15250:                                sdwCyclesRemaining -= 4;
        !          15251:                                bTemp2 = cpu.z80A - cpu.z80D;
        !          15252:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15253:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15254:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D];
        !          15255:                                cpu.z80A = bTemp2;
        !          15256:                                break;
        !          15257:                        }
        !          15258:                        case 0x93:
        !          15259:                        {
        !          15260:                                sdwCyclesRemaining -= 4;
        !          15261:                                bTemp2 = cpu.z80A - cpu.z80E;
        !          15262:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15263:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15264:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E];
        !          15265:                                cpu.z80A = bTemp2;
        !          15266:                                break;
        !          15267:                        }
        !          15268:                        case 0x94:
        !          15269:                        {
        !          15270:                                sdwCyclesRemaining -= 4;
        !          15271:                                bTemp2 = cpu.z80A - cpu.z80H;
        !          15272:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15273:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15274:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H];
        !          15275:                                cpu.z80A = bTemp2;
        !          15276:                                break;
        !          15277:                        }
        !          15278:                        case 0x95:
        !          15279:                        {
        !          15280:                                sdwCyclesRemaining -= 4;
        !          15281:                                bTemp2 = cpu.z80A - cpu.z80L;
        !          15282:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15283:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15284:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L];
        !          15285:                                cpu.z80A = bTemp2;
        !          15286:                                break;
        !          15287:                        }
        !          15288:                        case 0x96:
        !          15289:                        {
        !          15290:                                sdwCyclesRemaining -= 7;
        !          15291:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15292:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15293:                                {
        !          15294:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          15295:                                        {
        !          15296:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15297:                                                if (psMemRead->memoryCall)
        !          15298:                                                {
        !          15299:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          15300:                                                }
        !          15301:                                                else
        !          15302:                                                {
        !          15303:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          15304:                                                }
        !          15305:                                                psMemRead = NULL;
        !          15306:                                                break;
        !          15307:                                        }
        !          15308:                                        ++psMemRead;
        !          15309:                                }
        !          15310: 
        !          15311:                                if (psMemRead)
        !          15312:                                {
        !          15313:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          15314:                                }
        !          15315: 
        !          15316:                                bTemp2 = cpu.z80A - bTemp;
        !          15317:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15318:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15319:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          15320:                                cpu.z80A = bTemp2;
        !          15321:                                break;
        !          15322:                        }
        !          15323:                        case 0x97:
        !          15324:                        {
        !          15325:                                sdwCyclesRemaining -= 4;
        !          15326:                                bTemp2 = cpu.z80A - cpu.z80A;
        !          15327:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15328:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15329:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A];
        !          15330:                                cpu.z80A = bTemp2;
        !          15331:                                break;
        !          15332:                        }
        !          15333:                        case 0x98:
        !          15334:                        {
        !          15335:                                sdwCyclesRemaining -= 4;
        !          15336:                                bTemp2 = cpu.z80A - cpu.z80B - (cpu.z80F & Z80_FLAG_CARRY);
        !          15337:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15338:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15339:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15340:                                cpu.z80A = bTemp2;
        !          15341:                                break;
        !          15342:                        }
        !          15343:                        case 0x99:
        !          15344:                        {
        !          15345:                                sdwCyclesRemaining -= 4;
        !          15346:                                bTemp2 = cpu.z80A - cpu.z80C - (cpu.z80F & Z80_FLAG_CARRY);
        !          15347:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15348:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15349:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15350:                                cpu.z80A = bTemp2;
        !          15351:                                break;
        !          15352:                        }
        !          15353:                        case 0x9a:
        !          15354:                        {
        !          15355:                                sdwCyclesRemaining -= 4;
        !          15356:                                bTemp2 = cpu.z80A - cpu.z80D - (cpu.z80F & Z80_FLAG_CARRY);
        !          15357:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15358:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15359:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15360:                                cpu.z80A = bTemp2;
        !          15361:                                break;
        !          15362:                        }
        !          15363:                        case 0x9b:
        !          15364:                        {
        !          15365:                                sdwCyclesRemaining -= 4;
        !          15366:                                bTemp2 = cpu.z80A - cpu.z80E - (cpu.z80F & Z80_FLAG_CARRY);
        !          15367:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15368:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15369:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15370:                                cpu.z80A = bTemp2;
        !          15371:                                break;
        !          15372:                        }
        !          15373:                        case 0x9c:
        !          15374:                        {
        !          15375:                                sdwCyclesRemaining -= 4;
        !          15376:                                bTemp2 = cpu.z80A - cpu.z80H - (cpu.z80F & Z80_FLAG_CARRY);
        !          15377:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15378:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15379:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15380:                                cpu.z80A = bTemp2;
        !          15381:                                break;
        !          15382:                        }
        !          15383:                        case 0x9d:
        !          15384:                        {
        !          15385:                                sdwCyclesRemaining -= 4;
        !          15386:                                bTemp2 = cpu.z80A - cpu.z80L - (cpu.z80F & Z80_FLAG_CARRY);
        !          15387:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15388:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15389:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15390:                                cpu.z80A = bTemp2;
        !          15391:                                break;
        !          15392:                        }
        !          15393:                        case 0x9e:
        !          15394:                        {
        !          15395:                                sdwCyclesRemaining -= 7;
        !          15396:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15397:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15398:                                {
        !          15399:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          15400:                                        {
        !          15401:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15402:                                                if (psMemRead->memoryCall)
        !          15403:                                                {
        !          15404:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          15405:                                                }
        !          15406:                                                else
        !          15407:                                                {
        !          15408:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          15409:                                                }
        !          15410:                                                psMemRead = NULL;
        !          15411:                                                break;
        !          15412:                                        }
        !          15413:                                        ++psMemRead;
        !          15414:                                }
        !          15415: 
        !          15416:                                if (psMemRead)
        !          15417:                                {
        !          15418:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          15419:                                }
        !          15420: 
        !          15421:                                bTemp2 = cpu.z80A - bTemp - (cpu.z80F & Z80_FLAG_CARRY);
        !          15422:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15423:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15424:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15425:                                cpu.z80A = bTemp2;
        !          15426:                                break;
        !          15427:                        }
        !          15428:                        case 0x9f:
        !          15429:                        {
        !          15430:                                sdwCyclesRemaining -= 4;
        !          15431:                                bTemp2 = cpu.z80A - cpu.z80A - (cpu.z80F & Z80_FLAG_CARRY);
        !          15432:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15433:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15434:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          15435:                                cpu.z80A = bTemp2;
        !          15436:                                break;
        !          15437:                        }
        !          15438:                        case 0xa0:
        !          15439:                        {
        !          15440:                                sdwCyclesRemaining -= 4;
        !          15441:                                cpu.z80A &= cpu.z80B;
        !          15442:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15443:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          15444: 
        !          15445:                                break;
        !          15446:                        }
        !          15447:                        case 0xa1:
        !          15448:                        {
        !          15449:                                sdwCyclesRemaining -= 4;
        !          15450:                                cpu.z80A &= cpu.z80C;
        !          15451:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15452:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          15453: 
        !          15454:                                break;
        !          15455:                        }
        !          15456:                        case 0xa2:
        !          15457:                        {
        !          15458:                                sdwCyclesRemaining -= 4;
        !          15459:                                cpu.z80A &= cpu.z80D;
        !          15460:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15461:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          15462: 
        !          15463:                                break;
        !          15464:                        }
        !          15465:                        case 0xa3:
        !          15466:                        {
        !          15467:                                sdwCyclesRemaining -= 4;
        !          15468:                                cpu.z80A &= cpu.z80E;
        !          15469:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15470:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          15471: 
        !          15472:                                break;
        !          15473:                        }
        !          15474:                        case 0xa4:
        !          15475:                        {
        !          15476:                                sdwCyclesRemaining -= 4;
        !          15477:                                cpu.z80A &= cpu.z80H;
        !          15478:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15479:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          15480: 
        !          15481:                                break;
        !          15482:                        }
        !          15483:                        case 0xa5:
        !          15484:                        {
        !          15485:                                sdwCyclesRemaining -= 4;
        !          15486:                                cpu.z80A &= cpu.z80L;
        !          15487:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15488:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          15489: 
        !          15490:                                break;
        !          15491:                        }
        !          15492:                        case 0xa6:
        !          15493:                        {
        !          15494:                                sdwCyclesRemaining -= 7;
        !          15495:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15496:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15497:                                {
        !          15498:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          15499:                                        {
        !          15500:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15501:                                                if (psMemRead->memoryCall)
        !          15502:                                                {
        !          15503:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          15504:                                                }
        !          15505:                                                else
        !          15506:                                                {
        !          15507:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          15508:                                                }
        !          15509:                                                psMemRead = NULL;
        !          15510:                                                break;
        !          15511:                                        }
        !          15512:                                        ++psMemRead;
        !          15513:                                }
        !          15514: 
        !          15515:                                if (psMemRead)
        !          15516:                                {
        !          15517:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          15518:                                }
        !          15519: 
        !          15520:                                cpu.z80A &= bTemp;
        !          15521:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15522:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          15523: 
        !          15524:                                break;
        !          15525:                        }
        !          15526:                        case 0xa7:
        !          15527:                        {
        !          15528:                                sdwCyclesRemaining -= 4;
        !          15529:                                cpu.z80A &= cpu.z80A;
        !          15530:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15531:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          15532: 
        !          15533:                                break;
        !          15534:                        }
        !          15535:                        case 0xa8:
        !          15536:                        {
        !          15537:                                sdwCyclesRemaining -= 4;
        !          15538:                                cpu.z80A ^= cpu.z80B;
        !          15539:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15540:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15541: 
        !          15542:                                break;
        !          15543:                        }
        !          15544:                        case 0xa9:
        !          15545:                        {
        !          15546:                                sdwCyclesRemaining -= 4;
        !          15547:                                cpu.z80A ^= cpu.z80C;
        !          15548:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15549:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15550: 
        !          15551:                                break;
        !          15552:                        }
        !          15553:                        case 0xaa:
        !          15554:                        {
        !          15555:                                sdwCyclesRemaining -= 4;
        !          15556:                                cpu.z80A ^= cpu.z80D;
        !          15557:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15558:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15559: 
        !          15560:                                break;
        !          15561:                        }
        !          15562:                        case 0xab:
        !          15563:                        {
        !          15564:                                sdwCyclesRemaining -= 4;
        !          15565:                                cpu.z80A ^= cpu.z80E;
        !          15566:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15567:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15568: 
        !          15569:                                break;
        !          15570:                        }
        !          15571:                        case 0xac:
        !          15572:                        {
        !          15573:                                sdwCyclesRemaining -= 4;
        !          15574:                                cpu.z80A ^= cpu.z80H;
        !          15575:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15576:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15577: 
        !          15578:                                break;
        !          15579:                        }
        !          15580:                        case 0xad:
        !          15581:                        {
        !          15582:                                sdwCyclesRemaining -= 4;
        !          15583:                                cpu.z80A ^= cpu.z80L;
        !          15584:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15585:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15586: 
        !          15587:                                break;
        !          15588:                        }
        !          15589:                        case 0xae:
        !          15590:                        {
        !          15591:                                sdwCyclesRemaining -= 7;
        !          15592:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15593:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15594:                                {
        !          15595:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          15596:                                        {
        !          15597:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15598:                                                if (psMemRead->memoryCall)
        !          15599:                                                {
        !          15600:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          15601:                                                }
        !          15602:                                                else
        !          15603:                                                {
        !          15604:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          15605:                                                }
        !          15606:                                                psMemRead = NULL;
        !          15607:                                                break;
        !          15608:                                        }
        !          15609:                                        ++psMemRead;
        !          15610:                                }
        !          15611: 
        !          15612:                                if (psMemRead)
        !          15613:                                {
        !          15614:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          15615:                                }
        !          15616: 
        !          15617:                                cpu.z80A ^= bTemp;
        !          15618:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15619:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15620: 
        !          15621:                                break;
        !          15622:                        }
        !          15623:                        case 0xaf:
        !          15624:                        {
        !          15625:                                sdwCyclesRemaining -= 4;
        !          15626:                                cpu.z80A ^= cpu.z80A;
        !          15627:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15628:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15629: 
        !          15630:                                break;
        !          15631:                        }
        !          15632:                        case 0xb0:
        !          15633:                        {
        !          15634:                                sdwCyclesRemaining -= 4;
        !          15635:                                cpu.z80A |= cpu.z80B;
        !          15636:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15637:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15638: 
        !          15639:                                break;
        !          15640:                        }
        !          15641:                        case 0xb1:
        !          15642:                        {
        !          15643:                                sdwCyclesRemaining -= 4;
        !          15644:                                cpu.z80A |= cpu.z80C;
        !          15645:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15646:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15647: 
        !          15648:                                break;
        !          15649:                        }
        !          15650:                        case 0xb2:
        !          15651:                        {
        !          15652:                                sdwCyclesRemaining -= 4;
        !          15653:                                cpu.z80A |= cpu.z80D;
        !          15654:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15655:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15656: 
        !          15657:                                break;
        !          15658:                        }
        !          15659:                        case 0xb3:
        !          15660:                        {
        !          15661:                                sdwCyclesRemaining -= 4;
        !          15662:                                cpu.z80A |= cpu.z80E;
        !          15663:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15664:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15665: 
        !          15666:                                break;
        !          15667:                        }
        !          15668:                        case 0xb4:
        !          15669:                        {
        !          15670:                                sdwCyclesRemaining -= 4;
        !          15671:                                cpu.z80A |= cpu.z80H;
        !          15672:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15673:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15674: 
        !          15675:                                break;
        !          15676:                        }
        !          15677:                        case 0xb5:
        !          15678:                        {
        !          15679:                                sdwCyclesRemaining -= 4;
        !          15680:                                cpu.z80A |= cpu.z80L;
        !          15681:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15682:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15683: 
        !          15684:                                break;
        !          15685:                        }
        !          15686:                        case 0xb6:
        !          15687:                        {
        !          15688:                                sdwCyclesRemaining -= 7;
        !          15689:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15690:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15691:                                {
        !          15692:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          15693:                                        {
        !          15694:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15695:                                                if (psMemRead->memoryCall)
        !          15696:                                                {
        !          15697:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          15698:                                                }
        !          15699:                                                else
        !          15700:                                                {
        !          15701:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          15702:                                                }
        !          15703:                                                psMemRead = NULL;
        !          15704:                                                break;
        !          15705:                                        }
        !          15706:                                        ++psMemRead;
        !          15707:                                }
        !          15708: 
        !          15709:                                if (psMemRead)
        !          15710:                                {
        !          15711:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          15712:                                }
        !          15713: 
        !          15714:                                cpu.z80A |= bTemp;
        !          15715:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15716:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15717: 
        !          15718:                                break;
        !          15719:                        }
        !          15720:                        case 0xb7:
        !          15721:                        {
        !          15722:                                sdwCyclesRemaining -= 4;
        !          15723:                                cpu.z80A |= cpu.z80A;
        !          15724:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          15725:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          15726: 
        !          15727:                                break;
        !          15728:                        }
        !          15729:                        case 0xb8:
        !          15730:                        {
        !          15731:                                sdwCyclesRemaining -= 4;
        !          15732:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15733:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15734:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80B];
        !          15735:                                break;
        !          15736:                        }
        !          15737:                        case 0xb9:
        !          15738:                        {
        !          15739:                                sdwCyclesRemaining -= 4;
        !          15740:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15741:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15742:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80C];
        !          15743:                                break;
        !          15744:                        }
        !          15745:                        case 0xba:
        !          15746:                        {
        !          15747:                                sdwCyclesRemaining -= 4;
        !          15748:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15749:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15750:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80D];
        !          15751:                                break;
        !          15752:                        }
        !          15753:                        case 0xbb:
        !          15754:                        {
        !          15755:                                sdwCyclesRemaining -= 4;
        !          15756:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15757:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15758:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80E];
        !          15759:                                break;
        !          15760:                        }
        !          15761:                        case 0xbc:
        !          15762:                        {
        !          15763:                                sdwCyclesRemaining -= 4;
        !          15764:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15765:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15766:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80H];
        !          15767:                                break;
        !          15768:                        }
        !          15769:                        case 0xbd:
        !          15770:                        {
        !          15771:                                sdwCyclesRemaining -= 4;
        !          15772:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15773:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15774:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80L];
        !          15775:                                break;
        !          15776:                        }
        !          15777:                        case 0xbe:
        !          15778:                        {
        !          15779:                                sdwCyclesRemaining -= 7;
        !          15780:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15781:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15782:                                {
        !          15783:                                        if ((cpu.z80HL >= psMemRead->lowAddr) && (cpu.z80HL <= psMemRead->highAddr))
        !          15784:                                        {
        !          15785:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15786:                                                if (psMemRead->memoryCall)
        !          15787:                                                {
        !          15788:                                                        bTemp = psMemRead->memoryCall(cpu.z80HL, psMemRead);
        !          15789:                                                }
        !          15790:                                                else
        !          15791:                                                {
        !          15792:                                                        bTemp = *((UINT8 *) psMemRead->pUserArea + (cpu.z80HL - psMemRead->lowAddr));
        !          15793:                                                }
        !          15794:                                                psMemRead = NULL;
        !          15795:                                                break;
        !          15796:                                        }
        !          15797:                                        ++psMemRead;
        !          15798:                                }
        !          15799: 
        !          15800:                                if (psMemRead)
        !          15801:                                {
        !          15802:                                        bTemp = cpu.z80Base[cpu.z80HL];
        !          15803:                                }
        !          15804: 
        !          15805:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15806:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15807:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          15808:                                break;
        !          15809:                        }
        !          15810:                        case 0xbf:
        !          15811:                        {
        !          15812:                                sdwCyclesRemaining -= 4;
        !          15813:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15814:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15815:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | cpu.z80A];
        !          15816:                                break;
        !          15817:                        }
        !          15818:                        case 0xc0:
        !          15819:                        {
        !          15820:                                sdwCyclesRemaining -= 5;
        !          15821:                                if (!(cpu.z80F & Z80_FLAG_ZERO))
        !          15822:                                {
        !          15823:                                        dwElapsedTicks += 6;
        !          15824:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          15825:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          15826:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          15827:                                cpu.z80sp += 2; /* Pop the word off */
        !          15828:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          15829:                                }
        !          15830:                                break;
        !          15831:                        }
        !          15832:                        case 0xc1:
        !          15833:                        {
        !          15834:                                sdwCyclesRemaining -= 10;
        !          15835:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          15836:                                while (psMemRead->lowAddr != 0xffffffff)
        !          15837:                                {
        !          15838:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          15839:                                        {
        !          15840:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15841:                                                if (psMemRead->memoryCall)
        !          15842:                                                {
        !          15843:                                                        cpu.z80BC = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          15844:                                                        cpu.z80BC |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          15845:                                                }
        !          15846:                                                else
        !          15847:                                                {
        !          15848:                                                        cpu.z80BC = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          15849:                                                        cpu.z80BC |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          15850:                                                }
        !          15851:                                                psMemRead = NULL;
        !          15852:                                                break;
        !          15853:                                        }
        !          15854:                                        ++psMemRead;
        !          15855:                                }
        !          15856: 
        !          15857:                                if (psMemRead)
        !          15858:                                {
        !          15859:                                        cpu.z80BC = cpu.z80Base[cpu.z80sp];
        !          15860:                                        cpu.z80BC |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          15861:                                }
        !          15862: 
        !          15863:                                        cpu.z80sp += 2;
        !          15864:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          15865:                                break;
        !          15866:                        }
        !          15867:                        case 0xc2:
        !          15868:                        {
        !          15869:                                sdwCyclesRemaining -= 10;
        !          15870:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          15871:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          15872:                                if (!(cpu.z80F & Z80_FLAG_ZERO))
        !          15873:                                {
        !          15874:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          15875:                                }
        !          15876:                                break;
        !          15877:                        }
        !          15878:                        case 0xc3:
        !          15879:                        {
        !          15880:                                sdwCyclesRemaining -= 10;
        !          15881:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          15882:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          15883:                                pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          15884:                                break;
        !          15885:                        }
        !          15886:                        case 0xc4:
        !          15887:                        {
        !          15888:                                sdwCyclesRemaining -= 10;
        !          15889:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          15890:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          15891:                                if (!(cpu.z80F & Z80_FLAG_ZERO))
        !          15892:                                {
        !          15893:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15894:                                        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          15895:                                        *pbSP-- = cpu.z80pc >> 8;       /* MSB */
        !          15896:                                        *pbSP = (UINT8) cpu.z80pc;      /* LSB */
        !          15897:                                        cpu.z80sp -= 2; /* Back our stack up */
        !          15898:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          15899:                                }
        !          15900:                                break;
        !          15901:                        }
        !          15902:                        case 0xc5:
        !          15903:                        {
        !          15904:                                sdwCyclesRemaining -= 11;
        !          15905:                                        cpu.z80sp -= 2;
        !          15906:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          15907:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          15908:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          15909:                                {
        !          15910:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          15911:                                        {
        !          15912:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15913:                                                if (psMemWrite->memoryCall)
        !          15914:                                                {
        !          15915:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80BC & 0xff), psMemWrite);
        !          15916:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80BC >> 8), psMemWrite);
        !          15917:                                                }
        !          15918:                                                else
        !          15919:                                                {
        !          15920:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80BC;
        !          15921:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80BC >> 8;
        !          15922:                                                }
        !          15923:                                                psMemWrite = NULL;
        !          15924:                                                break;
        !          15925:                                        }
        !          15926:                                        ++psMemWrite;
        !          15927:                                }
        !          15928: 
        !          15929:                                if (psMemWrite)
        !          15930:                                {
        !          15931:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80BC;
        !          15932:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80BC >> 8);
        !          15933:                                }
        !          15934: 
        !          15935:                                break;
        !          15936:                        }
        !          15937:                        case 0xc6:
        !          15938:                        {
        !          15939:                                sdwCyclesRemaining -= 7;
        !          15940:                                bTemp = *pbPC++;
        !          15941:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          15942:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          15943:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          15944:                                cpu.z80A += bTemp;
        !          15945:                                break;
        !          15946:                        }
        !          15947:                        case 0xc7:
        !          15948:                        {
        !          15949:                                sdwCyclesRemaining -= 11;
        !          15950:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          15951:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          15952:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          15953:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          15954:                                cpu.z80sp -= 2; /* Back our stack up */
        !          15955:                                pbPC = cpu.z80Base + 0x00;      /* Normalize the address */
        !          15956:                                break;
        !          15957:                        }
        !          15958:                        case 0xc8:
        !          15959:                        {
        !          15960:                                sdwCyclesRemaining -= 5;
        !          15961:                                if (cpu.z80F & Z80_FLAG_ZERO)
        !          15962:                                {
        !          15963:                                        dwElapsedTicks += 6;
        !          15964:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          15965:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          15966:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          15967:                                cpu.z80sp += 2; /* Pop the word off */
        !          15968:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          15969:                                }
        !          15970:                                break;
        !          15971:                        }
        !          15972:                        case 0xc9:
        !          15973:                        {
        !          15974:                                sdwCyclesRemaining -= 10;
        !          15975:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          15976:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          15977:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          15978:                                cpu.z80sp += 2; /* Pop the word off */
        !          15979:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          15980:                                break;
        !          15981:                        }
        !          15982:                        case 0xca:
        !          15983:                        {
        !          15984:                                sdwCyclesRemaining -= 10;
        !          15985:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          15986:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          15987:                                if (cpu.z80F & Z80_FLAG_ZERO)
        !          15988:                                {
        !          15989:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          15990:                                }
        !          15991:                                break;
        !          15992:                        }
        !          15993:                        case 0xcb:
        !          15994:                        {
        !          15995:                                CBHandler();
        !          15996:                                break;
        !          15997:                        }
        !          15998:                        case 0xcc:
        !          15999:                        {
        !          16000:                                sdwCyclesRemaining -= 10;
        !          16001:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          16002:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16003:                                if (cpu.z80F & Z80_FLAG_ZERO)
        !          16004:                                {
        !          16005:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16006:                                        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16007:                                        *pbSP-- = cpu.z80pc >> 8;       /* MSB */
        !          16008:                                        *pbSP = (UINT8) cpu.z80pc;      /* LSB */
        !          16009:                                        cpu.z80sp -= 2; /* Back our stack up */
        !          16010:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16011:                                }
        !          16012:                                break;
        !          16013:                        }
        !          16014:                        case 0xcd:
        !          16015:                        {
        !          16016:                                sdwCyclesRemaining -= 17;
        !          16017:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          16018:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16019:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16020:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16021:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16022:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16023:                                cpu.z80sp -= 2; /* Back our stack up */
        !          16024:                                pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16025:                                break;
        !          16026:                        }
        !          16027:                        case 0xce:
        !          16028:                        {
        !          16029:                                sdwCyclesRemaining -= 7;
        !          16030:                                bTemp = *pbPC++ + (cpu.z80F & Z80_FLAG_CARRY);
        !          16031:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          16032:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          16033:                                                                pbAddAdcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          16034:                                cpu.z80A += bTemp;
        !          16035:                                break;
        !          16036:                        }
        !          16037:                        case 0xcf:
        !          16038:                        {
        !          16039:                                sdwCyclesRemaining -= 11;
        !          16040:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16041:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16042:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16043:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16044:                                cpu.z80sp -= 2; /* Back our stack up */
        !          16045:                                pbPC = cpu.z80Base + 0x08;      /* Normalize the address */
        !          16046:                                break;
        !          16047:                        }
        !          16048:                        case 0xd0:
        !          16049:                        {
        !          16050:                                sdwCyclesRemaining -= 5;
        !          16051:                                if (!(cpu.z80F & Z80_FLAG_CARRY))
        !          16052:                                {
        !          16053:                                        dwElapsedTicks += 6;
        !          16054:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          16055:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          16056:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          16057:                                cpu.z80sp += 2; /* Pop the word off */
        !          16058:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          16059:                                }
        !          16060:                                break;
        !          16061:                        }
        !          16062:                        case 0xd1:
        !          16063:                        {
        !          16064:                                sdwCyclesRemaining -= 10;
        !          16065:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          16066:                                while (psMemRead->lowAddr != 0xffffffff)
        !          16067:                                {
        !          16068:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          16069:                                        {
        !          16070:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16071:                                                if (psMemRead->memoryCall)
        !          16072:                                                {
        !          16073:                                                        cpu.z80DE = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          16074:                                                        cpu.z80DE |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          16075:                                                }
        !          16076:                                                else
        !          16077:                                                {
        !          16078:                                                        cpu.z80DE = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          16079:                                                        cpu.z80DE |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          16080:                                                }
        !          16081:                                                psMemRead = NULL;
        !          16082:                                                break;
        !          16083:                                        }
        !          16084:                                        ++psMemRead;
        !          16085:                                }
        !          16086: 
        !          16087:                                if (psMemRead)
        !          16088:                                {
        !          16089:                                        cpu.z80DE = cpu.z80Base[cpu.z80sp];
        !          16090:                                        cpu.z80DE |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          16091:                                }
        !          16092: 
        !          16093:                                        cpu.z80sp += 2;
        !          16094:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          16095:                                break;
        !          16096:                        }
        !          16097:                        case 0xd2:
        !          16098:                        {
        !          16099:                                sdwCyclesRemaining -= 10;
        !          16100:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          16101:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16102:                                if (!(cpu.z80F & Z80_FLAG_CARRY))
        !          16103:                                {
        !          16104:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16105:                                }
        !          16106:                                break;
        !          16107:                        }
        !          16108:                        case 0xd3:
        !          16109:                        {
        !          16110:                                sdwCyclesRemaining -= 11;
        !          16111:                        dwTemp = *pbPC++;
        !          16112:                                psIoWrite = cpu.z80IoWrite;     /* Beginning of our handler */
        !          16113:                                while (psIoWrite->lowIoAddr != 0xffff)
        !          16114:                                {
        !          16115:                                        if ((dwTemp >= psIoWrite->lowIoAddr) && (dwTemp <= psIoWrite->highIoAddr))
        !          16116:                                        {
        !          16117:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16118:                                                psIoWrite->IOCall(dwTemp, cpu.z80A, psIoWrite);
        !          16119:                                                psIoWrite = NULL;
        !          16120:                                                break;
        !          16121:                                        }
        !          16122:                                        ++psIoWrite;
        !          16123:                                }
        !          16124: 
        !          16125:                                break;
        !          16126:                        }
        !          16127:                        case 0xd4:
        !          16128:                        {
        !          16129:                                sdwCyclesRemaining -= 10;
        !          16130:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          16131:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16132:                                if (!(cpu.z80F & Z80_FLAG_CARRY))
        !          16133:                                {
        !          16134:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16135:                                        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16136:                                        *pbSP-- = cpu.z80pc >> 8;       /* MSB */
        !          16137:                                        *pbSP = (UINT8) cpu.z80pc;      /* LSB */
        !          16138:                                        cpu.z80sp -= 2; /* Back our stack up */
        !          16139:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16140:                                }
        !          16141:                                break;
        !          16142:                        }
        !          16143:                        case 0xd5:
        !          16144:                        {
        !          16145:                                sdwCyclesRemaining -= 11;
        !          16146:                                        cpu.z80sp -= 2;
        !          16147:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          16148:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          16149:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          16150:                                {
        !          16151:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          16152:                                        {
        !          16153:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16154:                                                if (psMemWrite->memoryCall)
        !          16155:                                                {
        !          16156:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80DE & 0xff), psMemWrite);
        !          16157:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80DE >> 8), psMemWrite);
        !          16158:                                                }
        !          16159:                                                else
        !          16160:                                                {
        !          16161:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80DE;
        !          16162:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80DE >> 8;
        !          16163:                                                }
        !          16164:                                                psMemWrite = NULL;
        !          16165:                                                break;
        !          16166:                                        }
        !          16167:                                        ++psMemWrite;
        !          16168:                                }
        !          16169: 
        !          16170:                                if (psMemWrite)
        !          16171:                                {
        !          16172:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80DE;
        !          16173:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80DE >> 8);
        !          16174:                                }
        !          16175: 
        !          16176:                                break;
        !          16177:                        }
        !          16178:                        case 0xd6:
        !          16179:                        {
        !          16180:                                sdwCyclesRemaining -= 7;
        !          16181:                                bTemp = *pbPC++;
        !          16182:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          16183:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          16184:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp];
        !          16185:                                cpu.z80A -= bTemp;
        !          16186:                                break;
        !          16187:                        }
        !          16188:                        case 0xd7:
        !          16189:                        {
        !          16190:                                sdwCyclesRemaining -= 11;
        !          16191:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16192:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16193:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16194:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16195:                                cpu.z80sp -= 2; /* Back our stack up */
        !          16196:                                pbPC = cpu.z80Base + 0x10;      /* Normalize the address */
        !          16197:                                break;
        !          16198:                        }
        !          16199:                        case 0xd8:
        !          16200:                        {
        !          16201:                                sdwCyclesRemaining -= 5;
        !          16202:                                if (cpu.z80F & Z80_FLAG_CARRY)
        !          16203:                                {
        !          16204:                                        dwElapsedTicks += 6;
        !          16205:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          16206:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          16207:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          16208:                                cpu.z80sp += 2; /* Pop the word off */
        !          16209:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          16210:                                }
        !          16211:                                break;
        !          16212:                        }
        !          16213:                        case 0xd9:
        !          16214:                        {
        !          16215:                                sdwCyclesRemaining -= 4;
        !          16216:                                dwTemp = cpu.z80DE;
        !          16217:                                cpu.z80DE = cpu.z80deprime;
        !          16218:                                cpu.z80deprime = dwTemp;
        !          16219:                                dwTemp = cpu.z80BC;
        !          16220:                                cpu.z80BC = cpu.z80bcprime;
        !          16221:                                cpu.z80bcprime = dwTemp;
        !          16222:                                dwTemp = cpu.z80HL;
        !          16223:                                cpu.z80HL = cpu.z80hlprime;
        !          16224:                                cpu.z80hlprime = dwTemp;
        !          16225:                                break;
        !          16226:                        }
        !          16227:                        case 0xda:
        !          16228:                        {
        !          16229:                                sdwCyclesRemaining -= 10;
        !          16230:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          16231:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16232:                                if (cpu.z80F & Z80_FLAG_CARRY)
        !          16233:                                {
        !          16234:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16235:                                }
        !          16236:                                break;
        !          16237:                        }
        !          16238:                        case 0xdb:
        !          16239:                        {
        !          16240:                                sdwCyclesRemaining -= 11;
        !          16241:                        dwTemp = *pbPC++;
        !          16242:                                psIoRead = cpu.z80IoRead;       /* Beginning of our handler */
        !          16243:                                while (psIoRead->lowIoAddr != 0xffff)
        !          16244:                                {
        !          16245:                                        if ((dwTemp >= psIoRead->lowIoAddr) && (dwTemp <= psIoRead->highIoAddr))
        !          16246:                                        {
        !          16247:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16248:                                                cpu.z80A = psIoRead->IOCall(dwTemp, psIoRead);
        !          16249:                                                psIoRead = NULL;
        !          16250:                                                break;
        !          16251:                                        }
        !          16252:                                        ++psIoRead;
        !          16253:                                }
        !          16254: 
        !          16255:                                if (psIoRead)
        !          16256:                                {
        !          16257:                                        cpu.z80A = 0xff; /* Unclaimed I/O read */
        !          16258:                                }
        !          16259: 
        !          16260:                                break;
        !          16261:                        }
        !          16262:                        case 0xdc:
        !          16263:                        {
        !          16264:                                sdwCyclesRemaining -= 10;
        !          16265:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          16266:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16267:                                if (cpu.z80F & Z80_FLAG_CARRY)
        !          16268:                                {
        !          16269:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16270:                                        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16271:                                        *pbSP-- = cpu.z80pc >> 8;       /* MSB */
        !          16272:                                        *pbSP = (UINT8) cpu.z80pc;      /* LSB */
        !          16273:                                        cpu.z80sp -= 2; /* Back our stack up */
        !          16274:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16275:                                }
        !          16276:                                break;
        !          16277:                        }
        !          16278:                        case 0xdd:
        !          16279:                        {
        !          16280:                                DDHandler();
        !          16281:                                break;
        !          16282:                        }
        !          16283:                        case 0xde:
        !          16284:                        {
        !          16285:                                sdwCyclesRemaining -= 7;
        !          16286:                                bTemp = *pbPC++ + (cpu.z80F & Z80_FLAG_CARRY);
        !          16287:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          16288:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          16289:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | bTemp | (((UINT32) cpu.z80F & Z80_FLAG_CARRY) << 16)];
        !          16290:                                cpu.z80A = cpu.z80A - bTemp;
        !          16291:                                break;
        !          16292:                        }
        !          16293:                        case 0xdf:
        !          16294:                        {
        !          16295:                                sdwCyclesRemaining -= 11;
        !          16296:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16297:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16298:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16299:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16300:                                cpu.z80sp -= 2; /* Back our stack up */
        !          16301:                                pbPC = cpu.z80Base + 0x18;      /* Normalize the address */
        !          16302:                                break;
        !          16303:                        }
        !          16304:                        case 0xe0:
        !          16305:                        {
        !          16306:                                sdwCyclesRemaining -= 5;
        !          16307:                                if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY))
        !          16308:                                {
        !          16309:                                        dwElapsedTicks += 6;
        !          16310:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          16311:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          16312:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          16313:                                cpu.z80sp += 2; /* Pop the word off */
        !          16314:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          16315:                                }
        !          16316:                                break;
        !          16317:                        }
        !          16318:                        case 0xe1:
        !          16319:                        {
        !          16320:                                sdwCyclesRemaining -= 10;
        !          16321:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          16322:                                while (psMemRead->lowAddr != 0xffffffff)
        !          16323:                                {
        !          16324:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          16325:                                        {
        !          16326:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16327:                                                if (psMemRead->memoryCall)
        !          16328:                                                {
        !          16329:                                                        cpu.z80HL = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          16330:                                                        cpu.z80HL |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          16331:                                                }
        !          16332:                                                else
        !          16333:                                                {
        !          16334:                                                        cpu.z80HL = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          16335:                                                        cpu.z80HL |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          16336:                                                }
        !          16337:                                                psMemRead = NULL;
        !          16338:                                                break;
        !          16339:                                        }
        !          16340:                                        ++psMemRead;
        !          16341:                                }
        !          16342: 
        !          16343:                                if (psMemRead)
        !          16344:                                {
        !          16345:                                        cpu.z80HL = cpu.z80Base[cpu.z80sp];
        !          16346:                                        cpu.z80HL |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          16347:                                }
        !          16348: 
        !          16349:                                        cpu.z80sp += 2;
        !          16350:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          16351:                                break;
        !          16352:                        }
        !          16353:                        case 0xe2:
        !          16354:                        {
        !          16355:                                sdwCyclesRemaining -= 10;
        !          16356:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          16357:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16358:                                if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY))
        !          16359:                                {
        !          16360:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16361:                                }
        !          16362:                                break;
        !          16363:                        }
        !          16364:                        case 0xe3:
        !          16365:                        {
        !          16366:                                sdwCyclesRemaining -= 19;
        !          16367:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          16368:                                while (psMemRead->lowAddr != 0xffffffff)
        !          16369:                                {
        !          16370:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          16371:                                        {
        !          16372:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16373:                                                if (psMemRead->memoryCall)
        !          16374:                                                {
        !          16375:                                                        dwAddr = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          16376:                                                        dwAddr |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          16377:                                                }
        !          16378:                                                else
        !          16379:                                                {
        !          16380:                                                        dwAddr = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          16381:                                                        dwAddr |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          16382:                                                }
        !          16383:                                                psMemRead = NULL;
        !          16384:                                                break;
        !          16385:                                        }
        !          16386:                                        ++psMemRead;
        !          16387:                                }
        !          16388: 
        !          16389:                                if (psMemRead)
        !          16390:                                {
        !          16391:                                        dwAddr = cpu.z80Base[cpu.z80sp];
        !          16392:                                        dwAddr |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          16393:                                }
        !          16394: 
        !          16395:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          16396:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          16397:                                {
        !          16398:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          16399:                                        {
        !          16400:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16401:                                                if (psMemWrite->memoryCall)
        !          16402:                                                {
        !          16403:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80HL & 0xff), psMemWrite);
        !          16404:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80HL >> 8), psMemWrite);
        !          16405:                                                }
        !          16406:                                                else
        !          16407:                                                {
        !          16408:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80HL;
        !          16409:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8;
        !          16410:                                                }
        !          16411:                                                psMemWrite = NULL;
        !          16412:                                                break;
        !          16413:                                        }
        !          16414:                                        ++psMemWrite;
        !          16415:                                }
        !          16416: 
        !          16417:                                if (psMemWrite)
        !          16418:                                {
        !          16419:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80HL;
        !          16420:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8);
        !          16421:                                }
        !          16422: 
        !          16423:                                cpu.z80HL = dwAddr;
        !          16424:                                break;
        !          16425:                        }
        !          16426:                        case 0xe4:
        !          16427:                        {
        !          16428:                                sdwCyclesRemaining -= 10;
        !          16429:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          16430:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16431:                                if (!(cpu.z80F & Z80_FLAG_OVERFLOW_PARITY))
        !          16432:                                {
        !          16433:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16434:                                        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16435:                                        *pbSP-- = cpu.z80pc >> 8;       /* MSB */
        !          16436:                                        *pbSP = (UINT8) cpu.z80pc;      /* LSB */
        !          16437:                                        cpu.z80sp -= 2; /* Back our stack up */
        !          16438:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16439:                                }
        !          16440:                                break;
        !          16441:                        }
        !          16442:                        case 0xe5:
        !          16443:                        {
        !          16444:                                sdwCyclesRemaining -= 11;
        !          16445:                                        cpu.z80sp -= 2;
        !          16446:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          16447:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          16448:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          16449:                                {
        !          16450:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          16451:                                        {
        !          16452:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16453:                                                if (psMemWrite->memoryCall)
        !          16454:                                                {
        !          16455:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80HL & 0xff), psMemWrite);
        !          16456:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80HL >> 8), psMemWrite);
        !          16457:                                                }
        !          16458:                                                else
        !          16459:                                                {
        !          16460:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80HL;
        !          16461:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80HL >> 8;
        !          16462:                                                }
        !          16463:                                                psMemWrite = NULL;
        !          16464:                                                break;
        !          16465:                                        }
        !          16466:                                        ++psMemWrite;
        !          16467:                                }
        !          16468: 
        !          16469:                                if (psMemWrite)
        !          16470:                                {
        !          16471:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80HL;
        !          16472:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80HL >> 8);
        !          16473:                                }
        !          16474: 
        !          16475:                                break;
        !          16476:                        }
        !          16477:                        case 0xe6:
        !          16478:                        {
        !          16479:                                sdwCyclesRemaining -= 7;
        !          16480:                                cpu.z80A &= *pbPC++;
        !          16481:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          16482:                                cpu.z80F |= bPostANDFlags[cpu.z80A];
        !          16483: 
        !          16484:                                break;
        !          16485:                        }
        !          16486:                        case 0xe7:
        !          16487:                        {
        !          16488:                                sdwCyclesRemaining -= 11;
        !          16489:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16490:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16491:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16492:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16493:                                cpu.z80sp -= 2; /* Back our stack up */
        !          16494:                                pbPC = cpu.z80Base + 0x20;      /* Normalize the address */
        !          16495:                                break;
        !          16496:                        }
        !          16497:                        case 0xe8:
        !          16498:                        {
        !          16499:                                sdwCyclesRemaining -= 5;
        !          16500:                                if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)
        !          16501:                                {
        !          16502:                                        dwElapsedTicks += 6;
        !          16503:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          16504:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          16505:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          16506:                                cpu.z80sp += 2; /* Pop the word off */
        !          16507:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          16508:                                }
        !          16509:                                break;
        !          16510:                        }
        !          16511:                        case 0xe9:
        !          16512:                        {
        !          16513:                                sdwCyclesRemaining -= 4;
        !          16514:                                pbPC = cpu.z80Base + cpu.z80HL;
        !          16515:                                break;
        !          16516:                        }
        !          16517:                        case 0xea:
        !          16518:                        {
        !          16519:                                sdwCyclesRemaining -= 10;
        !          16520:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          16521:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16522:                                if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)
        !          16523:                                {
        !          16524:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16525:                                }
        !          16526:                                break;
        !          16527:                        }
        !          16528:                        case 0xeb:
        !          16529:                        {
        !          16530:                                sdwCyclesRemaining -= 4;
        !          16531:                                dwAddr = cpu.z80DE;
        !          16532:                                cpu.z80DE = cpu.z80HL;
        !          16533:                                cpu.z80HL = dwAddr;
        !          16534:                                break;
        !          16535:                        }
        !          16536:                        case 0xec:
        !          16537:                        {
        !          16538:                                sdwCyclesRemaining -= 10;
        !          16539:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          16540:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16541:                                if (cpu.z80F & Z80_FLAG_OVERFLOW_PARITY)
        !          16542:                                {
        !          16543:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16544:                                        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16545:                                        *pbSP-- = cpu.z80pc >> 8;       /* MSB */
        !          16546:                                        *pbSP = (UINT8) cpu.z80pc;      /* LSB */
        !          16547:                                        cpu.z80sp -= 2; /* Back our stack up */
        !          16548:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16549:                                }
        !          16550:                                break;
        !          16551:                        }
        !          16552:                        case 0xed:
        !          16553:                        {
        !          16554:                                EDHandler();
        !          16555:                                break;
        !          16556:                        }
        !          16557:                        case 0xee:
        !          16558:                        {
        !          16559:                                sdwCyclesRemaining -= 7;
        !          16560:                                cpu.z80A ^= *pbPC++;
        !          16561:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          16562:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          16563: 
        !          16564:                                break;
        !          16565:                        }
        !          16566:                        case 0xef:
        !          16567:                        {
        !          16568:                                sdwCyclesRemaining -= 11;
        !          16569:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16570:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16571:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16572:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16573:                                cpu.z80sp -= 2; /* Back our stack up */
        !          16574:                                pbPC = cpu.z80Base + 0x28;      /* Normalize the address */
        !          16575:                                break;
        !          16576:                        }
        !          16577:                        case 0xf0:
        !          16578:                        {
        !          16579:                                sdwCyclesRemaining -= 5;
        !          16580:                                if (!(cpu.z80F & Z80_FLAG_SIGN))
        !          16581:                                {
        !          16582:                                        dwElapsedTicks += 6;
        !          16583:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          16584:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          16585:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          16586:                                cpu.z80sp += 2; /* Pop the word off */
        !          16587:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          16588:                                }
        !          16589:                                break;
        !          16590:                        }
        !          16591:                        case 0xf1:
        !          16592:                        {
        !          16593:                                sdwCyclesRemaining -= 10;
        !          16594:                                psMemRead = cpu.z80MemRead;     /* Beginning of our handler */
        !          16595:                                while (psMemRead->lowAddr != 0xffffffff)
        !          16596:                                {
        !          16597:                                        if ((cpu.z80sp >= psMemRead->lowAddr) && (cpu.z80sp <= psMemRead->highAddr))
        !          16598:                                        {
        !          16599:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16600:                                                if (psMemRead->memoryCall)
        !          16601:                                                {
        !          16602:                                                        cpu.z80AF = psMemRead->memoryCall(cpu.z80sp, psMemRead);
        !          16603:                                                        cpu.z80AF |= (UINT32) ((UINT32) psMemRead->memoryCall(cpu.z80sp + 1, psMemRead) << 8);
        !          16604:                                                }
        !          16605:                                                else
        !          16606:                                                {
        !          16607:                                                        cpu.z80AF = *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr));
        !          16608:                                                        cpu.z80AF |= (UINT32) ((UINT32) *((UINT8 *) psMemRead->pUserArea + (cpu.z80sp - psMemRead->lowAddr + 1)) << 8);
        !          16609:                                                }
        !          16610:                                                psMemRead = NULL;
        !          16611:                                                break;
        !          16612:                                        }
        !          16613:                                        ++psMemRead;
        !          16614:                                }
        !          16615: 
        !          16616:                                if (psMemRead)
        !          16617:                                {
        !          16618:                                        cpu.z80AF = cpu.z80Base[cpu.z80sp];
        !          16619:                                        cpu.z80AF |= (UINT32) ((UINT32) cpu.z80Base[cpu.z80sp + 1] << 8);
        !          16620:                                }
        !          16621: 
        !          16622:                                        cpu.z80sp += 2;
        !          16623:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          16624:                                break;
        !          16625:                        }
        !          16626:                        case 0xf2:
        !          16627:                        {
        !          16628:                                sdwCyclesRemaining -= 10;
        !          16629:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          16630:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16631:                                if (!(cpu.z80F & Z80_FLAG_SIGN))
        !          16632:                                {
        !          16633:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16634:                                }
        !          16635:                                break;
        !          16636:                        }
        !          16637:                        case 0xf3:
        !          16638:                        {
        !          16639:                                sdwCyclesRemaining -= 4;
        !          16640:                                cpu.z80iff &= (~IFF1);
        !          16641:                                break;
        !          16642:                        }
        !          16643:                        case 0xf4:
        !          16644:                        {
        !          16645:                                sdwCyclesRemaining -= 10;
        !          16646:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          16647:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16648:                                if (!(cpu.z80F & Z80_FLAG_SIGN))
        !          16649:                                {
        !          16650:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16651:                                        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16652:                                        *pbSP-- = cpu.z80pc >> 8;       /* MSB */
        !          16653:                                        *pbSP = (UINT8) cpu.z80pc;      /* LSB */
        !          16654:                                        cpu.z80sp -= 2; /* Back our stack up */
        !          16655:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16656:                                }
        !          16657:                                break;
        !          16658:                        }
        !          16659:                        case 0xf5:
        !          16660:                        {
        !          16661:                                sdwCyclesRemaining -= 11;
        !          16662:                                        cpu.z80sp -= 2;
        !          16663:                                        pbSP = (cpu.z80Base + cpu.z80sp);       /* Normalize the stack pointer */
        !          16664:                                psMemWrite = cpu.z80MemWrite;   /* Beginning of our handler */
        !          16665:                                while (psMemWrite->lowAddr != 0xffffffff)
        !          16666:                                {
        !          16667:                                        if ((cpu.z80sp >= psMemWrite->lowAddr) && (cpu.z80sp <= psMemWrite->highAddr))
        !          16668:                                        {
        !          16669:                                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16670:                                                if (psMemWrite->memoryCall)
        !          16671:                                                {
        !          16672:                                                        psMemWrite->memoryCall(cpu.z80sp, (cpu.z80AF & 0xff), psMemWrite);
        !          16673:                                                        psMemWrite->memoryCall(cpu.z80sp + 1, (cpu.z80AF >> 8), psMemWrite);
        !          16674:                                                }
        !          16675:                                                else
        !          16676:                                                {
        !          16677:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr)) = cpu.z80AF;
        !          16678:                                                        *((UINT8 *) psMemWrite->pUserArea + (cpu.z80sp - psMemWrite->lowAddr) + 1) = cpu.z80AF >> 8;
        !          16679:                                                }
        !          16680:                                                psMemWrite = NULL;
        !          16681:                                                break;
        !          16682:                                        }
        !          16683:                                        ++psMemWrite;
        !          16684:                                }
        !          16685: 
        !          16686:                                if (psMemWrite)
        !          16687:                                {
        !          16688:                                        cpu.z80Base[cpu.z80sp] = (UINT8) cpu.z80AF;
        !          16689:                                        cpu.z80Base[cpu.z80sp + 1] = (UINT8) ((UINT32) cpu.z80AF >> 8);
        !          16690:                                }
        !          16691: 
        !          16692:                                break;
        !          16693:                        }
        !          16694:                        case 0xf6:
        !          16695:                        {
        !          16696:                                sdwCyclesRemaining -= 7;
        !          16697:                                cpu.z80A |= *pbPC++;
        !          16698:                                cpu.z80F &= ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN);
        !          16699:                                cpu.z80F |= bPostORFlags[cpu.z80A];
        !          16700: 
        !          16701:                                break;
        !          16702:                        }
        !          16703:                        case 0xf7:
        !          16704:                        {
        !          16705:                                sdwCyclesRemaining -= 11;
        !          16706:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16707:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16708:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16709:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16710:                                cpu.z80sp -= 2; /* Back our stack up */
        !          16711:                                pbPC = cpu.z80Base + 0x30;      /* Normalize the address */
        !          16712:                                break;
        !          16713:                        }
        !          16714:                        case 0xf8:
        !          16715:                        {
        !          16716:                                sdwCyclesRemaining -= 5;
        !          16717:                                if (cpu.z80F & Z80_FLAG_SIGN)
        !          16718:                                {
        !          16719:                                        dwElapsedTicks += 6;
        !          16720:                                pbSP = cpu.z80Base + cpu.z80sp; /* Normalize our stack PTR */
        !          16721:                                dwAddr = *pbSP++;       /* Pop LSB */
        !          16722:                                dwAddr |= ((UINT32) *pbSP << 8);        /* Pop MSB */
        !          16723:                                cpu.z80sp += 2; /* Pop the word off */
        !          16724:                                pbPC = (cpu.z80Base + dwAddr);  /* Point PC to our return address */
        !          16725:                                }
        !          16726:                                break;
        !          16727:                        }
        !          16728:                        case 0xf9:
        !          16729:                        {
        !          16730:                                sdwCyclesRemaining -= 6;
        !          16731:                                cpu.z80sp = cpu.z80HL;
        !          16732:                                break;
        !          16733:                        }
        !          16734:                        case 0xfa:
        !          16735:                        {
        !          16736:                                sdwCyclesRemaining -= 10;
        !          16737:                                        dwAddr = *pbPC++;       /* Get LSB first */
        !          16738:                                        dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16739:                                if (cpu.z80F & Z80_FLAG_SIGN)
        !          16740:                                {
        !          16741:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16742:                                }
        !          16743:                                break;
        !          16744:                        }
        !          16745:                        case 0xfb:
        !          16746:                        {
        !          16747:                                sdwCyclesRemaining -= 4;
        !          16748:                                cpu.z80iff |= IFF1;
        !          16749:                                break;
        !          16750:                        }
        !          16751:                        case 0xfc:
        !          16752:                        {
        !          16753:                                sdwCyclesRemaining -= 10;
        !          16754:                                dwAddr = *pbPC++;       /* Get LSB first */
        !          16755:                                dwAddr |= ((UINT32) *pbPC++ << 8); /* Get MSB last */
        !          16756:                                if (cpu.z80F & Z80_FLAG_SIGN)
        !          16757:                                {
        !          16758:                                        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16759:                                        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16760:                                        *pbSP-- = cpu.z80pc >> 8;       /* MSB */
        !          16761:                                        *pbSP = (UINT8) cpu.z80pc;      /* LSB */
        !          16762:                                        cpu.z80sp -= 2; /* Back our stack up */
        !          16763:                                        pbPC = cpu.z80Base + dwAddr;    /* Normalize the address */
        !          16764:                                }
        !          16765:                                break;
        !          16766:                        }
        !          16767:                        case 0xfd:
        !          16768:                        {
        !          16769:                                FDHandler();
        !          16770:                                break;
        !          16771:                        }
        !          16772:                        case 0xfe:
        !          16773:                        {
        !          16774:                                sdwCyclesRemaining -= 7;
        !          16775:                                cpu.z80F = (cpu.z80F & ~(Z80_FLAG_CARRY | Z80_FLAG_NEGATIVE | Z80_FLAG_OVERFLOW_PARITY | 
        !          16776:                                                           Z80_FLAG_HALF_CARRY | Z80_FLAG_ZERO | Z80_FLAG_SIGN)) |
        !          16777:                                                                pbSubSbcTable[((UINT32) cpu.z80A << 8) | *pbPC++];
        !          16778:                                break;
        !          16779:                        }
        !          16780:                        case 0xff:
        !          16781:                        {
        !          16782:                                sdwCyclesRemaining -= 11;
        !          16783:                                cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16784:                                pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16785:                                *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16786:                                *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16787:                                cpu.z80sp -= 2; /* Back our stack up */
        !          16788:                                pbPC = cpu.z80Base + 0x38;      /* Normalize the address */
        !          16789:                                break;
        !          16790:                        }
        !          16791:                }
        !          16792:        }
        !          16793: 
        !          16794:        dwElapsedTicks += (dwOriginalCycles - sdwCyclesRemaining);
        !          16795: 
        !          16796:        cpu.z80pc = (UINT32) pbPC - (UINT32) cpu.z80Base;
        !          16797:        return(dwReturnCode); /* Indicate success */
        !          16798: }
        !          16799: 
        !          16800: /* Get mz80's context */
        !          16801: 
        !          16802: void mz80GetContext(void *pData)
        !          16803: {
        !          16804:        memcpy(pData, &cpu, sizeof(CONTEXTMZ80));
        !          16805: }
        !          16806: 
        !          16807: /* Set mz80's context */
        !          16808: 
        !          16809: void mz80SetContext(void *pData)
        !          16810: {
        !          16811:        memcpy(&cpu, pData, sizeof(CONTEXTMZ80));
        !          16812: }
        !          16813: 
        !          16814: /* Get mz80's context size */
        !          16815: 
        !          16816: UINT32 mz80GetContextSize(void)
        !          16817: {
        !          16818:        return(sizeof(CONTEXTMZ80));
        !          16819: }
        !          16820: 
        !          16821: /* This will return the elapsed ticks */
        !          16822: 
        !          16823: UINT32 mz80GetElapsedTicks(UINT32 dwClear)
        !          16824: {
        !          16825:        UINT32 dwTemp = dwElapsedTicks;
        !          16826: 
        !          16827:        if (dwClear)
        !          16828:        {
        !          16829:                dwElapsedTicks = 0;
        !          16830:        }
        !          16831: 
        !          16832:        return(dwTemp);
        !          16833: }
        !          16834: 
        !          16835: /* Releases mz80 from its current timeslice */
        !          16836: 
        !          16837: void mz80ReleaseTimeslice(void)
        !          16838: {
        !          16839:        dwOriginalCycles -= sdwCyclesRemaining;
        !          16840:        sdwCyclesRemaining = 0;
        !          16841: }
        !          16842: 
        !          16843: /* This routine is mz80's reset handler */
        !          16844: 
        !          16845: void mz80reset(void)
        !          16846: {
        !          16847:        cpu.z80halted = 0;
        !          16848:        cpu.z80AF = 0;
        !          16849:        cpu.z80F = Z80_FLAG_ZERO;
        !          16850:        cpu.z80BC = 0;
        !          16851:        cpu.z80DE = 0;
        !          16852:        cpu.z80HL = 0;
        !          16853:        cpu.z80afprime = 0;
        !          16854:        cpu.z80bcprime = 0;
        !          16855:        cpu.z80deprime = 0;
        !          16856:        cpu.z80hlprime = 0;
        !          16857:        cpu.z80i = 0;
        !          16858:        cpu.z80r = 0;
        !          16859:        cpu.z80IX = 0xffff; /* Yes, this is intentional */
        !          16860:        cpu.z80IY = 0xffff; /* Yes, this is intentional */
        !          16861:        cpu.z80pc = 0;
        !          16862:        cpu.z80sp = 0;
        !          16863:        cpu.z80interruptMode = 0;
        !          16864:        cpu.z80intAddr = 0x38;
        !          16865:        cpu.z80nmiAddr = 0x66;
        !          16866: }
        !          16867: 
        !          16868: /* Interrupt handler */
        !          16869: 
        !          16870: UINT32 mz80int(UINT32 dwLowAddr)
        !          16871: {
        !          16872:        cpu.z80halted = 0;
        !          16873:        if (0 == (cpu.z80iff & IFF1))
        !          16874:                return(0xffffffff);
        !          16875:        cpu.z80iff &= ~(IFF1 | IFF2);
        !          16876:        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16877:        *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16878:        *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16879:        cpu.z80sp -= 2; /* Back our stack up */
        !          16880:        if (2 == cpu.z80interruptMode)
        !          16881:        {
        !          16882:                cpu.z80pc = ((UINT16) cpu.z80i << 8) | (dwLowAddr & 0xff);
        !          16883:                cpu.z80pc = ((UINT16) cpu.z80Base[cpu.z80pc + 1] << 8) | (cpu.z80Base[cpu.z80pc]);
        !          16884:        }
        !          16885:        else
        !          16886:        {
        !          16887:                cpu.z80pc = cpu.z80intAddr;
        !          16888:        }
        !          16889:        pbPC = cpu.z80Base + cpu.z80pc; /* Normalize the address */
        !          16890:        return(0);
        !          16891: }
        !          16892: 
        !          16893: /* NMI Handler */
        !          16894: 
        !          16895: UINT32 mz80nmi(void)
        !          16896: {
        !          16897:        cpu.z80halted = 0;
        !          16898:        pbSP = (cpu.z80Base + cpu.z80sp - 1);   /* Normalize the stack pointer */
        !          16899:        *pbSP-- = cpu.z80pc >> 8;       /* LSB */
        !          16900:        *pbSP = (UINT8) cpu.z80pc;      /* MSB */
        !          16901:        cpu.z80sp -= 2; /* Back our stack up */
        !          16902:        cpu.z80pc = cpu.z80nmiAddr;     /* Our NMI */
        !          16903:        return(0);
        !          16904: }
        !          16905: 
        !          16906: /* Initialize MZ80 for action */
        !          16907: 
        !          16908: void mz80init(void)
        !          16909: {
        !          16910:        UINT32 dwLoop;
        !          16911:        UINT8 *pbTempPtr;
        !          16912:        UINT8 *pbTempPtr2;
        !          16913:        UINT8 bNewAdd;
        !          16914:        UINT8 bNewSub;
        !          16915:        UINT8 bFlag;
        !          16916:        UINT8 bLow;
        !          16917:        UINT8 bHigh;
        !          16918:        UINT8 bCarry;
        !          16919: 
        !          16920:        if (NULL == pbAddAdcTable)
        !          16921:        {
        !          16922:                pbAddAdcTable = malloc(256*256*2);
        !          16923: 
        !          16924:                if (NULL == pbAddAdcTable)
        !          16925:                {
        !          16926:                        return;
        !          16927:                }
        !          16928: 
        !          16929:                pbTempPtr = pbAddAdcTable;
        !          16930: 
        !          16931:                pbSubSbcTable = malloc(256*256*2);
        !          16932: 
        !          16933:                if (NULL == pbSubSbcTable)
        !          16934:                {
        !          16935:                        return;
        !          16936:                }
        !          16937: 
        !          16938:                pbTempPtr2 = pbSubSbcTable;
        !          16939: 
        !          16940:                for (dwLoop = 0; dwLoop < (256*256*2); dwLoop++)
        !          16941:                {
        !          16942:                        bLow = dwLoop & 0xff;
        !          16943:                        bHigh = (dwLoop >> 8) & 0xff;
        !          16944:                        bCarry = (dwLoop >> 16);
        !          16945: 
        !          16946:                        bFlag = 0;
        !          16947:                        bNewAdd = bHigh + bLow + bCarry;
        !          16948: 
        !          16949:                        if (0 == bNewAdd)
        !          16950:                        {
        !          16951:                                bFlag |= Z80_FLAG_ZERO;
        !          16952:                        }
        !          16953:                        else
        !          16954:                        {
        !          16955:                                bFlag = bNewAdd & 0x80; /* Sign flag */
        !          16956:                        }
        !          16957: 
        !          16958:                        if (((UINT32) bLow + (UINT32) bHigh + (UINT32) bCarry) >= 0x100)
        !          16959:                        {
        !          16960:                                bFlag |= Z80_FLAG_CARRY;
        !          16961:                        }
        !          16962: 
        !          16963:                        if ( ((bLow ^ bHigh ^ 0x80) & (bLow ^ (bNewAdd & 0x80))) & 0x80)
        !          16964:                        {
        !          16965:                                bFlag |= Z80_FLAG_OVERFLOW_PARITY;
        !          16966:                        }
        !          16967: 
        !          16968:                        if (((bLow & 0x0f) + (bHigh & 0x0f) + bCarry) >= 0x10)
        !          16969:                        {
        !          16970:                                bFlag |= Z80_FLAG_HALF_CARRY;
        !          16971:                        }
        !          16972: 
        !          16973:                        *pbTempPtr++ = bFlag;   /* Store our new flag */
        !          16974: 
        !          16975:                        // Now do subtract - Zero
        !          16976: 
        !          16977:                        bFlag = Z80_FLAG_NEGATIVE;
        !          16978:                        bNewSub = bHigh - bLow - bCarry;
        !          16979: 
        !          16980:                        if (0 == bNewSub)
        !          16981:                        {
        !          16982:                                bFlag |= Z80_FLAG_ZERO;
        !          16983:                        }
        !          16984:                        else
        !          16985:                        {
        !          16986:                                bFlag |= bNewSub & 0x80; /* Sign flag */
        !          16987:                        }
        !          16988: 
        !          16989:                        if ( ((INT32) bHigh - (INT32) bLow - (INT32) bCarry) < 0)
        !          16990:                        {
        !          16991:                                bFlag |= Z80_FLAG_CARRY;
        !          16992:                        }
        !          16993: 
        !          16994:                        if ( ((INT32) (bHigh & 0xf) - (INT32) (bLow & 0x0f) - (INT32) bCarry) < 0)
        !          16995:                        {
        !          16996:                                bFlag |= Z80_FLAG_HALF_CARRY;
        !          16997:                        }
        !          16998: 
        !          16999:                        if ( ((bLow ^ bHigh) & (bHigh ^ bNewSub) & 0x80) )
        !          17000:                        {
        !          17001:                                bFlag |= Z80_FLAG_OVERFLOW_PARITY;
        !          17002:                        }
        !          17003: 
        !          17004:                        *pbTempPtr2++ = bFlag;  /* Store our sub flag */
        !          17005: 
        !          17006:                }
        !          17007:        }
        !          17008: }
        !          17009: /* Shut down MZ80 */
        !          17010: 
        !          17011: void mz80shutdown(void)
        !          17012: {
        !          17013: }
        !          17014: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.