2008-12-01 04:00:36 +00:00
|
|
|
#include "Iop_Vblank.h"
|
|
|
|
#include "IopBios.h"
|
|
|
|
#include "../Log.h"
|
|
|
|
|
|
|
|
using namespace Iop;
|
|
|
|
using namespace std;
|
|
|
|
|
2008-12-08 03:43:30 +00:00
|
|
|
#define LOG_NAME "iop_vblank"
|
|
|
|
#define FUNCTION_WAITVBLANKSTART "WaitVblankStart"
|
|
|
|
#define FUNCTION_WAITVBLANKEND "WaitVblankEnd"
|
2008-12-01 04:00:36 +00:00
|
|
|
|
|
|
|
CVblank::CVblank(CIopBios& bios) :
|
|
|
|
m_bios(bios)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CVblank::~CVblank()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
string CVblank::GetId() const
|
|
|
|
{
|
|
|
|
return "vblank";
|
|
|
|
}
|
|
|
|
|
|
|
|
string CVblank::GetFunctionName(unsigned int functionId) const
|
|
|
|
{
|
|
|
|
switch(functionId)
|
|
|
|
{
|
2008-12-08 03:43:30 +00:00
|
|
|
case 4:
|
|
|
|
return FUNCTION_WAITVBLANKSTART;
|
|
|
|
break;
|
2008-12-01 04:00:36 +00:00
|
|
|
case 5:
|
|
|
|
return FUNCTION_WAITVBLANKEND;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return "unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CVblank::Invoke(CMIPS& context, unsigned int functionId)
|
|
|
|
{
|
|
|
|
switch(functionId)
|
|
|
|
{
|
2008-12-08 03:43:30 +00:00
|
|
|
case 4:
|
|
|
|
WaitVblankStart();
|
|
|
|
break;
|
2008-12-01 04:00:36 +00:00
|
|
|
case 5:
|
|
|
|
WaitVblankEnd();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
CLog::GetInstance().Print(LOG_NAME, "Unknown function called (%d).\r\n", functionId);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-08 03:43:30 +00:00
|
|
|
void CVblank::WaitVblankStart()
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
2011-05-05 04:28:11 +00:00
|
|
|
CLog::GetInstance().Print(LOG_NAME, FUNCTION_WAITVBLANKSTART "();\r\n");
|
2008-12-08 03:43:30 +00:00
|
|
|
#endif
|
2011-05-05 04:28:11 +00:00
|
|
|
m_bios.SleepThreadTillVBlankStart();
|
2008-12-08 03:43:30 +00:00
|
|
|
}
|
|
|
|
|
2008-12-01 04:00:36 +00:00
|
|
|
void CVblank::WaitVblankEnd()
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
2011-05-05 04:28:11 +00:00
|
|
|
CLog::GetInstance().Print(LOG_NAME, FUNCTION_WAITVBLANKEND "();\r\n");
|
2008-12-01 04:00:36 +00:00
|
|
|
#endif
|
2011-05-05 04:28:11 +00:00
|
|
|
m_bios.SleepThreadTillVBlankEnd();
|
2008-12-01 04:00:36 +00:00
|
|
|
}
|