MagicEngine
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Japanese English 

PC-FX interrupts and VSync?

 
Post new topic   Reply to topic    MagicEngine Forum Index -> General
View previous topic :: View next topic  
Author Message
cdoty
Member
Member


Joined: 02 Feb 2005
Posts: 73
Location: Houston, TX

PostPosted: Wed Jul 28, 2010 7:53 am    Post subject: PC-FX interrupts and VSync? Reply with quote

Any program written with the PCFXga libraries locks up in VSyncWait, under Magic Engine FX.

I've tried enabling the VDC interrupt and turning the IRQ for the interrupt on.

The program runs normally in mednafen (which may not be checking the interrupt status?); and does function, under ME-FX, if the VSyncWait call is removed.

Any idea how to get VSyncWait working?
_________________
Visit RasterSoft on facebook or visit the website.
Back to top
View user's profile Send private message Visit poster's website AIM Address
dmichel
Admin
Admin


Joined: 04 Apr 2002
Posts: 1166
Location: France

PostPosted: Wed Jul 28, 2010 10:11 am    Post subject: Reply with quote

Hmm, I'm not aware of any interrupt problem, but may be the library you use expect some initialization to be done by the BIOS, and since MEFX doesn't have one this could be a problem.

What SDK do you use? The one with the LCC compiler?

I use this one and interrupts work for me, I wrote my own interrupt handler though.
_________________
David Michel
Back to top
View user's profile Send private message
cdoty
Member
Member


Joined: 02 Feb 2005
Posts: 73
Location: Houston, TX

PostPosted: Wed Jul 28, 2010 2:10 pm    Post subject: Reply with quote

dmichel wrote:
Hmm, I'm not aware of any interrupt problem, but may be the library you use expect some initialization to be done by the BIOS, and since MEFX doesn't have one this could be a problem.

What SDK do you use? The one with the LCC compiler?

I use this one and interrupts work for me, I wrote my own interrupt handler though.


xe does the same thing. Although, I'm not sure if it uses the bios. I should get my PC-FX within the next few weeks.

I'm using the GMaker/GMaker Plus SDK.

I think the interrupt handler might be the problem.
_________________
Visit RasterSoft on facebook or visit the website.
Back to top
View user's profile Send private message Visit poster's website AIM Address
cdoty
Member
Member


Joined: 02 Feb 2005
Posts: 73
Location: Houston, TX

PostPosted: Thu Jul 29, 2010 2:57 am    Post subject: Reply with quote

Would you mind posting some code to show how you've set up your interrupt routine?

I looked through the Maze2D example, and tried to implement all of the prioirity, resetting the mask bits, setting the interrupt level to 7, clearing the status register, enabling the IRQ, reseting the 6270 irq bit, setting up the king raster irq, setting the king raster count, reading the king status, implementing my own handler, reading the 6270 vblank status.

I'm not sure what I missed, but none of that worked.

Here's the second track of the CD. if it would help at all:
http://www.rastersoft.net/PCFX/PCFXInvades.rar

Here's a cut and paste of the IRQ stuff:

Code:

bool   g_bVBlank   = false;

void EnableInterrupts()
{
   g_bVBlank   = false;
   
   cache_disable();
   cache_clear();

   irq_disable();

   set_irq_mask(BIT_IRQM_73 | BIT_IRQM_SIO | BIT_IRQM_7B | BIT_IRQM_KING | BIT_IRQM_7A | BIT_IRQM_KP | BIT_IRQM_EXT | BIT_IRQM_TMI | BIT_IRQM_AERR);
      
   set_king_raster_irq(KING_RASTER_IRQ_OFF);

   set_irq_prio(IRQ_PRIOB, IRQ_KP);
   set_irq_vector(&int_pad, IRQ_LEVELB);

   set_irq_prio(IRQ_PRIOD, IRQ_KING);
   set_irq_vector(&VSyncHandler, IRQ_LEVELD);

   reset_irq_mask(BIT_IRQM_KING | BIT_IRQM_KP | BIT_IRQM_EXT | BIT_IRQM_TMI | BIT_IRQM_AERR);

   set_irq_level(0x0007);

   // Enable interrupts
   irq_enable();

   // Also tried 140 to see if it would trigger on a line
   set_king_raster_count(0);

   _get_king_sr();
   
   set_king_raster_irq(KING_RASTER_IRQ_ON);

   cache_enable();
}

void interrupt VSyncHandler()
{
   regsave r0-r31;

   g_bVBlank   = true;

   _get_king_sr();
}

void WaitForVBlank()
{
   while (false == g_bVBlank);

   g_bVBlank   = false;
}

_________________
Visit RasterSoft on facebook or visit the website.


Last edited by cdoty on Thu Jul 29, 2010 1:22 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address
dmichel
Admin
Admin


Joined: 04 Apr 2002
Posts: 1166
Location: France

PostPosted: Thu Jul 29, 2010 11:26 am    Post subject: Reply with quote

Sure, here it is :

Code:
void InitInterrupt()
{
   IRQ_Init();
   IRQ_SetVector(IRQ_LEVEL_7UPA, Intr7up);
   IRQ_ResetMask(IRQ_LEVEL_7UPA);
   IRQ_Enable();
}
void __interrupt Intr7up()
{
   int vreg;

   vreg = __inporth(0x0C00);
   __outporth(IO_7UPA, 7);
   __outporth(IO_7UPA+4, vscr_x);
   __outporth(IO_7UPA, 8);
   __outporth(IO_7UPA+4, vscr_y);
   __outporth(IO_7UPA, vreg);
   vsync++;
   (void)inporth(IO_7UPA_STATUS);
}
void WaitVsync()
{
   int a;
   do {
      a = vsync;
   } while (a == vsyncOld);
   vsyncOld = a;
}


I disassembled IRQ_Init() too to see what it does :

- it disables IRQs and set the IRQ level to 0
- it sets the IRQ mask to 0xFFFF
- it sets the IRQ priority 0 register to 0x0977
- it sets the IRQ priority 1 register to 0x0053
- and it sets all the IRQ vectors to a default vector

But while checking the interrupt code in MEFX I found out that the KING raster interrupt is not supported, it looks like I never implemented it. ^^;
_________________
David Michel
Back to top
View user's profile Send private message
cdoty
Member
Member


Joined: 02 Feb 2005
Posts: 73
Location: Houston, TX

PostPosted: Thu Jul 29, 2010 1:42 pm    Post subject: Reply with quote

dmichel wrote:
Sure, here it is :
I disassembled IRQ_Init() too to see what it does :

- it disables IRQs and set the IRQ level to 0
- it sets the IRQ mask to 0xFFFF
- it sets the IRQ priority 0 register to 0x0977
- it sets the IRQ priority 1 register to 0x0053
- and it sets all the IRQ vectors to a default vector


Thank you.

What is the IRQ level set to in IRQ_Enable()?

It looks like I have the IRQ levels backwards. So, an IRQ level of 0x0D would be needed to see the King interrupt?

dmichel wrote:
But while checking the interrupt code in MEFX I found out that the KING raster interrupt is not supported, it looks like I never implemented it. ^^;


Whew, that's good to hear! Smile

All of the examples made it look easy to use interrupts.

I guess the official SDK must have used the HuC6270 as the vblank interrupt source.

Is the King interrupt available on a normal PC-FX?

On the PC-FXGA, I wonder if the King interrupt is used mainly in updating the Huc6273?
_________________
Visit RasterSoft on facebook or visit the website.
Back to top
View user's profile Send private message Visit poster's website AIM Address
cdoty
Member
Member


Joined: 02 Feb 2005
Posts: 73
Location: Houston, TX

PostPosted: Thu Jul 29, 2010 2:08 pm    Post subject: Reply with quote

Using the 6270A interrupt, and enabling the vblank irq on the 6270, it worked.

Thank you.
_________________
Visit RasterSoft on facebook or visit the website.
Back to top
View user's profile Send private message Visit poster's website AIM Address
dmichel
Admin
Admin


Joined: 04 Apr 2002
Posts: 1166
Location: France

PostPosted: Thu Jul 29, 2010 5:51 pm    Post subject: Reply with quote

Great!

cdoty wrote:
What is the IRQ level set to in IRQ_Enable()?


IRQ_Enable() just clears the interrupt disable flag in the status register of the V810. IRQ_Init() had set it.

Quote:
It looks like I have the IRQ levels backwards. So, an IRQ level of 0x0D would be needed to see the King interrupt?


The IRQ level in the status register must be lower than the level of an interrupt for it to be triggered, so usually you set it to 0 to not block any interrupt.

And when an interrupt happens the IRQ level is automatically changed to the level of the interrupt so that a same level or a lower level interrupt can not happen until the current interrupt is finished.

Quote:
Is the King interrupt available on a normal PC-FX?


Yup, it's used a lot for all the DMA operations in the KING RAM.

Quote:
On the PC-FXGA, I wonder if the King interrupt is used mainly in updating the Huc6273?


Hmm, I dunno, but the HuC6273 has its own interrupt too. Although I think there are some problems with it, a bug I think that makes conflict with the interrupt of the second HuC6270.
_________________
David Michel
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    MagicEngine Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group