diff src/gb/gbCodesCB.h @ 1:f9f4f1b99eed

importing src directory
author Robert McIntyre <rlm@mit.edu>
date Sat, 03 Mar 2012 10:31:27 -0600
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/gb/gbCodesCB.h	Sat Mar 03 10:31:27 2012 -0600
     1.3 @@ -0,0 +1,1269 @@
     1.4 + case 0x00:
     1.5 +   // RLC B
     1.6 +   AF.B.B0 = (BC.B.B1 & 0x80)?C_FLAG:0;
     1.7 +   BC.B.B1 = ((BC.B.B1<<1) | (BC.B.B1>>7)) & 0xFF;
     1.8 +   AF.B.B0 |= ZeroTable[BC.B.B1];
     1.9 +   break;
    1.10 + case 0x01:
    1.11 +   // RLC C
    1.12 +   AF.B.B0 = (BC.B.B0 & 0x80)?C_FLAG:0;
    1.13 +   BC.B.B0 = ((BC.B.B0<<1) | (BC.B.B0>>7)) & 0xFF;
    1.14 +   AF.B.B0 |= ZeroTable[BC.B.B0];
    1.15 +   break;
    1.16 + case 0x02:
    1.17 +   // RLC D
    1.18 +   AF.B.B0 = (DE.B.B1 & 0x80)?C_FLAG:0;
    1.19 +   DE.B.B1 = ((DE.B.B1<<1) | (DE.B.B1>>7)) & 0xFF;
    1.20 +   AF.B.B0 |= ZeroTable[DE.B.B1];
    1.21 +   break;
    1.22 + case 0x03:
    1.23 +   // RLC E
    1.24 +   AF.B.B0 = (DE.B.B0 & 0x80)?C_FLAG:0;
    1.25 +   DE.B.B0 = ((DE.B.B0<<1) | (DE.B.B0>>7)) & 0xFF;
    1.26 +   AF.B.B0 |= ZeroTable[DE.B.B0];
    1.27 +   break;
    1.28 + case 0x04:
    1.29 +   // RLC H
    1.30 +   AF.B.B0 = (HL.B.B1 & 0x80)?C_FLAG:0;
    1.31 +   HL.B.B1 = ((HL.B.B1<<1) | (HL.B.B1>>7)) & 0xFF;
    1.32 +   AF.B.B0 |= ZeroTable[HL.B.B1];
    1.33 +   break;
    1.34 + case 0x05:
    1.35 +   // RLC L
    1.36 +   AF.B.B0 = (HL.B.B0 & 0x80)?C_FLAG:0;
    1.37 +   HL.B.B0 = ((HL.B.B0<<1) | (HL.B.B0>>7)) & 0xFF;
    1.38 +   AF.B.B0 |= ZeroTable[HL.B.B0];
    1.39 +   break;
    1.40 + case 0x06:
    1.41 +   // RLC (HL)
    1.42 +   tempValue=gbReadMemory(HL.W);
    1.43 +   AF.B.B0 = (tempValue & 0x80)?C_FLAG:0;
    1.44 +   tempValue = ((tempValue<<1) | (tempValue>>7)) & 0xFF;
    1.45 +   AF.B.B0 |= ZeroTable[tempValue];
    1.46 +   gbWriteMemory(HL.W,tempValue);
    1.47 +   break;
    1.48 + case 0x07:
    1.49 +   // RLC A
    1.50 +   AF.B.B0 = (AF.B.B1 & 0x80)?C_FLAG:0;
    1.51 +   AF.B.B1 = ((AF.B.B1<<1) | (AF.B.B1>>7)) & 0xFF;
    1.52 +   AF.B.B0 |= ZeroTable[AF.B.B1];
    1.53 +   break;
    1.54 + case 0x08:
    1.55 +   // RRC B
    1.56 +   AF.B.B0=(BC.B.B1&0x01 ? C_FLAG : 0);
    1.57 +   BC.B.B1=((BC.B.B1>>1)|(BC.B.B1<<7)) & 0xFF;
    1.58 +   AF.B.B0|=ZeroTable[BC.B.B1];
    1.59 +   break;
    1.60 + case 0x09:
    1.61 +   // RRC C
    1.62 +   AF.B.B0=(BC.B.B0&0x01 ? C_FLAG : 0);
    1.63 +   BC.B.B0=((BC.B.B0>>1)|(BC.B.B0<<7)) & 0xFF;
    1.64 +   AF.B.B0|=ZeroTable[BC.B.B0];
    1.65 +   break;
    1.66 + case 0x0a:
    1.67 +   // RRC D
    1.68 +   AF.B.B0=(DE.B.B1&0x01 ? C_FLAG : 0);
    1.69 +   DE.B.B1=((DE.B.B1>>1)|(DE.B.B1<<7)) & 0xFF;
    1.70 +   AF.B.B0|=ZeroTable[DE.B.B1];
    1.71 +   break;
    1.72 + case 0x0b:
    1.73 +   // RRC E
    1.74 +   AF.B.B0=(DE.B.B0&0x01 ? C_FLAG : 0);
    1.75 +   DE.B.B0=((DE.B.B0>>1)|(DE.B.B0<<7)) & 0xFF;
    1.76 +   AF.B.B0|=ZeroTable[DE.B.B0];
    1.77 +   break;
    1.78 + case 0x0c:
    1.79 +   // RRC H
    1.80 +   AF.B.B0=(HL.B.B1&0x01 ? C_FLAG : 0);
    1.81 +   HL.B.B1=((HL.B.B1>>1)|(HL.B.B1<<7)) & 0xFF;
    1.82 +   AF.B.B0|=ZeroTable[HL.B.B1];
    1.83 +   break;
    1.84 + case 0x0d:
    1.85 +   // RRC L
    1.86 +   AF.B.B0=(HL.B.B0&0x01 ? C_FLAG : 0);
    1.87 +   HL.B.B0=((HL.B.B0>>1)|(HL.B.B0<<7)) & 0xFF;
    1.88 +   AF.B.B0|=ZeroTable[HL.B.B0];
    1.89 +   break;
    1.90 + case 0x0e:
    1.91 +   // RRC (HL)
    1.92 +   tempValue=gbReadMemory(HL.W);
    1.93 +   AF.B.B0=(tempValue&0x01 ? C_FLAG : 0);
    1.94 +   tempValue=((tempValue>>1)|(tempValue<<7)) & 0xFF;
    1.95 +   AF.B.B0|=ZeroTable[tempValue];
    1.96 +   gbWriteMemory(HL.W,tempValue);
    1.97 +   break;
    1.98 + case 0x0f:
    1.99 +   // RRC A
   1.100 +   AF.B.B0=(AF.B.B1&0x01 ? C_FLAG : 0);
   1.101 +   AF.B.B1=((AF.B.B1>>1)|(AF.B.B1<<7)) & 0xFF;
   1.102 +   AF.B.B0|=ZeroTable[AF.B.B1];
   1.103 +   break;
   1.104 + case 0x10:
   1.105 +   // RL B
   1.106 +   if(BC.B.B1&0x80) {
   1.107 +     BC.B.B1=((BC.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.108 +     AF.B.B0=ZeroTable[BC.B.B1]|C_FLAG;
   1.109 +   } else {
   1.110 +     BC.B.B1=((BC.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.111 +     AF.B.B0=ZeroTable[BC.B.B1];
   1.112 +   }
   1.113 +   break;
   1.114 + case 0x11:
   1.115 +   // RL C
   1.116 +   if(BC.B.B0&0x80) {
   1.117 +     BC.B.B0=((BC.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.118 +     AF.B.B0=ZeroTable[BC.B.B0]|C_FLAG;
   1.119 +   } else {
   1.120 +     BC.B.B0=((BC.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.121 +     AF.B.B0=ZeroTable[BC.B.B0];
   1.122 +   }
   1.123 +   break;
   1.124 + case 0x12:
   1.125 +   // RL D
   1.126 +   if(DE.B.B1&0x80) {
   1.127 +     DE.B.B1=((DE.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.128 +     AF.B.B0=ZeroTable[DE.B.B1]|C_FLAG;
   1.129 +   } else {
   1.130 +     DE.B.B1=((DE.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.131 +     AF.B.B0=ZeroTable[DE.B.B1];
   1.132 +   }
   1.133 +   break;
   1.134 + case 0x13:
   1.135 +   // RL E
   1.136 +   if(DE.B.B0&0x80) {
   1.137 +     DE.B.B0=((DE.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.138 +     AF.B.B0=ZeroTable[DE.B.B0]|C_FLAG;
   1.139 +   } else {
   1.140 +     DE.B.B0=((DE.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.141 +     AF.B.B0=ZeroTable[DE.B.B0];
   1.142 +   }
   1.143 +   break;
   1.144 + case 0x14:
   1.145 +   // RL H
   1.146 +   if(HL.B.B1&0x80) {
   1.147 +     HL.B.B1=((HL.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.148 +     AF.B.B0=ZeroTable[HL.B.B1]|C_FLAG;
   1.149 +   } else {
   1.150 +     HL.B.B1=((HL.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.151 +     AF.B.B0=ZeroTable[HL.B.B1];
   1.152 +   }
   1.153 +   break;
   1.154 + case 0x15:
   1.155 +   // RL L
   1.156 +   if(HL.B.B0&0x80) {
   1.157 +     HL.B.B0=((HL.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.158 +     AF.B.B0=ZeroTable[HL.B.B0]|C_FLAG;
   1.159 +   } else {
   1.160 +     HL.B.B0=((HL.B.B0<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.161 +     AF.B.B0=ZeroTable[HL.B.B0];
   1.162 +   }
   1.163 +   break;
   1.164 + case 0x16:
   1.165 +   // RL (HL)
   1.166 +   tempValue=gbReadMemory(HL.W);
   1.167 +   if(tempValue&0x80) {
   1.168 +     tempValue=((tempValue<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.169 +     AF.B.B0=ZeroTable[tempValue]|C_FLAG;
   1.170 +   } else {
   1.171 +     tempValue=((tempValue<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.172 +     AF.B.B0=ZeroTable[tempValue];
   1.173 +   }
   1.174 +   gbWriteMemory(HL.W,tempValue);
   1.175 +   break;
   1.176 + case 0x17:
   1.177 +   // RL A
   1.178 +   if(AF.B.B1&0x80) {
   1.179 +     AF.B.B1=((AF.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.180 +     AF.B.B0=ZeroTable[AF.B.B1]|C_FLAG;
   1.181 +   } else {
   1.182 +     AF.B.B1=((AF.B.B1<<1)|(AF.B.B0&C_FLAG ? 1 : 0)) & 0xFF;
   1.183 +     AF.B.B0=ZeroTable[AF.B.B1];
   1.184 +   }
   1.185 +   break;
   1.186 + case 0x18:
   1.187 +   // RR B
   1.188 +   if(BC.B.B1&0x01) {
   1.189 +     BC.B.B1=(BC.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.190 +     AF.B.B0=ZeroTable[BC.B.B1]|C_FLAG;
   1.191 +   } else {
   1.192 +     BC.B.B1=(BC.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.193 +     AF.B.B0=ZeroTable[BC.B.B1];
   1.194 +   }
   1.195 +   break;
   1.196 + case 0x19:
   1.197 +   // RR C
   1.198 +   if(BC.B.B0&0x01) {
   1.199 +     BC.B.B0=(BC.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.200 +     AF.B.B0=ZeroTable[BC.B.B0]|C_FLAG;
   1.201 +   } else {
   1.202 +     BC.B.B0=(BC.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.203 +     AF.B.B0=ZeroTable[BC.B.B0];
   1.204 +   }
   1.205 +   break;
   1.206 + case 0x1a:
   1.207 +   // RR D
   1.208 +   if(DE.B.B1&0x01) {
   1.209 +     DE.B.B1=(DE.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.210 +     AF.B.B0=ZeroTable[DE.B.B1]|C_FLAG;
   1.211 +   } else {
   1.212 +     DE.B.B1=(DE.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.213 +     AF.B.B0=ZeroTable[DE.B.B1];
   1.214 +   }
   1.215 +   break;
   1.216 + case 0x1b:
   1.217 +   // RR E
   1.218 +   if(DE.B.B0&0x01) {
   1.219 +     DE.B.B0=(DE.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.220 +     AF.B.B0=ZeroTable[DE.B.B0]|C_FLAG;
   1.221 +   } else {
   1.222 +     DE.B.B0=(DE.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.223 +     AF.B.B0=ZeroTable[DE.B.B0];
   1.224 +   }
   1.225 +   break;
   1.226 + case 0x1c:
   1.227 +   // RR H
   1.228 +   if(HL.B.B1&0x01) {
   1.229 +     HL.B.B1=(HL.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.230 +     AF.B.B0=ZeroTable[HL.B.B1]|C_FLAG;
   1.231 +   } else {
   1.232 +     HL.B.B1=(HL.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.233 +     AF.B.B0=ZeroTable[HL.B.B1];
   1.234 +   }
   1.235 +   break;
   1.236 + case 0x1d:
   1.237 +   // RR L
   1.238 +   if(HL.B.B0&0x01) {
   1.239 +     HL.B.B0=(HL.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.240 +     AF.B.B0=ZeroTable[HL.B.B0]|C_FLAG;
   1.241 +   } else {
   1.242 +     HL.B.B0=(HL.B.B0>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.243 +     AF.B.B0=ZeroTable[HL.B.B0];
   1.244 +   }
   1.245 +   break;
   1.246 + case 0x1e:
   1.247 +   // RR (HL)
   1.248 +   tempValue=gbReadMemory(HL.W);
   1.249 +   if(tempValue&0x01) {
   1.250 +     tempValue=(tempValue>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.251 +     AF.B.B0=ZeroTable[tempValue]|C_FLAG;
   1.252 +   } else {
   1.253 +     tempValue=(tempValue>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.254 +     AF.B.B0=ZeroTable[tempValue];
   1.255 +   }
   1.256 +   gbWriteMemory(HL.W,tempValue);
   1.257 +   break;
   1.258 + case 0x1f:
   1.259 +   // RR A
   1.260 +   if(AF.B.B1&0x01) {
   1.261 +     AF.B.B1=(AF.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.262 +     AF.B.B0=ZeroTable[AF.B.B1]|C_FLAG;
   1.263 +   } else {
   1.264 +     AF.B.B1=(AF.B.B1>>1)|(AF.B.B0 & C_FLAG ? 0x80:0);
   1.265 +     AF.B.B0=ZeroTable[AF.B.B1];
   1.266 +   }
   1.267 +   break;
   1.268 + case 0x20:
   1.269 +   // SLA B
   1.270 +   AF.B.B0=(BC.B.B1&0x80?C_FLAG : 0);
   1.271 +   BC.B.B1<<=1;
   1.272 +   AF.B.B0|=ZeroTable[BC.B.B1];
   1.273 +   break;
   1.274 + case 0x21:
   1.275 +   // SLA C
   1.276 +   AF.B.B0=(BC.B.B0&0x80?C_FLAG : 0);
   1.277 +   BC.B.B0<<=1;
   1.278 +   AF.B.B0|=ZeroTable[BC.B.B0];
   1.279 +   break;
   1.280 + case 0x22:
   1.281 +   // SLA D
   1.282 +   AF.B.B0=(DE.B.B1&0x80?C_FLAG : 0);
   1.283 +   DE.B.B1<<=1;
   1.284 +   AF.B.B0|=ZeroTable[DE.B.B1];
   1.285 +   break;
   1.286 + case 0x23:
   1.287 +   // SLA E
   1.288 +   AF.B.B0=(DE.B.B0&0x80?C_FLAG : 0);
   1.289 +   DE.B.B0<<=1;
   1.290 +   AF.B.B0|=ZeroTable[DE.B.B0];
   1.291 +   break;
   1.292 + case 0x24:
   1.293 +   // SLA H
   1.294 +   AF.B.B0=(HL.B.B1&0x80?C_FLAG : 0);
   1.295 +   HL.B.B1<<=1;
   1.296 +   AF.B.B0|=ZeroTable[HL.B.B1];
   1.297 +   break;
   1.298 + case 0x25:
   1.299 +   // SLA L
   1.300 +   AF.B.B0=(HL.B.B0&0x80?C_FLAG : 0);
   1.301 +   HL.B.B0<<=1;
   1.302 +   AF.B.B0|=ZeroTable[HL.B.B0];
   1.303 +   break;
   1.304 + case 0x26:
   1.305 +   // SLA (HL)
   1.306 +   tempValue=gbReadMemory(HL.W);
   1.307 +   AF.B.B0=(tempValue&0x80?C_FLAG : 0);
   1.308 +   tempValue<<=1;
   1.309 +   AF.B.B0|=ZeroTable[tempValue];
   1.310 +   gbWriteMemory(HL.W,tempValue);
   1.311 +   break;
   1.312 + case 0x27:
   1.313 +   // SLA A
   1.314 +   AF.B.B0=(AF.B.B1&0x80?C_FLAG : 0);
   1.315 +   AF.B.B1<<=1;
   1.316 +   AF.B.B0|=ZeroTable[AF.B.B1];
   1.317 +   break;
   1.318 + case 0x28:
   1.319 +   // SRA B
   1.320 +   AF.B.B0=(BC.B.B1&0x01 ? C_FLAG: 0);
   1.321 +   BC.B.B1=(BC.B.B1>>1)|(BC.B.B1&0x80);
   1.322 +   AF.B.B0|=ZeroTable[BC.B.B1];
   1.323 +   break;
   1.324 + case 0x29:
   1.325 +   // SRA C
   1.326 +   AF.B.B0=(BC.B.B0&0x01 ? C_FLAG: 0);
   1.327 +   BC.B.B0=(BC.B.B0>>1)|(BC.B.B0&0x80);
   1.328 +   AF.B.B0|=ZeroTable[BC.B.B0];
   1.329 +   break;
   1.330 + case 0x2a:
   1.331 +   // SRA D
   1.332 +   AF.B.B0=(DE.B.B1&0x01 ? C_FLAG: 0);
   1.333 +   DE.B.B1=(DE.B.B1>>1)|(DE.B.B1&0x80);
   1.334 +   AF.B.B0|=ZeroTable[DE.B.B1];
   1.335 +   break;
   1.336 + case 0x2b:
   1.337 +   // SRA E
   1.338 +   AF.B.B0=(DE.B.B0&0x01 ? C_FLAG: 0);
   1.339 +   DE.B.B0=(DE.B.B0>>1)|(DE.B.B0&0x80);
   1.340 +   AF.B.B0|=ZeroTable[DE.B.B0];
   1.341 +   break;
   1.342 + case 0x2c:
   1.343 +   // SRA H
   1.344 +   AF.B.B0=(HL.B.B1&0x01 ? C_FLAG: 0);
   1.345 +   HL.B.B1=(HL.B.B1>>1)|(HL.B.B1&0x80);
   1.346 +   AF.B.B0|=ZeroTable[HL.B.B1];
   1.347 +   break;
   1.348 + case 0x2d:
   1.349 +   // SRA L
   1.350 +   AF.B.B0=(HL.B.B0&0x01 ? C_FLAG: 0);
   1.351 +   HL.B.B0=(HL.B.B0>>1)|(HL.B.B0&0x80);
   1.352 +   AF.B.B0|=ZeroTable[HL.B.B0];
   1.353 +   break;
   1.354 + case 0x2e:
   1.355 +   // SRA (HL)
   1.356 +   tempValue=gbReadMemory(HL.W);
   1.357 +   AF.B.B0=(tempValue&0x01 ? C_FLAG: 0);
   1.358 +   tempValue=(tempValue>>1)|(tempValue&0x80);
   1.359 +   AF.B.B0|=ZeroTable[tempValue];
   1.360 +   gbWriteMemory(HL.W,tempValue);
   1.361 +   break;
   1.362 + case 0x2f:
   1.363 +   // SRA A
   1.364 +   AF.B.B0=(AF.B.B1&0x01 ? C_FLAG: 0);
   1.365 +   AF.B.B1=(AF.B.B1>>1)|(AF.B.B1&0x80);
   1.366 +   AF.B.B0|=ZeroTable[AF.B.B1];
   1.367 +   break;
   1.368 + case 0x30:
   1.369 +   // SWAP B
   1.370 +   BC.B.B1 = (BC.B.B1&0xf0)>>4 | (BC.B.B1&0x0f)<<4;
   1.371 +   AF.B.B0 = ZeroTable[BC.B.B1];
   1.372 +   break;
   1.373 + case 0x31:
   1.374 +   // SWAP C
   1.375 +   BC.B.B0 = (BC.B.B0&0xf0)>>4 | (BC.B.B0&0x0f)<<4;
   1.376 +   AF.B.B0 = ZeroTable[BC.B.B0];
   1.377 +   break;
   1.378 + case 0x32:
   1.379 +  // SWAP D
   1.380 +  DE.B.B1 = (DE.B.B1&0xf0)>>4 | (DE.B.B1&0x0f)<<4;
   1.381 +  AF.B.B0 = ZeroTable[DE.B.B1];
   1.382 +  break;
   1.383 + case 0x33:
   1.384 +   // SWAP E
   1.385 +   DE.B.B0 = (DE.B.B0&0xf0)>>4 | (DE.B.B0&0x0f)<<4;
   1.386 +   AF.B.B0 = ZeroTable[DE.B.B0];
   1.387 +   break;
   1.388 + case 0x34:
   1.389 +   // SWAP H
   1.390 +   HL.B.B1 = (HL.B.B1&0xf0)>>4 | (HL.B.B1&0x0f)<<4;
   1.391 +   AF.B.B0 = ZeroTable[HL.B.B1];
   1.392 +   break;
   1.393 + case 0x35:
   1.394 +   // SWAP L
   1.395 +   HL.B.B0 = (HL.B.B0&0xf0)>>4 | (HL.B.B0&0x0f)<<4;
   1.396 +   AF.B.B0 = ZeroTable[HL.B.B0];
   1.397 +   break;
   1.398 + case 0x36:
   1.399 +   // SWAP (HL)
   1.400 +   tempValue=gbReadMemory(HL.W);
   1.401 +   tempValue = (tempValue&0xf0)>>4 | (tempValue&0x0f)<<4;
   1.402 +   AF.B.B0 = ZeroTable[tempValue];
   1.403 +   gbWriteMemory(HL.W,tempValue);
   1.404 +   break;
   1.405 + case 0x37:
   1.406 +   // SWAP A
   1.407 +   AF.B.B1 = (AF.B.B1&0xf0)>>4 | (AF.B.B1&0x0f)<<4;
   1.408 +   AF.B.B0 = ZeroTable[AF.B.B1];
   1.409 +   break;
   1.410 + case 0x38:
   1.411 +   // SRL B
   1.412 +   AF.B.B0=(BC.B.B1&0x01)?C_FLAG:0;
   1.413 +   BC.B.B1>>=1;
   1.414 +   AF.B.B0|=ZeroTable[BC.B.B1];
   1.415 +   break;
   1.416 + case 0x39:
   1.417 +   // SRL C
   1.418 +   AF.B.B0=(BC.B.B0&0x01)?C_FLAG:0;
   1.419 +   BC.B.B0>>=1;
   1.420 +   AF.B.B0|=ZeroTable[BC.B.B0];
   1.421 +   break;
   1.422 + case 0x3a:
   1.423 +   // SRL D
   1.424 +   AF.B.B0=(DE.B.B1&0x01)?C_FLAG:0;
   1.425 +   DE.B.B1>>=1;
   1.426 +   AF.B.B0|=ZeroTable[DE.B.B1];
   1.427 +   break;
   1.428 + case 0x3b:
   1.429 +   // SRL E
   1.430 +   AF.B.B0=(DE.B.B0&0x01)?C_FLAG:0;
   1.431 +   DE.B.B0>>=1;
   1.432 +   AF.B.B0|=ZeroTable[DE.B.B0];
   1.433 +   break;
   1.434 + case 0x3c:
   1.435 +   // SRL H
   1.436 +   AF.B.B0=(HL.B.B1&0x01)?C_FLAG:0;
   1.437 +   HL.B.B1>>=1;
   1.438 +   AF.B.B0|=ZeroTable[HL.B.B1];
   1.439 +   break;
   1.440 + case 0x3d:
   1.441 +   // SRL L
   1.442 +   AF.B.B0=(HL.B.B0&0x01)?C_FLAG:0;
   1.443 +   HL.B.B0>>=1;
   1.444 +   AF.B.B0|=ZeroTable[HL.B.B0];
   1.445 +   break;
   1.446 + case 0x3e:
   1.447 +   // SRL (HL)
   1.448 +   tempValue=gbReadMemory(HL.W);
   1.449 +   AF.B.B0=(tempValue&0x01)?C_FLAG:0;
   1.450 +   tempValue>>=1;
   1.451 +   AF.B.B0|=ZeroTable[tempValue];
   1.452 +   gbWriteMemory(HL.W,tempValue);
   1.453 +   break;
   1.454 + case 0x3f:
   1.455 +   // SRL A
   1.456 +   AF.B.B0=(AF.B.B1&0x01)?C_FLAG:0;
   1.457 +   AF.B.B1>>=1;
   1.458 +   AF.B.B0|=ZeroTable[AF.B.B1];
   1.459 +   break;
   1.460 + case 0x40:
   1.461 +   // BIT 0,B
   1.462 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<0)? 0:Z_FLAG);
   1.463 +   break;
   1.464 + case 0x41:
   1.465 +   // BIT 0,C
   1.466 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<0)? 0:Z_FLAG);
   1.467 +   break;
   1.468 + case 0x42:
   1.469 +   // BIT 0,D
   1.470 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<0)? 0:Z_FLAG);
   1.471 +   break;
   1.472 + case 0x43:
   1.473 +   // BIT 0,E
   1.474 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<0)? 0:Z_FLAG);
   1.475 +   break;
   1.476 + case 0x44:
   1.477 +   // BIT 0,H
   1.478 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<0)? 0:Z_FLAG);
   1.479 +   break;
   1.480 + case 0x45:
   1.481 +   // BIT 0,L
   1.482 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<0)? 0:Z_FLAG);
   1.483 +   break;
   1.484 + case 0x46:
   1.485 +   // BIT 0,(HL)
   1.486 +   tempValue=gbReadMemory(HL.W);
   1.487 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<0)? 0:Z_FLAG);
   1.488 +   break;
   1.489 + case 0x47:
   1.490 +   // BIT 0,A
   1.491 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<0)? 0:Z_FLAG);
   1.492 +   break;
   1.493 + case 0x48:
   1.494 +   // BIT 1,B
   1.495 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<1)? 0:Z_FLAG);
   1.496 +   break;
   1.497 + case 0x49:
   1.498 +   // BIT 1,C
   1.499 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<1)? 0:Z_FLAG);
   1.500 +   break;
   1.501 + case 0x4a:
   1.502 +   // BIT 1,D
   1.503 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<1)? 0:Z_FLAG);
   1.504 +   break;
   1.505 + case 0x4b:
   1.506 +   // BIT 1,E
   1.507 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<1)? 0:Z_FLAG);
   1.508 +   break;
   1.509 + case 0x4c:
   1.510 +   // BIT 1,H
   1.511 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<1)? 0:Z_FLAG);
   1.512 +   break;
   1.513 + case 0x4d:
   1.514 +   // BIT 1,L
   1.515 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<1)? 0:Z_FLAG);
   1.516 +   break;
   1.517 + case 0x4e:
   1.518 +   // BIT 1,(HL)
   1.519 +   tempValue=gbReadMemory(HL.W);
   1.520 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<1)? 0:Z_FLAG);
   1.521 +   break;
   1.522 + case 0x4f:
   1.523 +   // BIT 1,A
   1.524 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<1)? 0:Z_FLAG);
   1.525 +   break;
   1.526 + case 0x50:
   1.527 +   // BIT 2,B
   1.528 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<2)? 0:Z_FLAG);
   1.529 +   break;
   1.530 + case 0x51:
   1.531 +   // BIT 2,C
   1.532 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<2)? 0:Z_FLAG);
   1.533 +   break;
   1.534 + case 0x52:
   1.535 +   // BIT 2,D
   1.536 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<2)? 0:Z_FLAG);
   1.537 +   break;
   1.538 + case 0x53:
   1.539 +   // BIT 2,E
   1.540 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<2)? 0:Z_FLAG);
   1.541 +   break;
   1.542 + case 0x54:
   1.543 +   // BIT 2,H
   1.544 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<2)? 0:Z_FLAG);
   1.545 +   break;
   1.546 + case 0x55:
   1.547 +   // BIT 2,L
   1.548 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<2)? 0:Z_FLAG);
   1.549 +   break;
   1.550 + case 0x56:
   1.551 +   // BIT 2,(HL)
   1.552 +   tempValue=gbReadMemory(HL.W);
   1.553 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<2)? 0:Z_FLAG);
   1.554 +   break;
   1.555 + case 0x57:
   1.556 +   // BIT 2,A
   1.557 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<2)? 0:Z_FLAG);
   1.558 +   break;
   1.559 + case 0x58:
   1.560 +   // BIT 3,B
   1.561 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<3)? 0:Z_FLAG);
   1.562 +   break;
   1.563 + case 0x59:
   1.564 +   // BIT 3,C
   1.565 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<3)? 0:Z_FLAG);
   1.566 +   break;
   1.567 + case 0x5a:
   1.568 +   // BIT 3,D
   1.569 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<3)? 0:Z_FLAG);
   1.570 +   break;
   1.571 + case 0x5b:
   1.572 +   // BIT 3,E
   1.573 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<3)? 0:Z_FLAG);
   1.574 +   break;
   1.575 + case 0x5c:
   1.576 +   // BIT 3,H
   1.577 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<3)? 0:Z_FLAG);
   1.578 +   break;
   1.579 + case 0x5d:
   1.580 +   // BIT 3,L
   1.581 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<3)? 0:Z_FLAG);
   1.582 +   break;
   1.583 + case 0x5e:
   1.584 +   // BIT 3,(HL)
   1.585 +   tempValue=gbReadMemory(HL.W);
   1.586 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<3)? 0:Z_FLAG);
   1.587 +   break;
   1.588 + case 0x5f:
   1.589 +   // BIT 3,A
   1.590 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<3)? 0:Z_FLAG);
   1.591 +   break;
   1.592 + case 0x60:
   1.593 +   // BIT 4,B
   1.594 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<4)? 0:Z_FLAG);
   1.595 +   break;
   1.596 + case 0x61:
   1.597 +   // BIT 4,C
   1.598 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<4)? 0:Z_FLAG);
   1.599 +   break;
   1.600 + case 0x62:
   1.601 +   // BIT 4,D
   1.602 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<4)? 0:Z_FLAG);
   1.603 +   break;
   1.604 + case 0x63:
   1.605 +   // BIT 4,E
   1.606 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<4)? 0:Z_FLAG);
   1.607 +   break;
   1.608 + case 0x64:
   1.609 +   // BIT 4,H
   1.610 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<4)? 0:Z_FLAG);
   1.611 +   break;
   1.612 + case 0x65:
   1.613 +   // BIT 4,L
   1.614 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<4)? 0:Z_FLAG);
   1.615 +   break;
   1.616 + case 0x66:
   1.617 +   // BIT 4,(HL)
   1.618 +   tempValue=gbReadMemory(HL.W);
   1.619 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<4)? 0:Z_FLAG);
   1.620 +   break;
   1.621 + case 0x67:
   1.622 +   // BIT 4,A
   1.623 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<4)? 0:Z_FLAG);
   1.624 +   break;
   1.625 + case 0x68:
   1.626 +   // BIT 5,B
   1.627 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<5)? 0:Z_FLAG);
   1.628 +   break;
   1.629 + case 0x69:
   1.630 +   // BIT 5,C
   1.631 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<5)? 0:Z_FLAG);
   1.632 +   break;
   1.633 + case 0x6a:
   1.634 +   // BIT 5,D
   1.635 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<5)? 0:Z_FLAG);
   1.636 +   break;
   1.637 + case 0x6b:
   1.638 +   // BIT 5,E
   1.639 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<5)? 0:Z_FLAG);
   1.640 +   break;
   1.641 + case 0x6c:
   1.642 +   // BIT 5,H
   1.643 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<5)? 0:Z_FLAG);
   1.644 +   break;
   1.645 + case 0x6d:
   1.646 +   // BIT 5,L
   1.647 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<5)? 0:Z_FLAG);
   1.648 +   break;
   1.649 + case 0x6e:
   1.650 +   // BIT 5,(HL)
   1.651 +   tempValue=gbReadMemory(HL.W);
   1.652 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<5)? 0:Z_FLAG);
   1.653 +   break;
   1.654 + case 0x6f:
   1.655 +   // BIT 5,A
   1.656 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<5)? 0:Z_FLAG);
   1.657 +   break;
   1.658 + case 0x70:
   1.659 +   // BIT 6,B
   1.660 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<6)? 0:Z_FLAG);
   1.661 +   break;
   1.662 + case 0x71:
   1.663 +   // BIT 6,C
   1.664 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<6)? 0:Z_FLAG);
   1.665 +   break;
   1.666 + case 0x72:
   1.667 +   // BIT 6,D
   1.668 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<6)? 0:Z_FLAG);
   1.669 +   break;
   1.670 + case 0x73:
   1.671 +   // BIT 6,E
   1.672 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<6)? 0:Z_FLAG);
   1.673 +   break;
   1.674 + case 0x74:
   1.675 +   // BIT 6,H
   1.676 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<6)? 0:Z_FLAG);
   1.677 +   break;
   1.678 + case 0x75:
   1.679 +   // BIT 6,L
   1.680 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<6)? 0:Z_FLAG);
   1.681 +   break;
   1.682 + case 0x76:
   1.683 +   // BIT 6,(HL)
   1.684 +   tempValue=gbReadMemory(HL.W);
   1.685 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<6)? 0:Z_FLAG);
   1.686 +   break;
   1.687 + case 0x77:
   1.688 +   // BIT 6,A
   1.689 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<6)? 0:Z_FLAG);
   1.690 +   break;
   1.691 + case 0x78:
   1.692 +   // BIT 7,B
   1.693 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B1&(1<<7)? 0:Z_FLAG);
   1.694 +   break;
   1.695 + case 0x79:
   1.696 +   // BIT 7,C
   1.697 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(BC.B.B0&(1<<7)? 0:Z_FLAG);
   1.698 +   break;
   1.699 + case 0x7a:
   1.700 +   // BIT 7,D
   1.701 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B1&(1<<7)? 0:Z_FLAG);
   1.702 +   break;
   1.703 + case 0x7b:
   1.704 +   // BIT 7,E
   1.705 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(DE.B.B0&(1<<7)? 0:Z_FLAG);
   1.706 +   break;
   1.707 + case 0x7c:
   1.708 +   // BIT 7,H
   1.709 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B1&(1<<7)? 0:Z_FLAG);
   1.710 +   break;
   1.711 + case 0x7d:
   1.712 +   // BIT 7,L
   1.713 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(HL.B.B0&(1<<7)? 0:Z_FLAG);
   1.714 +   break;
   1.715 + case 0x7e:
   1.716 +   // BIT 7,(HL)
   1.717 +   tempValue=gbReadMemory(HL.W);
   1.718 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(tempValue&(1<<7)? 0:Z_FLAG);
   1.719 +   break;
   1.720 + case 0x7f:
   1.721 +   // BIT 7,A
   1.722 +   AF.B.B0=(AF.B.B0&C_FLAG)|H_FLAG|(AF.B.B1&(1<<7)? 0:Z_FLAG);
   1.723 +   break;
   1.724 + case 0x80:
   1.725 +   // RES 0,B
   1.726 +   BC.B.B1&=~(1<<0);
   1.727 +   break;
   1.728 + case 0x81:
   1.729 +   // RES 0,C
   1.730 +   BC.B.B0&=~(1<<0);
   1.731 +   break;
   1.732 + case 0x82:
   1.733 +   // RES 0,D
   1.734 +   DE.B.B1&=~(1<<0);
   1.735 +   break;
   1.736 + case 0x83:
   1.737 +   // RES 0,E
   1.738 +   DE.B.B0&=~(1<<0);
   1.739 +   break;
   1.740 + case 0x84:
   1.741 +   // RES 0,H
   1.742 +   HL.B.B1&=~(1<<0);
   1.743 +   break;
   1.744 + case 0x85:
   1.745 +   // RES 0,L
   1.746 +   HL.B.B0&=~(1<<0);
   1.747 +   break;
   1.748 + case 0x86:
   1.749 +   // RES 0,(HL)
   1.750 +   tempValue=gbReadMemory(HL.W);
   1.751 +   tempValue&=~(1<<0);
   1.752 +   gbWriteMemory(HL.W,tempValue);
   1.753 +   break;
   1.754 + case 0x87:
   1.755 +   // RES 0,A
   1.756 +   AF.B.B1&=~(1<<0);
   1.757 +   break;
   1.758 + case 0x88:
   1.759 +   // RES 1,B
   1.760 +   BC.B.B1&=~(1<<1);
   1.761 +   break;
   1.762 + case 0x89:
   1.763 +   // RES 1,C
   1.764 +   BC.B.B0&=~(1<<1);
   1.765 +   break;
   1.766 + case 0x8a:
   1.767 +   // RES 1,D
   1.768 +   DE.B.B1&=~(1<<1);
   1.769 +   break;
   1.770 + case 0x8b:
   1.771 +   // RES 1,E
   1.772 +   DE.B.B0&=~(1<<1);
   1.773 +   break;
   1.774 + case 0x8c:
   1.775 +   // RES 1,H
   1.776 +   HL.B.B1&=~(1<<1);
   1.777 +   break;
   1.778 + case 0x8d:
   1.779 +   // RES 1,L
   1.780 +   HL.B.B0&=~(1<<1);
   1.781 +   break;
   1.782 + case 0x8e:
   1.783 +   // RES 1,(HL)
   1.784 +   tempValue=gbReadMemory(HL.W);
   1.785 +   tempValue&=~(1<<1);
   1.786 +   gbWriteMemory(HL.W,tempValue);
   1.787 +   break;
   1.788 + case 0x8f:
   1.789 +   // RES 1,A
   1.790 +   AF.B.B1&=~(1<<1);
   1.791 +   break;
   1.792 + case 0x90:
   1.793 +   // RES 2,B
   1.794 +   BC.B.B1&=~(1<<2);
   1.795 +   break;
   1.796 + case 0x91:
   1.797 +   // RES 2,C
   1.798 +   BC.B.B0&=~(1<<2);
   1.799 +   break;
   1.800 + case 0x92:
   1.801 +   // RES 2,D
   1.802 +   DE.B.B1&=~(1<<2);
   1.803 +   break;
   1.804 + case 0x93:
   1.805 +   // RES 2,E
   1.806 +   DE.B.B0&=~(1<<2);
   1.807 +   break;
   1.808 + case 0x94:
   1.809 +   // RES 2,H
   1.810 +   HL.B.B1&=~(1<<2);
   1.811 +   break;
   1.812 + case 0x95:
   1.813 +   // RES 2,L
   1.814 +   HL.B.B0&=~(1<<2);
   1.815 +   break;
   1.816 + case 0x96:
   1.817 +   // RES 2,(HL)
   1.818 +   tempValue=gbReadMemory(HL.W);
   1.819 +   tempValue&=~(1<<2);
   1.820 +   gbWriteMemory(HL.W,tempValue);
   1.821 +   break;
   1.822 + case 0x97:
   1.823 +   // RES 2,A
   1.824 +   AF.B.B1&=~(1<<2);
   1.825 +   break;
   1.826 + case 0x98:
   1.827 +   // RES 3,B
   1.828 +   BC.B.B1&=~(1<<3);
   1.829 +   break;
   1.830 + case 0x99:
   1.831 +   // RES 3,C
   1.832 +   BC.B.B0&=~(1<<3);
   1.833 +   break;
   1.834 + case 0x9a:
   1.835 +   // RES 3,D
   1.836 +   DE.B.B1&=~(1<<3);
   1.837 +   break;
   1.838 + case 0x9b:
   1.839 +   // RES 3,E
   1.840 +   DE.B.B0&=~(1<<3);
   1.841 +   break;
   1.842 + case 0x9c:
   1.843 +   // RES 3,H
   1.844 +   HL.B.B1&=~(1<<3);
   1.845 +   break;
   1.846 + case 0x9d:
   1.847 +   // RES 3,L
   1.848 +   HL.B.B0&=~(1<<3);
   1.849 +   break;
   1.850 + case 0x9e:
   1.851 +   // RES 3,(HL)
   1.852 +   tempValue=gbReadMemory(HL.W);
   1.853 +   tempValue&=~(1<<3);
   1.854 +   gbWriteMemory(HL.W,tempValue);
   1.855 +   break;
   1.856 + case 0x9f:
   1.857 +   // RES 3,A
   1.858 +   AF.B.B1&=~(1<<3);
   1.859 +   break;
   1.860 + case 0xa0:
   1.861 +   // RES 4,B
   1.862 +   BC.B.B1&=~(1<<4);
   1.863 +   break;
   1.864 + case 0xa1:
   1.865 +   // RES 4,C
   1.866 +   BC.B.B0&=~(1<<4);
   1.867 +   break;
   1.868 + case 0xa2:
   1.869 +   // RES 4,D
   1.870 +   DE.B.B1&=~(1<<4);
   1.871 +   break;
   1.872 + case 0xa3:
   1.873 +   // RES 4,E
   1.874 +   DE.B.B0&=~(1<<4);
   1.875 +   break;
   1.876 + case 0xa4:
   1.877 +   // RES 4,H
   1.878 +   HL.B.B1&=~(1<<4);
   1.879 +   break;
   1.880 + case 0xa5:
   1.881 +   // RES 4,L
   1.882 +   HL.B.B0&=~(1<<4);
   1.883 +   break;
   1.884 + case 0xa6:
   1.885 +   // RES 4,(HL)
   1.886 +   tempValue=gbReadMemory(HL.W);
   1.887 +   tempValue&=~(1<<4);
   1.888 +   gbWriteMemory(HL.W,tempValue);
   1.889 +   break;
   1.890 + case 0xa7:
   1.891 +   // RES 4,A
   1.892 +   AF.B.B1&=~(1<<4);
   1.893 +   break;
   1.894 + case 0xa8:
   1.895 +   // RES 5,B
   1.896 +   BC.B.B1&=~(1<<5);
   1.897 +   break;
   1.898 + case 0xa9:
   1.899 +   // RES 5,C
   1.900 +   BC.B.B0&=~(1<<5);
   1.901 +   break;
   1.902 + case 0xaa:
   1.903 +   // RES 5,D
   1.904 +   DE.B.B1&=~(1<<5);
   1.905 +   break;
   1.906 + case 0xab:
   1.907 +   // RES 5,E
   1.908 +   DE.B.B0&=~(1<<5);
   1.909 +   break;
   1.910 + case 0xac:
   1.911 +   // RES 5,H
   1.912 +   HL.B.B1&=~(1<<5);
   1.913 +   break;
   1.914 + case 0xad:
   1.915 +   // RES 5,L
   1.916 +   HL.B.B0&=~(1<<5);
   1.917 +   break;
   1.918 + case 0xae:
   1.919 +   // RES 5,(HL)
   1.920 +   tempValue=gbReadMemory(HL.W);
   1.921 +   tempValue&=~(1<<5);
   1.922 +   gbWriteMemory(HL.W,tempValue);
   1.923 +   break;
   1.924 + case 0xaf:
   1.925 +   // RES 5,A
   1.926 +   AF.B.B1&=~(1<<5);
   1.927 +   break;
   1.928 + case 0xb0:
   1.929 +   // RES 6,B
   1.930 +   BC.B.B1&=~(1<<6);
   1.931 +   break;
   1.932 + case 0xb1:
   1.933 +   // RES 6,C
   1.934 +   BC.B.B0&=~(1<<6);
   1.935 +   break;
   1.936 + case 0xb2:
   1.937 +   // RES 6,D
   1.938 +   DE.B.B1&=~(1<<6);
   1.939 +   break;
   1.940 + case 0xb3:
   1.941 +   // RES 6,E
   1.942 +   DE.B.B0&=~(1<<6);
   1.943 +   break;
   1.944 + case 0xb4:
   1.945 +   // RES 6,H
   1.946 +   HL.B.B1&=~(1<<6);
   1.947 +   break;
   1.948 + case 0xb5:
   1.949 +   // RES 6,L
   1.950 +   HL.B.B0&=~(1<<6);
   1.951 +   break;
   1.952 + case 0xb6:
   1.953 +   // RES 6,(HL)
   1.954 +   tempValue=gbReadMemory(HL.W);
   1.955 +   tempValue&=~(1<<6);
   1.956 +   gbWriteMemory(HL.W,tempValue);
   1.957 +   break;
   1.958 + case 0xb7:
   1.959 +   // RES 6,A
   1.960 +   AF.B.B1&=~(1<<6);
   1.961 +   break;
   1.962 + case 0xb8:
   1.963 +   // RES 7,B
   1.964 +   BC.B.B1&=~(1<<7);
   1.965 +   break;
   1.966 + case 0xb9:
   1.967 +   // RES 7,C
   1.968 +   BC.B.B0&=~(1<<7);
   1.969 +   break;
   1.970 + case 0xba:
   1.971 +   // RES 7,D
   1.972 +   DE.B.B1&=~(1<<7);
   1.973 +   break;
   1.974 + case 0xbb:
   1.975 +   // RES 7,E
   1.976 +   DE.B.B0&=~(1<<7);
   1.977 +   break;
   1.978 + case 0xbc:
   1.979 +   // RES 7,H
   1.980 +   HL.B.B1&=~(1<<7);
   1.981 +   break;
   1.982 + case 0xbd:
   1.983 +   // RES 7,L
   1.984 +   HL.B.B0&=~(1<<7);
   1.985 +   break;
   1.986 + case 0xbe:
   1.987 +   // RES 7,(HL)
   1.988 +   tempValue=gbReadMemory(HL.W);
   1.989 +   tempValue&=~(1<<7);
   1.990 +   gbWriteMemory(HL.W,tempValue);
   1.991 +   break;
   1.992 + case 0xbf:
   1.993 +   // RES 7,A
   1.994 +   AF.B.B1&=~(1<<7);
   1.995 +   break;
   1.996 + case 0xc0:
   1.997 +   // SET 0,B
   1.998 +   BC.B.B1|=1<<0;
   1.999 +   break;
  1.1000 + case 0xc1:
  1.1001 +   // SET 0,C
  1.1002 +   BC.B.B0|=1<<0;
  1.1003 +   break;
  1.1004 + case 0xc2:
  1.1005 +   // SET 0,D
  1.1006 +   DE.B.B1|=1<<0;
  1.1007 +   break;
  1.1008 + case 0xc3:
  1.1009 +   // SET 0,E
  1.1010 +   DE.B.B0|=1<<0;
  1.1011 +   break;
  1.1012 + case 0xc4:
  1.1013 +   // SET 0,H
  1.1014 +   HL.B.B1|=1<<0;
  1.1015 +   break;
  1.1016 + case 0xc5:
  1.1017 +   // SET 0,L
  1.1018 +   HL.B.B0|=1<<0;
  1.1019 +   break;
  1.1020 + case 0xc6:
  1.1021 +   // SET 0,(HL)
  1.1022 +   tempValue=gbReadMemory(HL.W);
  1.1023 +   tempValue|=1<<0;
  1.1024 +   gbWriteMemory(HL.W,tempValue);
  1.1025 +   break;
  1.1026 + case 0xc7:
  1.1027 +   // SET 0,A
  1.1028 +   AF.B.B1|=1<<0;
  1.1029 +   break;
  1.1030 + case 0xc8:
  1.1031 +   // SET 1,B
  1.1032 +   BC.B.B1|=1<<1;
  1.1033 +   break;
  1.1034 + case 0xc9:
  1.1035 +   // SET 1,C
  1.1036 +   BC.B.B0|=1<<1;
  1.1037 +   break;
  1.1038 + case 0xca:
  1.1039 +   // SET 1,D
  1.1040 +   DE.B.B1|=1<<1;
  1.1041 +   break;
  1.1042 + case 0xcb:
  1.1043 +   // SET 1,E
  1.1044 +   DE.B.B0|=1<<1;
  1.1045 +   break;
  1.1046 + case 0xcc:
  1.1047 +   // SET 1,H
  1.1048 +   HL.B.B1|=1<<1;
  1.1049 +   break;
  1.1050 + case 0xcd:
  1.1051 +   // SET 1,L
  1.1052 +   HL.B.B0|=1<<1;
  1.1053 +   break;
  1.1054 + case 0xce:
  1.1055 +   // SET 1,(HL)
  1.1056 +   tempValue=gbReadMemory(HL.W);
  1.1057 +   tempValue|=1<<1;
  1.1058 +   gbWriteMemory(HL.W,tempValue);
  1.1059 +   break;
  1.1060 + case 0xcf:
  1.1061 +   // SET 1,A
  1.1062 +   AF.B.B1|=1<<1;
  1.1063 +   break;
  1.1064 + case 0xd0:
  1.1065 +   // SET 2,B
  1.1066 +   BC.B.B1|=1<<2;
  1.1067 +   break;
  1.1068 + case 0xd1:
  1.1069 +   // SET 2,C
  1.1070 +   BC.B.B0|=1<<2;
  1.1071 +   break;
  1.1072 + case 0xd2:
  1.1073 +   // SET 2,D
  1.1074 +   DE.B.B1|=1<<2;
  1.1075 +   break;
  1.1076 + case 0xd3:
  1.1077 +   // SET 2,E
  1.1078 +   DE.B.B0|=1<<2;
  1.1079 +   break;
  1.1080 + case 0xd4:
  1.1081 +   // SET 2,H
  1.1082 +   HL.B.B1|=1<<2;
  1.1083 +   break;
  1.1084 + case 0xd5:
  1.1085 +   // SET 2,L
  1.1086 +   HL.B.B0|=1<<2;
  1.1087 +   break;
  1.1088 + case 0xd6:
  1.1089 +   // SET 2,(HL)
  1.1090 +   tempValue=gbReadMemory(HL.W);
  1.1091 +   tempValue|=1<<2;
  1.1092 +   gbWriteMemory(HL.W,tempValue);
  1.1093 +   break;
  1.1094 + case 0xd7:
  1.1095 +   // SET 2,A
  1.1096 +   AF.B.B1|=1<<2;
  1.1097 +   break;
  1.1098 + case 0xd8:
  1.1099 +   // SET 3,B
  1.1100 +   BC.B.B1|=1<<3;
  1.1101 +   break;
  1.1102 + case 0xd9:
  1.1103 +   // SET 3,C
  1.1104 +   BC.B.B0|=1<<3;
  1.1105 +   break;
  1.1106 + case 0xda:
  1.1107 +   // SET 3,D
  1.1108 +   DE.B.B1|=1<<3;
  1.1109 +   break;
  1.1110 + case 0xdb:
  1.1111 +   // SET 3,E
  1.1112 +   DE.B.B0|=1<<3;
  1.1113 +   break;
  1.1114 + case 0xdc:
  1.1115 +   // SET 3,H
  1.1116 +   HL.B.B1|=1<<3;
  1.1117 +   break;
  1.1118 + case 0xdd:
  1.1119 +   // SET 3,L
  1.1120 +   HL.B.B0|=1<<3;
  1.1121 +   break;
  1.1122 + case 0xde:
  1.1123 +   // SET 3,(HL)
  1.1124 +   tempValue=gbReadMemory(HL.W);
  1.1125 +   tempValue|=1<<3;
  1.1126 +   gbWriteMemory(HL.W,tempValue);
  1.1127 +   break;
  1.1128 + case 0xdf:
  1.1129 +   // SET 3,A
  1.1130 +   AF.B.B1|=1<<3;
  1.1131 +   break;
  1.1132 + case 0xe0:
  1.1133 +   // SET 4,B
  1.1134 +   BC.B.B1|=1<<4;
  1.1135 +   break;
  1.1136 + case 0xe1:
  1.1137 +   // SET 4,C
  1.1138 +   BC.B.B0|=1<<4;
  1.1139 +   break;
  1.1140 + case 0xe2:
  1.1141 +   // SET 4,D
  1.1142 +   DE.B.B1|=1<<4;
  1.1143 +   break;
  1.1144 + case 0xe3:
  1.1145 +   // SET 4,E
  1.1146 +   DE.B.B0|=1<<4;
  1.1147 +   break;
  1.1148 + case 0xe4:
  1.1149 +   // SET 4,H
  1.1150 +   HL.B.B1|=1<<4;
  1.1151 +   break;
  1.1152 + case 0xe5:
  1.1153 +   // SET 4,L
  1.1154 +   HL.B.B0|=1<<4;
  1.1155 +   break;
  1.1156 + case 0xe6:
  1.1157 +   // SET 4,(HL)
  1.1158 +   tempValue=gbReadMemory(HL.W);
  1.1159 +   tempValue|=1<<4;
  1.1160 +   gbWriteMemory(HL.W,tempValue);
  1.1161 +   break;
  1.1162 + case 0xe7:
  1.1163 +   // SET 4,A
  1.1164 +   AF.B.B1|=1<<4;
  1.1165 +   break;
  1.1166 + case 0xe8:
  1.1167 +   // SET 5,B
  1.1168 +   BC.B.B1|=1<<5;
  1.1169 +   break;
  1.1170 + case 0xe9:
  1.1171 +   // SET 5,C
  1.1172 +   BC.B.B0|=1<<5;
  1.1173 +   break;
  1.1174 + case 0xea:
  1.1175 +   // SET 5,D
  1.1176 +   DE.B.B1|=1<<5;
  1.1177 +   break;
  1.1178 + case 0xeb:
  1.1179 +   // SET 5,E
  1.1180 +   DE.B.B0|=1<<5;
  1.1181 +   break;
  1.1182 + case 0xec:
  1.1183 +   // SET 5,H
  1.1184 +   HL.B.B1|=1<<5;
  1.1185 +   break;
  1.1186 + case 0xed:
  1.1187 +   // SET 5,L
  1.1188 +   HL.B.B0|=1<<5;
  1.1189 +   break;
  1.1190 + case 0xee:
  1.1191 +   // SET 5,(HL)
  1.1192 +   tempValue=gbReadMemory(HL.W);
  1.1193 +   tempValue|=1<<5;
  1.1194 +   gbWriteMemory(HL.W,tempValue);
  1.1195 +   break;
  1.1196 + case 0xef:
  1.1197 +   // SET 5,A
  1.1198 +   AF.B.B1|=1<<5;
  1.1199 +   break;
  1.1200 + case 0xf0:
  1.1201 +   // SET 6,B
  1.1202 +   BC.B.B1|=1<<6;
  1.1203 +   break;
  1.1204 + case 0xf1:
  1.1205 +   // SET 6,C
  1.1206 +   BC.B.B0|=1<<6;
  1.1207 +   break;
  1.1208 + case 0xf2:
  1.1209 +   // SET 6,D
  1.1210 +   DE.B.B1|=1<<6;
  1.1211 +   break;
  1.1212 + case 0xf3:
  1.1213 +   // SET 6,E
  1.1214 +   DE.B.B0|=1<<6;
  1.1215 +   break;
  1.1216 + case 0xf4:
  1.1217 +   // SET 6,H
  1.1218 +   HL.B.B1|=1<<6;
  1.1219 +   break;
  1.1220 + case 0xf5:
  1.1221 +   // SET 6,L
  1.1222 +   HL.B.B0|=1<<6;
  1.1223 +   break;
  1.1224 + case 0xf6:
  1.1225 +   // SET 6,(HL)
  1.1226 +   tempValue=gbReadMemory(HL.W);
  1.1227 +   tempValue|=1<<6;
  1.1228 +   gbWriteMemory(HL.W,tempValue);
  1.1229 +   break;
  1.1230 + case 0xf7:
  1.1231 +   // SET 6,A
  1.1232 +   AF.B.B1|=1<<6;
  1.1233 +   break;
  1.1234 + case 0xf8:
  1.1235 +   // SET 7,B
  1.1236 +   BC.B.B1|=1<<7;
  1.1237 +   break;
  1.1238 + case 0xf9:
  1.1239 +   // SET 7,C
  1.1240 +   BC.B.B0|=1<<7;
  1.1241 +   break;
  1.1242 + case 0xfa:
  1.1243 +   // SET 7,D
  1.1244 +   DE.B.B1|=1<<7;
  1.1245 +   break;
  1.1246 + case 0xfb:
  1.1247 +   // SET 7,E
  1.1248 +   DE.B.B0|=1<<7;
  1.1249 +   break;
  1.1250 + case 0xfc:
  1.1251 +   // SET 7,H
  1.1252 +   HL.B.B1|=1<<7;
  1.1253 +   break;
  1.1254 + case 0xfd:
  1.1255 +   // SET 7,L
  1.1256 +   HL.B.B0|=1<<7;
  1.1257 +   break;
  1.1258 + case 0xfe:
  1.1259 +   // SET 7,(HL)
  1.1260 +   tempValue=gbReadMemory(HL.W);
  1.1261 +   tempValue|=1<<7;
  1.1262 +   gbWriteMemory(HL.W,tempValue);
  1.1263 +   break;
  1.1264 + case 0xff:
  1.1265 +   // SET 7,A
  1.1266 +   AF.B.B1|=1<<7;
  1.1267 +   break;
  1.1268 + default:
  1.1269 +   systemMessage(0, N_("Unknown opcode %02x at %04x"),
  1.1270 +                 gbReadOpcode(PC.W-1),PC.W-1);
  1.1271 +   emulating = false;
  1.1272 +   return;