X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Ffame%2Ffamec_opcodes.h;fp=cpu%2Ffame%2Ffamec_opcodes.h;h=e1e1e4511ecdad3c26d8622b26965ac82f89ada5;hb=c060a9ab9c428e1ed9c4159b56529a2a36031e44;hp=03a64de5f3bd3941d93a6f6303cb3996ccba540e;hpb=b06778874d140bd5187cb74444ddc40931b9bd1d;p=picodrive.git diff --git a/cpu/fame/famec_opcodes.h b/cpu/fame/famec_opcodes.h index 03a64de..e1e1e45 100644 --- a/cpu/fame/famec_opcodes.h +++ b/cpu/fame/famec_opcodes.h @@ -39961,3 +39961,101 @@ OPCODE(0xE7E7) RET(14) } +#ifdef PICODRIVE_HACK +// 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 + { + extern int idle_hit_counter; + idle_hit_counter++; + } + m68kcontext.io_cycle_counter = 10; +RET(10) +} + +// BCC +OPCODE(0x6601_idle) +{ + if (flag_NotZ) + { + extern int idle_hit_counter; + idle_hit_counter++; + PC += ((s8)(Opcode & 0xFE)) >> 1; + m68kcontext.io_cycle_counter = 8; + } +RET(8) +} + +OPCODE(0x6701_idle) +{ + if (!flag_NotZ) + { + extern int idle_hit_counter; + idle_hit_counter++; + 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