32x: improve irq handling + few bugfixes

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@866 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2010-01-23 23:36:58 +00:00
parent 04092e329b
commit 1f1ff763e6
10 changed files with 43 additions and 38 deletions

View file

@ -17,7 +17,6 @@
* - some constant propagation
*
* TODO:
* - proper SMC handling
* - better constant propagation
* - stack caching?
* - bug fixing

View file

@ -74,15 +74,6 @@ void sh2_execute(SH2 *sh2_, int cycles)
{
UINT32 opcode;
/* FIXME: Darxide doesn't like this */
if (sh2->test_irq && !sh2->delay && sh2->pending_level > ((sh2->sr >> 4) & 0x0f))
{
int level = sh2->pending_level;
int vector = sh2->irq_callback(sh2, level);
sh2_do_irq(sh2, level, vector);
sh2->test_irq = 0;
}
if (sh2->delay)
{
sh2->ppc = sh2->delay;
@ -119,6 +110,15 @@ void sh2_execute(SH2 *sh2_, int cycles)
}
sh2->icount--;
if (sh2->test_irq && !sh2->delay && sh2->pending_level > ((sh2->sr >> 4) & 0x0f))
{
int level = sh2->pending_level;
int vector = sh2->irq_callback(sh2, level);
sh2_do_irq(sh2, level, vector);
sh2->test_irq = 0;
}
}
while (sh2->icount > 0 || sh2->delay); /* can't interrupt before delay */

View file

@ -54,15 +54,23 @@ void sh2_do_irq(SH2 *sh2, int level, int vector)
// sh2->icount -= 13;
}
void sh2_irl_irq(SH2 *sh2, int level)
void sh2_irl_irq(SH2 *sh2, int level, int nested_call)
{
sh2->pending_irl = level;
if (level > sh2->pending_int_irq)
sh2->pending_level = level;
else
sh2->pending_level = sh2->pending_int_irq;
if (level < sh2->pending_int_irq)
level = sh2->pending_int_irq;
sh2->pending_level = level;
sh2->test_irq = 1;
if (!nested_call) {
// not in memhandler, so handle this now (recompiler friendly)
// do this to avoid missing irqs that other SH2 might clear
if (level > ((sh2->sr >> 4) & 0x0f)) {
int vector = sh2->irq_callback(sh2, level);
sh2_do_irq(sh2, level, vector);
}
}
else
sh2->test_irq = 1;
}
void sh2_internal_irq(SH2 *sh2, int level, int vector)

View file

@ -61,7 +61,7 @@ extern SH2 *sh2; // active sh2. XXX: consider removing
int sh2_init(SH2 *sh2, int is_slave);
void sh2_finish(SH2 *sh2);
void sh2_reset(SH2 *sh2);
void sh2_irl_irq(SH2 *sh2, int level);
void sh2_irl_irq(SH2 *sh2, int level, int nested_call);
void sh2_internal_irq(SH2 *sh2, int level, int vector);
void sh2_do_irq(SH2 *sh2, int level, int vector);