ppsspp/Core/HLE/sceKernelVTimer.cpp
Unknown W. Brackets 595759ef78 Implement a factory for kernel objects.
Couldn't think of a better way to do this, maybe there's some fancy
one I don't know about.

Also finished up a couple left over kernel objects.

Maybe a quarter the way there?
2012-12-28 13:55:22 -08:00

92 lines
2.3 KiB
C++

// Copyright (c) 2012- PPSSPP Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0 or later versions.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official git repository and contact information can be found at
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include "sceKernel.h"
#include "sceKernelVTimer.h"
#include "HLE.h"
//////////////////////////////////////////////////////////////////////////
// VTIMER
//////////////////////////////////////////////////////////////////////////
struct VTimer : public KernelObject
{
const char *GetName() {return name;}
const char *GetTypeName() {return "VTimer";}
static u32 GetMissingErrorCode() { return SCE_KERNEL_ERROR_UNKNOWN_VTID; }
int GetIDType() const { return SCE_KERNEL_TMID_VTimer; }
virtual void DoState(PointerWrap &p)
{
p.Do(size);
p.Do(name);
p.Do(startTime);
p.Do(running);
p.Do(handler);
p.Do(handlerTime);
p.Do(argument);
p.DoMarker("VTimer");
}
SceSize size;
char name[KERNELOBJECT_MAX_NAME_LENGTH+1];
u64 startTime;
bool running;
u32 handler;
u64 handlerTime;
u32 argument;
};
KernelObject *__KernelVTimerObject()
{
return new VTimer;
}
void sceKernelCreateVTimer()
{
DEBUG_LOG(HLE,"sceKernelCreateVTimer");
const char *name = Memory::GetCharPointer(PARAM(0));
VTimer *vt = new VTimer();
SceUID uid = kernelObjects.Create(vt);
strncpy(vt->name, name, 32);
vt->running = true;
vt->startTime = 0; //TODO fix
RETURN(uid); //TODO: return timer ID
}
void sceKernelStartVTimer()
{
int timerID = PARAM(0);
DEBUG_LOG(HLE,"sceKernelStartVTimer(%i)", timerID);
RETURN(0); //ok; 1=alreadyrunning
}
void sceKernelSetVTimerHandler()
{
DEBUG_LOG(HLE,"sceKernelSetVTimerHandler");
}
// Not sure why this is exposed...
void _sceKernelReturnFromTimerHandler()
{
DEBUG_LOG(HLE,"_sceKernelReturnFromTimerHandler");
}