mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #37 from unknownbrackets/master
Add a few minor wraps and asserts
This commit is contained in:
commit
59d623a0f2
3 changed files with 46 additions and 42 deletions
|
@ -104,6 +104,11 @@ template<u32 func(const char *, u32)> void WrapU_CU() {
|
|||
RETURN((u32)retval);
|
||||
}
|
||||
|
||||
template<u32 func(u32, const char *)> void WrapU_UC() {
|
||||
int retval = func(PARAM(0), Memory::GetCharPointer(PARAM(1)));
|
||||
RETURN(retval);
|
||||
}
|
||||
|
||||
template<u32 func(const char *, u32, u32)> void WrapU_CUU() {
|
||||
int retval = func(Memory::GetCharPointer(PARAM(0)), PARAM(1), PARAM(2));
|
||||
RETURN((u32)retval);
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
#define CTRL_ANALOG_X 0
|
||||
#define CTRL_ANALOG_Y 1
|
||||
|
||||
#define CTRL_MODE_DIGITAL 0
|
||||
#define CTRL_MODE_ANALOG 1
|
||||
|
||||
|
||||
// Returned control data
|
||||
struct _ctrl_data
|
||||
|
@ -154,18 +157,19 @@ void sceCtrlInit()
|
|||
DEBUG_LOG(HLE,"sceCtrlInit");
|
||||
}
|
||||
|
||||
void sceCtrlSetSamplingMode()
|
||||
u32 sceCtrlSetSamplingMode(u32 mode)
|
||||
{
|
||||
u32 mode = PARAM(0);
|
||||
u32 retVal = 0;
|
||||
|
||||
DEBUG_LOG(HLE,"sceCtrlSetSamplingMode(%i)", mode);
|
||||
_assert_msg_(HLE, mode >= 0 && mode <= 1, "sceCtrlSetSamplingMode: mode outside expected range.");
|
||||
|
||||
if (ctrlInited)
|
||||
{
|
||||
RETURN((u32)analogEnabled);
|
||||
// Looks odd
|
||||
analogEnabled = mode == 1 ? true : false;
|
||||
return;
|
||||
retVal = analogEnabled == true ? CTRL_MODE_ANALOG : CTRL_MODE_DIGITAL;
|
||||
analogEnabled = mode == CTRL_MODE_ANALOG ? true : false;
|
||||
}
|
||||
RETURN(0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void sceCtrlSetIdleCancelThreshold()
|
||||
|
@ -173,33 +177,30 @@ void sceCtrlSetIdleCancelThreshold()
|
|||
DEBUG_LOG(HLE,"UNIMPL sceCtrlSetIdleCancelThreshold");
|
||||
}
|
||||
|
||||
void sceCtrlReadBufferPositive()
|
||||
u32 sceCtrlReadBufferPositive(u32 ctrlDataPtr, u32 nBufs)
|
||||
{
|
||||
u32 ctrlDataPtr = PARAM(0);
|
||||
// u32 nBufs = PARAM(1);
|
||||
DEBUG_LOG(HLE,"sceCtrlReadBufferPositive(%08x)", PARAM(0));
|
||||
DEBUG_LOG(HLE,"sceCtrlReadBufferPositive(%08x, %i)", ctrlDataPtr, nBufs);
|
||||
_assert_msg_(HLE, nBufs > 0, "sceCtrlReadBufferPositive: trying to read nothing?");
|
||||
|
||||
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
|
||||
// Let's just ignore if ctrl is inited or not; some games don't init it (Super Fruit Fall)
|
||||
std::lock_guard<std::recursive_mutex> guard(ctrlMutex);
|
||||
// Let's just ignore if ctrl is inited or not; some games don't init it (Super Fruit Fall)
|
||||
//if (ctrlInited)
|
||||
//{
|
||||
SampleControls();
|
||||
memcpy(Memory::GetPointer(ctrlDataPtr), &ctrl, sizeof(_ctrl_data));
|
||||
memcpy(Memory::GetPointer(ctrlDataPtr), &ctrl, sizeof(_ctrl_data));
|
||||
//}
|
||||
RETURN(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void sceCtrlPeekLatch() {
|
||||
u32 latchDataPtr = PARAM(0);
|
||||
u32 sceCtrlPeekLatch(u32 latchDataPtr) {
|
||||
ERROR_LOG(HLE,"FAKE sceCtrlPeekLatch(%08x)", latchDataPtr);
|
||||
|
||||
if (Memory::IsValidAddress(latchDataPtr))
|
||||
Memory::WriteStruct(latchDataPtr, &latch);
|
||||
RETURN(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void sceCtrlReadLatch() {
|
||||
u32 latchDataPtr = PARAM(0);
|
||||
u32 sceCtrlReadLatch(u32 latchDataPtr) {
|
||||
ERROR_LOG(HLE,"FAKE sceCtrlReadLatch(%08x)", latchDataPtr);
|
||||
|
||||
// Hackery to do it here.
|
||||
|
@ -210,23 +211,23 @@ void sceCtrlReadLatch() {
|
|||
if (Memory::IsValidAddress(latchDataPtr))
|
||||
Memory::WriteStruct(latchDataPtr, &latch);
|
||||
|
||||
RETURN(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const HLEFunction sceCtrl[] =
|
||||
{
|
||||
{0x6a2774f3, sceCtrlInit, "sceCtrlInit"}, //(int unknown), init with 0
|
||||
{0x1f4011e6, sceCtrlSetSamplingMode, "sceCtrlSetSamplingMode"}, //(int on);
|
||||
{0x1f803938, sceCtrlReadBufferPositive, "sceCtrlReadBufferPositive"}, //(ctrl_data_t* paddata, int unknown) // unknown should be 1
|
||||
{0x1f4011e6, &WrapU_U<sceCtrlSetSamplingMode>, "sceCtrlSetSamplingMode"}, //(int on);
|
||||
{0x1f803938, &WrapU_UU<sceCtrlReadBufferPositive>, "sceCtrlReadBufferPositive"}, //(ctrl_data_t* paddata, int unknown) // unknown should be 1
|
||||
{0x6A2774F3, 0, "sceCtrlSetSamplingCycle"}, //?
|
||||
{0x6A2774F3,sceCtrlInit,"sceCtrlSetSamplingCycle"},
|
||||
{0x02BAAD91,0,"sceCtrlGetSamplingCycle"},
|
||||
{0xDA6B76A1,0,"sceCtrlGetSamplingMode"},
|
||||
{0x3A622550,sceCtrlReadBufferPositive,"sceCtrlPeekBufferPositive"},
|
||||
{0x3A622550,&WrapU_UU<sceCtrlReadBufferPositive>, "sceCtrlPeekBufferPositive"},
|
||||
{0xC152080A,0,"sceCtrlPeekBufferNegative"},
|
||||
{0x60B81F86,0,"sceCtrlReadBufferNegative"},
|
||||
{0xB1D0E5CD,sceCtrlPeekLatch,"sceCtrlPeekLatch"},
|
||||
{0x0B588501,sceCtrlReadLatch,"sceCtrlReadLatch"},
|
||||
{0xB1D0E5CD,&WrapU_U<sceCtrlPeekLatch>,"sceCtrlPeekLatch"},
|
||||
{0x0B588501,&WrapU_U<sceCtrlReadLatch>,"sceCtrlReadLatch"},
|
||||
{0x348D99D4,0,"sceCtrl_348D99D4"},
|
||||
{0xAF5960F3,0,"sceCtrl_AF5960F3"},
|
||||
{0xA68FD260,0,"sceCtrlClearRapidFire"},
|
||||
|
|
|
@ -94,29 +94,27 @@ void sceUmdGetDiscInfo()
|
|||
RETURN(0);
|
||||
}
|
||||
|
||||
void sceUmdActivate()
|
||||
u32 sceUmdActivate(u32 unknown, const char *name)
|
||||
{
|
||||
u32 unknown = PARAM(0);
|
||||
const char *name = Memory::GetCharPointer(PARAM(1));
|
||||
u32 retVal = 0;
|
||||
__KernelUmdActivate();
|
||||
DEBUG_LOG(HLE,"%i=sceUmdActivate(%08x, %s)", retVal, unknown, name);
|
||||
u32 notifyArg = UMD_PRESENT | UMD_READABLE;
|
||||
__KernelNotifyCallbackType(THREAD_CALLBACK_UMD, -1, notifyArg);
|
||||
RETURN(retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
void sceUmdDeactivate()
|
||||
u32 sceUmdDeactivate(u32 unknown, const char *name)
|
||||
{
|
||||
DEBUG_LOG(HLE,"sceUmdDeactivate()");
|
||||
bool triggerCallback = umdActivated;
|
||||
u8 triggerCallback = umdActivated;
|
||||
__KernelUmdDeactivate();
|
||||
|
||||
if (triggerCallback) {
|
||||
u32 notifyArg = UMD_PRESENT | UMD_READY;
|
||||
__KernelNotifyCallbackType(THREAD_CALLBACK_UMD, -1, notifyArg);
|
||||
}
|
||||
RETURN(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 sceUmdRegisterUMDCallBack(u32 cbId)
|
||||
|
@ -131,12 +129,12 @@ u32 sceUmdUnRegisterUMDCallBack(u32 cbId)
|
|||
return __KernelUnregisterCallback(THREAD_CALLBACK_UMD, cbId);
|
||||
}
|
||||
|
||||
void sceUmdGetDriveStat()
|
||||
u32 sceUmdGetDriveStat()
|
||||
{
|
||||
//u32 retVal = PSP_UMD_INITED | PSP_UMD_READY | PSP_UMD_PRESENT;
|
||||
u32 retVal = __KernelUmdGetState();
|
||||
DEBUG_LOG(HLE,"0x%02x=sceUmdGetDriveStat()",retVal);
|
||||
RETURN(retVal);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,25 +176,25 @@ void sceUmdCancelWaitDriveStat()
|
|||
RETURN(0);
|
||||
}
|
||||
|
||||
void sceUmdGetErrorStat()
|
||||
u32 sceUmdGetErrorStat()
|
||||
{
|
||||
DEBUG_LOG(HLE,"%i=sceUmdGetErrorStat()", umdErrorStat);
|
||||
RETURN(umdErrorStat);
|
||||
return umdErrorStat;
|
||||
}
|
||||
|
||||
|
||||
const HLEFunction sceUmdUser[] =
|
||||
{
|
||||
{0xC6183D47,sceUmdActivate,"sceUmdActivate"},
|
||||
{0x6B4A146C,sceUmdGetDriveStat,"sceUmdGetDriveStat"},
|
||||
{0xC6183D47,&WrapU_UC<sceUmdActivate>,"sceUmdActivate"},
|
||||
{0x6B4A146C,&WrapU_V<sceUmdGetDriveStat>,"sceUmdGetDriveStat"},
|
||||
{0x46EBB729,sceUmdCheckMedium,"sceUmdCheckMedium"},
|
||||
{0xE83742BA,sceUmdDeactivate,"sceUmdDeactivate"},
|
||||
{0xE83742BA,&WrapU_UC<sceUmdDeactivate>,"sceUmdDeactivate"},
|
||||
{0x8EF08FCE,sceUmdWaitDriveStat,"sceUmdWaitDriveStat"},
|
||||
{0x56202973,sceUmdWaitDriveStatWithTimer,"sceUmdWaitDriveStatWithTimer"},
|
||||
{0x4A9E5E29,sceUmdWaitDriveStatCB,"sceUmdWaitDriveStatCB"},
|
||||
{0x6af9b50a,sceUmdCancelWaitDriveStat,"sceUmdCancelWaitDriveStat"},
|
||||
{0x6B4A146C,sceUmdGetDriveStat,"sceUmdGetDriveStat"},
|
||||
{0x20628E6F,sceUmdGetErrorStat,"sceUmdGetErrorStat"},
|
||||
{0x6B4A146C,&WrapU_V<sceUmdGetDriveStat>,"sceUmdGetDriveStat"},
|
||||
{0x20628E6F,&WrapU_V<sceUmdGetErrorStat>,"sceUmdGetErrorStat"},
|
||||
{0x340B7686,sceUmdGetDiscInfo,"sceUmdGetDiscInfo"},
|
||||
{0xAEE7404D,&WrapU_U<sceUmdRegisterUMDCallBack>,"sceUmdRegisterUMDCallBack"},
|
||||
{0xBD2BDE07,&WrapU_U<sceUmdUnRegisterUMDCallBack>,"sceUmdUnRegisterUMDCallBack"},
|
||||
|
|
Loading…
Add table
Reference in a new issue