diff --git a/pcsx2/x86/BaseblockEx.cpp b/pcsx2/x86/BaseblockEx.cpp index 22a6765e60..bb933f301d 100644 --- a/pcsx2/x86/BaseblockEx.cpp +++ b/pcsx2/x86/BaseblockEx.cpp @@ -70,10 +70,27 @@ int BaseBlocks::LastIndex(u32 startpc) const return imin; } -BASEBLOCKEX* BaseBlocks::GetByX86(uptr ip) const +BASEBLOCKEX* BaseBlocks::GetByX86(uptr ip) { - // TODO - return 0; + if (0 == blocks.size()) + return 0; + + int imin = 0, imax = blocks.size() - 1, imid; + + while(imin != imax) { + imid = (imin+imax+1)>>1; + + if (blocks[imid].fnptr > ip) + imax = imid - 1; + else + imin = imid; + } + + if (ip < blocks[imin].fnptr || + ip >= blocks[imin].fnptr + blocks[imin].x86size) + return 0; + + return &blocks[imin]; } void BaseBlocks::Link(u32 pc, uptr jumpptr) diff --git a/pcsx2/x86/BaseblockEx.h b/pcsx2/x86/BaseblockEx.h index 6ebe592d5e..ab52f311ae 100644 --- a/pcsx2/x86/BaseblockEx.h +++ b/pcsx2/x86/BaseblockEx.h @@ -73,7 +73,7 @@ public: BASEBLOCKEX* New(u32 startpc, uptr fnptr); int LastIndex (u32 startpc) const; - BASEBLOCKEX* GetByX86(uptr ip) const; + BASEBLOCKEX* GetByX86(uptr ip); inline int Index (u32 startpc) const { diff --git a/pcsx2/x86/ix86/ix86.inl b/pcsx2/x86/ix86/ix86.inl index ae4f5829af..6a6376de3c 100644 --- a/pcsx2/x86/ix86/ix86.inl +++ b/pcsx2/x86/ix86/ix86.inl @@ -2356,7 +2356,7 @@ emitterT void eAND32RmtoR( x86IntRegType to, x86IntRegType from ) emitterT void eAND32RmtoROffset( x86IntRegType to, x86IntRegType from, int offset ) { RexRB(0,to,from); - write16( 0x23 ); + write8( 0x23 ); WriteRmOffsetFrom(to,from,offset); }