X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Main.cpp;h=b6f49c3b2f532098e5a975b046a247d3b955c60b;hb=19a2e09532d56379faa16b2a95bff6703a35774f;hp=1f532a0d93d52ab597c467a8861d972cdd4cce77;hpb=52ac6b1c8f65fe2477ffc3a7fc63ca8ae9d7e59f;p=cyclone68000.git diff --git a/Main.cpp b/Main.cpp index 1f532a0..b6f49c3 100644 --- a/Main.cpp +++ b/Main.cpp @@ -25,8 +25,8 @@ int arm_op_count; // opcodes often used by games static const unsigned short hot_opcodes[] = { - 0x6701, // beq $3 - 0x6601, // bne $3 + 0x6702, // beq $3 + 0x6602, // bne $3 0x51c8, // dbra Dn, $2 0x4a38, // tst.b $0.w 0xd040, // add.w Dn, Dn @@ -34,7 +34,7 @@ static const unsigned short hot_opcodes[] = { 0x0240, // andi.w #$0, D0 0x2038, // move.l $0.w, D0 0xb0b8, // cmp.l $0.w, D0 - 0x6001, // bra $3 + 0x6002, // bra $3 0x30c0, // move.w D0, (A0)+ 0x3028, // move.w ($0,A0), D0 0x0c40, // cmpi.w #$0, D0 @@ -52,7 +52,7 @@ static const unsigned short hot_opcodes[] = { 0xb038, // cmp.b $0.w, D0 0x3039, // move.w $0.l, D0 0x4840, // swap D0 - 0x6101, // bsr $3 + 0x6102, // bsr $3 0x6100, // bsr $2 0x5e40, // addq.w #7, D0 0x1039, // move.b $0.l, D0 @@ -64,10 +64,10 @@ static const unsigned short hot_opcodes[] = { 0xc040, // and.w D0, D0 0x3180, // move.w D0, (A0,D0.w) 0x1198, // move.b (A0)+, (A0,D0.w) - 0x6501, // bcs $3 + 0x6502, // bcs $3 0x6500, // bcs $2 - 0x6401, // bcc $3 - 0x6a01, // bpl $3 + 0x6402, // bcc $3 + 0x6a02, // bpl $3 0x41f0, // lea (A0,D0.w), A0 0x4a28, // tst.b ($0,A0) 0x0828, // btst #$0, ($0,A0) @@ -169,13 +169,14 @@ static void AddressErrorWrapper(char rw, const char *dataprg, int iw) } #endif -void FlushPC(void) +void FlushPC(int force) { #if MEMHANDLERS_NEED_PC - if (pc_dirty) - ot(" str r4,[r7,#0x40] ;@ Save PC\n"); -#endif + force |= pc_dirty; pc_dirty = 0; +#endif + if (force) + ot(" str r4,[r7,#0x40] ;@ Save PC\n"); } static void PrintFramework() @@ -306,7 +307,12 @@ static void PrintFramework() ot(" bx lr\n"); ltorg(); #else - ot(";@ do nothing\n"); + ot(";@ fix final jumptable entries\n"); + ot(" ldr r12,=CycloneJumpTab\n"); + ot(" add r12,r12,#0x10000*4\n"); + ot(" ldr r0,[r12,#-3*4]\n"); + ot(" str r0,[r12,#-2*4]\n"); + ot(" str r0,[r12,#-1*4]\n"); ot(" bx lr\n"); #endif ot("\n"); @@ -630,7 +636,7 @@ static void PrintFramework() ot(" ldr r6,[r7,#0x54]\n"); ot(" ldrh r8,[r4],#2 ;@ Fetch next opcode\n"); ot(" subs r5,r5,#44 ;@ Subtract cycles\n"); - ot(" ldrge pc,[r6,r8,asl #2] ;@ Jump to opcode handler\n"); + ot(" ldrgt pc,[r6,r8,asl #2] ;@ Jump to opcode handler\n"); ot(" b CycloneEnd\n"); ot("\n"); @@ -842,7 +848,7 @@ static void PrintFramework() ot(" ldr r6,[r7,#0x54]\n"); ot(" ldrh r8,[r4],#2 ;@ Fetch next opcode\n"); ot(" subs r5,r5,#50 ;@ Subtract cycles\n"); - ot(" ldrge pc,[r6,r8,asl #2] ;@ Jump to opcode handler\n"); + ot(" ldrgt pc,[r6,r8,asl #2] ;@ Jump to opcode handler\n"); ot(" b CycloneEnd\n"); ot("\n"); #endif @@ -855,7 +861,7 @@ static void PrintFramework() ot(" cmp r5,#0\n"); ot(" orr r0,r0,#2 ;@ go to trace mode\n"); ot(" str r0,[r7,#0x58]\n"); - ot(" blt CycloneEnd\n"); // should take care of situation where we come here when already tracing + ot(" ble CycloneEnd\n"); // should take care of situation where we come here when already tracing ot(";@ CheckInterrupt:\n"); ot(" movs r0,r1,lsr #24 ;@ Get IRQ level\n"); ot(" beq CycloneDoTrace\n"); @@ -898,13 +904,13 @@ static void PrintFramework() ot(" bl Exception\n"); ot(" ldrh r8,[r4],#2 ;@ Fetch next opcode\n"); ot(" subs r5,r5,#34 ;@ Subtract cycles\n"); - ot(" ldrge pc,[r6,r8,asl #2] ;@ Jump to opcode handler\n"); + ot(" ldrgt pc,[r6,r8,asl #2] ;@ Jump to opcode handler\n"); ot(" b CycloneEnd\n"); ot("\n"); ot("TraceDisabled%s\n", ms?"":":"); ot(" ldrh r8,[r4],#2 ;@ Fetch next opcode\n"); ot(" cmp r5,#0\n"); - ot(" ldrge pc,[r6,r8,asl #2] ;@ Jump to opcode handler\n"); + ot(" ldrgt pc,[r6,r8,asl #2] ;@ Jump to opcode handler\n"); ot(" b CycloneEnd\n"); ot("\n"); #endif @@ -1267,9 +1273,9 @@ static int CycloneMake() ot(" %s CycloneDoTrace\n",globl); ot(" %s CycloneJumpTab\n",globl); ot(" %s Op____\n",globl); - ot(" %s Op6001\n",globl); - ot(" %s Op6601\n",globl); - ot(" %s Op6701\n",globl); + ot(" %s Op6002\n",globl); + ot(" %s Op6602\n",globl); + ot(" %s Op6702\n",globl); #endif ot("\n"); ot(ms?"CycloneVer dcd 0x":"CycloneVer: .long 0x");