if (EaCanWrite(tea)==0) return 1;\r
}\r
\r
- use=OpBase(op);\r
+ use=OpBase(op,size);\r
use&=~0x0e00; // Use same handler for all registers\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
- OpStart(op);\r
+ OpStart(op,tea);\r
\r
if(type==1||type==3) {\r
Cycles=8;\r
if(size>=2) Cycles+=2;\r
}\r
\r
- EaCalc (0,0x0e00,sea,0);\r
- EaRead (0, 0,sea,0,0x0e00);\r
+ EaCalcReadNoSE(-1,10,sea,0,0x0e00);\r
+\r
+ EaCalcReadNoSE((type>0)?11:-1,0,tea,size,0x003f);\r
+\r
if (tea>=0x10)\r
- ot(" and r10,r0,#7 ;@ mem - do mod 8\n");\r
- else ot(" and r10,r0,#31 ;@ reg - do mod 32\n");\r
+ ot(" and r10,r10,#7 ;@ mem - do mod 8\n"); // size always 0\r
+ else ot(" and r10,r10,#31 ;@ reg - do mod 32\n"); // size always 2\r
ot("\n");\r
\r
- EaCalc(11,0x003f,tea,size);\r
- EaRead(11, 0,tea,size,0x003f);\r
ot(" mov r1,#1\n");\r
ot(" tst r0,r1,lsl r10 ;@ Do arithmetic\n");\r
ot(" bicne r9,r9,#0x40000000\n");\r
if (type==2) ot(" bic r1,r0,r1,lsl r10 ;@ Clear bit\n");\r
if (type==3) ot(" orr r1,r0,r1,lsl r10 ;@ Set bit\n");\r
ot("\n");\r
- EaWrite(11, 1,tea,size,0x003f);\r
+ EaWrite(11, 1,tea,size,0x003f,0,0);\r
}\r
- OpEnd();\r
+ OpEnd(tea);\r
\r
return 0;\r
}\r
if (EaCanWrite(tea)==0) return 1;\r
}\r
\r
- use=OpBase(op);\r
+ use=OpBase(op,size);\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
- OpStart(op);\r
+ OpStart(op,sea,tea);\r
\r
- ot(" mov r10,#1\n");\r
ot("\n");\r
- EaCalc ( 0,0x0000,sea,0);\r
- EaRead ( 0, 0,sea,0,0);\r
+ EaCalcReadNoSE(-1,0,sea,0,0);\r
+ ot(" mov r10,#1\n");\r
ot(" bic r9,r9,#0x40000000 ;@ Blank Z flag\n");\r
if (tea>=0x10)\r
- ot(" and r0,r0,#7 ;@ mem - do mod 8\n");\r
- else ot(" and r0,r0,#0x1F ;@ reg - do mod 32\n");\r
+ ot(" and r0,r0,#7 ;@ mem - do mod 8\n"); // size always 0\r
+ else ot(" and r0,r0,#0x1F ;@ reg - do mod 32\n"); // size always 2\r
ot(" mov r10,r10,lsl r0 ;@ Make bit mask\n");\r
ot("\n");\r
\r
if(size>=2) Cycles+=2;\r
}\r
\r
- EaCalc (11,0x003f,tea,size);\r
- EaRead (11, 0,tea,size,0x003f);\r
+ EaCalcReadNoSE((type>0)?11:-1,0,tea,size,0x003f);\r
ot(" tst r0,r10 ;@ Do arithmetic\n");\r
ot(" orreq r9,r9,#0x40000000 ;@ Get Z flag\n");\r
ot("\n");\r
if (type==2) ot(" bic r1,r0,r10 ;@ Clear bit\n");\r
if (type==3) ot(" orr r1,r0,r10 ;@ Set bit\n");\r
ot("\n");\r
- EaWrite(11, 1,tea,size,0x003f);\r
+ EaWrite(11, 1,tea,size,0x003f,0,0);\r
}\r
\r
- OpEnd();\r
+ OpEnd(sea,tea);\r
\r
return 0;\r
}\r
if (EaCanRead (ea,size)==0||EaAn(ea)) return 1;\r
if (EaCanWrite(ea )==0) return 1;\r
\r
- use=OpBase(op);\r
+ use=OpBase(op,size);\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
- OpStart(op); Cycles=size<2?4:6;\r
+ OpStart(op,ea); Cycles=size<2?4:6;\r
if(ea >= 0x10) {\r
Cycles*=2;\r
-#ifdef CYCLONE_FOR_GENESIS\r
+#if CYCLONE_FOR_GENESIS\r
// This is same as in Starscream core, CLR uses only 6 cycles for memory EAs.\r
// May be this is similar case as with TAS opcode, but this time the dummy\r
// read is ignored somehow? Without this hack Fatal Rewind hangs even in Gens.\r
#endif\r
}\r
\r
- EaCalc (10,0x003f,ea,size);\r
+ EaCalc (10,0x003f,ea,size,0,0);\r
\r
- if (type!=1) EaRead (10,0,ea,size,0x003f); // Don't need to read for 'clr'\r
+ if (type!=1) EaRead (10,0,ea,size,0x003f,0,0); // Don't need to read for 'clr' (or do we, for a dummy read?)\r
if (type==1) ot("\n");\r
\r
if (type==0)\r
{\r
ot(";@ Negx:\n");\r
GetXBit(1);\r
- if(size!=2) ot(" mov r0,r0,lsl #%i\n",size?16:24);\r
+ if(size!=2) ot(" mov r0,r0,asl #%i\n",size?16:24);\r
ot(" rscs r1,r0,#0 ;@ do arithmetic\n");\r
ot(" orr r3,r9,#0xb0000000 ;@ for old Z\n");\r
OpGetFlags(1,1,0);\r
if(size!=2) {\r
- ot(" movs r1,r1,asr #%i\n",size?16:24);\r
+ ot(" movs r1,r1,asr #%i\n",size?16:24);\r
ot(" orreq r9,r9,#0x40000000 ;@ possily missed Z\n");\r
- }\r
- ot(" andeq r9,r9,r3 ;@ fix Z\n");\r
+ }\r
+ ot(" andeq r9,r9,r3 ;@ fix Z\n");\r
ot("\n");\r
}\r
\r
if (type==2)\r
{\r
ot(";@ Neg:\n");\r
- if(size!=2) ot(" mov r0,r0,lsl #%i\n",size?16:24);\r
+ if(size!=2) ot(" mov r0,r0,asl #%i\n",size?16:24);\r
ot(" rsbs r1,r0,#0\n");\r
OpGetFlags(1,1);\r
if(size!=2) ot(" mov r1,r1,asr #%i\n",size?16:24);\r
if (type==3)\r
{\r
ot(";@ Not:\n");\r
- ot(" mvn r1,r0\n");\r
+ if(size!=2) {\r
+ ot(" mov r0,r0,asl #%i\n",size?16:24);\r
+ ot(" mvn r1,r0,asr #%i\n",size?16:24);\r
+ }\r
+ else\r
+ ot(" mvn r1,r0\n");\r
ot(" adds r1,r1,#0 ;@ Defines NZ, clears CV\n");\r
OpGetFlags(0,0);\r
ot("\n");\r
}\r
\r
- EaWrite(10, 1,ea,size,0x003f);\r
+ EaWrite(10, 1,ea,size,0x003f,0,0);\r
\r
- OpEnd();\r
+ OpEnd(ea);\r
\r
return 0;\r
}\r
// See if we can do this opcode:\r
if (EaCanWrite(sea)==0||EaAn(sea)) return 1;\r
\r
- use=OpBase(op);\r
+ use=OpBase(op,size);\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
- OpStart(op); Cycles=4;\r
+ OpStart(op,sea); Cycles=4;\r
\r
EaCalc ( 0,0x003f,sea,size,1);\r
EaRead ( 0, 0,sea,size,0x003f,1);\r
ot(" mrs r9,cpsr ;@ r9=flags\n");\r
ot("\n");\r
\r
- OpEnd();\r
+ OpEnd(sea);\r
return 0;\r
}\r
\r
size=(op>>6)&1;\r
shift=32-(8<<size);\r
\r
- use=OpBase(op);\r
+ use=OpBase(op,size);\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
OpStart(op); Cycles=4;\r
\r
- EaCalc (10,0x0007,ea,size+1);\r
- EaRead (10, 0,ea,size+1,0x0007);\r
+ EaCalc (10,0x0007,ea,size+1,0,0);\r
+ EaRead (10, 0,ea,size+1,0x0007,0,0);\r
\r
ot(" mov r0,r0,asl #%d\n",shift);\r
ot(" adds r0,r0,#0 ;@ Defines NZ, clears CV\n");\r
ot(" mov r1,r0,asr #%d\n",shift);\r
ot("\n");\r
\r
- EaWrite(10, 1,ea,size+1,0x0007);\r
+ EaWrite(10, 1,ea,size+1,0x0007,0,0);\r
\r
OpEnd();\r
return 0;\r
// See if we can do this opcode:\r
if (EaCanWrite(ea)==0) return 1;\r
\r
- use=OpBase(op);\r
+ use=OpBase(op,size);\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
- OpStart(op); Cycles=8;\r
+ OpStart(op,ea); Cycles=8;\r
if (ea<8) Cycles=4;\r
\r
- ot(" mov r1,#0\n");\r
+ if (cc)\r
+ ot(" mov r1,#0\n");\r
\r
- if (cc!=1)\r
+ switch (cc)\r
{\r
- ot(";@ Is the condition true?\n");\r
- if ((cc&~1)==2) ot(" eor r9,r9,#0x20000000 ;@ Invert carry for hi/ls\n");\r
- ot(" msr cpsr_flg,r9 ;@ ARM flags = 68000 flags\n");\r
- if ((cc&~1)==2) ot(" eor r9,r9,#0x20000000 ;@ Invert carry for hi/ls\n");\r
- ot(" mvn%s r1,r1\n",cond[cc]);\r
+ case 0: // T\r
+ ot(" mvn r1,#0\n");\r
+ if (ea<8) Cycles+=2;\r
+ break;\r
+ case 1: // F\r
+ break;\r
+ case 2: // hi\r
+ ot(" tst r9,#0x60000000 ;@ hi: !C && !Z\n");\r
+ ot(" mvneq r1,r1\n");\r
+ if (ea<8) ot(" subeq r5,r5,#2 ;@ Extra cycles\n");\r
+ break;\r
+ case 3: // ls\r
+ ot(" tst r9,#0x60000000 ;@ ls: C || Z\n");\r
+ ot(" mvnne r1,r1\n");\r
+ if (ea<8) ot(" subne r5,r5,#2 ;@ Extra cycles\n");\r
+ break;\r
+ default:\r
+ ot(";@ Is the condition true?\n");\r
+ ot(" msr cpsr_flg,r9 ;@ ARM flags = 68000 flags\n");\r
+ ot(" mvn%s r1,r1\n",cond[cc]);\r
+ if (ea<8) ot(" sub%s r5,r5,#2 ;@ Extra cycles\n",cond[cc]);\r
+ break;\r
}\r
\r
- if (cc!=1 && ea<8) ot(" sub%s r5,r5,#2 ;@ Extra cycles\n",cond[cc]);\r
ot("\n");\r
\r
- EaCalc (0,0x003f, ea,size);\r
- EaWrite(0, 1, ea,size,0x003f);\r
+ EaCalc (0,0x003f, ea,size,0,0);\r
+ EaWrite(0, 1, ea,size,0x003f,0,0);\r
\r
- OpEnd();\r
+ OpEnd(ea);\r
return 0;\r
}\r
\r
if (usereg)\r
{\r
ot(";@ Use Dn for count:\n");\r
- ot(" and r2,r8,#7<<9\n");\r
+ ot(" and r2,r8,#0x0e00\n");\r
ot(" ldr r2,[r7,r2,lsr #7]\n");\r
ot(" and r2,r2,#63\n");\r
ot("\n");\r
if (usereg) { // store X only if count is not 0\r
ot(" cmp %s,#0 ;@ shifting by 0?\n",pct);\r
ot(" biceq r9,r9,#0x20000000 ;@ if so, clear carry\n");\r
- ot(" movne r1,r9,lsr #28\n");\r
- ot(" strneb r1,[r7,#0x45] ;@ else Save X bit\n");\r
+ ot(" strne r9,[r7,#0x4c] ;@ else Save X bit\n");\r
} else {\r
// count will never be 0 if we use immediate\r
- ot(" mov r1,r9,lsr #28\n");\r
- ot(" strb r1,[r7,#0x45] ;@ Save X bit\n");\r
+ ot(" str r9,[r7,#0x4c] ;@ Save X bit\n");\r
}\r
\r
if (type==0 && dir) {\r
if(count == 1) {\r
if(dir==0) {\r
if(size!=2) {\r
- ot(" orr r0,r0,r0,lsr #%i\n", size?16:24);\r
- ot(" bic r0,r0,#0x%x\n", 1<<(32-wide));\r
- }\r
+ ot(" orr r0,r0,r0,lsr #%i\n", size?16:24);\r
+ ot(" bic r0,r0,#0x%x\n", 1<<(32-wide));\r
+ }\r
GetXBit(0);\r
ot(" movs r0,r0,rrx\n");\r
OpGetFlags(0,1);\r
} else {\r
- ot(" ldrb r3,[r7,#0x45]\n");\r
+ ot(" ldr r3,[r7,#0x4c]\n");\r
ot(" movs r0,r0,lsl #1\n");\r
OpGetFlags(0,1);\r
- ot(" tst r3,#2\n");\r
+ ot(" tst r3,#0x20000000\n");\r
ot(" orrne r0,r0,#0x%x\n", 1<<(32-wide));\r
ot(" bicne r9,r9,#0x40000000 ;@ clear Z in case it got there\n");\r
}\r
ot(" orr r0,r3,r0 ;@ r0=Rotated value\n");\r
\r
ot(";@ Insert X bit into r2-1:\n");\r
- ot(" ldrb r3,[r7,#0x45]\n");\r
+ ot(" ldr r3,[r7,#0x4c]\n");\r
ot(" sub r2,r2,#1\n");\r
- ot(" and r3,r3,#2\n");\r
- ot(" mov r3,r3,lsr #1\n");\r
+ ot(" and r3,r3,#0x20000000\n");\r
+ ot(" mov r3,r3,lsr #29\n");\r
ot(" orr r0,r0,r3,lsl r2\n");\r
ot("\n");\r
\r
ot(" bicne r9,r9,#0x40000000 ;@ make sure we didn't mess Z\n");\r
}\r
if (usereg) { // store X only if count is not 0\r
- ot(" mov r2,r9,lsr #28\n");\r
- ot(" strb r2,[r7,#0x45] ;@ if not 0, Save X bit\n");\r
+ ot(" str r9,[r7,#0x4c] ;@ if not 0, Save X bit\n");\r
ot(" b nozerox%.4x\n",op);\r
ot("norotx%.4x%s\n",op,ms?"":":");\r
- ot(" ldrb r2,[r7,#0x45]\n");\r
+ ot(" ldr r2,[r7,#0x4c]\n");\r
ot(" adds r0,r0,#0 ;@ Defines NZ, clears CV\n");\r
OpGetFlags(0,0);\r
- ot(" and r2,r2,#2\n");\r
- ot(" orr r9,r9,r2,lsl #28 ;@ C = old_X\n");\r
+ ot(" and r2,r2,#0x20000000\n");\r
+ ot(" orr r9,r9,r2 ;@ C = old_X\n");\r
ot("nozerox%.4x%s\n",op,ms?"":":");\r
}\r
\r
if (EaCanRead(ea,0)==0) return 1;\r
if (EaCanWrite(ea)==0) return 1;\r
\r
- use=OpBase(op);\r
+ use=OpBase(op,size);\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
- OpStart(op); Cycles=6; // EmitAsr() will add 2\r
+ OpStart(op,ea); Cycles=6; // EmitAsr() will add 2\r
\r
EaCalc (10,0x003f,ea,size,1);\r
EaRead (10, 0,ea,size,0x003f,1);\r
\r
EaWrite(10, 0,ea,size,0x003f,1);\r
\r
- OpEnd();\r
+ OpEnd(ea);\r
return 0;\r
}\r
\r
-int OpTas(int op)\r
+int OpTas(int op, int gen_special)\r
{\r
int ea=0;\r
int use=0;\r
// See if we can do this opcode:\r
if (EaCanWrite(ea)==0 || EaAn(ea)) return 1;\r
\r
- use=OpBase(op);\r
+ use=OpBase(op,0);\r
if (op!=use) { OpUse(op,use); return 0; } // Use existing handler\r
\r
- OpStart(op); Cycles=4;\r
+ if (!gen_special) OpStart(op,ea);\r
+ else\r
+ ot("Op%.4x_%s\n", op, ms?"":":");\r
+\r
+ Cycles=4;\r
if(ea>=8) Cycles+=10;\r
\r
EaCalc (10,0x003f,ea,0,1);\r
\r
#if CYCLONE_FOR_GENESIS\r
// the original Sega hardware ignores write-back phase (to memory only)\r
- if (ea < 0x10) {\r
+ if (ea < 0x10 || gen_special) {\r
#endif\r
ot(" orr r1,r1,#0x80000000 ;@ set bit7\n");\r
\r
}\r
#endif\r
\r
- OpEnd();\r
+ OpEnd(ea);\r
+\r
+#if (CYCLONE_FOR_GENESIS == 2)\r
+ if (!gen_special && ea >= 0x10) {\r
+ OpTas(op, 1);\r
+ }\r
+#endif\r
+\r
return 0;\r
}\r
\r