From 0787af868fcaf537eb53483c50973983894de7c3 Mon Sep 17 00:00:00 2001 From: notaz Date: Wed, 16 Feb 2022 01:20:31 +0200 Subject: [PATCH] drc: try not to end the block prematurely Fixes: 4919de1e88095f00466f6674323d518fc520b0db (was not really broken, only load delay detection can't work with blocks that are too small) --- libpcsxcore/new_dynarec/new_dynarec.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 95564230..6ade3bb0 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -7070,8 +7070,24 @@ static noinline void pass1_disassemble(u_int pagelimit) /* Is this the end of the block? */ if (i > 0 && dops[i-1].is_ujump) { - if(dops[i-1].rt1==0) { // Continue past subroutine call (JAL) - done=2; + if (dops[i-1].rt1 == 0) { // not jal + int found_bbranch = 0, t = (ba[i-1] - start) / 4; + if ((u_int)(t - i) < 64 && start + (t+64)*4 < pagelimit) { + // scan for a branch back to i+1 + for (j = t; j < t + 64; j++) { + int tmpop = source[j] >> 26; + if (tmpop == 1 || ((tmpop & ~3) == 4)) { + int t2 = j + 1 + (int)(signed short)source[j]; + if (t2 == i + 1) { + //printf("blk expand %08x<-%08x\n", start + (i+1)*4, start + j*4); + found_bbranch = 1; + break; + } + } + } + } + if (!found_bbranch) + done = 2; } else { if(stop_after_jal) done=1; -- 2.39.2