mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-06 23:58:04 -04:00
idle loops adjusted
git-svn-id: file:///home/notaz/opt/svn/PicoDrive@549 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
parent
1413b9a118
commit
5ed2a20eaa
5 changed files with 89 additions and 52 deletions
|
@ -22,8 +22,8 @@ patch_desc_table:
|
|||
.word (0x75f8<<16) | 0x67f8, idle_detector_bcc8, idle_beq, Op6701 @ beq.s
|
||||
.word (0x75f6<<16) | 0x67f6, idle_detector_bcc8, idle_beq, Op6701 @ beq.s
|
||||
.word (0x75f2<<16) | 0x67f2, idle_detector_bcc8, idle_beq, Op6701 @ beq.s
|
||||
.word (0x7dfe<<16) | 0x60fe, idle_detector_dead, idle_bra, Op6001 @ bra.s
|
||||
.word (0x7dfc<<16) | 0x60fc, idle_detector_dead, idle_bra, Op6001 @ bra.s
|
||||
.word (0x7dfe<<16) | 0x60fe, idle_detector_bcc8, idle_bra, Op6001 @ bra.s
|
||||
.word (0x7dfc<<16) | 0x60fc, idle_detector_bcc8, idle_bra, Op6001 @ bra.s
|
||||
|
||||
|
||||
.text
|
||||
|
@ -90,10 +90,12 @@ cfi_loop:
|
|||
|
||||
|
||||
.macro inc_counter cond
|
||||
@ ldr r0, =idle_hit_counter
|
||||
@ ldr r1, [r0]
|
||||
@ add r1, r1, #1
|
||||
@ str\cond r1, [r0]
|
||||
@ ldr\cond r0, [r7, #0x60]
|
||||
@ mov r11,lr
|
||||
@ sub r0, r4, r0
|
||||
@ sub r0, r0, #2
|
||||
@ bl\cond SekRegisterIdleHit
|
||||
@ mov lr, r11
|
||||
.endm
|
||||
|
||||
idle_bra:
|
||||
|
@ -139,43 +141,36 @@ idle_detector_bcc8:
|
|||
and r2, r8, #0x00ff
|
||||
orr r2, r2, #0x7100
|
||||
orreq r2, r2, #0x0200
|
||||
tst r8, #0x0100 @ 67xx (beq)?
|
||||
orrne r2, r2, #0x0400
|
||||
mov r0, r8, lsr #8
|
||||
cmp r0, #0x66
|
||||
orrgt r2, r2, #0x0400 @ 67xx (beq)
|
||||
orrlt r2, r2, #0x0c00 @ 60xx (bra)
|
||||
|
||||
@ r2 = patch_opcode
|
||||
sub r0, r4, #2
|
||||
ldrh r1, [r0]
|
||||
mov r11,r2
|
||||
mov r3, r7
|
||||
bl SekRegisterIdlePatch
|
||||
cmp r0, #1 @ 0 - ok to patch, 1 - no patch, 2 - remove detector
|
||||
strlth r11,[r4, #-2]
|
||||
ble exit_detector
|
||||
|
||||
@ remove detector from Cyclone
|
||||
tst r8, #0x0100 @ 67xx (beq)?
|
||||
mov r0, r8, lsr #8
|
||||
cmp r0, #0x66
|
||||
ldrlt r1, =Op6001
|
||||
ldreq r1, =Op6601
|
||||
ldrne r1, =Op6701
|
||||
ldrgt r1, =Op6701
|
||||
|
||||
ldr r3, =CycloneJumpTab
|
||||
str r1, [r3, r8, lsl #2]
|
||||
bx r1
|
||||
|
||||
exit_detector:
|
||||
tst r8, #0x0100 @ 67xx (beq)?
|
||||
mov r0, r8, lsr #8
|
||||
cmp r0, #0x66
|
||||
blt Op6001
|
||||
beq Op6601
|
||||
b Op6701
|
||||
|
||||
|
||||
idle_detector_dead:
|
||||
@ patch without further questions
|
||||
and r2, r8, #0x00ff
|
||||
orr r2, r2, #0x7d00
|
||||
sub r0, r4, #2
|
||||
ldrh r1, [r0]
|
||||
mov r11,r2
|
||||
bl SekRegisterIdlePatch
|
||||
strh r11,[r4, #-2]
|
||||
b Op6001
|
||||
|
||||
.pool
|
||||
|
||||
|
|
|
@ -5041,8 +5041,8 @@ idle_install:
|
|||
INSTALL_IDLE(0x75f8, 0x67f8, idle_detector_bcc8, 0x6701_idle, 0x6701);
|
||||
INSTALL_IDLE(0x75f6, 0x67f6, idle_detector_bcc8, 0x6701_idle, 0x6701);
|
||||
INSTALL_IDLE(0x75f2, 0x67f2, idle_detector_bcc8, 0x6701_idle, 0x6701);
|
||||
INSTALL_IDLE(0x7dfe, 0x60fe, idle_detector_dead, 0x6001_idle, 0x6001);
|
||||
INSTALL_IDLE(0x7dfc, 0x60fc, idle_detector_dead, 0x6001_idle, 0x6001);
|
||||
INSTALL_IDLE(0x7dfe, 0x60fe, idle_detector_bcc8, 0x6001_idle, 0x6001);
|
||||
INSTALL_IDLE(0x7dfc, 0x60fc, idle_detector_bcc8, 0x6001_idle, 0x6001);
|
||||
return 0;
|
||||
|
||||
idle_remove:
|
||||
|
|
|
@ -40013,7 +40013,7 @@ RET(8)
|
|||
|
||||
|
||||
extern int SekIsIdleCode(unsigned short *dst, int bytes);
|
||||
extern int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop);
|
||||
extern int SekRegisterIdlePatch(unsigned int pc, int oldop, int newop, void *ctx);
|
||||
|
||||
OPCODE(idle_detector_bcc8)
|
||||
{
|
||||
|
@ -40032,18 +40032,22 @@ OPCODE(idle_detector_bcc8)
|
|||
ret = SekIsIdleCode(dest_pc, bytes);
|
||||
newop = (Opcode & 0xfe) | 0x7100;
|
||||
if (!ret) newop |= 0x200;
|
||||
if (Opcode & 0x0100) newop |= 0x400; // beq
|
||||
if ( Opcode & 0x0100) newop |= 0x400; // beq
|
||||
if (!(Opcode & 0x0f00)) newop |= 0xc00; // bra
|
||||
|
||||
ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop);
|
||||
ret = SekRegisterIdlePatch(GET_PC - 2, Opcode, newop, &m68kcontext);
|
||||
switch (ret)
|
||||
{
|
||||
case 0: PC[-1] = newop; break;
|
||||
case 1: break;
|
||||
case 2: JumpTable[Opcode] = (Opcode & 0x0100) ? CAST_OP(0x6701) : CAST_OP(0x6601); break;
|
||||
case 2: JumpTable[Opcode] = (Opcode & 0x0f00) ?
|
||||
((Opcode & 0x0100) ? CAST_OP(0x6701) : CAST_OP(0x6601)) :
|
||||
CAST_OP(0x6001); break;
|
||||
}
|
||||
|
||||
end:
|
||||
cond_true = (Opcode & 0x0100) ? !flag_NotZ : flag_NotZ; // beq?
|
||||
if ((Opcode & 0xff00) == 0x6000) cond_true = 1;
|
||||
else cond_true = (Opcode & 0x0100) ? !flag_NotZ : flag_NotZ; // beq?
|
||||
if (cond_true)
|
||||
{
|
||||
PC = dest_pc;
|
||||
|
@ -40052,14 +40056,4 @@ end:
|
|||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue