X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Ffame%2Ffamec_opcodes.h;h=ecbc056eaddf7f892601b3e2e85c517d0a21e3bc;hb=8187ba84b7ed56e2535a8381ac66fb5b32414b39;hp=8586603b2c9369b952326378c5a67856b1be4c4c;hpb=d0ae0cb4bb73e6e2fc10e7b19a5a72a012db6d6a;p=picodrive.git diff --git a/cpu/fame/famec_opcodes.h b/cpu/fame/famec_opcodes.h index 8586603..ecbc056 100644 --- a/cpu/fame/famec_opcodes.h +++ b/cpu/fame/famec_opcodes.h @@ -18292,8 +18292,19 @@ OPCODE(0x4AD0) flag_V = 0; flag_NotZ = res; flag_N = res; +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(8) +#endif } // TAS @@ -18310,8 +18321,20 @@ OPCODE(0x4AD8) flag_V = 0; flag_NotZ = res; flag_N = res; + +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(8) +#endif } // TAS @@ -18328,8 +18351,20 @@ OPCODE(0x4AE0) flag_V = 0; flag_NotZ = res; flag_N = res; + +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO +#ifdef USE_CYCLONE_TIMING +RET(20) +#else RET(10) +#endif } // TAS @@ -18346,8 +18381,20 @@ OPCODE(0x4AE8) flag_V = 0; flag_NotZ = res; flag_N = res; + +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO +#ifdef USE_CYCLONE_TIMING +RET(22) +#else RET(12) +#endif } // TAS @@ -18364,8 +18411,20 @@ OPCODE(0x4AF0) flag_V = 0; flag_NotZ = res; flag_N = res; + +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO +#ifdef USE_CYCLONE_TIMING +RET(24) +#else RET(14) +#endif } // TAS @@ -18381,8 +18440,20 @@ OPCODE(0x4AF8) flag_V = 0; flag_NotZ = res; flag_N = res; + +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO +#ifdef USE_CYCLONE_TIMING +RET(22) +#else RET(12) +#endif } // TAS @@ -18398,8 +18469,20 @@ OPCODE(0x4AF9) flag_V = 0; flag_NotZ = res; flag_N = res; + +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO +#ifdef USE_CYCLONE_TIMING +RET(26) +#else RET(16) +#endif } // TAS @@ -18416,8 +18499,20 @@ OPCODE(0x4ADF) flag_V = 0; flag_NotZ = res; flag_N = res; + +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO +#ifdef USE_CYCLONE_TIMING +RET(18) +#else RET(8) +#endif } // TAS @@ -18434,8 +18529,20 @@ OPCODE(0x4AE7) flag_V = 0; flag_NotZ = res; flag_N = res; + +#ifdef PICODRIVE_HACK + if (g_m68kcontext == &PicoCpuFS68k) { + res |= 0x80; + WRITE_BYTE_F(adr, res); + } +#endif + POST_IO -RET(10) +#ifdef USE_CYCLONE_TIMING +RET(20) +#else +RET(8) +#endif } // ILLEGAL @@ -39854,3 +39961,105 @@ OPCODE(0xE7E7) RET(14) } +#ifdef PICODRIVE_HACK +#if 0 +#define UPDATE_IDLE_COUNT { \ + extern int idle_hit_counter; \ + idle_hit_counter++; \ +} +#else +#define UPDATE_IDLE_COUNT +#endif + +// BRA +OPCODE(0x6001_idle) +{ +#ifdef FAMEC_CHECK_BRANCHES + u32 newPC = (u32)(PC) - BasePC; + s8 offs=Opcode; + newPC += offs; + SET_PC(newPC); + CHECK_BRANCH_EXCEPTION(offs) +#else + PC += ((s8)(Opcode & 0xFE)) >> 1; +#endif + UPDATE_IDLE_COUNT + m68kcontext.io_cycle_counter = 10; +RET(10) +} + +// BCC +OPCODE(0x6601_idle) +{ + if (flag_NotZ) + { + UPDATE_IDLE_COUNT + PC += ((s8)(Opcode & 0xFE)) >> 1; + m68kcontext.io_cycle_counter = 8; + } +RET(8) +} + +OPCODE(0x6701_idle) +{ + if (!flag_NotZ) + { + UPDATE_IDLE_COUNT + PC += ((s8)(Opcode & 0xFE)) >> 1; + m68kcontext.io_cycle_counter = 8; + } +RET(8) +} + + +extern int SekIsIdleCode(unsigned short *dst, int bytes); +extern int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop); + +OPCODE(idle_detector_bcc8) +{ + extern int idledet_start_frame; + extern char Pico[]; + int frame_count, cond_true, bytes, ret, newop; + u16 *dest_pc; + + dest_pc = PC + (((s8)(Opcode & 0xFE)) >> 1); + + frame_count = *(int *)(Pico+0x22208+0x1c); // Pico.m.frame_count + if (frame_count < idledet_start_frame) + goto end; + + bytes = 0 - (s8)(Opcode & 0xFE) - 2; + ret = SekIsIdleCode(dest_pc, bytes); + newop = (Opcode & 0xfe) | 0x7100; + if (!ret) newop |= 0x200; + if (Opcode & 0x0100) newop |= 0x400; // beq + + ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop); + switch (ret) + { + case 0: PC[-1] = newop; break; + case 1: break; + case 2: JumpTable[Opcode] = (Opcode & 0x0100) ? CAST_OP(0x6701) : CAST_OP(0x6601); break; + } + +end: + cond_true = (Opcode & 0x0100) ? !flag_NotZ : flag_NotZ; // beq? + if (cond_true) + { + PC = dest_pc; + m68kcontext.io_cycle_counter -= 2; + } +RET(8) +} + +OPCODE(idle_detector_dead) +{ + // patch without further questions + int newop = 0x7d00 | (Opcode & 0xff); + PC[-1] = newop; + SekRegisterIdlePatch(GET_PC - 2, Opcode, newop); + + PC += ((s8)(Opcode & 0xFE)) >> 1; +RET(10) +} +#endif // PICODRIVE_HACK